Public report of osaurus-ai/osaurus, published 26 October 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 26 October 2026, 11:45 UTC · Survey ID cd_06aba366485c4f2a9314262a5002c064
osaurus-ai/osaurus
Measured 26 October 2026, 11:42 UTC, at code version fc75a1e
No regression since the last survey
A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.
CAI scoreWeak
CriticalWeakAdequateStrongExemplary
No change since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A very large codebase: 690,981 lines of product code in 13 projects, tests not counted · Estimated rebuild effort: about 5.8 person-years · Weakest lens: Event-Driven, 10
Findings by how serious they are
59 critical5029 serious188 minor
20 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.
This survey was produced by
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
26 October 2026, 11:42 UTC
A measurement, not a certificate. The Code Assurance Index records a number
together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee
the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that
implements it, and today Watchdog is the only one that does.
The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸
70of 70 dimensions measured by tools.
5226of 5276 findings point to an exact file and line, so you can open each one in the code. The other 50 concern the repository as a whole, such as missing documentation.
70dimensions across 8 lenses, read from 690,981 lines of product code in 13 projects.
osaurus-ai/osaurus falls short of our standard for a preview release because it has message handlers that wait for another service. It scores 39 out of 100 and is rated Weak, and 50 of its 59 critical findings are security problems.
Event-Driven, at 10, is the weakest lens and counts most in the score. The best first step is stopping the event handlers from waiting on other services, worth about 24 points. Raising Event-Driven to 65 would lift the score to about 62.
Forty-two pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Five passwords or keys are open to anyone who can read the repository, and four parts of the code are no longer understood by anyone working on it. Pinning each tool to an exact version, replacing each exposed password or key and having someone learn the forgotten files would close these risks. Limiting each secret to its own step would fix the two secrets exposed to more of the pipeline than needed, and updating the vulnerable packages would deal with the package with a known security hole. The three tests that check nothing need to check the result they produce.
The product code is 690,981 lines, about €840,000 to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
If Event-Driven rose from 10 to 65, the lowest score rated Strong, the score would rise from 39 to about 62.
Code composition: what the lines of code are
Product code 70%Tests 30%
New since the last survey: 378 findings
These 378 critical or serious findings weren't in the previous survey, on 12 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
Watchdog compares every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.
Fixed since the last survey: 279 findings
These 279 critical or serious findings were in the previous survey, on 12 October 2026, and are gone from this one. The first 100 are listed here.
€280,000 to €1,400,000, for 4,641 to 14,723 hours of work, about 5.8 person-years for 3 to 11 engineers
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.7 at a score of 39. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Very large: 690,981 lines of product code
What it is not
Not a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.
How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Replace the synchronous wait with `async`/`await` so the handler never blocks on a peer/resource.
Resolve the 1 Assertions commented out finding(s) in Test Quality — start with osaurusUITests.swift.
Raises the score by about 1 point · Low effort · Test Quality
3
Resolve the 1 No assertions (empty test) finding(s) in Test Quality — start with ModelRuntimePrefixTests.swift.
Raises the score by about 1 point · Low effort · Test Quality
Diagnosis: what the measurements show together
Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.
Where the investment is most exposed · Value at risk
This code would cost about €840,000 to build again, about 5.8 person-years of work. Its weakest lens is Event-Driven, at 10 (Critical). Event-Driven is about whether the parts of the system can rely on the messages they send each other. Because the weakest lens counts most in the score, work on Event-Driven also moves the score most.
Based on: the rebuild estimate · the Event-Driven grade · how much each lens counts
What to do: Start with the Event-Driven actions in Top priorities.
If you do one thing first · First action
Replace the synchronous wait with `async`/`await` so the handler never blocks on a peer/resource. Of all the actions in this report, it raises the score most for the work it takes: about 24 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.4 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 4% to 9% on every change. The history of the code shows how much it changes: about 550,033 lines over the last 90 days, which is about 2,230,689 lines a year. At that pace, the extra work comes to an estimated 227.7 to 1366.2 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
16 modules, with 12 dependencies between them. One loop runs through 4 of the modules, marked above the diagonal.
Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
Packages~OsaurusNetworking uses repository, so a change to repository can break Packages~OsaurusNetworking, while a change to Packages~OsaurusNetworking can't break repository.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
11→15 Packages~OsaurusNetworking uses Packages~OsaurusCLI~OsaurusCLICorepart of a loop✕
Connections
1 pair of types, where a type in Packages~OsaurusNetworking uses a type in Packages~OsaurusCLI~OsaurusCLICore.
Packages~OsaurusNetworking uses Packages~OsaurusCLI~OsaurusCLICore, so a change to Packages~OsaurusCLI~OsaurusCLICore can break Packages~OsaurusNetworking, while a change to Packages~OsaurusNetworking can't break Packages~OsaurusCLI~OsaurusCLICore.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
repository uses Packages~OsaurusNetworking, so a change to Packages~OsaurusNetworking can break repository, while a change to repository can't break Packages~OsaurusNetworking.
Position
Below the diagonal: repository uses a module listed above it, which is the healthy direction.
12→15 repository uses Packages~OsaurusCLI~OsaurusCLICorepart of a loop✕
Connections
2431 pairs of types, where a type in repository uses a type in Packages~OsaurusCLI~OsaurusCLICore. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
repository uses Packages~OsaurusCLI~OsaurusCLICore, so a change to Packages~OsaurusCLI~OsaurusCLICore can break repository, while a change to repository can't break Packages~OsaurusCLI~OsaurusCLICore.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
337 pairs of types, where a type in Packages~OsaurusEvals~OsaurusEvalsKit uses a type in repository. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
Packages~OsaurusEvals~OsaurusEvalsKit uses repository, so a change to repository can break Packages~OsaurusEvals~OsaurusEvalsKit, while a change to Packages~OsaurusEvals~OsaurusEvalsKit can't break repository.
Position
Below the diagonal: Packages~OsaurusEvals~OsaurusEvalsKit uses a module listed above it, which is the healthy direction.
13→15 Packages~OsaurusEvals~OsaurusEvalsKit uses Packages~OsaurusCLI~OsaurusCLICorepart of a loop✕
Connections
87 pairs of types, where a type in Packages~OsaurusEvals~OsaurusEvalsKit uses a type in Packages~OsaurusCLI~OsaurusCLICore. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
Packages~OsaurusEvals~OsaurusEvalsKit uses Packages~OsaurusCLI~OsaurusCLICore, so a change to Packages~OsaurusCLI~OsaurusCLICore can break Packages~OsaurusEvals~OsaurusEvalsKit, while a change to Packages~OsaurusEvals~OsaurusEvalsKit can't break Packages~OsaurusCLI~OsaurusCLICore.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
34 pairs of types, where a type in Packages~OsaurusPlugins~StatsPack~OsaurusStatsPack uses a type in repository. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
Packages~OsaurusPlugins~StatsPack~OsaurusStatsPack uses repository, so a change to repository can break Packages~OsaurusPlugins~StatsPack~OsaurusStatsPack, while a change to Packages~OsaurusPlugins~StatsPack~OsaurusStatsPack can't break repository.
Position
Below the diagonal: Packages~OsaurusPlugins~StatsPack~OsaurusStatsPack uses a module listed above it, which is the healthy direction.
159 pairs of types, where a type in Packages~OsaurusCLI~OsaurusCLICore uses a type in repository. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
Packages~OsaurusCLI~OsaurusCLICore uses repository, so a change to repository can break Packages~OsaurusCLI~OsaurusCLICore, while a change to Packages~OsaurusCLI~OsaurusCLICore can't break repository.
Position
Below the diagonal: Packages~OsaurusCLI~OsaurusCLICore uses a module listed above it, which is the healthy direction.
Packages~OsaurusCLI~OsaurusCLICore uses Packages~OsaurusEvals~OsaurusEvalsKit, so a change to Packages~OsaurusEvals~OsaurusEvalsKit can break Packages~OsaurusCLI~OsaurusCLICore, while a change to Packages~OsaurusCLI~OsaurusCLICore can't break Packages~OsaurusEvals~OsaurusEvalsKit.
Position
Below the diagonal: Packages~OsaurusCLI~OsaurusCLICore uses a module listed above it, which is the healthy direction.
Packages~OsaurusEvals~OsaurusEvalsCLI uses repository, so a change to repository can break Packages~OsaurusEvals~OsaurusEvalsCLI, while a change to Packages~OsaurusEvals~OsaurusEvalsCLI can't break repository.
Position
Below the diagonal: Packages~OsaurusEvals~OsaurusEvalsCLI uses a module listed above it, which is the healthy direction.
Packages~OsaurusEvals~OsaurusEvalsCLI uses Packages~OsaurusEvals~OsaurusEvalsKit, so a change to Packages~OsaurusEvals~OsaurusEvalsKit can break Packages~OsaurusEvals~OsaurusEvalsCLI, while a change to Packages~OsaurusEvals~OsaurusEvalsCLI can't break Packages~OsaurusEvals~OsaurusEvalsKit.
Position
Below the diagonal: Packages~OsaurusEvals~OsaurusEvalsCLI uses a module listed above it, which is the healthy direction.
Packages~OsaurusEvals~OsaurusEvalsCLI uses Packages~OsaurusCLI~OsaurusCLICore, so a change to Packages~OsaurusCLI~OsaurusCLICore can break Packages~OsaurusEvals~OsaurusEvalsCLI, while a change to Packages~OsaurusEvals~OsaurusEvalsCLI can't break Packages~OsaurusCLI~OsaurusCLICore.
Position
Below the diagonal: Packages~OsaurusEvals~OsaurusEvalsCLI uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 64% · Adequate · gated by D2 ·
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2025 — Injection
44
High / Critical
A03:2025 — Software Supply Chain Failures
12
High / Critical
A07:2025 — Authentication Failures
6
High / Critical
A02:2025 — Security Misconfiguration
1
Medium
Roadmap
First, replace synchronous waits in handlers with async/await to prevent blocking on peers or resources. Second, integrate a SAST step into CI to ensure security regressions fail the build immediately. Finally, improve test quality by addressing commented-out assertions, empty tests, and unverified test projects, starting with osaurusUITests.swift and ModelRuntimePrefixTests.swift.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Replace the synchronous wait with `async`/`await` so the handler never blocks on a peer/resource.
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Swift: await instead of blocking — `try await Task.sleep(for:)` for Thread.sleep/sleep, a checked continuation instead of a DispatchSemaphore or DispatchGroup wait, the async Process and URLSession APIs; never park a thread waiting on a Task — the cooperative pool cannot guarantee it progress.
Raise allocation-aware density on the hot paths — currently 164 use(s) across 732,860 production line(s) (~0.2/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 59
A definite problem that already costs you something and drags the score down: a
missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here
tends to cause failures elsewhere.
Serious — 5029
Likely wrong, but not failing yet. It degrades
the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to
carry for two years either.
Minor — 188
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 20
Something this survey could not settle
from the outside, and which could be critical or serious. Either a control was required and no
positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves
nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean
result. These are excluded from the score rather than awarded a pass, so the number on the cover neither
rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each
one is named under Limitations.
Methodology & how to trust this report
Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 70 of 70 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 70 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 5226 of 5276 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D4 Code Duplication — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 2043 duplicated block group(s) on this row were found in the languages this pass could tokenize, and they do NOT cover all of this repository's production source: .c (260,585 lines, 27% of production source) went unread, because no language model this pass could load exposed a clone-unit token stream for those file kinds. Duplication in that source is UNMEASURED — its absence from the count above is a gap in this analyzer's language coverage, not a finding that the code is free of duplication.
D8 Code Coverage — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: the Swift half could not be measured — the Swift suite in Packages/OsaurusCLI produced no coverage export. Coverage is excluded from the score rather than counted as a near-zero. This is OUR limitation, not a defect in the repo. In the meantime, commit (or publish into the working tree) the lcov/Cobertura report your CI produces and the real number is read on the next scan. You can widen what we reach: optional: commit the lcov/Cobertura report your CI produces, and the real number is read on the next scan.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.swift) and this repository declares a SwiftPM test suite (7 packages), but it was not re-run: the analyzer environment could not run it. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
D26 Project Cohesion — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Project size and spread are measured over build units whose source a code model reads. This repository's .c source is a material share of its production lines and was read by none, so the score is a verdict about the units that were read. Not a finding that the unread source is cohesive — it is unmeasured.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift`, `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsDev.swift`, `Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift`, `Packages/OsaurusCore/AppDelegate.swift`, `Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift`, … (+230 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
AX1 Captive dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in Packages/OsaurusCore/Services/Sandbox/SandboxBridgeTokenStore.swift, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
AX6 Interface segregation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
AXR1 Runtime accessibility — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via Dockerfile (sandbox/Dockerfile). docker build failed (exit 1) — ------ Dockerfile:1 -------------------- 1 | >>> FROM alpine:latest 2 | 3 | RUN mkdir -p /run /tmp -------------------- ERROR: failed to solve: alpine:latest: failed to resolve source metadata for docker.io/library/alpine:latest: failed to do request: Head "https://registry-1.docker.io/v2/library/alpine/manifests/latest": Forbidden; runtime evidence skipped.
C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
C2 Access Controls — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'SQLite3' is imported (Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:2), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'SQLite3' is imported (Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:2), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Go, Python, Swift, c, objectivec is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
IC1 Incompleteness & stubs — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Go, Python, Swift, c, objectivec is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9). Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
X3 Exception handling — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 60 further occurrence(s) are not listed individually; the score already reflects all 100.
X4 Structured logging — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Kotlin, Python, PHP, Dart, Ruby, Scala and Rust source only, and no C# was loaded, and this repository's JavaScript/TypeScript, Python and PHP make no call through a named logger, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X5 Nullable reference types — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax and MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, and Kotlin source only, and no C# was loaded, no TypeScript was found, and this repository's C, Objectivec, Python, Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X7 Silent fallback defaults — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 13 further occurrence(s) are not listed individually; the score already reflects all 53.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D7 Architectural Integrity: Layering is checked against detected/declared rules — an architecture whose boundaries live in convention or in code review, not in a rule a scanner can read, is not enforced here.
D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (REDACTED, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
DM4 Rich vs anemic domain model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
DM6 Domain ↔ infrastructure boundary: Infrastructure reached through a hand-rolled wrapper, a domain-named facade, reflection, or a string-keyed service locator resolves to a non-infra type and isn't seen; the body scan is symbol resolution over syntax, not full dataflow. A clean result means "no resolved infra reference in a domain body", not a proof of purity.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
663 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was HTTPHandler.channelRead at 249. A further 47 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being HotkeyRecorder.keyGlyph at 69 — they are counted neither in the figure above nor in this dimension's score. 15 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: Packages/OsaurusCore/Views/Voice/HotkeyRecorder.swift (HotkeyRecorder.keyGlyph at 69), Packages/OsaurusCore/Views/Management/ManagementView.swift (ManagementView.contentView at 32), Packages/OsaurusCore/Models/Configuration/ManagementTab.swift (ManagementTab.icon at 31), Packages/OsaurusCore/Services/FeatureTelemetry.swift (FeatureTelemetry.settingsTabToken at 31), Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionManager.swift (AgentChannelConnectionManagerError.errorDescription at 24), and 10 more not listed here. They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.
+ 656 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 6 bodies over 120 down to 120 or less in Cyclomatic Complexity — start with HTTPHandler.channelRead (cyclomatic 249), ConfigPlanner.validate (cyclomatic 184), AppleScriptLoop.run (cyclomatic 172). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 6 together lifts Cyclomatic Complexity from 5.1 to about 5.8/10, projected with the scoring formula itself and assuming each lands exactly at 120; a cleaner split scores higher.
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 999 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 5 bodies over 240 down to 240 or less in Cognitive Complexity — start with ConfigPlanner.validate (cognitive 452), AgentToolLoop.run (cognitive 411), AppleScriptLoop.run (cognitive 307). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 5 together lifts Cognitive Complexity from 2.6 to about 3.6/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes7.9 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 229 MethodTooLong finding(s) in God Classes — start with HTTPHandler.swift (32), ChatView.swift (8), RemoteProviderService.swift (8). — One of this dimension's main actionable groups (229 warning-level).
Resolve the 220 FileTooLong finding(s) in God Classes — start with HTTPHandler.swift, ChatView.swift, AgentsView.swift. — One of this dimension's main actionable groups (220 warning-level).
Resolve the 160 ClassTooLong finding(s) in God Classes — start with FolderTools.swift (4), AgentsView.swift (3), ChatView.swift (2). — One of this dimension's main actionable groups (160 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
2043 duplicated block group(s) detected. A further 122 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 12 of the 2165 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population. Measured on part of this repository only: .c (27% of production source) was not exposed to the token comparison, so duplication there is unmeasured and is not in this count.
+ 443 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 115 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with AgentChannelMessageFormatter.swift (3), ChatHistoryDatabase.swift (3), ScreenContextDistiller.swift (2). — One of this dimension's main actionable groups (115 warning-level).
Resolve the 110 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with HTTPHandler.swift (4), IMessageRPCClient.swift (4), ConfigurationTools.swift (3). — One of this dimension's main actionable groups (110 warning-level).
Resolve the 105 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with AgentsView.swift (4), Schedule.swift (3), NativeMessageCellView.swift (3). — One of this dimension's main actionable groups (105 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling9.4 / 10Stronggated by 1 serious finding✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
13 production modules (Go+SwiftPM+Xcode), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; a workspace's implicit (product-name) dependency is not visible there; 1 module(s) off the main sequence, with abstractness counted on 11 of the 13 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).
Off the main sequence: OsaurusNetworking
What to do
Resolve the 1 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
Enforce Coupling in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
Resolve the 36 Low cohesion finding(s) in Cohesion (LCOM4) — start with NativeMessageCellView.swift (3), REDACTED (2), SelectableTextView.swift. — One of this dimension's main actionable groups (36 warning-level).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the code respects its intended layering / architecture rules.
Method: Enforcement rung (Prevented/Verified/Documented) per checkable ADR via Roslyn, plus dependency cycles via the engine shared with D5/AX3. Deterministic, exact.
No mechanizable ADR was identified, so enforcement is not measured. Dependency cycles not checked (no project-reference graph; where this repository's language has an import-cycle lens, cycles are reported there).
What to do
Enforce Architectural Integrity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d7_recommendation.md.
Do you agree with this assessment?
D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.
Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.
12856 test methods: 12852 unit, 0 integration, 0 BDD, 4 e2e. The Python suite contributes 11 test function(s) across 3 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only. The Go suite contributes 4 test case(s) across 1 `_test.go` file(s) declaring at least one — every `func Test…(t *testing.T)` that `go test` would collect, plus the suite methods a testify-style runner reaches; a table-driven case list counts once, so this is a floor. Its tier split is INFERRED from file names, paths and build constraints, not declared: 0 of those file(s) use Go's external test package (`package x_test`), which is a visibility boundary rather than a pyramid tier and was not read as one.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.7 / 10Adequategated by 3 critical findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
41 skipped (34 with a documented reason), 261 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 12841 tests.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 Assertions commented out finding(s) in Test Quality — start with osaurusUITests.swift. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 No assertions (empty test) finding(s) in Test Quality — start with ModelRuntimePrefixTests.swift. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 Test project verifies nothing finding(s) in Test Quality — start with osaurusUITests.swift. — One of this dimension's main actionable groups (1 issue-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
39 outdated direct SwiftPM dependencies, 0 pinning defect(s). 57 of 62 direct dependencies had their releases listed (0 naming no readable repository, 5 pinned to a branch or a revision rather than a version). SwiftPM has no package registry: a dependency is a repository URL and its releases are that repository's semver tags, so currency is answered by listing tags rather than by querying an index. Only a newer tag on the SAME MAJOR is reported — a `from:` requirement admits everything below the next major and nothing above it, so a major crossing needs a Package.swift edit rather than an update, and naming the update as its remedy would be wrong. Whether any dependency is DEPRECATED or ABANDONED is not graded and cannot be: a repository publishes no such marker, and there is no registry that could carry one. Known CVEs in this dependency graph are D30's question.
Outdated: aptabase-swift · ×32
What to do
Enforce Dependency Hygiene in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 45 SwiftPM package(s) use a banned license. SwiftPM has no package registry, so each package's licence is the one its repository declares: 42 of them read from the licence file the repository carries at the revision REDACTED pins, and 3 — unpinned, or whose licence file could not be read or named — from api.deps.dev, which reports the licence the repository declares today. Graded: every package a committed REDACTED pins, direct and transitive, and every declared dependency none pins. 1 of them are declared by a manifest that commits no REDACTED (a library, whose resolution is its consumer's), so their own dependencies are resolved by whoever builds it and are not in this verdict. 3 of them declare no licence that matches a known SPDX licence; that is missing data, not a violation, and none of them is charged.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Resolve the 128 Hotspot finding(s) in Churn × Complexity Hotspots — start with ChatView.swift, HTTPHandler.swift, AgentToolLoop.swift. — One of this dimension's main actionable groups (128 warning-level).
Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with CodeBlockView.swift. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor8.5 / 10Strong✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
207 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift. Counted over 1406 of the 1587 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1 · ×4
Further sole-owners (lower concentration)
What to do
Resolve the 4 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (4 recommendation-level).
Resolve the 1 Further sole-owners (lower concentration) finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
13 deducted task-comment markers across 690981 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
Resolve the 12 TodoComment finding(s) in Explicit Debt — start with AgentToolLoop.swift (4), AgentInlineBlocks.swift (2), ChatView.swift (2). — One of this dimension's main actionable groups (12 warning-level).
Resolve the 1 HackComment finding(s) in Explicit Debt — start with EvalBootstrap.swift. — One of this dimension's main actionable groups (1 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
0 of 1 evaluated ADRs have a defect readable from the log itself (a missing or empty section, no title, a single option, consequences with no cost, no status, a missing enforcement field, a status the log contradicts, a dangling link, an unlinked second decision on one question). How well each record argues its case is not measured.
2 of 9 build units (Go, Make, SwiftPM, Xcode) flagged as possibly oversized/incoherent. This repository's .c source was read by no build unit, so this covers part of the tree, not all of it.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: REDACTED scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
5 finding(s): 0 critical, 5 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
What to do
Resolve the 5 REDACTED finding(s) in Secrets (history) — start with REDACTED (2), REDACTED, REDACTED. — One of this dimension's main actionable groups (5 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
44 finding(s): 0 critical, 44 high, 0 medium, 0 low. 42 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 51 file(s) — `Packages/OsaurusCore/AppDelegate.swift` (line 187, line 754), `Packages/OsaurusCore/Folder/ChatFolderState.swift` (line 360), `Packages/OsaurusCore/Managers/AgentManager.swift` (line 75), `Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift` (lines 346–347, line 349, lines 364–365, …), `Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift` (lines 551–552), … (+46 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 4 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.
REDACTED
REDACTED
What to do
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 issue-level).
No action in Static Analysis (SAST) — all 42 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (42 issue-level, 0 of them charged here).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.
Resolve the 1 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 6 Medium CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (3), REDACTED (3). — One of this dimension's main actionable groups (6 warning-level).
Resolve the 1 Medium vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
39 of 1406 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalScoreboard.swift. Counted over 1406 of the 1587 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Resolve the 4 Orphaned knowledge finding(s) in Knowledge Freshness — start with EvalScoreboard.swift, EvalReviewReport.swift, EvalReviewReportCLI.swift. — One of this dimension's main actionable groups (4 issue-level).
Resolve the 35 Orphaned file finding(s) in Knowledge Freshness — start with InstallationDiagnostics.swift, classify-runtime-proof-summary.py, PairingApprovalView.swift. — One of this dimension's main actionable groups (35 recommendation-level).
Resolve the 1 Further orphaned files (smaller) finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 6 Change coupling finding(s) in Change Coupling — start with SystemPermission.swift, NativeBlockViews.swift, ChatConfiguration.swift. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 1 Change-coupling hub finding(s) in Change Coupling — start with Package.swift. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.
Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.
What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.
Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 0 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Do you agree with this assessment?
AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified
Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.
Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.
Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.
Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.
Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.
Do you agree with this assessment?
DM4 · Rich vs anemic domain model10.0 / 10Exemplary✓ Tool-verified
Other · Domain Modelling — Whether domain entities own their behaviour — a data-only reference entity whose logic lives in a foreign service is anemic. Rich models enforce their own invariants.
Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.
Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.
Other · Domain Modelling — Whether a reference entity protects its own invariants — a class whose identity is a computed content hash but whose hashed fields are publicly mutable bypasses that invariant. Encapsulated state keeps identity-bearing fields immutable.
Method: Roslyn (DDD-gated): entities scanned for publicly writable state — public setters, and (C#/VB) own mutable collections handed out through an auto-property, a public field or a bare-field expression getter, where a computed/copying getter is never charged. One finding per entity; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.
Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.
Other · Domain Modelling — Whether the domain layer stays free of infrastructure dependencies — a domain entity fused to a persistence ORM on its own declaration (active-record), or reaching a web-framework transport type in its own method, couples the domain to infrastructure. The clean-architecture dependency rule.
Method: Roslyn (DDD-gated): domain-layer types scanned for infrastructure usage in member SIGNATURES and inside method/accessor BODIES — resolved calls and object-creations into EF/Marten/HTTP/Mongo/Redis/message-bus types (not just a namespace allowlist). Deterministic, symbol-resolved, exhaustive over domain-layer bodies, DDD-native.
Coverage: Domain layer identified by NAMESPACE heuristic; infrastructure then resolved by symbol in member SIGNATURES and method/accessor BODIES — rename the layer and the check evaporates.
Other · Event-Driven — Whether event/message handlers avoid synchronous blocking waits — a blocking wait inside a handler stalls throughput and risks deadlock.
Method: Roslyn semantic scan (event-driven gated): event-handler bodies scanned for HTTP/gRPC invocations by resolved symbol type, not substring. Deterministic, semantic-resolved.
`ChannelReplayNonceStore.consume` is an event/message handler that blocks on a synchronous wait (a semaphore/queue `.wait`/`.sync`) — it stalls the handler on a peer or resource and serialises throughput, and can deadlock under load. Await the work asynchronously (`async`/`await`) instead of blocking the handler. — Packages/OsaurusCore/Services/Channels/ChannelReplayNonceStore.swift:72
`Keychain.onWriteQueueSync` is an event/message handler that blocks on a synchronous wait (a semaphore/queue `.wait`/`.sync`) — it stalls the handler on a peer or resource and serialises throughput, and can deadlock under load. Await the work asynchronously (`async`/`await`) instead of blocking the handler. — Packages/OsaurusCore/Services/Keychain/Keychain.swift:254
What to do
Replace the synchronous wait with `async`/`await` so the handler never blocks on a peer/resource.
Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
What to do
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Add a README to the 5 of 8 project(s) that lack one — worth up to 1.3 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
1 ADR-shaped document(s) detected by content — `Packages/OsaurusEvals/Config/capability-search-sweep.md`. They are not under a conventional ADR folder (docs/adr/) and are not named NNNN-title.md, and this check found them by their decision signature rather than by where they live — so a reader who does not already know these paths has no route to them. Detected by content signature only: records kept outside the repository, or written without a Status/Decision/Consequences shape, are not visible to this check and are not counted here.
What to do
Move ADRs under docs/adr/ (or docs/adrs/) and name them NNNN-title.md so they're easy to find.
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
README.md links to `CONTRIBUTING.md`, but `CONTRIBUTING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — README.md:356
Packages/OsaurusEvals/Suites/ComputerUse/README.md links to `../../../docs/COMPUTER_USE_EVIDENCE.md`, but `Packages/docs/COMPUTER_USE_EVIDENCE.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — Packages/OsaurusEvals/Suites/ComputerUse/README.md:45
What to do
Reconcile the README with reality: README.md links to `CONTRIBUTING.md`, but `CONTRIBUTING.md` does not exist; Packages/OsaurusEvals/Suites/ComputerUse/README.md links to `../../../docs/COMPUTER_USE_EVIDENCE.md`, but `Packages/docs/COMPUTER_USE_EVIDENCE.md` does not exist.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Do you agree with this assessment?
P2 · Observability6.3 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
Only 3/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `App`, `Packages/OsaurusCLI`, `helpers/osaurus-wa`.
What to do
Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
Add OpenTelemetry tracing/metrics (swift-otel with swift-distributed-tracing) so requests are traceable across the system, not just health-probable.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 59583 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
What to do
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.
Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.
What to do
Raise allocation-aware density on the hot paths — currently 164 use(s) across 732,860 production line(s) (~0.2/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
Go: on hot paths, reuse buffers and objects through sync.Pool, preallocate slices and maps with make([]T, 0, n) / make(map[K]V, n), size builders with Grow, append with strconv.Append*, and reslice with buf[:0] instead of allocating anew.
Swift: on hot paths, reserveCapacity before appending, use ContiguousArray for class-element arrays, work in place with withUnsafeBufferPointer/withUnsafeTemporaryAllocation, and make large values ~Copyable with borrowing/consuming parameters.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
`launchAppIfNeeded` is async and calls .waitUntilExit() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs. — Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/AppControl.swift:23
`shutdown` is async and calls .wait() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs. — Packages/OsaurusCore/Models/Plugin/ExternalPlugin.swift:863
`sleep` is async and calls sleep — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs. — Packages/OsaurusCore/Services/AgentChannel/AgentChannelTransportRuntime.swift:80
`extractKernel` is async and calls .waitUntilExit() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs. — Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:2646
What to do
Swift: await instead of blocking — `try await Task.sleep(for:)` for Thread.sleep/sleep, a checked continuation instead of a DispatchSemaphore or DispatchGroup wait, the async Process and URLSession APIs; never park a thread waiting on a Task — the cooperative pool cannot guarantee it progress.
Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.
Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.
Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Only 0/1 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
`configureIsolatedLocalProvider` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — scripts/evals/pi-harness-runner.mjs:32
What to do
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.
Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.
Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.
Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.
Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×2) — scripts/evals/pi-harness-runner.mjs:235, scripts/evals/pi-harness-runner.mjs:241
`if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — helpers/osaurus-wa/rpc.go:40
`catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×37) — Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:308, Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalReviewReportCLI.swift:710, Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:172, …
What to do
Swallowed exception (empty catch)
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 3 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X6 Hand-rolled structured-format parsing — 4 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 4 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C4 Data Retention — Not assessed: this repository stores data through 'SQLite3' (Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:2) but declares no persisted model this check reads (SwiftData @Model, Core Data, Realm, GRDB and Fluent types, GRDB and SQLite.swift columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL migrations). Personal data may be written through raw SQL or a hosted backend, so whether a retention limit applies here could not be established, and its absence is not scored.
C5 Data-Subject Rights — Not assessed: this repository stores data through 'SQLite3' (Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:2) but declares no persisted model this check reads (SwiftData @Model, Core Data NSManagedObject, Realm Object, GRDB record and Fluent Model properties, GRDB and SQLite.swift columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether data-subject rights apply here could not be established, and their absence is not scored.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 51 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No Go request handler (a net/http, Gin, Echo, Fiber or fasthttp handler, or a gRPC service method) is declared as a method or function, and no handler function literal writes a value captured from outside it, so no state is shared between request goroutines. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. No Swift request handler (a Vapor, Hummingbird, Kitura, Swifter or Perfect route handler, as a method or a registered closure) is declared, so no state is shared between request threads. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
AXR1 Runtime accessibility — docker build failed (exit 1) — ------ Dockerfile:1 -------------------- 1 | >>> FROM alpine:latest 2 | 3 | RUN mkdir -p /run /tmp -------------------- ERROR: failed to solve: alpine:latest: failed to resolve source metadata for docker.io/library/alpine:latest: failed to do request: Head "https://registry-1.docker.io/v2/library/alpine/manifests/latest": Forbidden; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
D11 Test Reliability — Test reliability not included — the .swift suite was found but not re-run
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D21 Naming Consistency — Naming consistency is measured on C# only; Go, JavaScript, Python, Swift not measured.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed Swift surface was not measured.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — D24 reads C# and Visual Basic comments only — this repository's production source is .go, .py, .swift, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D25 ADR Conformance — None of 0 binding record(s) states a rule in checkable form (a backticked element with a prohibition, or an `adr-rules` block), so conformance cannot be read from the code. Write the rule as an `adr-rules` block (`forbid:` a symbol, a package or a dependency) to make it checkable.
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.swift), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D32 Data Compliance (PII/GDPR) — 235 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D8 Code Coverage — Coverage not measured — Swift suite
DM1 Aggregate boundaries — not scored for Swift: the sidecar flattens array/collection types (a child COLLECTION = legitimate membership vs a single embedded aggregate is indistinguishable), and aggregate-vs-value-object classification cannot be told apart in source (every struct-holding-struct reads alike) — reported as guidance rather than measured
DM2 Strongly-typed ids — no in-repo typed-id idiom — primitive-obsession recorded as advisory DM8, DM2 not gated
DM3 Integration-event coupling — not scored for Swift: a cross-SwiftPM-target domain leak cannot be told apart in source from a legitimate shared-kernel/contracts module, and most repositories ship a single module — reported as guidance rather than measured
DM7 Repository granularity — not scored for Swift: 'a repository per CHILD entity' needs the aggregate-root structure, which is not source-resolvable — reported as guidance rather than measured
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — Reported, not scored — this card publishes what the CI gate does with the test inventory rather than grading it. The findings above are its output.
P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the Go, JavaScript/TypeScript, Python, Swift source, so there is no service whose uptime a failing dependency could take down
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (lcov — `swift test --enable-code-coverage` (SwiftPM) or `xcodebuild test -scheme <YourScheme> -enableCodeCoverage YES` (an .xcodeproj/.xcworkspace suite), then `xcrun llvm-cov export -format=lcov`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for `Benchmark("…")` in a file importing package-benchmark, or package-benchmark in Package.swift, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
Orphaned knowledge Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalScoreboard.swift:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalReviewReportCLI.swift:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Blocking wait inside a handler: ChannelReplayNonceStore.consume Packages/OsaurusCore/Services/Channels/ChannelReplayNonceStore.swift:72— `ChannelReplayNonceStore.consume` is an event/message handler that blocks on a synchronous wait (a semaphore/queue `.wait`/`.sync`) — it stalls the handler on a peer or resource and serialises throughput, and can deadlock under load. Await the work asynchronously (`async`/`await`) instead of blocking the handler.
Blocking wait inside a handler: Keychain.onWriteQueueSync Packages/OsaurusCore/Services/Keychain/Keychain.swift:254— `Keychain.onWriteQueueSync` is an event/message handler that blocks on a synchronous wait (a semaphore/queue `.wait`/`.sync`) — it stalls the handler on a peer or resource and serialises throughput, and can deadlock under load. Await the work asynchronously (`async`/`await`) instead of blocking the handler.
Assertions commented out: testExample App/osaurusUITests/osaurusUITests.swift:25— The test body contains commented-out assertion calls and no live one — it runs, verifies nothing, and still passes. Restore the assertions or delete the test; a green test that checks nothing is worse than an absent one.
D10 · Test Quality· No assertions (empty test) · ×1
No assertions (empty test): modelRuntimeIsAnActor Packages/OsaurusCore/Tests/Model/ModelRuntimePrefixTests.swift:22— Test method has an empty body — it asserts nothing and exercises no code.
D10 · Test Quality· Test project verifies nothing · ×1
Test project verifies nothing: osaurusUITests App/osaurusUITests/osaurusUITests.swift:25— No conventional assertion call was detected in 3 of 3 tests in `osaurusUITests` — the project as a whole, not one method. 1 of them has its assertions commented out, so this suite did verify conventionally and was switched off — it is not an approval/verifier harness.
No assertions: testLaunchPerformance App/osaurusUITests/osaurusUITests.swift:51— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: testLaunch App/osaurusUITests/osaurusUITestsLaunchTests.swift:20— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: nonImageToolResult_isIgnored Packages/OsaurusCore/Tests/AgentDelegation/NativeImageToolArtifactBridgeTests.swift:249— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: createWithAppleApps Packages/OsaurusCore/Tests/AppleApps/AppleAppsDeclarativeConfigTests.swift:204— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: blankScriptInvalid Packages/OsaurusCore/Tests/AppleScript/AppleScriptTests.swift:45— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: missingScriptInvalid Packages/OsaurusCore/Tests/AppleScript/AppleScriptTests.swift:54— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: nonJSONInvalid Packages/OsaurusCore/Tests/AppleScript/AppleScriptTests.swift:63— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: reasoningOnlyLengthIsNotClassifiedAsFinalResponse Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:553— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: reasoningOnlyNaturalStopRequiresVisibleAnswer Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:566— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: intentionalReasoningOnlyDirectChatRemainsFinal Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:579— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: intentionalUnclosedReasoningOnlyDirectChatRemainsFinal Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:592— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: unclosedReasoningWithContentEndsWithoutTransparentReplay Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:627— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: announceOnlyTextIsRecoverableNotFinal Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:711— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: genuineAnswersStayFinal Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:912— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: announceOnlyTextIsFinalWhenNoToolsWereOffered Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:938— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: omittedContentPreservesFinalResponseClassification Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:955— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: announceCheckDoesNotShadowEarlierTerminalReasons Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:971— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: permissionToContinueIsFlagged Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:992— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: substantiveQuestionsAreNotTreatedAsStalls Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:1018— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: continuationPhraseMidAnswerDoesNotFlag Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:1043— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: runtimeContextErrorPropagatesDespiteEstimate Packages/OsaurusCore/Tests/Chat/AgentToolLoopTests.swift:3223— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: multiToolRequiredChoiceStaysRequired Packages/OsaurusCore/Tests/Chat/ChatEngineTests.swift:453— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: deleteSessionsAsync_emptyBatchFiresCompletionImmediately Packages/OsaurusCore/Tests/Chat/ChatHistoryDatabaseTests.swift:395— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: rejectsClaudeExportIndexWithBatchNames Packages/OsaurusCore/Tests/Chat/ChatSessionImporterTests.swift:436— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: codingRequest_withBareSingularNoun_doesNotForceRedactFile Packages/OsaurusCore/Tests/Chat/ChatToolChoicePolicyTests.swift:235— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
MethodTooLong: ChatSession.dispatchSend Packages/OsaurusCore/Views/Chat/ChatView.swift:6498— MethodTooLong — dispatchSend runs 1147 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1047 over it, 11.47× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AppleScriptLoop.run Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:310— MethodTooLong — run runs 1030 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 930 over it, 10.30× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HTTPHandler.handleAgentRunEndpoint Packages/OsaurusCore/Networking/HTTPHandler.swift:9936— MethodTooLong — handleAgentRunEndpoint runs 942 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 842 over it, 9.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HTTPHandler.channelRead Packages/OsaurusCore/Networking/HTTPHandler.swift:489— MethodTooLong — channelRead runs 788 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 688 over it, 7.88× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AgentToolLoop.run Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2334— MethodTooLong — run runs 695 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 595 over it, 6.95× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: SubagentSession.runPrepared Packages/OsaurusCore/Subagent/SubagentSession.swift:519— MethodTooLong — runPrepared runs 610 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 510 over it, 6.10× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AgentLoopEvaluator.runConversation Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:702— MethodTooLong — runConversation runs 497 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 397 over it, 4.97× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: EvalRunner.runAgentLoopCaseWithSettings Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:33— MethodTooLong — runAgentLoopCaseWithSettings runs 472 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 372 over it, 4.72× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ConfigPlanner.validate Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:400— MethodTooLong — validate runs 435 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 335 over it, 4.35× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ModelRuntime.loadContainer Packages/OsaurusCore/Services/ModelRuntime.swift:4520— MethodTooLong — loadContainer runs 421 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 321 over it, 4.21× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ChatView.chatModeContent Packages/OsaurusCore/Views/Chat/ChatView.swift:10106— MethodTooLong — chatModeContent runs 411 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 311 over it, 4.11× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HTTPHandler.handlePluginRoute Packages/OsaurusCore/Networking/HTTPHandler.swift:2873— MethodTooLong — handlePluginRoute runs 407 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 307 over it, 4.07× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HTTPHandler.handleChatCompletions Packages/OsaurusCore/Networking/HTTPHandler.swift:14446— MethodTooLong — handleChatCompletions runs 396 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 296 over it, 3.96× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: SystemPromptComposer.appendGatedSections Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:968— MethodTooLong — appendGatedSections runs 390 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 290 over it, 3.90× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: EvalRunner.runCacheProofCase Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerCacheProof.swift:158— MethodTooLong — runCacheProofCase runs 361 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 261 over it, 3.61× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ClaudePluginInstaller.install Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:221— MethodTooLong — install runs 346 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 246 over it, 3.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: TokenizerBridge.applyChatTemplate Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:211— MethodTooLong — applyChatTemplate runs 343 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 243 over it, 3.43× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AgentChannelEvalHarness.runProactivePublish REDACTED:663— MethodTooLong — runProactivePublish runs 307 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 207 over it, 3.07× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ChatSession.processStreamDeltas Packages/OsaurusCore/Views/Chat/ChatView.swift:5189— MethodTooLong — processStreamDeltas runs 303 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 203 over it, 3.03× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: OsaurusInspectTool.describeItem Packages/OsaurusCore/Tools/ConfigurationTools.swift:1301— MethodTooLong — describeItem runs 290 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 190 over it, 2.90× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: RemoteProviderService._streamRemote Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2851— MethodTooLong — _streamRemote runs 284 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 184 over it, 2.84× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: PluginHostContext.completeStream Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1807— MethodTooLong — completeStream runs 281 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 181 over it, 2.81× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ModelDownloadService.runOrchestration Packages/OsaurusCore/Services/ModelDownloadService.swift:376— MethodTooLong — runOrchestration runs 274 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 174 over it, 2.74× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ContentBlock.generateBlocks Packages/OsaurusCore/Models/Chat/ContentBlock.swift:591— MethodTooLong — generateBlocks runs 273 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 173 over it, 2.73× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HTTPHandler.handleCompletions Packages/OsaurusCore/Networking/HTTPHandler.swift:13991— MethodTooLong — handleCompletions runs 270 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 170 over it, 2.70× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FileTooLong: Networking/HTTPHandler.swift Packages/OsaurusCore/Networking/HTTPHandler.swift— FileTooLong — 13112 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: HTTPHandler (222-18250). The bar is 500 significant lines; this is 12612 over it, 26.22× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Chat/ChatView.swift Packages/OsaurusCore/Views/Chat/ChatView.swift— FileTooLong — 6411 significant lines (blank, comment-only and punctuation-only lines excluded), about 69% of them inside a single declaration: ChatSession (143-9064). The bar is 500 significant lines; this is 5911 over it, 12.82× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Agent/AgentsView.swift Packages/OsaurusCore/Views/Agent/AgentsView.swift— FileTooLong — 6064 significant lines (blank, comment-only and punctuation-only lines excluded), about 67% of them inside a single declaration: AgentDetailView (1380-7679). The bar is 500 significant lines; this is 5564 over it, 12.13× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Chat/FloatingInputCard.swift Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift— FileTooLong — 5768 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 5268 over it, 11.54× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Services/ModelRuntime.swift Packages/OsaurusCore/Services/ModelRuntime.swift— FileTooLong — 4880 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 4380 over it, 9.76× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Provider/RemoteProviderService.swift Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift— FileTooLong — 4201 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3701 over it, 8.40× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Folder/FolderTools.swift Packages/OsaurusCore/Folder/FolderTools.swift— FileTooLong — 3740 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3240 over it, 7.48× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Chat/NativeMessageCellView.swift Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift— FileTooLong — 2547 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2047 over it, 5.09× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Tools/BuiltinSandboxTools.swift Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift— FileTooLong — 2394 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1894 over it, 4.79× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Plugin/PluginHostAPI.swift Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift— FileTooLong — 2346 significant lines (blank, comment-only and punctuation-only lines excluded), about 68% of them inside a single declaration: PluginHostContext (64-2916). The bar is 500 significant lines; this is 1846 over it, 4.69× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Schedule/SchedulesView.swift Packages/OsaurusCore/Views/Schedule/SchedulesView.swift— FileTooLong — 2341 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1841 over it, 4.68× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Settings/ProvidersView.swift Packages/OsaurusCore/Views/Settings/ProvidersView.swift— FileTooLong — 2280 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1780 over it, 4.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Chat/ChatSessionSidebar.swift Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift— FileTooLong — 2229 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1729 over it, 4.46× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Chat/SystemPromptComposer.swift Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift— FileTooLong — 2138 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: SystemPromptComposer (19-4084). The bar is 500 significant lines; this is 1638 over it, 4.28× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Plugin/PluginsView.swift Packages/OsaurusCore/Views/Plugin/PluginsView.swift— FileTooLong — 2097 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1597 over it, 4.19× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Storage/MemoryDatabase.swift Packages/OsaurusCore/Storage/MemoryDatabase.swift— FileTooLong — 2031 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: MemoryDatabase (56-3112). The bar is 500 significant lines; this is 1531 over it, 4.06× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Settings/RemoteProviderEditSheet.swift Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift— FileTooLong — 1924 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1424 over it, 3.85× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Settings/ServerView.swift Packages/OsaurusCore/Views/Settings/ServerView.swift— FileTooLong — 1882 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1382 over it, 3.76× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Configuration/SettingsSearchIndex.swift Packages/OsaurusCore/Models/Configuration/SettingsSearchIndex.swift— FileTooLong — 1754 significant lines (blank, comment-only and punctuation-only lines excluded), about 98% of them inside a single declaration: SettingsSearchIndex (78-2247). The bar is 500 significant lines; this is 1254 over it, 3.51× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Declarative/ConfigApplier.swift Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift— FileTooLong — 1751 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: ConfigApplier (68-2511). The bar is 500 significant lines; this is 1251 over it, 3.50× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Declarative/ConfigPlanner.swift Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift— FileTooLong — 1749 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: ConfigPlanner (163-2523). The bar is 500 significant lines; this is 1249 over it, 3.50× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: OsaurusEvalsKit/EvalCase.swift Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift— FileTooLong — 1743 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: EvalCase (23-3620). The bar is 500 significant lines; this is 1243 over it, 3.49× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Loop/AppleScriptLoop.swift Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift— FileTooLong — 1742 significant lines (blank, comment-only and punctuation-only lines excluded), about 93% of them inside a single declaration: AppleScriptLoop (305-2639). The bar is 500 significant lines; this is 1242 over it, 3.48× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Chat/AgentToolLoop.swift Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift— FileTooLong — 1733 significant lines (blank, comment-only and punctuation-only lines excluded), about 74% of them inside a single declaration: AgentToolLoop (1122-3550). The bar is 500 significant lines; this is 1233 over it, 3.47× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Storage/AgentDatabase.swift Packages/OsaurusCore/Storage/AgentDatabase.swift— FileTooLong — 1697 significant lines (blank, comment-only and punctuation-only lines excluded), about 90% of them inside a single declaration: AgentDatabase (289-2661). The bar is 500 significant lines; this is 1197 over it, 3.39× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
ClassTooLong: HTTPHandler Packages/OsaurusCore/Networking/HTTPHandler.swift:222— ClassTooLong — 12978 significant lines (blank, comment-only and punctuation-only lines excluded), 245 methods. The bar is 400 significant lines; this is 12578 over it, 32.45× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ChatSession Packages/OsaurusCore/Views/Chat/ChatView.swift:142— ClassTooLong — 4436 significant lines (blank, comment-only and punctuation-only lines excluded), 173 methods. The bar is 400 significant lines; this is 4036 over it, 11.09× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AgentDetailView Packages/OsaurusCore/Views/Agent/AgentsView.swift:1380— ClassTooLong — 4065 significant lines (blank, comment-only and punctuation-only lines excluded), 100 methods. The bar is 400 significant lines; this is 3665 over it, 10.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: SystemPromptComposer Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:19— ClassTooLong — 2135 significant lines (blank, comment-only and punctuation-only lines excluded), 68 methods. The bar is 400 significant lines; this is 1735 over it, 5.34× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: MemoryDatabase Packages/OsaurusCore/Storage/MemoryDatabase.swift:56— ClassTooLong — 2001 significant lines (blank, comment-only and punctuation-only lines excluded), 113 methods. The bar is 400 significant lines; this is 1601 over it, 5.00× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: EvalCase Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:23— ClassTooLong — 1741 significant lines (blank, comment-only and punctuation-only lines excluded), 1 methods. The bar is 400 significant lines; this is 1341 over it, 4.35× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ConfigApplier Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:68— ClassTooLong — 1728 significant lines (blank, comment-only and punctuation-only lines excluded), 44 methods. The bar is 400 significant lines; this is 1328 over it, 4.32× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: SettingsSearchIndex Packages/OsaurusCore/Models/Configuration/SettingsSearchIndex.swift:78— ClassTooLong — 1720 significant lines (blank, comment-only and punctuation-only lines excluded), 2 methods. The bar is 400 significant lines; this is 1320 over it, 4.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ConfigPlanner Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:162— ClassTooLong — 1660 significant lines (blank, comment-only and punctuation-only lines excluded), 44 methods. The bar is 400 significant lines; this is 1260 over it, 4.15× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AppleScriptLoop Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:305— ClassTooLong — 1612 significant lines (blank, comment-only and punctuation-only lines excluded), 27 methods. The bar is 400 significant lines; this is 1212 over it, 4.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: PluginHostContext Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:64— ClassTooLong — 1606 significant lines (blank, comment-only and punctuation-only lines excluded), 120 methods. The bar is 400 significant lines; this is 1206 over it, 4.02× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ChatHistoryDatabase Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:40— ClassTooLong — 1590 significant lines (blank, comment-only and punctuation-only lines excluded), 108 methods. The bar is 400 significant lines; this is 1190 over it, 3.98× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ToolRegistry Packages/OsaurusCore/Tools/ToolRegistry.swift:178— ClassTooLong — 1552 significant lines (blank, comment-only and punctuation-only lines excluded), 85 methods. The bar is 400 significant lines; this is 1152 over it, 3.88× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AgentDatabase Packages/OsaurusCore/Storage/AgentDatabase.swift:289— ClassTooLong — 1519 significant lines (blank, comment-only and punctuation-only lines excluded), 74 methods. The bar is 400 significant lines; this is 1119 over it, 3.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: EvalRunner Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:18— ClassTooLong — 1499 significant lines (blank, comment-only and punctuation-only lines excluded), 155 methods. The bar is 400 significant lines; this is 1099 over it, 3.75× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: MLXBatchAdapter Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:33— ClassTooLong — 1460 significant lines (blank, comment-only and punctuation-only lines excluded), 40 methods. The bar is 400 significant lines; this is 1060 over it, 3.65× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ComputerUseLoop Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:175— ClassTooLong — 1414 significant lines (blank, comment-only and punctuation-only lines excluded), 38 methods. The bar is 400 significant lines; this is 1014 over it, 3.54× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AgentChannelConnectionService Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:36— ClassTooLong — 1372 significant lines (blank, comment-only and punctuation-only lines excluded), 47 methods. The bar is 400 significant lines; this is 972 over it, 3.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ChatWindowState Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:140— ClassTooLong — 1316 significant lines (blank, comment-only and punctuation-only lines excluded), 90 methods. The bar is 400 significant lines; this is 916 over it, 3.29× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AgentChannelMessageStore Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:460— ClassTooLong — 1299 significant lines (blank, comment-only and punctuation-only lines excluded), 70 methods. The bar is 400 significant lines; this is 899 over it, 3.25× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AgentToolLoop Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:1122— ClassTooLong — 1291 significant lines (blank, comment-only and punctuation-only lines excluded), 46 methods. The bar is 400 significant lines; this is 891 over it, 3.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ChatView Packages/OsaurusCore/Views/Chat/ChatView.swift:9093— ClassTooLong — 1280 significant lines (blank, comment-only and punctuation-only lines excluded), 47 methods. The bar is 400 significant lines; this is 880 over it, 3.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: N8nSettingsView Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:23— ClassTooLong — 1257 significant lines (blank, comment-only and punctuation-only lines excluded), 32 methods. The bar is 400 significant lines; this is 857 over it, 3.14× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ModelDownloadView Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:54— ClassTooLong — 1250 significant lines (blank, comment-only and punctuation-only lines excluded), 32 methods. The bar is 400 significant lines; this is 850 over it, 3.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ProviderEditSheet Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1176— ClassTooLong — 1239 significant lines (blank, comment-only and punctuation-only lines excluded), 36 methods. The bar is 400 significant lines; this is 839 over it, 3.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Hotspot: Packages/OsaurusCore/Views/Chat/ChatView.swift Packages/OsaurusCore/Views/Chat/ChatView.swift:6498— Packages/OsaurusCore/Views/Chat/ChatView.swift changed 137 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 225 in ChatSession.dispatchSend at line 6498. 22 of those changes were fix/bug commits, and the other 115 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Chat/ChatView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Networking/HTTPHandler.swift Packages/OsaurusCore/Networking/HTTPHandler.swift:489— Packages/OsaurusCore/Networking/HTTPHandler.swift changed 65 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 249 in HTTPHandler.channelRead at line 489. 4 of those changes were fix/bug commits, and the other 61 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Networking/HTTPHandler.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2334— Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 155 in AgentToolLoop.run at line 2334. 4 of those changes were fix/bug commits, and the other 27 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:2713— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift changed 44 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 102 in SystemPromptComposer.resolveTools at line 2713. 5 of those changes were fix/bug commits, and the other 39 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/ModelRuntime.swift Packages/OsaurusCore/Services/ModelRuntime.swift:4520— Packages/OsaurusCore/Services/ModelRuntime.swift changed 74 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 58 in ModelRuntime.loadContainer at line 4520. 14 of those changes were fix/bug commits, and the other 60 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/ModelRuntime.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:908— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift changed 86 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in FloatingInputCard.body at line 908. 9 of those changes were fix/bug commits, and the other 77 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:400— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 184 in ConfigPlanner.validate at line 400. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Tools/ToolRegistry.swift Packages/OsaurusCore/Tools/ToolRegistry.swift:1117— Packages/OsaurusCore/Tools/ToolRegistry.swift changed 47 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in ToolRegistry.execute at line 1117. 7 of those changes were fix/bug commits, and the other 40 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Tools/ToolRegistry.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/AppDelegate.swift Packages/OsaurusCore/AppDelegate.swift:172— Packages/OsaurusCore/AppDelegate.swift changed 46 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in AppDelegate.applicationDidFinishLaunching at line 172. 5 of those changes were fix/bug commits, and the other 41 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/AppDelegate.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:1259— Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift changed 44 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 55 in MLXBatchAdapter.additionalContext at line 1259. 7 of those changes were fix/bug commits, and the other 37 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2851— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 69 in RemoteProviderService._streamRemote at line 2851. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Subagent/SubagentSession.swift Packages/OsaurusCore/Subagent/SubagentSession.swift:519— Packages/OsaurusCore/Subagent/SubagentSession.swift changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 124 in SubagentSession.runPrepared at line 519. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Subagent/SubagentSession.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:33— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 109 in EvalRunner.runAgentLoopCaseWithSettings at line 33. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Models/Chat/ContentBlock.swift Packages/OsaurusCore/Models/Chat/ContentBlock.swift:591— Packages/OsaurusCore/Models/Chat/ContentBlock.swift changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 111 in ContentBlock.generateBlocks at line 591. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Models/Chat/ContentBlock.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:702— Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 86 in AgentLoopEvaluator.runConversation at line 702. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Managers/Model/ModelManager.swift Packages/OsaurusCore/Managers/Model/ModelManager.swift:2258— Packages/OsaurusCore/Managers/Model/ModelManager.swift changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in ModelManager.scanLocalModels at line 2258. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Managers/Model/ModelManager.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1352— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 67 in ConfigApplier.applyMCPServers at line 1352. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Folder/FolderTools.swift Packages/OsaurusCore/Folder/FolderTools.swift:1175— Packages/OsaurusCore/Folder/FolderTools.swift changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 69 in FileReadTool.readResolved at line 1175. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Folder/FolderTools.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Chat/AgentTaskState.swift Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:662— Packages/OsaurusCore/Services/Chat/AgentTaskState.swift changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 74 in AgentTaskState.record at line 662. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Chat/AgentTaskState.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:211— Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 114 in TokenizerBridge.applyChatTemplate at line 211. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Services/Chat/ChatEngine.swift Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1312— Packages/OsaurusCore/Services/Chat/ChatEngine.swift changed 20 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 49 in ChatEngine.wrapStreamWithLogging at line 1312. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Services/Chat/ChatEngine.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Views/Agent/AgentsView.swift Packages/OsaurusCore/Views/Agent/AgentsView.swift:1875— Packages/OsaurusCore/Views/Agent/AgentsView.swift changed 42 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in AgentDetailView.bodyCore at line 1875. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Agent/AgentsView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2300— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift changed 26 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 33 in SessionRow.body at line 2300. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2602— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in NativeMessageCellView.configureAsUserMessage at line 2602. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Packages/OsaurusCore/Tools/ConfigurationTools.swift Packages/OsaurusCore/Tools/ConfigurationTools.swift:1301— Packages/OsaurusCore/Tools/ConfigurationTools.swift changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 56 in OsaurusInspectTool.describeItem at line 1301. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Tools/ConfigurationTools.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Duplicated block (6 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:370— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:370-375 | Packages/OsaurusCore/Services/HuggingFaceService.swift:1073-1079 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:370` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:516— Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:516-521 | Packages/OsaurusCore/AppleApps/Reminders/RemindersService.swift:395-400 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:380— Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:380-385 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:317-322 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:380` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `service` to `ContactsServicing` in one and `RemindersServicing` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 2) Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120— Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120-125 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:122-128 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:127— Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:127-132 | Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:196-201 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:127` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/AppleScript/Exec/MockAppleScriptWorld.swift:378— Packages/OsaurusCore/AppleScript/Exec/MockAppleScriptWorld.swift:378-383 | Packages/OsaurusCore/Models/Chat/FileDiff.swift:493-498 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Exec/MockAppleScriptWorld.swift:378` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:128— Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:128-133 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3508-3515 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:128` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:364— Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:364-369 | Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:392-397 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:364` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/ElementCache.swift:128— Packages/OsaurusCore/ComputerUse/Driver/Mac/ElementCache.swift:128-133 | Packages/OsaurusCore/ComputerUse/Driver/Mac/ElementCache.swift:176-181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/Mac/ElementCache.swift:128` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:895— Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:895-900 | Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:418-423 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:895` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:897— Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:897-902 | Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:112-117 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:897` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1386— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1386-1391 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2000-2005 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1386` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:330— Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:330-335 | Packages/OsaurusCore/Services/Documents/PDFEditor.swift:339-344 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:330` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Folder/WorkspaceWriteSafety.swift:559— Packages/OsaurusCore/Folder/WorkspaceWriteSafety.swift:559-567 | Packages/OsaurusCore/Services/Knowledge/KnowledgeDiff.swift:94-99 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/WorkspaceWriteSafety.swift:559` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Identity/APIKeyManager.swift:126— Packages/OsaurusCore/Identity/APIKeyManager.swift:126-131 | Packages/OsaurusCore/Identity/APIKeyManager.swift:157-162 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Identity/APIKeyManager.swift:126` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:520— Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:520-526 | Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:643-648 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:520` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Managers/Model/ModelManager.swift:1908— Packages/OsaurusCore/Managers/Model/ModelManager.swift:1908-1920 | Packages/OsaurusCore/Managers/Model/ModelManager.swift:1941-1946 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Model/ModelManager.swift:1908` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:481— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:481-486 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:772-777 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/AnthropicAPI.swift:481` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:262— Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:262-267 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:309-314 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:99— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:99-104 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:160-165 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Models/Chat/RequestLog.swift:833— Packages/OsaurusCore/Models/Chat/RequestLog.swift:833-838 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:892-897 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/RequestLog.swift:833` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:520— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:520-525 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1727-1732 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:520` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:3993— Packages/OsaurusCore/Networking/HTTPHandler.swift:3993-3999 | Packages/OsaurusCore/Networking/HTTPLoopHelpers.swift:181-186 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:3993` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:467— Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:467-472 | Packages/OsaurusCore/Services/HuggingFaceService.swift:792-798 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:467` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:392— Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:392-397 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:75-80 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:377— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:377-381 | Packages/OsaurusCore/Services/HuggingFaceService.swift:1081-1085 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:377` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:586— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:586-590 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:964-968 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:586` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:125— Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:125-129 | Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:147-151 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/AppleApps/Support/AppleSchema.swift:14— Packages/OsaurusCore/AppleApps/Support/AppleSchema.swift:14-18 | Packages/OsaurusCore/Tools/SandboxPluginTool.swift:307-312 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/SandboxPluginTool.swift:307` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatSessionExportCoordinator.swift:154— Packages/OsaurusCore/Managers/Chat/ChatSessionExportCoordinator.swift:154-158 | Packages/OsaurusCore/Managers/Chat/ChatSessionExporter.swift:318-322 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:822— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:822-826 | Packages/OsaurusCore/Managers/WindowManager.swift:521-527 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:822` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:828— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:828-832 | Packages/OsaurusCore/Managers/WindowManager.swift:529-533 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:828` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Managers/Model/ModelManager.swift:1592— Packages/OsaurusCore/Managers/Model/ModelManager.swift:1592-1596 | Packages/OsaurusCore/Managers/Model/ModelManager.swift:1605-1609 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Model/ModelManager.swift:1592` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Managers/WatcherManager.swift:865— Packages/OsaurusCore/Managers/WatcherManager.swift:865-870 | Packages/OsaurusCore/Services/Knowledge/KnowledgeFolderWatcher.swift:183-187 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/WatcherManager.swift:865` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Models/API/EmbeddingAPI.swift:25— Packages/OsaurusCore/Models/API/EmbeddingAPI.swift:25-29 | Packages/OsaurusCore/Services/HuggingFaceService.swift:163-167 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/EmbeddingAPI.swift:25` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1309— Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1309-1313 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1517-1522 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1309` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Models/Chat/FileDiff.swift:277— Packages/OsaurusCore/Models/Chat/FileDiff.swift:277-281 | Packages/OsaurusCore/Models/Chat/FileDiff.swift:285-289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/FileDiff.swift:277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Models/Configuration/MLXModel.swift:356— Packages/OsaurusCore/Models/Configuration/MLXModel.swift:356-360 | Packages/OsaurusCore/Services/ModelRuntime.swift:5849-5874 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/MLXModel.swift:356` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Models/Configuration/ModelOptions.swift:96— Packages/OsaurusCore/Models/Configuration/ModelOptions.swift:96-100 | Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:973-977 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/ModelOptions.swift:96` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:12415— Packages/OsaurusCore/Networking/HTTPHandler.swift:12415-12419 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16938-16948 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12415` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:16938— Packages/OsaurusCore/Networking/HTTPHandler.swift:16938-16942 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17594-17598 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16938` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/PluginHost/main.swift:293— Packages/OsaurusCore/PluginHost/main.swift:293-297 | Packages/OsaurusCore/PluginHost/main.swift:299-303 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PluginHost/main.swift:293` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:206— Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:206-210 | Packages/OsaurusCore/Services/ModelRuntime/ImageEffectiveParameters.swift:24-28 — before extracting anything, compare `Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift` and `Packages/OsaurusCore/Services/ModelRuntime/ImageEffectiveParameters.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:206` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/Auth/PKCE.swift:56— Packages/OsaurusCore/Services/Auth/PKCE.swift:56-60 | Packages/OsaurusCore/Services/Channels/ChannelSecurityEncoding.swift:12-16 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3512— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3512-3516 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2091-2095 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3512` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3517— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3517-3521 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2096-2100 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3517` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) REDACTED:1354— REDACTED:1354-1358 | REDACTED:1369-1377 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1369` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/Documents/CSVEmitter.swift:91— Packages/OsaurusCore/Services/Documents/CSVEmitter.swift:91-95 | Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:512-516 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/CSVEmitter.swift:91` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:213— Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:213-217 | Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:136-140 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) Packages/OsaurusCore/Services/ExternalModelLocator.swift:438— Packages/OsaurusCore/Services/ExternalModelLocator.swift:438-442 | Packages/OsaurusCore/Services/ExternalModelLocator.swift:459-463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ExternalModelLocator.swift:438` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppDelegate.swift:922— Packages/OsaurusCore/AppDelegate.swift:922-930 | Packages/OsaurusCore/AppDelegate.swift:3020-3028 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppleApps/AppleApp.swift:48— Packages/OsaurusCore/AppleApps/AppleApp.swift:48-56 | Packages/OsaurusCore/AppleApps/AppleApp.swift:170-178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/AppleApp.swift:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:433— Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:433-441 | Packages/OsaurusCore/AppleApps/Reminders/RemindersService.swift:350-358 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:433` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:412— Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:412-420 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:318-326 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:412` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:258— Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:258-266 | Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:287-295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:258` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:268` calls `boolean` and `Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:297` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 2) Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:25— Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:25-33 | Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:70-78 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/ComputerUse/Policy/AutonomyPolicy.swift:122— Packages/OsaurusCore/ComputerUse/Policy/AutonomyPolicy.swift:122-130 | Packages/OsaurusCore/ComputerUse/Policy/AutonomyPolicy.swift:132-140 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2173— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2173-2181 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:18-29 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2173` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:340— Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:340-348 | Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:397-405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Folder/FileWriteDocumentRouting.swift:497— Packages/OsaurusCore/Folder/FileWriteDocumentRouting.swift:497-505 | Packages/OsaurusCore/Services/Documents/OOXML/XLSXFormula.swift:53-61 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:4098— Packages/OsaurusCore/Folder/FolderTools.swift:4098-4106 | Packages/OsaurusCore/Folder/FolderTools.swift:4223-4231 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:4098` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:785— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:785-793 | Packages/OsaurusCore/Managers/WindowManager.swift:467-475 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:575— Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:575-583 | Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:644-653 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Managers/InsightsService.swift:679— Packages/OsaurusCore/Managers/InsightsService.swift:679-687 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:568-576 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/InsightsService.swift:679` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Managers/SkillImportPolicy.swift:154— Packages/OsaurusCore/Managers/SkillImportPolicy.swift:154-162 | Packages/OsaurusCore/Managers/SkillManager.swift:726-734 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/AgentChannel/N8nSetupFlow.swift:26— Packages/OsaurusCore/Models/AgentChannel/N8nSetupFlow.swift:26-34 | Packages/OsaurusCore/Models/AgentChannel/N8nSetupFlow.swift:46-54 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:748— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:748-756 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:901-909 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:748` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:63— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:63-71 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:426-434 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:63` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:148— Packages/OsaurusCore/Models/Schedule/Schedule.swift:148-156 | Packages/OsaurusCore/Models/Schedule/Schedule.swift:176-184 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/Schedule.swift:148` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:544— Packages/OsaurusCore/Models/Schedule/Schedule.swift:544-552 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:135-143 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/Schedule.swift:544` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:620— Packages/OsaurusCore/Models/Schedule/Schedule.swift:620-628 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:218-226 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/Schedule.swift:620` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:599— Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:599-607 | Packages/OsaurusCore/Services/Channels/ChannelReplyTokenService.swift:193-201 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Models/Theme/ThemeConfigurationStore.swift:47— Packages/OsaurusCore/Models/Theme/ThemeConfigurationStore.swift:47-55 | Packages/OsaurusCore/Models/Theme/ThemeConfigurationStore.swift:76-84 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/ThemeConfigurationStore.swift:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:8034— Packages/OsaurusCore/Networking/HTTPHandler.swift:8034-8042 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8053-8061 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11864— Packages/OsaurusCore/Networking/HTTPHandler.swift:11864-11872 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12249-12257 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11864` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:12248` calls `runRequestTask` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:11862` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:192— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:192-198 | Packages/OsaurusCore/Services/HuggingFaceService.swift:954-960 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:192` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsList.swift:38— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsList.swift:38-45 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsUninstall.swift:77-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsList.swift:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:111— Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:111-118 | Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:138-144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:232— Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:232-238 | Packages/OsaurusCore/Models/Configuration/CodexCLIConfiguration.swift:353-359 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:138— Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:138-144 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift:54-60 — before extracting anything, compare `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift` and `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:138` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Configuration/Declarative/AgentToolSelectionResolver.swift:61— Packages/OsaurusCore/Configuration/Declarative/AgentToolSelectionResolver.swift:61-67 | Packages/OsaurusCore/Configuration/Declarative/AgentToolSelectionResolver.swift:133-139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2148— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2148-2154 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2172-2178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2148` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2399— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2399-2405 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2469-2475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2399` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:322— Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:322-328 | Packages/OsaurusCore/Services/Documents/PDFEditor.swift:331-337 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:322` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:5798— Packages/OsaurusCore/Folder/FolderTools.swift:5798-5804 | Packages/OsaurusCore/Folder/FolderTools.swift:5887-5893 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:5798` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:845— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:845-851 | Packages/OsaurusCore/Managers/WindowManager.swift:585-591 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:845` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:246— Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:246-252 | Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:285-291 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1348— Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1348-1354 | Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1361-1368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1348` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Managers/SkillManager.swift:982— Packages/OsaurusCore/Managers/SkillManager.swift:982-988 | Packages/OsaurusCore/Managers/SkillManager.swift:1013-1019 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/SkillManager.swift:982` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Managers/SkillManager.swift:1021` calls `deletingLastPathComponent` and `Packages/OsaurusCore/Managers/SkillManager.swift:990` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Models/Agent/Agent.swift:1452— Packages/OsaurusCore/Models/Agent/Agent.swift:1452-1458 | Packages/OsaurusCore/Models/AgentDelegation/SubagentConfiguration.swift:1236-1242 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:6074— Packages/OsaurusCore/Networking/HTTPHandler.swift:6074-6080 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7069-7075 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6074` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:12609— Packages/OsaurusCore/Networking/HTTPHandler.swift:12609-12618 | Packages/OsaurusCore/Services/Harness/HarnessTurnDriver.swift:78-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12609` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1304— Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1304-1310 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1331-1337 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1304` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424-3430 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3587-3593 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/Documents/PDFReadingOrder.swift:460— Packages/OsaurusCore/Services/Documents/PDFReadingOrder.swift:460-466 | Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:378-384 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/PDFReadingOrder.swift:460` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:33— Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:33-39 | Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:50-56 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:503— Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:503-509 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift:597-603 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:503` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:49— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:49-55 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:44-50 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:49` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/LocalReasoningCapability.swift:663— Packages/OsaurusCore/Services/LocalReasoningCapability.swift:663-670 | Packages/OsaurusCore/Services/LocalReasoningCapability.swift:700-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:72— Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:72-78 | Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:153-159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:72` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:90— Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:90-97 | Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:65-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:90` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:235— Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:235-242 | Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:253-260 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Managers/InsightsService.swift:426— Packages/OsaurusCore/Managers/InsightsService.swift:426-433 | Packages/OsaurusCore/Managers/InsightsService.swift:439-446 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/InsightsService.swift:439` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Managers/InsightsService.swift:437` calls `trimmingCharacters` and `Packages/OsaurusCore/Managers/InsightsService.swift:425` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Managers/InsightsService.swift:669— Packages/OsaurusCore/Managers/InsightsService.swift:669-676 | Packages/OsaurusCore/Managers/InsightsService.swift:985-992 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:1660— Packages/OsaurusCore/Managers/MCPProviderManager.swift:1660-1667 | Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:589-597 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:589` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1199— Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1199-1206 | Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1209-1216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1199` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Models/Agent/Agent.swift:44— Packages/OsaurusCore/Models/Agent/Agent.swift:44-51 | Packages/OsaurusCore/Models/Agent/Agent.swift:83-95 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Agent.swift:44` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Models/Agent/DefaultAgentConfigurationStore.swift:83— Packages/OsaurusCore/Models/Agent/DefaultAgentConfigurationStore.swift:83-90 | Packages/OsaurusCore/Models/Configuration/AppConfiguration.swift:230-237 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/DefaultAgentConfigurationStore.swift:83` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:772— Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:772-779 | Packages/OsaurusCore/Tools/Database/DatabaseFilePathResolver.swift:294-301 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:772` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:65— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:65-72 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:309-316 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:65` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:27— Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:27-34 | Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:74-81 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:27` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:1744— Packages/OsaurusCore/Networking/HTTPHandler.swift:1744-1751 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15840-15847 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1744` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:4867— Packages/OsaurusCore/Networking/HTTPHandler.swift:4867-4874 | Packages/OsaurusCore/Networking/HTTPLoopHelpers.swift:167-174 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4867` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:14455— Packages/OsaurusCore/Networking/HTTPHandler.swift:14455-14462 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17565-17572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14455` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17122— Packages/OsaurusCore/Networking/HTTPHandler.swift:17122-17129 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17206-17213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:487— Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:487-494 | Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:599-606 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:597` calls `error` and `Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:486` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:395— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:395-402 | Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:292-303 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:395` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:304` calls `pointingHandCursor` and `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:403` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:237— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:237-244 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:247-254 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:237` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) REDACTED:780— REDACTED:780-787 | REDACTED:811-818 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:780` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:345— Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:345-352 | Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:355-362 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:407— Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:407-414 | Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:453-460 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:407` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:789— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:789-798 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:876-883 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:789` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:844— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:844-851 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:876-883 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:844` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Documents/BusinessDocumentStudioService.swift:876— Packages/OsaurusCore/Services/Documents/BusinessDocumentStudioService.swift:876-883 | Packages/OsaurusCore/Services/Documents/PDFPPTXWorkflowService.swift:251-264 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/PDFPPTXWorkflowService.swift:251` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) Packages/OsaurusCore/Services/Documents/PDFPPTXWorkflowService.swift:114— Packages/OsaurusCore/Services/Documents/PDFPPTXWorkflowService.swift:114-121 | Packages/OsaurusCore/Services/Documents/PDFPPTXWorkflowService.swift:186-193 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
TooManyMethods: HTTPHandler Packages/OsaurusCore/Networking/HTTPHandler.swift:222— TooManyMethods — 245 methods, declared across 4 files: Networking/HTTPHandler.swift (228), Networking/HTTPProtocolErrors.swift (11), Networking/HTTPLoopHelpers.swift (4), Networking/HTTPRequestParse.swift (2). The bar is 30 methods; this is 215 over it, 8.17× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ModelRuntime Packages/OsaurusCore/Services/ModelRuntime.swift:155— TooManyMethods — 206 methods. The bar is 30 methods; this is 176 over it, 6.87× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ChatSession Packages/OsaurusCore/Views/Chat/ChatView.swift:142— TooManyMethods — 173 methods, declared across 4 files: Chat/ChatView.swift (163), Chat/ChatSessionWarmup.swift (4), Chat/ChatSession+Harness.swift (4), Folder/PromptWorkingFolderTool.swift (2). The bar is 30 methods; this is 143 over it, 5.77× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: RemoteProviderService Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:157— TooManyMethods — 159 methods. The bar is 30 methods; this is 129 over it, 5.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: PluginHostContext Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:64— TooManyMethods — 120 methods, declared across 2 files: Plugin/PluginHostAPI.swift (115), Plugin/PluginHostAPI+SessionPersistence.swift (5). The bar is 30 methods; this is 90 over it, 4.00× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: MemoryDatabase Packages/OsaurusCore/Storage/MemoryDatabase.swift:56— TooManyMethods — 113 methods. The bar is 30 methods; this is 83 over it, 3.77× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ChatHistoryDatabase Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:40— TooManyMethods — 108 methods. The bar is 30 methods; this is 78 over it, 3.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AgentDetailView Packages/OsaurusCore/Views/Agent/AgentsView.swift:1380— TooManyMethods — 100 methods. The bar is 30 methods; this is 70 over it, 3.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: BackgroundTaskManager REDACTED:79— TooManyMethods — 93 methods. The bar is 30 methods; this is 63 over it, 3.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: FloatingInputCard Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:16— TooManyMethods — 92 methods. The bar is 30 methods; this is 62 over it, 3.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ChatWindowState Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:140— TooManyMethods — 90 methods. The bar is 30 methods; this is 60 over it, 3.00× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: FileChangeJournal Packages/OsaurusCore/Services/FileHistory/FileChangeJournal.swift:32— TooManyMethods — 89 methods, declared across 3 files: FileHistory/FileChangeJournal.swift (56), FileHistory/FileChangeJournal+Revert.swift (32), FileHistory/FileDiffEngine.swift (1). The bar is 30 methods; this is 59 over it, 2.97× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ToolRegistry Packages/OsaurusCore/Tools/ToolRegistry.swift:178— TooManyMethods — 85 methods. The bar is 30 methods; this is 55 over it, 2.83× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AgentManager Packages/OsaurusCore/Managers/AgentManager.swift:54— TooManyMethods — 84 methods, declared across 2 files: Managers/AgentManager.swift (79), Managers/AgentManager+Harness.swift (5). The bar is 30 methods; this is 54 over it, 2.80× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: OsaurusRouterAPIClient Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:3— TooManyMethods — 81 methods. The bar is 30 methods; this is 51 over it, 2.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: RemoteProviderManager Packages/OsaurusCore/Managers/RemoteProviderManager.swift:46— TooManyMethods — 77 methods. The bar is 30 methods; this is 47 over it, 2.57× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: OsaurusEvalsCLI Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:28— TooManyMethods — 77 methods, declared across 8 files: OsaurusEvalsCLI/EvalReviewReportCLI.swift (22), OsaurusEvalsCLI/OsaurusEvalsCLI.swift (15), OsaurusEvalsCLI/OsaurusEvalsCaptureScreenCLI.swift (12), OsaurusEvalsCLI/EvalDiffMatrixCLI.swift (10), +4 more file(s). The bar is 30 methods; this is 47 over it, 2.57× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: SlackConnectionService Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:328— TooManyMethods — 76 methods. The bar is 30 methods; this is 46 over it, 2.53× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AgentDatabase Packages/OsaurusCore/Storage/AgentDatabase.swift:289— TooManyMethods — 74 methods. The bar is 30 methods; this is 44 over it, 2.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: WorkspacesService Packages/OsaurusCore/Services/Router/WorkspacesService.swift:15— TooManyMethods — 71 methods. The bar is 30 methods; this is 41 over it, 2.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AppDelegate Packages/OsaurusCore/AppDelegate.swift:21— TooManyMethods — 70 methods. The bar is 30 methods; this is 40 over it, 2.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AgentChannelMessageStore Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:460— TooManyMethods — 70 methods. The bar is 30 methods; this is 40 over it, 2.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: SystemPromptComposer Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:19— TooManyMethods — 68 methods. The bar is 30 methods; this is 38 over it, 2.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: PluginManager Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:15— TooManyMethods — 65 methods. The bar is 30 methods; this is 35 over it, 2.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ChatWindowManager Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:54— TooManyMethods — 64 methods. The bar is 30 methods; this is 34 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Duplicated block (12 lines × 2) Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:117— Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:117-128 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:174-185 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:117` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:81— Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:81-92 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2519-2530 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:81` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206— Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206-217 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2882-2893 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:292— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:292-303 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:312-323 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:292` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:4093— Packages/OsaurusCore/Folder/FolderTools.swift:4093-4104 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:60-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:4093` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Managers/ScheduleManager.swift:547— Packages/OsaurusCore/Managers/ScheduleManager.swift:547-558 | Packages/OsaurusCore/Managers/WatcherManager.swift:716-727 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/ScheduleManager.swift:547` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:206— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:206-217 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:493-504 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/AnthropicAPI.swift:206` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:902— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:902-913 | Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:580-591 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/AnthropicAPI.swift:902` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:204— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:204-215 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:283-294 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:113— Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:113-124 | Packages/OsaurusCore/Models/Template/TemplateRequirements.swift:263-274 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:113` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:76— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:76-87 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:382-393 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:76` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:167— Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:167-178 | Packages/OsaurusCore/Models/Template/TemplateRequirements.swift:262-273 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:167` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:93— Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:93-104 | Packages/OsaurusCore/Models/Watcher/WatcherStore.swift:87-98 — before extracting anything, compare `Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift` and `Packages/OsaurusCore/Models/Watcher/WatcherStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:5810— Packages/OsaurusCore/Networking/HTTPHandler.swift:5810-5821 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6659-6670 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5810` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:5926— Packages/OsaurusCore/Networking/HTTPHandler.swift:5926-5937 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8120-8131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5926` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:6263— Packages/OsaurusCore/Networking/HTTPHandler.swift:6263-6274 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7777-7788 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6263` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11462— Packages/OsaurusCore/Networking/HTTPHandler.swift:11462-11473 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11500-11511 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11462` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15075— Packages/OsaurusCore/Networking/HTTPHandler.swift:15075-15086 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15387-15398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:209— Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:209-220 | Packages/OsaurusCore/Tools/ToolEnvelope.swift:604-615 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:209` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundActivity.swift:158— Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundActivity.swift:158-169 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundActivity.swift:176-187 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundActivity.swift:158` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:494— Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:494-505 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:584-595 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:494` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/AgentCollaboration/AgentCollaborationService.swift:92— Packages/OsaurusCore/Services/AgentCollaboration/AgentCollaborationService.swift:92-103 | Packages/OsaurusCore/Services/AgentCollaboration/AgentCollaborationService.swift:113-124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentCollaboration/AgentCollaborationService.swift:92` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:449— Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:449-460 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:499-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:449` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/ChunkedFileDownloader.swift:677— Packages/OsaurusCore/Services/ChunkedFileDownloader.swift:677-688 | Packages/OsaurusCore/Services/ModelDownloadService.swift:2019-2030 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ChunkedFileDownloader.swift:677` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1117— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1117-1128 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1198-1209 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:325— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:325-337 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:376-388 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:270— Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:270-282 | Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:364-376 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1859— Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1859-1871 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1929-1941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1859` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:51— Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:51-63 | Packages/OsaurusCore/Models/AgentDelegation/DelegationRecord.swift:61-73 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:51` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:750— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:750-762 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:785-797 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:750` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:2480— Packages/OsaurusCore/Folder/FolderTools.swift:2480-2492 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2272-2284 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:2480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:5367— Packages/OsaurusCore/Folder/FolderTools.swift:5367-5379 | Packages/OsaurusCore/Folder/FolderTools.swift:5891-5903 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:1274— Packages/OsaurusCore/Managers/MCPProviderManager.swift:1274-1286 | Packages/OsaurusCore/Managers/MCPProviderManager.swift:1329-1341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/AgentCollaboration/AgentCollaborationProtocol.swift:104— Packages/OsaurusCore/Models/AgentCollaboration/AgentCollaborationProtocol.swift:104-116 | Packages/OsaurusCore/Models/AgentCollaboration/AgentCollaborationProtocol.swift:119-131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:239— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:239-251 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:480-492 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:239` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:52— Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:52-64 | Packages/OsaurusCore/Utils/StorageLocationStandards.swift:109-121 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:52` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:51— Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:51-63 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:212-224 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:51` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:178— Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:178-190 | Packages/OsaurusCore/Services/Chat/ComposeRequest.swift:70-82 — before extracting anything, compare `Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift` and `Packages/OsaurusCore/Services/Chat/ComposeRequest.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:178` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:291— Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:291-303 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:486-498 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:291` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Memory/MemoryModels.swift:45— Packages/OsaurusCore/Models/Memory/MemoryModels.swift:45-57 | Packages/OsaurusCore/PrivacyFilter/Core/PrivacyRule.swift:188-200 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Memory/MemoryModels.swift:45` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:484— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:484-496 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:697-709 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:484` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:594— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:594-606 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:626-638 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:5694— Packages/OsaurusCore/Networking/HTTPHandler.swift:5694-5706 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5788-5800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5694` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:6948— Packages/OsaurusCore/Networking/HTTPHandler.swift:6948-6960 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7516-7528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6948` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11041— Packages/OsaurusCore/Networking/HTTPHandler.swift:11041-11053 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11107-11119 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11041` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:11104` calls `server` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:11040` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:12490— Packages/OsaurusCore/Networking/HTTPHandler.swift:12490-12502 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17495-17507 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12490` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15319— Packages/OsaurusCore/Networking/HTTPHandler.swift:15319-15331 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16626-16638 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15319` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15719— Packages/OsaurusCore/Networking/HTTPHandler.swift:15719-15731 | Packages/OsaurusCore/Services/Chat/ChatEngine.swift:502-514 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3834— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3834-3846 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:4016-4028 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3834` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:997— Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:997-1009 | Packages/OsaurusCore/Utils/StringCleaning.swift:168-180 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:997` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:340— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:340-349 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:432-441 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:340` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:275— Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:275-284 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:301-310 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:275` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2495— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2495-2504 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1786-1795 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2495` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:86— Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:86-95 | Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:97-106 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:86` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:96` calls `stringArray` and `Packages/OsaurusCore/Browser/Tool/BrowserChildTools.swift:85` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigManifest.swift:900— Packages/OsaurusCore/Configuration/Declarative/ConfigManifest.swift:900-909 | Packages/OsaurusCore/Configuration/Declarative/ConfigManifest.swift:914-923 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigManifest.swift:900` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2412— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2412-2421 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2506-2516 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2412` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:2624— Packages/OsaurusCore/Folder/FolderTools.swift:2624-2633 | Packages/OsaurusCore/Folder/FolderTools.swift:3538-3547 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) REDACTED:671— REDACTED:671-680 | REDACTED:1781-1790 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:671` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Managers/Model/SpeechModelManager.swift:266— Packages/OsaurusCore/Managers/Model/SpeechModelManager.swift:266-277 | Packages/OsaurusCore/Services/AgentDelegation/ChatResidencyHandoff.swift:262-271 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Model/SpeechModelManager.swift:266` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1645— Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1645-1654 | Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1670-1679 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/Agent/Agent.swift:871— Packages/OsaurusCore/Models/Agent/Agent.swift:871-880 | Packages/OsaurusCore/Services/Chat/AgentConfigSnapshot.swift:222-231 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelSetupFlow.swift:154— Packages/OsaurusCore/Models/AgentChannel/AgentChannelSetupFlow.swift:154-163 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:762-771 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/Configuration/ServerHealth.swift:20— Packages/OsaurusCore/Models/Configuration/ServerHealth.swift:20-29 | Packages/OsaurusCore/Models/Configuration/ServerHealth.swift:32-41 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:496— Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:496-505 | Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:535-544 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:496` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:143— Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:143-154 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:120-129 — before extracting anything, compare `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:222— Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:222-231 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:177-186 — before extracting anything, compare `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:594— Packages/OsaurusCore/Models/Schedule/Schedule.swift:594-603 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:186-195 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Schedule/Schedule.swift:606` calls `decodeIfPresent` and `Packages/OsaurusCore/Models/Watcher/Watcher.swift:196` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:7922— Packages/OsaurusCore/Networking/HTTPHandler.swift:7922-7931 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8144-8153 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:7922` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17239— Packages/OsaurusCore/Networking/HTTPHandler.swift:17239-17248 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17991-18000 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17239` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:654— Packages/OsaurusCore/Networking/RelayTunnelManager.swift:654-663 | Packages/OsaurusCore/Networking/RelayTunnelManager.swift:1232-1241 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/RelayTunnelManager.swift:654` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:283— Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:283-292 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2349-2358 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:283` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3456— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3456-3465 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1847-1857 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3456` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3451— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3451-3460 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1822-1831 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3451` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:51— Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:51-60 | Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:40-49 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:89— Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:89-98 | Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:24-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:89` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:34` calls `max` and `Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:99` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:59— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:59-69 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:62-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:59` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:120— Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:120-130 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift:36-46 — before extracting anything, compare `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift` and `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:120` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:485— Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:485-495 | Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:667-677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:867— Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:867-877 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:878-888 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1206— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1206-1216 | Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1219-1229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1206` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:620— Packages/OsaurusCore/Managers/MCPProviderManager.swift:620-630 | Packages/OsaurusCore/Managers/RemoteProviderManager.swift:970-980 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:641— Packages/OsaurusCore/Managers/MCPProviderManager.swift:641-651 | Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1007-1017 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:71— Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:71-81 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:73-83 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:71` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:171— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:171-181 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:299-309 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:171` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:168— Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:168-178 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:252-262 — before extracting anything, compare `Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1572— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1572-1582 | Packages/OsaurusCore/Models/Theme/Theme.swift:1120-1130 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1572` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:1546— Packages/OsaurusCore/Networking/HTTPHandler.swift:1546-1556 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15892-15902 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1546` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:3434— Packages/OsaurusCore/Networking/HTTPHandler.swift:3434-3444 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5806-5816 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:3434` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:9673— Packages/OsaurusCore/Networking/HTTPHandler.swift:9673-9683 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9834-9844 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11293— Packages/OsaurusCore/Networking/HTTPHandler.swift:11293-11303 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11325-11335 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11293` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:418— Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:418-428 | Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:591-601 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:418` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:431— Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:431-441 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:502-512 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:431` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:62— Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:62-72 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:181-191 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:860— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:860-870 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1261-1271 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:860` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:72— Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:72-82 | Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:61-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:880— Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:880-890 | Packages/OsaurusCore/Services/Documents/XLSXEmitter.swift:356-366 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1158— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1158-1168 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1246-1256 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1158` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1350— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1350-1360 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1416-1426 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1350` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:376— Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:376-386 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift:222-232 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (11 lines × 2) Packages/OsaurusCore/Services/Method/MethodService.swift:132— Packages/OsaurusCore/Services/Method/MethodService.swift:132-142 | Packages/OsaurusCore/Services/Method/MethodService.swift:152-162 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Method/MethodService.swift:132` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/Method/MethodService.swift:131` calls `replacingOccurrences` and `Packages/OsaurusCore/Services/Method/MethodService.swift:151` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2352— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2352-2365 | Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2423-2436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1668— Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1668-1681 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6466-6479 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1668` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:926— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:926-939 | Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:604-617 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/AnthropicAPI.swift:926` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Agent/Agent.swift:894— Packages/OsaurusCore/Models/Agent/Agent.swift:894-907 | Packages/OsaurusCore/Services/Chat/AgentConfigSnapshot.swift:256-269 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:240— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:240-253 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:291-304 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:240` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:890— Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:890-903 | Packages/OsaurusCore/Tools/Database/DatabaseFilePathResolver.swift:311-324 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:905` calls `sanitizeArtifactFilename`, `extractPathComponent` and `Packages/OsaurusCore/Tools/Database/DatabaseFilePathResolver.swift:326` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:256— Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:256-269 | Packages/OsaurusCore/Services/Chat/ChatToolChoicePolicy.swift:162-175 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:256` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:109— Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:109-122 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:164-177 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:109` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Models/Plugin/SandboxConfiguration.swift:98— Packages/OsaurusCore/Models/Plugin/SandboxConfiguration.swift:98-111 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:288-301 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Plugin/SandboxConfiguration.swift:98` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:9262— Packages/OsaurusCore/Networking/HTTPHandler.swift:9262-9275 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9295-9308 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9262` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:9753— Packages/OsaurusCore/Networking/HTTPHandler.swift:9753-9766 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12131-12144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9753` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:12222— Packages/OsaurusCore/Networking/HTTPHandler.swift:12222-12235 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12251-12264 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12222` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:483— Packages/OsaurusCore/Networking/RelayTunnelManager.swift:483-496 | Packages/OsaurusCore/Networking/RelayTunnelManager.swift:1136-1149 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/RelayTunnelManager.swift:483` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:699— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:699-712 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:2425-2438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:714` calls `set`, `String` and `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:2439` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3425— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3425-3438 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3521-3534 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3425` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) REDACTED:508— REDACTED:508-521 | REDACTED:538-551 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:508` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:844— Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:844-857 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:881-894 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:844` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:191— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:191-204 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:353-366 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:191` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:486— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:486-499 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:581-594 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:486` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1150— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1150-1163 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1305-1318 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1150` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:263— Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:263-276 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppHelperInstaller.swift:230-243 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppHelperInstaller.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:263` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `pins` to `IMessageHelperPins` in one and `WhatsAppHelperPins` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:221— Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:221-234 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift:212-225 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:221` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:1407— Packages/OsaurusCore/Services/ModelRuntime.swift:1407-1420 | Packages/OsaurusCore/Services/ModelRuntime.swift:1463-1476 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:1407` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:2273— Packages/OsaurusCore/Services/ModelRuntime.swift:2273-2286 | Packages/OsaurusCore/Services/ModelRuntime.swift:2422-2435 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:190— Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:190-203 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:251-264 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:190` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2144— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2144-2158 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2161-2175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2362— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2362-2376 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2447-2461 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2362` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Folder/FileCopyTool.swift:120— Packages/OsaurusCore/Folder/FileCopyTool.swift:120-134 | Packages/OsaurusCore/Folder/FileCopyTool.swift:168-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FileCopyTool.swift:120` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:136— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:136-150 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:180-194 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1219— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1219-1233 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1738-1752 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1219` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1218` calls `ensureMessageStart` and `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1737` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:323— Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:323-337 | Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:408-422 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:323` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:3486— Packages/OsaurusCore/Networking/HTTPHandler.swift:3486-3500 | Packages/OsaurusCore/Networking/HTTPHandler.swift:3514-3528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:3486` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:13196— Packages/OsaurusCore/Networking/HTTPHandler.swift:13196-13210 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13298-13312 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13196` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:14041— Packages/OsaurusCore/Networking/HTTPHandler.swift:14041-14055 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14503-14517 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14041` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15045— Packages/OsaurusCore/Networking/HTTPHandler.swift:15045-15059 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15357-15371 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15045` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:15041` calls `rejectInvalidHTTPToolChoice`, `ResponsesInferenceRequest`, `ollama` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:15355` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:167— Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:167-181 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppHelperInstaller.swift:168-182 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppHelperInstaller.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:165— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:165-179 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:147-161 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:165` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:487— Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:487-501 | Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:503-517 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:107— Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:107-121 | Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:177-191 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/ModelResidencyManager.swift:107` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1096— Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1096-1110 | Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1113-1127 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1096` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/Schedule/ScheduleHistoryService.swift:230— Packages/OsaurusCore/Services/Schedule/ScheduleHistoryService.swift:230-244 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:286-300 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:590— Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:590-604 | Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:620-634 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:590` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:401— Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:401-415 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1687-1701 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:401` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:952— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:952-966 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:1437-1451 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:952` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Storage/AgentDatabase.swift:1134— Packages/OsaurusCore/Storage/AgentDatabase.swift:1134-1148 | Packages/OsaurusCore/Storage/AgentDatabase.swift:1293-1307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentDatabase.swift:1134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1096— Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1096-1110 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1141-1155 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1096` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:790— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:790-804 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:817-831 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:790` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:805` calls `log` and `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:832` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Subagent/SpawnDescriptors.swift:245— Packages/OsaurusCore/Subagent/SpawnDescriptors.swift:245-259 | Packages/OsaurusCore/Subagent/SpawnDescriptors.swift:288-302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/SpawnDescriptors.swift:245` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Tools/AgentChannelTools.swift:94— Packages/OsaurusCore/Tools/AgentChannelTools.swift:94-108 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:236-250 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/AgentChannelTools.swift:94` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Packages/OsaurusCore/Utils/ChatPerfTrace.swift:178— Packages/OsaurusCore/Utils/ChatPerfTrace.swift:178-192 | Packages/OsaurusCore/Utils/TTFTTrace.swift:136-150 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Utils/ChatPerfTrace.swift:178` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Swallowed exception (caught, then discarded) helpers/osaurus-wa/rpc.go:40— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:308— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalReviewReportCLI.swift:710— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:172— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:206— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift:277— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:248— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:257— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Identity/IdentityView.swift:292— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:445— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:421— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:1342— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:352— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Utils/LoginShellPath.swift:85— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Tools/ConfigurationTools.swift:1090— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Subagent/OwnedSubagentOperation.swift:37— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:413— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Storage/StorageExportService.swift:368— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1256— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1388— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1402— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1817— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1896— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/GitHubSkillService.swift:1947— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) Packages/OsaurusCore/Services/HuggingFaceService.swift:410— `catch` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Low cohesion: SelectableNSTextView (LCOM4 17) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:1011— SelectableNSTextView's methods fall into 17 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 17 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: AgentManager (LCOM4 15) Packages/OsaurusCore/Managers/AgentManager.swift:54— AgentManager's methods fall into 15 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 15 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: UpdaterViewModel (LCOM4 11) Packages/OsaurusCore/Services/UpdaterService.swift:11— UpdaterViewModel's methods fall into 11 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 11 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: LocalAgentBridge (LCOM4 11) Packages/OsaurusCore/Services/AgentBridge/LocalAgentBridge.swift:31— LocalAgentBridge's methods fall into 11 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 11 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: String (LCOM4 11) Packages/OsaurusCore/Folder/FileEditMatcher.swift:520— String's methods fall into 11 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 11 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Array (LCOM4 11) Packages/OsaurusCore/AppleApps/Music/MusicService.swift:345— Array's methods fall into 11 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 11 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Data (LCOM4 10) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:1048— Data's methods fall into 10 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 10 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: AppDelegate (LCOM4 9) Packages/OsaurusCore/AppDelegate.swift:21— AppDelegate's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: CodeNSTextView (LCOM4 9) Packages/OsaurusCore/Views/Common/CodeBlockView.swift:437— CodeNSTextView's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: XMLElement (LCOM4 8) Packages/OsaurusCore/Services/Documents/OOXML/OOXMLPackage.swift:348— XMLElement's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: SkillManager (LCOM4 7) Packages/OsaurusCore/Managers/SkillManager.swift:64— SkillManager's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: HuggingFaceService (LCOM4 6) Packages/OsaurusCore/Services/HuggingFaceService.swift:11— HuggingFaceService's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: NotificationService (LCOM4 6) Packages/OsaurusCore/Services/NotificationService.swift:12— NotificationService's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: FakeSlackClient (LCOM4 6) REDACTED:44— FakeSlackClient's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: MLXService (LCOM4 6) Packages/OsaurusCore/Services/Inference/MLXService.swift:18— MLXService's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: CellTextView (LCOM4 6) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:962— CellTextView's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: FixtureCUDriver (LCOM4 5) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/FixtureCUDriver.swift:25— FixtureCUDriver's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: MockMacDriver (LCOM4 5) Packages/OsaurusCore/ComputerUse/Driver/MockMacDriver.swift:13— MockMacDriver's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: NDJSONResponseWriter (LCOM4 5) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:627— NDJSONResponseWriter's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: FakeTelegramClient (LCOM4 5) REDACTED:143— FakeTelegramClient's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: PluginHostContext (LCOM4 5) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:64— PluginHostContext's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: AudioInputManager (LCOM4 4) Packages/OsaurusCore/Managers/SpeechService.swift:133— AudioInputManager's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: BackgroundTaskState (LCOM4 4) Packages/OsaurusCore/Models/BackgroundTaskModels.swift:152— BackgroundTaskState's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: PluginRuntime (LCOM4 4) Packages/OsaurusCore/PluginHost/main.swift:361— PluginRuntime's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: ChatWindowManager (LCOM4 4) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:54— ChatWindowManager's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
+ 11 more in this group — see findings.md.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×34
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:181— Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:181-198 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:214-229 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:241-258 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:276-291 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:229— Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:229-244 | Packages/OsaurusCore/Models/Configuration/CodexCLIConfiguration.swift:351-372 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:206-220 | Packages/OsaurusCore/Tools/ToolEnvelope.swift:601-615 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:660— Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:660-681 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:683-726 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:728-759 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:761-786 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:229— Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:229-236 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:807-815 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:861-870 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:975-984 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:238— Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:238-245 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:817-825 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:872-881 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:986-995 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Models/Chat/RequestLog.swift:995— Packages/OsaurusCore/Models/Chat/RequestLog.swift:995-1003 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1006-1014 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1021-1035 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1042-1056 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:77— Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:77-90 | Packages/OsaurusCore/Models/Project/ProjectStore.swift:40-52 | Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:71-89 | Packages/OsaurusCore/Models/Watcher/WatcherStore.swift:71-83 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:4602— Packages/OsaurusCore/Networking/HTTPHandler.swift:4602-4896 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15001-15181 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15295-15464 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16550-16911 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:13991— Packages/OsaurusCore/Networking/HTTPHandler.swift:13991-14315 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15001-15181 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15295-15464 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17026-17174 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:15001— Packages/OsaurusCore/Networking/HTTPHandler.swift:15001-15181 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15295-15464 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17026-17174 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17694-17881 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:87— Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:87-109 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:140-159 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:161-180 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:182-201 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:788— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:788-825 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:842-873 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:875-892 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:894-931 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/Documents/CSVAdapter.swift:86— Packages/OsaurusCore/Services/Documents/CSVAdapter.swift:86-125 | Packages/OsaurusCore/Services/Documents/PlainTextAdapter.swift:25-68 | Packages/OsaurusCore/Services/Documents/RichDocumentAdapter.swift:26-99 | Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:28-100 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:174— Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:174-203 | Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:454-477 | Packages/OsaurusCore/Services/Provider/ProviderReplayDiagnostics.swift:204-246 | Packages/OsaurusCore/Services/Provider/XAIOAuthService.swift:317-340 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/Method/MethodSearchService.swift:258— Packages/OsaurusCore/Services/Method/MethodSearchService.swift:258-271 | Packages/OsaurusCore/Services/Skill/SkillSearchService.swift:354-367 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:842-855 | Packages/OsaurusCore/Utils/TextSimilarity.swift:61-74 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1147— Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1147-1175 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1241-1274 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1276-1295 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1297-1336 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Services/SystemPermissionService.swift:889— Packages/OsaurusCore/Services/SystemPermissionService.swift:889-921 | Packages/OsaurusCore/Services/SystemPermissionService.swift:928-955 | Packages/OsaurusCore/Services/SystemPermissionService.swift:961-987 | Packages/OsaurusCore/Services/SystemPermissionService.swift:1028-1042 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:422— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:422-476 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:897-930 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1034-1073 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:245-290 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:422— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:422-476 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:842-890 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:892-942 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2189-2216 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1468— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1468-1561 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1889-1976 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2273-2301 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2359-2429 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1571— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1571-1589 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1978-1996 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2844-2862 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2865-2883 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1595— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1595-1620 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1626-1648 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1650-1669 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1676-1695 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:272— Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:272-279 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:306-313 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:429-436 | Packages/OsaurusCore/Views/Settings/ServerView.swift:609-616 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1398— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1398-1436 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:925-1049 | Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:215-250 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:180-226 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:302— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:302-314 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:436-474 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:986-1032 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:297-309 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (16 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:854— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:854-869 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1079-1094 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:854` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:129— Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:129-144 | Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:969-984 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Folder/RedactionTools.swift:536— Packages/OsaurusCore/Folder/RedactionTools.swift:536-551 | Packages/OsaurusCore/Folder/RedactionTools.swift:590-605 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/RedactionTools.swift:536` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:1167— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:1167-1182 | Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:1260-1275 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:1167` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Managers/HotKeyManager.swift:73— Packages/OsaurusCore/Managers/HotKeyManager.swift:73-88 | Packages/OsaurusCore/Managers/TranscriptionHotKeyManager.swift:92-108 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/HotKeyManager.swift:73` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:3104— Packages/OsaurusCore/Networking/HTTPHandler.swift:3104-3119 | Packages/OsaurusCore/Networking/HTTPHandler.swift:3142-3157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:4603— Packages/OsaurusCore/Networking/HTTPHandler.swift:4603-4618 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14447-14462 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4603` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:13343— Packages/OsaurusCore/Networking/HTTPHandler.swift:13343-13358 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13412-13427 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:13359` calls `makeHop` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:13428` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17256— Packages/OsaurusCore/Networking/HTTPHandler.swift:17256-17271 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18008-18023 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17256` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:71— Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:71-86 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:129-144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:71` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:132— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:132-147 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:111-126 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:132` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:38— Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:38-53 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift:37-52 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:359— Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:359-374 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift:205-220 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:460— Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:460-475 | Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:508-523 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:460` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1656— Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1656-1671 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2137-2152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1656` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1755— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1755-1770 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1871-1886 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:392— Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:392-407 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:666-681 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:392` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:682` calls `registryParameterText` and `Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:408` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1572— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1572-1587 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1979-1994 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Storage/MemoryDatabase.swift:2845— Packages/OsaurusCore/Storage/MemoryDatabase.swift:2845-2860 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2866-2881 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:176— Packages/OsaurusCore/Views/Agent/AgentsView.swift:176-191 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:91-106 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:176` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:113— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:113-128 | Packages/OsaurusCore/Views/Template/TemplateImportReviewView.swift:101-116 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:113` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Chat/MessageTableRepresentable.swift:301— Packages/OsaurusCore/Views/Chat/MessageTableRepresentable.swift:301-316 | Packages/OsaurusCore/Views/Chat/MessageTableRepresentable.swift:362-377 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/MessageTableRepresentable.swift:301` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2356— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2356-2371 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:546-561 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2356` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3390— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3390-3405 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1350-1365 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:181— Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:181-196 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:243-258 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:181` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:197` calls `frame` and `Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:259` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:233— Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:233-238 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:210-215 | Packages/OsaurusCore/Tools/ToolEnvelope.swift:605-610 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Support/AppleScriptBridge.swift:233` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1643— Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1643-1653 | Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1668-1678 | Packages/OsaurusCore/Tools/SchemaValidator.swift:846-851 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1643` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:41— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:41-46 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:204-209 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:283-288 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:15075— Packages/OsaurusCore/Networking/HTTPHandler.swift:15075-15080 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15387-15392 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17708-17713 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3505— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3505-3512 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1852-1859 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3112-3117 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3505` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:523— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:523-528 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:833-838 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:620-627 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:523` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:43— Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:43-50 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:313-318 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:621-626 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:43` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:60— Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:60-65 | Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:314-319 | Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:453-458 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:610— Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:610-615 | Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:618-623 | Packages/OsaurusCore/Services/Router/OsaurusRouterAPIClient.swift:645-650 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Storage/ActivityLogStore.swift:982— Packages/OsaurusCore/Storage/ActivityLogStore.swift:982-987 | Packages/OsaurusCore/Storage/ActivityLogStore.swift:993-998 | Packages/OsaurusCore/Storage/ActivityLogStore.swift:1013-1018 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1659— Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1659-1664 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2082-2089 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2627-2632 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1659` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:119— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:119-124 | Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:65-71 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:121-126 — before extracting anything, compare `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift` and `Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 141 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6538— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6538-6543 | Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:755-763 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:89-97 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:98` calls `fixedSize` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6544` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6537— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6537-6542 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1150-1158 | Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:228-233 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6537` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:152— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:152-157 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:250-256 | Packages/OsaurusCore/Views/Template/TemplateImportSheet.swift:66-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:152` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:167— Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:167-172 | Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:210-216 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:584-591 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:167` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3194— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3194-3200 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3256-3261 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3300-3310 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3194` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3202` calls `constraint` and `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3263` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:207— Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:207-212 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1939-1944 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1978-1983 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:691— Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:691-696 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2578-2583 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:732-737 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:691` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:817— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:817-822 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:566-573 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:272-277 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:817` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2367— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2367-2372 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:139-144 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:557-562 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2367` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:514— Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:514-519 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:808-813 | Packages/OsaurusCore/Views/Settings/SearchView.swift:660-665 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/SearchView.swift:666` calls `localizedHelp` and `Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:520` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1151— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1151-1159 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2120-2128 | Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:229-234 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2129` calls `fixedSize` and `Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:235` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:559— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:559-565 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:531-536 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:898-904 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:559` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) Packages/OsaurusCore/Services/Method/MethodSearchService.swift:32— Packages/OsaurusCore/Services/Method/MethodSearchService.swift:32-37 | Packages/OsaurusCore/Services/Skill/SkillSearchService.swift:46-51 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:128-133 — before extracting anything, compare `Packages/OsaurusCore/Services/Method/MethodSearchService.swift` and `Packages/OsaurusCore/Services/Skill/SkillSearchService.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (18 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:69— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:69-86 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:112-129 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:69` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:661— Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:661-678 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:762-779 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:762` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Managers/HotKeyManager.swift:52— Packages/OsaurusCore/Managers/HotKeyManager.swift:52-69 | Packages/OsaurusCore/Managers/TranscriptionHotKeyManager.swift:70-87 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/HotKeyManager.swift:52` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Managers/WatcherManager.swift:325— Packages/OsaurusCore/Managers/WatcherManager.swift:325-342 | Packages/OsaurusCore/Services/Knowledge/KnowledgeFolderWatcher.swift:89-106 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/WatcherManager.swift:325` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:284— Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:284-301 | Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:325-342 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:284` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1584— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1584-1601 | Packages/OsaurusCore/Models/Theme/Theme.swift:1132-1149 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1584` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:4621— Packages/OsaurusCore/Networking/HTTPHandler.swift:4621-4638 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16621-16638 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4621` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:13214— Packages/OsaurusCore/Networking/HTTPHandler.swift:13214-13231 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13316-13333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13214` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15020— Packages/OsaurusCore/Networking/HTTPHandler.swift:15020-15037 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15314-15331 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15020` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17305— Packages/OsaurusCore/Networking/HTTPHandler.swift:17305-17322 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18057-18074 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17305` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationTypes.swift:291— Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationTypes.swift:291-308 | Packages/OsaurusCore/Services/MediaGeneration/VeniceMediaCatalog.swift:150-167 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1558— Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1558-1575 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1899-1916 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:818— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:818-835 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:843-860 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:818` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:274— Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:274-291 | Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:305-322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:274` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3686— Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3686-3703 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3768-3785 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3787` calls `agentNodeWorkdir` and `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3705` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:343— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:343-360 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:458-475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:343` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:677— Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:677-694 | Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:1078-1095 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:677` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8527— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8527-8544 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:579-596 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8527` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:354— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:354-371 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:467-484 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:354` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:407— Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:407-424 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:498-515 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:540— Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:540-557 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:1237-1254 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:540` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2544— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2544-2561 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:698-715 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2544` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2608— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2608-2625 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:762-779 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2608` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1268— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1268-1285 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1396-1413 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1268` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:1950— Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:1950-1967 | Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:1975-1992 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:1950` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Managers/BlockMemoizer.swift:414— Packages/OsaurusCore/Managers/BlockMemoizer.swift:414-430 | Packages/OsaurusCore/Views/Chat/MessageThreadView.swift:80-96 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/BlockMemoizer.swift:414` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Managers/InsightsService.swift:658— Packages/OsaurusCore/Managers/InsightsService.swift:658-674 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:547-563 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:963— Packages/OsaurusCore/Networking/HTTPHandler.swift:963-979 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1102-1118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:963` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11508— Packages/OsaurusCore/Networking/HTTPHandler.swift:11508-11524 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11551-11567 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11508` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:11550` calls `requiresOwnerChannel` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:11507` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:13103— Packages/OsaurusCore/Networking/HTTPHandler.swift:13103-13119 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13187-13203 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1848— Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1848-1864 | Packages/OsaurusCore/Services/Chat/ChatEngine.swift:2012-2028 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1848` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:578— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:578-594 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:640-656 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:578` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:241— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:241-257 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:217-233 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:241` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:416— Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:416-432 | Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:472-488 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:196— Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:196-212 | Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:389-405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:196` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Services/SystemPermissionService.swift:936— Packages/OsaurusCore/Services/SystemPermissionService.swift:936-952 | Packages/OsaurusCore/Services/SystemPermissionService.swift:968-984 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Tools/KnowledgeTools.swift:291— Packages/OsaurusCore/Tools/KnowledgeTools.swift:291-307 | Packages/OsaurusCore/Tools/SearchMemoryTool.swift:125-141 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Chat/ChatView.swift:9698— Packages/OsaurusCore/Views/Chat/ChatView.swift:9698-9714 | Packages/OsaurusCore/Views/Chat/HostedRunNotice.swift:117-133 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatView.swift:9698` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:188— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:188-204 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:181-197 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:260— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:260-276 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:255-271 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:260` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:254` calls `reloadAuthentication` and `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:259` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2293— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2293-2309 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:402-418 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2293` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:257— Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:257-273 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1317-1333 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:257` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:750— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:750-766 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:684-700 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:750` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:107— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:107-123 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:3026-3042 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:107` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:713— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:713-729 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2908-2924 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:713` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2907` calls `GitHubTokenCard` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:712` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:779— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:779-795 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2981-2997 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `10` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:298— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:298-314 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:288-304 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 354 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:298` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:437— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:437-453 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:568-588 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:437` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:836— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:836-852 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1284-1300 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:836` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1592— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1592-1608 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1857-1873 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Browser/Runtime/BrowserSessionCatalog.swift:185— Packages/OsaurusCore/Browser/Runtime/BrowserSessionCatalog.swift:185-191 | Packages/OsaurusCore/Models/Agent/AgentInviteStore.swift:238-244 | Packages/OsaurusCore/Models/Agent/RemoteAgentStore.swift:39-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Runtime/BrowserSessionCatalog.swift:185` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:755— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:755-761 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:772-778 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:908-914 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:755` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1167— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1167-1173 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1223-1229 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1742-1748 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1167` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1221` calls `writeString` and `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1166` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Services/Chat/GroundedConfigClaimCheck.swift:244— Packages/OsaurusCore/Services/Chat/GroundedConfigClaimCheck.swift:244-250 | Packages/OsaurusCore/Services/Chat/GroundedFileSideEffectCheck.swift:117-123 | Packages/OsaurusCore/Services/Chat/GroundedKnowledgeClaimCheck.swift:166-172 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:846— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:846-852 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:878-884 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:899-905 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:846` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:1780— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:1780-1786 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:1796-1802 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:1817-1823 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:521— Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:521-527 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:708-714 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:814-820 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:521` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:528` calls `transition` and `Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:715` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3416— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3416-3422 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:4783-4789 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5302-5308 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3416` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `2` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:4782` calls `HStack` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3415` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5832— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5832-5838 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:517-526 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2574-2580 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5832` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8492— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8492-8498 | Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:503-509 | Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:427-434 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8492` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:530— Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:530-539 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:180-186 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:413-420 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:530` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `2` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:188` calls `Spacer` and `Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:422` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:151— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:151-157 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:353-359 | Packages/OsaurusCore/Views/Template/TemplateImportSheet.swift:65-71 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:151` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:60— Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:60-66 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228-238 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:222-232 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:60` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:270— Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:270-276 | Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:282-288 | Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:442-448 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:536— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:536-544 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1054-1062 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1072-1078 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:142— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:142-148 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:763-769 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:250-256 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:142` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:139` calls `HStack` and `Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:247` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:504— Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:504-510 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:444-450 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:582-588 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:504` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:492— Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:492-498 | Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:372-378 | Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:400-406 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:492` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:499` calls `lineLimit`, `frame` and `Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:379` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2753— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2753-2759 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2980-2986 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3035-3041 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2753` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1096— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1096-1102 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:877-883 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:421-427 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 243 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1096` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:230— Packages/OsaurusCore/Services/Discord/DiscordAPIClient.swift:230-236 | Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:519-525 | Packages/OsaurusCore/Services/Telegram/TelegramAPIClient.swift:390-396 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:28— Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:28-34 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:50-56 | Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:49-55 — before extracting anything, compare `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift` and `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 126 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:213— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:213-219 | Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:251-257 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:434-440 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:444` calls `clearCachedBotIdentity` and `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:223` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1315— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1315-1321 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1283-1289 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1494-1500 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (7 lines × 3) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:2157— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:2157-2163 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:459-465 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:581-587 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:2154` calls `unsafeBitCast` and `Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:457` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:213— Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:213-217 | Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:455-459 | Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:650-654 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:460` calls `lowercased` and `Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:655` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Models/Chat/RequestLog.swift:887— Packages/OsaurusCore/Models/Chat/RequestLog.swift:887-891 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1297-1301 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1535-1539 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/RequestLog.swift:887` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:5983— Packages/OsaurusCore/Networking/HTTPHandler.swift:5983-5987 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8182-8186 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8269-8273 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5983` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:194— Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:194-198 | Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:468-472 | Packages/OsaurusCore/Services/Provider/XAIOAuthService.swift:331-335 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:194` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Services/Method/MethodSearchService.swift:260— Packages/OsaurusCore/Services/Method/MethodSearchService.swift:260-264 | Packages/OsaurusCore/Services/Skill/SkillSearchService.swift:356-360 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:844-848 — before extracting anything, compare `Packages/OsaurusCore/Services/Method/MethodSearchService.swift` and `Packages/OsaurusCore/Services/Skill/SkillSearchService.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Method/MethodSearchService.swift:260` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:96— Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:96-100 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:138-142 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:156-160 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5569— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5569-5575 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1750-1754 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2350-2355 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5569` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:7073— Packages/OsaurusCore/Views/Agent/AgentsView.swift:7073-7077 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:111-115 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:31-36 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:7073` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:331— Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:331-335 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1267-1271 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1113-1117 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:169— Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:169-173 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:157-161 | Packages/OsaurusCore/Views/Template/TemplateImportSheet.swift:71-75 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:227— Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:227-231 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:285-290 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:778-783 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:227` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1297— Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1297-1301 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1535-1539 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolActivityView.swift:304-308 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1297` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:481— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:481-485 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:835-839 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:616-622 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:481` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:236— Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:236-240 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:284-288 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1800-1805 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:236` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:241` calls `truncationMode` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1806` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:601— Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:601-605 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:743-747 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:467-471 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:606` calls `multilineTextAlignment` and `Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:472` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:746— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:746-750 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1934-1938 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:756-760 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:746` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2271— Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2271-2275 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2285-2289 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2492-2496 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2271` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `14` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:812— Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:812-819 | Packages/OsaurusCore/Views/Settings/SearchView.swift:954-958 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1194-1201 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:812` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:425— Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:425-429 | Packages/OsaurusCore/Services/Context/PluginCreatorGate.swift:28-36 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:340-344 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Management/ManagerHeader.swift:251— Packages/OsaurusCore/Views/Management/ManagerHeader.swift:251-255 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:304-308 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:369-373 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Models/Documents/PresentationDocument.swift:150— Packages/OsaurusCore/Models/Documents/PresentationDocument.swift:150-158 | Packages/OsaurusCore/PrivacyFilter/Core/ScrubResult.swift:91-95 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:52-56 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalReviewReportCLI.swift:730— Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalReviewReportCLI.swift:730-734 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:630-634 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:988-992 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:40— Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:40-44 | Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:50-54 | Packages/OsaurusCore/Storage/PluginDatabase.swift:429-433 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:40` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2054— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2054-2058 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2060-2064 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2087-2091 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2054` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1090— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1090-1094 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:744-748 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1210-1214 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 306 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:270— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:270-278 | Packages/OsaurusCore/Services/HuggingFaceService.swift:372-380 | Packages/OsaurusCore/Services/HuggingFaceService.swift:783-791 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:84— Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:84-92 | Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:144-152 | Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:171-179 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:419— Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:419-427 | Packages/OsaurusCore/Models/Plugin/PluginHTTP.swift:136-144 | Packages/OsaurusCore/Views/Chat/NativeChartView.swift:53-61 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:419` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:14801— Packages/OsaurusCore/Networking/HTTPHandler.swift:14801-14809 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17188-17197 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17965-17974 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:418— Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:418-426 | Packages/OsaurusCore/Services/ChunkedFileDownloader.swift:681-689 | Packages/OsaurusCore/Services/ModelDownloadService.swift:2023-2031 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:418` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1609— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1609-1617 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1176-1184 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1260-1268 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1245— Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1245-1253 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1279-1287 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1302-1310 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1245` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6162— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6162-6170 | Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:559-567 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:244-252 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6162` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:50— Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:50-58 | Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:66-74 | Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:199-207 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:50` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:754— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:754-762 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2119-2127 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:88-96 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:754` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:208— Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:208-216 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:725-733 | Packages/OsaurusCore/Views/Tool/ToolPermissionBanner.swift:76-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:208` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:164— Packages/OsaurusCore/Views/Credits/CreditsView.swift:164-172 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:285-293 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:89-97 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:164` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `14` in one and `10` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:707— Packages/OsaurusCore/Views/Credits/CreditsView.swift:707-715 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:367-375 | Packages/OsaurusCore/Views/Settings/SearchView.swift:533-541 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:707` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:376` calls `fixedSize` and `Packages/OsaurusCore/Views/Settings/SearchView.swift:542` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:286— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:286-294 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:727-735 | Packages/OsaurusCore/Views/Settings/ServerView.swift:589-597 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:286` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:530— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:530-538 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:732-740 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:1056-1064 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:530` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1029— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1029-1037 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1785-1793 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:382-390 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1029` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1278— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1278-1286 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1305-1313 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1716-1724 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1278` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2177— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2177-2185 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:560-568 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1463-1471 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:569` calls `frame` and `Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1472` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:630— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:630-638 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:924-932 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:454-462 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:630` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Settings/ServerView.swift:302— Packages/OsaurusCore/Views/Settings/ServerView.swift:302-310 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2131-2139 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2282-2290 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerView.swift:302` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `16` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:330— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:330-338 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:263-271 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:626-634 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:330` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:486— Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:486-494 | Packages/OsaurusCore/Views/Settings/ConfigurationView.swift:367-375 | Packages/OsaurusCore/Views/Settings/OrchestratorSettingsView.swift:394-402 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (9 lines × 3) Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:125— Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:125-133 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:69-77 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:108-116 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:78` calls `decodeIfPresent` and `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:134` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 3) scripts/live-proof/run-local-family-chat-tool-proof.py:40— scripts/live-proof/run-local-family-chat-tool-proof.py:40-48 | scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:38-46 | scripts/live-proof/run-local-vl-media-cache-proof.py:41-49 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:102— Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:102-113 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:51-62 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:88-99 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:102` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:114` calls `clampPollInterval` and `Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:100` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:71— Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:71-82 | Packages/OsaurusCore/Services/GitHubSkillService.swift:546-557 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1123-1134 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:71` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:13164— Packages/OsaurusCore/Networking/HTTPHandler.swift:13164-13175 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13264-13275 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13695-13706 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13164` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusCore/PrivacyFilter/Core/Placeholder.swift:29— Packages/OsaurusCore/PrivacyFilter/Core/Placeholder.swift:29-40 | Packages/OsaurusCore/PrivacyFilter/Core/Placeholder.swift:46-57 | Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:478-489 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:193— Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:193-204 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:1087-1098 | Packages/OsaurusCore/Services/Router/OsaurusRouterWorkspaceTypes.swift:118-129 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:193` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Services/GitHubSkillService.swift:545— Packages/OsaurusCore/Services/GitHubSkillService.swift:545-556 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1122-1133 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1432-1443 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/GitHubSkillService.swift:545` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:915— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:915-926 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1058-1069 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:274-285 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:915` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:288` calls `pruneToRetentionLimit` and `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:929` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:136— Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:136-147 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:732-743 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1321-1332 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:136` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:134` calls `lineLimit` and `Packages/OsaurusCore/Views/Settings/ServerView.swift:1319` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886— Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886-897 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:531-542 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:733-744 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:1141— Packages/OsaurusCore/Views/Credits/CreditsView.swift:1141-1152 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2206-2217 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:376-387 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1168— Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1168-1179 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2578-2589 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:732-743 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1168` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:537— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:537-548 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:639-650 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:748-759 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:537` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:551— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:551-562 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:653-664 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:773-784 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:551` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1301— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1301-1312 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1362-1373 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1434-1445 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1301` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2191— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2191-2202 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:576-587 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1476-1487 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2191` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:573` calls `Spacer` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2188` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:718— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:718-729 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:637-648 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:777-788 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:718` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:636` calls `padding` and `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:717` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:248— Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:248-259 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:282-293 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:312-326 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:248` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:97— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:97-108 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:135-146 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:193-204 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:97` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:971— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:971-982 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:984-995 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:997-1008 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1772— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1772-1783 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:118-129 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:573-584 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1772` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:940— Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:940-951 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3604-3615 | Packages/OsaurusCore/Views/Common/CodeBlockView.swift:490-503 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Common/CodeBlockView.swift:486` calls `cursorUpdate`, `chatTextCursorUpdate` and `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3602` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:381— Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:381-388 | Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:405-412 | Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:423-430 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:381` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:73— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:73-80 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:127-134 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:337-344 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/AnthropicAPI.swift:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:257— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:257-264 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:267-274 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:277-284 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:257` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:611— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:611-618 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5683-5690 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7890-7897 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:611` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3659— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3659-3666 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3671-3678 | Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:152-159 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3659` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3656` calls `AgentDetailSection`, `L`, `VStack` and `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:151` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5427— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5427-5434 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:679-686 | Packages/OsaurusCore/Views/Settings/SearchView.swift:887-894 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5427` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834-5841 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:558-567 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:415-423 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseOverviewView.swift:320— Packages/OsaurusCore/Views/Agent/Database/DatabaseOverviewView.swift:320-328 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:522-532 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1058-1065 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseOverviewView.swift:320` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1406— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1406-1413 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1654-1661 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1932-1939 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1406` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1665— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1665-1672 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1962-1969 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2085-2092 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1665` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:572— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:572-579 | Packages/OsaurusCore/Views/Chat/NativeCompactionMarkerView.swift:196-203 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:286-293 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:572` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:176— Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:176-183 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:128-135 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:161-168 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:176` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026-2034 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2052-2059 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2069-2076 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:170— Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:170-177 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:179-186 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:372-379 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:170` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:352— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:352-359 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:473-480 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:425-432 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:352` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:223— Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:223-230 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:123-132 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:680-687 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:223` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:440— Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:440-447 | Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:452-459 | Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:514-521 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:440` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `5` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:1054— Packages/OsaurusCore/Views/Credits/CreditsView.swift:1054-1065 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:643-650 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolActivityView.swift:368-375 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (8 lines × 3) Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:498— Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:498-505 | Packages/OsaurusCore/Services/Provider/OpenRouterOAuthService.swift:147-154 | Packages/OsaurusCore/Services/Provider/XAIOAuthService.swift:208-215 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (8 lines × 3) helpers/osaurus-wa/bridge.go:871— helpers/osaurus-wa/bridge.go:871-878 | helpers/osaurus-wa/bridge.go:905-912 | helpers/osaurus-wa/bridge.go:968-975 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×19
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:146— Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:146-158 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift:138-150 | Packages/OsaurusCore/Managers/TTSService.swift:753-770 | Packages/OsaurusCore/Services/ModelRuntime/PrefillDebugLog.swift:80-97 | Packages/OsaurusCore/Utils/KnowledgeLogger.swift:60-77 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:894— Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:894-905 | Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:417-427 | Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:79-124 | Packages/OsaurusCore/Models/Plugin/PluginHTTP.swift:122-144 | Packages/OsaurusCore/Views/Chat/NativeChartView.swift:47-61 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:40— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:40-96 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:98-157 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:159-201 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:203-280 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:282-333 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Models/Chat/RequestLog.swift:884— Packages/OsaurusCore/Models/Chat/RequestLog.swift:884-897 | Packages/OsaurusCore/Services/FileHistory/FileChangeModels.swift:258-272 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1296-1308 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1534-1560 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolActivityView.swift:303-314 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:62— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:62-92 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:230-258 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:302-337 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:371-398 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:475-499 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:141— Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:141-149 | Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:318-326 | Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:256-264 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:225-233 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:274-282 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:725— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:725-774 | Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:501-552 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1077-1132 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:811-862 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:596-651 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:709— Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:709-748 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1031-1065 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1069-1127 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1140-1178 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1180-1232 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:312— Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:312-348 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:351-377 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2630-2658 | Packages/OsaurusCore/Views/Chat/ChatTabStripView.swift:970-998 | Packages/OsaurusCore/Views/Chat/ProjectDetailView.swift:182-209 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:387— Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:387-450 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:452-526 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:528-589 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:726-775 | Packages/OsaurusCore/Views/Common/GlassBackground.swift:182-244 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1451— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1451-1476 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2176-2203 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:559-588 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1462-1488 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsHelpers.swift:48-63 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Insights/InsightsView.swift:40— Packages/OsaurusCore/Views/Insights/InsightsView.swift:40-94 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:78-133 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:39-97 | Packages/OsaurusCore/Views/Settings/SearchView.swift:43-79 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandsView.swift:21-89 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:107— Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:107-120 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:128-158 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:181-271 | Packages/OsaurusCore/Views/Settings/FileHistoryRetentionSection.swift:24-70 | Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:220-268 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:201— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:201-256 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:244-304 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1271-1327 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2383-2433 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:919-949 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:35— Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:35-69 | Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:163-195 | Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:197-207 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolSheets.swift:121-139 | Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:398-425 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:393— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:393-414 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:881-903 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:504-525 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:510-530 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1136-1158 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:416— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:416-453 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:839-879 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:527-588 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:563-595 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1042-1097 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:508— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:508-543 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:782-825 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:690-749 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:686-740 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:998-1028 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:994— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:994-1011 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1377-1394 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1472-1489 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1026-1043 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1505-1522 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Duplicated block (11 lines × 3) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:183— Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:183-193 | Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:266-276 | Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:355-365 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:279` calls `date` and `Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:194` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:204— Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:204-215 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:104-115 | Packages/OsaurusCore/Models/Template/MCPServerHint.swift:39-49 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:204` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:5661— Packages/OsaurusCore/Networking/HTTPHandler.swift:5661-5671 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5899-5909 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6432-6442 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5661` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:129— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:129-139 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:207-217 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:108-118 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:218` calls `sendBackpressure` and `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:140` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:401— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:401-411 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:739-749 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:504-514 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:554— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:554-564 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:864-874 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:653-663 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Storage/MemoryDatabase.swift:2289— Packages/OsaurusCore/Storage/MemoryDatabase.swift:2289-2299 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2385-2395 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2413-2423 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:2289` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `limit` to `Int = 200` in one and `Int = 500` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3191— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3191-3201 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6963-6973 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7000-7010 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3191` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:492— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:492-502 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:842-852 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:640-650 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:492` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758-769 | Packages/OsaurusCore/Views/Settings/AgentChannelDispatchRoutingEditor.swift:222-232 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2889-2900 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:757` calls `padding` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2888` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:989— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:989-999 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:856-866 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2873-2883 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:989` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2884` calls `background` and `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:1000` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Settings/PermissionsView.swift:196— Packages/OsaurusCore/Views/Settings/PermissionsView.swift:196-206 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3393-3403 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:642-652 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/PermissionsView.swift:196` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3391` calls `lineLimit`, `fixedSize` and `Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:641` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2317— Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2317-2327 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2335-2345 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2355-2365 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2317` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:114— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:114-124 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:569-579 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:695-705 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:114` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:1026— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:1026-1036 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1766-1776 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1376-1386 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:512— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:512-522 | Packages/OsaurusCore/Storage/MethodDatabase.swift:90-100 | Packages/OsaurusCore/Storage/ToolDatabase.swift:145-155 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:119— Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:119-129 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:172-182 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:231-241 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (11 lines × 3) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1116— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1116-1128 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:512-522 | Packages/OsaurusCore/Storage/ToolDatabase.swift:435-447 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (11 lines × 3) scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:287— scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:287-297 | scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:304-326 | scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:329-343 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (5 lines × 4) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:270— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:270-274 | Packages/OsaurusCore/Services/HuggingFaceService.swift:372-376 | Packages/OsaurusCore/Services/HuggingFaceService.swift:783-787 | Packages/OsaurusCore/Services/HuggingFaceService.swift:1022-1026 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 4) Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120— Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120-125 | Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:142-146 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:121-128 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:178-185 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:661— Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:661-665 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:686-690 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:729-733 | Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:762-766 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `selector` to `String?) async -> (success: Bool` in one and `String?` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:691` calls `replacingOccurrences` and `Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:666` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:15073— Packages/OsaurusCore/Networking/HTTPHandler.swift:15073-15078 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15385-15390 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17039-17045 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17706-17710 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15073` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:17047` calls `writeMessageStart` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:15080` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:134— Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:134-138 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:149-153 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:344-348 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:361-365 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8949— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8949-8953 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:201-205 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:194-198 | Packages/OsaurusCore/Views/Settings/ExternalModelsSettingsView.swift:89-93 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8949` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `5` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8948— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8948-8952 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:207-211 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:436-440 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:677-681 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8948` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8954` calls `Spacer` and `Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:213` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:417— Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:417-421 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:490-494 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:556-560 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:763-767 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:763— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:763-769 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:817-821 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:972-976 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:566-573 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:763` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:771` calls `Button`, `dismiss` and `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:978` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:119— Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:119-123 | Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:336-340 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:92-96 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:117-121 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `7` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:125` calls `lineLimit` and `Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:342` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2754— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2754-2758 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2981-2985 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3036-3040 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:271-276 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2754` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:45— Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:45-49 | Packages/OsaurusCore/Services/Router/OsaurusRouterWorkspaceTypes.swift:1004-1008 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:583-587 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:604-608 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 4) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:439— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:439-443 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:814-818 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:578-582 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:1076-1080 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
Duplicated block (5 lines × 4) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:105— Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:105-109 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:202-206 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:323-327 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCaptureScreenCLI.swift:404-408 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:229— Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:229-233 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:807-811 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:861-865 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:975-979 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:812` calls `decodeIfPresent` and `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:234` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:238— Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:238-242 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:817-821 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:872-876 | Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:986-990 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:238` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:823` calls `encode` and `Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:244` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) Packages/OsaurusCore/Services/Documents/CSVAdapter.swift:86— Packages/OsaurusCore/Services/Documents/CSVAdapter.swift:86-90 | Packages/OsaurusCore/Services/Documents/PlainTextAdapter.swift:25-29 | Packages/OsaurusCore/Services/Documents/RichDocumentAdapter.swift:26-30 | Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:28-32 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/CSVAdapter.swift:86` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Documents/RichDocumentAdapter.swift:32` calls `lowercased`, `RichDocumentSourceFormat`, `documentType` and `Packages/OsaurusCore/Services/Documents/PlainTextAdapter.swift:31` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:78— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:78-87 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:248-257 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:310-321 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:69— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:69-78 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:173-182 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:301-310 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:12051— Packages/OsaurusCore/Networking/HTTPHandler.swift:12051-12060 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12128-12137 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12219-12228 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12051` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:12883— Packages/OsaurusCore/Networking/HTTPHandler.swift:12883-12892 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13602-13611 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13665-13674 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12883` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `path` to `"/images/generations"` in one and `"/images/edits"` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1547— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1547-1556 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1962-1971 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2447-2456 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1547` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:95— Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:95-104 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:107-116 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:84-93 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:95` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:412— Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:412-421 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:485-494 | Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:551-560 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:412` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:545— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:545-554 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:647-656 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:742-751 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:545` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1833— Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1833-1842 | Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1859-1868 | Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1895-1904 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1833` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1894` calls `autocorrectionDisabled` and `Packages/OsaurusCore/Views/Onboarding/OnboardingConfigureAIView.swift:1832` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1275— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1275-1284 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1395-1404 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1686-1695 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:350— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:350-359 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:408-419 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1386-1397 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:350` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47— Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47-56 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:47-56 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:67-76 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1924— Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1924-1933 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2815-2824 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:305-314 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1924` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:722— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:722-731 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:765-774 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:789-798 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Models/Agent/RemoteAgentStore.swift:50— Packages/OsaurusCore/Models/Agent/RemoteAgentStore.swift:50-59 | Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:94-103 | Packages/OsaurusCore/Models/Project/ProjectStore.swift:56-65 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (10 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1290— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1290-1299 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1299-1308 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1469-1478 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `IMessageConnectionConfiguration` in one and `TelegramConnectionConfiguration` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8–9 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:39— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:39-46 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Show.swift:116-124 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:39` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/AppDelegate.swift:1894— Packages/OsaurusCore/AppDelegate.swift:1894-1901 | Packages/OsaurusCore/AppDelegate.swift:1939-1947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppDelegate.swift:1894` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:43— Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:43-50 | Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:116-124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Messages/MessagesTools.swift:43` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1072— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1072-1079 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1104-1112 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1072` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:520— Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:520-528 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16263-16270 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1333— Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1333-1341 | Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1360-1367 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1333` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1367` calls `localName`, `attribute` and `Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1341` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:3325— Packages/OsaurusCore/Services/ModelRuntime.swift:3325-3332 | Packages/OsaurusCore/Services/ModelRuntime.swift:7700-7708 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:3325` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:391— Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:391-398 | Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:458-466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1305— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1305-1312 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1037-1045 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:1305` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:165— Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:165-172 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:795-803 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:165` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:105— Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:105-113 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolSheets.swift:408-415 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Views/Credits/CreditsView.swift:332— Packages/OsaurusCore/Views/Credits/CreditsView.swift:332-339 | Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:420-428 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:332` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Views/Credits/CreditsView.swift:1198— Packages/OsaurusCore/Views/Credits/CreditsView.swift:1198-1205 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:703-711 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:1198` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8–9 lines × 2) Packages/OsaurusCore/Views/Model/ChatModelPickerPreviews.swift:111— Packages/OsaurusCore/Views/Model/ChatModelPickerPreviews.swift:111-119 | Packages/OsaurusCore/Views/Model/ChatModelPickerPreviews.swift:123-130 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ChatModelPickerPreviews.swift:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:57— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:57-64 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:75-83 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Models/Plugin/ExternalPlugin.swift:650— Packages/OsaurusCore/Models/Plugin/ExternalPlugin.swift:650-668 | Packages/OsaurusCore/Tools/ToolRegistry.swift:117-135 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:559— Packages/OsaurusCore/Models/Schedule/Schedule.swift:559-577 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:150-168 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/Schedule.swift:559` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:3083— Packages/OsaurusCore/Networking/HTTPHandler.swift:3083-3101 | Packages/OsaurusCore/Networking/HTTPHandler.swift:3123-3141 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:8807— Packages/OsaurusCore/Networking/HTTPHandler.swift:8807-8825 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9169-9187 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:8807` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:14010— Packages/OsaurusCore/Networking/HTTPHandler.swift:14010-14028 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14058-14076 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14010` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:16363— Packages/OsaurusCore/Networking/HTTPHandler.swift:16363-16381 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16392-16410 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16363` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Services/Chat/GroundedFileSideEffectCheck.swift:117— Packages/OsaurusCore/Services/Chat/GroundedFileSideEffectCheck.swift:117-135 | Packages/OsaurusCore/Services/Chat/GroundedKnowledgeClaimCheck.swift:166-184 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/GroundedFileSideEffectCheck.swift:117` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:1006— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:1006-1024 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1746-1764 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:1006` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:266— Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:266-284 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift:161-179 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:266` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift:182` calls `sameTeamTrust`, `verified` and `Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:285` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1592— Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1592-1610 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1990-2008 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1592` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758-776 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2889-2907 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:758` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:757` calls `padding` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2888` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1129— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1129-1147 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1814-1832 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1129` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1126` calls `frame` and `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1811` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:462— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:462-480 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1363-1381 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:462` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:482` calls `SettingsDivider` and `Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1382` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:94— Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:94-112 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:119-137 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:94` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestExtract.swift:32— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestExtract.swift:32-41 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:25-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestExtract.swift:32` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestExtract.swift:30` calls `extractManifest` and `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:23` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Managers/WatcherManager.swift:120— Packages/OsaurusCore/Managers/WatcherManager.swift:120-129 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:137-145 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:1289— Packages/OsaurusCore/Models/Chat/ContentBlock.swift:1289-1298 | Packages/OsaurusCore/Tools/RenderChartTool.swift:882-890 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:216— Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:216-225 | Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:234-242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:216` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:13149— Packages/OsaurusCore/Networking/HTTPHandler.swift:13149-13158 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13234-13242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13149` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:1235— Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:1235-1243 | Packages/OsaurusCore/PrivacyFilter/Core/StreamingUnscrubber.swift:261-270 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:1235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Services/Chat/ContextCompactionService.swift:598— Packages/OsaurusCore/Services/Chat/ContextCompactionService.swift:598-607 | Packages/OsaurusCore/Services/Inference/CoreModelService.swift:768-776 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/ContextCompactionService.swift:598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Services/ProcessMemoryProbe.swift:26— Packages/OsaurusCore/Services/ProcessMemoryProbe.swift:26-34 | Packages/OsaurusCore/Services/SystemMonitorService.swift:272-281 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Tools/ConfigurationTools.swift:808— Packages/OsaurusCore/Tools/ConfigurationTools.swift:808-817 | Packages/OsaurusCore/Tools/ConfigurationTools.swift:1367-1375 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/ConfigurationTools.swift:808` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Tools/SchemaValidator.swift:145— Packages/OsaurusCore/Tools/SchemaValidator.swift:145-154 | Packages/OsaurusCore/Tools/SchemaValidator.swift:294-302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/SchemaValidator.swift:145` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:127— Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:127-135 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:1057-1066 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:127` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:120— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:120-129 | Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:232-240 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `1` in one and `3` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9–10 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:769— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:769-777 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2970-2979 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:769` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:88— Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:88-97 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:182-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:88` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:748— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:748-768 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1629-1649 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:748` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Managers/SkillManager.swift:990— Packages/OsaurusCore/Managers/SkillManager.swift:990-1010 | Packages/OsaurusCore/Managers/SkillManager.swift:1022-1042 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/SkillManager.swift:990` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Managers/SkillManager.swift:1021` calls `deletingLastPathComponent` and `Packages/OsaurusCore/Managers/SkillManager.swift:989` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:5662— Packages/OsaurusCore/Networking/HTTPHandler.swift:5662-5682 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6433-6453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5662` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1417— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1417-1437 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1475-1495 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1417` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:357— Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift:357-377 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift:439-459 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageRPCClient.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/WhatsApp/WhatsAppRPCClient.swift:439` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:188— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:188-208 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:167-187 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:188` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:2871— Packages/OsaurusCore/Views/Agent/AgentsView.swift:2871-2891 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8826-8846 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:2871` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:2870` calls `saveAgent` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8825` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:375— Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:375-395 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:373-393 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:36— Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:36-56 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3234-3254 — before extracting anything, compare `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift` and `Packages/OsaurusCore/Views/Settings/ProvidersView.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2580— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2580-2600 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:734-754 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2580` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:568— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:568-588 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:819-839 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:568` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:923— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:923-943 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1098-1118 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 354 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:923` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) Packages/OsaurusCore/Views/Settings/ServerView.swift:2237— Packages/OsaurusCore/Views/Settings/ServerView.swift:2237-2257 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2408-2428 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerView.swift:2237` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1064— Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1064-1083 | Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1084-1103 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1064` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Subagent/SubagentSession.swift:397— Packages/OsaurusCore/Subagent/SubagentSession.swift:397-416 | Packages/OsaurusCore/Subagent/SubagentSession.swift:482-501 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:4865— Packages/OsaurusCore/Views/Agent/AgentsView.swift:4865-4884 | Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:935-954 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:4865` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Agent/CapabilitiesTableRepresentable.swift:139— Packages/OsaurusCore/Views/Agent/CapabilitiesTableRepresentable.swift:139-158 | Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:188-207 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:369— Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:369-388 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:439-458 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:369` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:579— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:579-598 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:690-709 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:579` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:575` calls `Text`, `pluralizedMemory`, `max` and `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:689` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:312— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:312-331 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:3106-3125 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:312` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2053— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2053-2072 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1136-1155 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2053` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2141— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2141-2160 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1217-1236 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2141` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1306— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1306-1325 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1434-1453 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1306` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:754— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:754-773 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:880-899 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:754` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Settings/ServerView.swift:2261— Packages/OsaurusCore/Views/Settings/ServerView.swift:2261-2280 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2430-2449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerView.swift:2261` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Packages/OsaurusCore/Views/Theme/ThemesView.swift:1635— Packages/OsaurusCore/Views/Theme/ThemesView.swift:1635-1654 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:2184-2203 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
TodoComment Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1720— /// Todo discipline: when true, some `todo` call with at least one — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Views/Chat/AgentInlineBlocks.swift:42— /// Todo pill until the user dismisses it. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Views/Chat/AgentInlineBlocks.swift:131— /// Todo pill to avoid flicker when the cursor crosses the pill's — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Views/Chat/ChatView.swift:7793— // Todo replaces one session-scoped checklist wholesale. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Views/Chat/ChatView.swift:8379— // Todo notice disappears. No prose classifier, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Views/Agent/AgentsView.swift:3598— // TODO(mode-merge): the spec (§9.4 / §13) allows per-field overrides — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Tools/AgentLoopTools.swift:94— // todo-staleness nudge could never arm (pending == 0), the UI block — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:1925— /// Todo is model-authored progress metadata, not an execution precondition. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2492— // Todo is advisory UI state, not a runtime lock. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2512— // Todo forever instead of returning to the actual pending action. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:3505— // Todo staleness: when the session todo still has unchecked — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment Packages/OsaurusCore/Models/Chat/ContentBlock.swift:1460— /// (todo banner, completion banner, clarify overlay) rather than — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
Duplicated block (23 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:168— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:168-190 | Packages/OsaurusCore/Services/HuggingFaceService.swift:930-952 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Models/Agent/AgentStore.swift:514— Packages/OsaurusCore/Models/Agent/AgentStore.swift:514-536 | Packages/OsaurusCore/Models/Agent/AgentStore.swift:551-573 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:8158— Packages/OsaurusCore/Networking/HTTPHandler.swift:8158-8180 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8245-8267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:8158` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11475— Packages/OsaurusCore/Networking/HTTPHandler.swift:11475-11497 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11513-11535 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11475` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:909— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:909-931 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1314-1336 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:909` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1072— Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1072-1094 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1117-1139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1072` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:569— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:569-591 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1113-1135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2401— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2401-2423 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3428-3450 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:407— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:407-429 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:251-273 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:407` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3124— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3124-3146 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:893-915 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3124` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23 lines × 2) Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:196— Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:196-218 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:434-456 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:196` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:194` calls `padding` and `Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:432` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (23 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAppleScript.swift:263— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAppleScript.swift:263-285 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerScreenContext.swift:183-205 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAppleScript.swift:263` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:355— Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:355-367 | Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:444-457 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:355` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:458— Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:458-471 | Packages/OsaurusCore/ComputerUse/Perception/FrameScrubber.swift:322-334 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:919— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:919-932 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:971-983 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:919` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:7996— Packages/OsaurusCore/Networking/HTTPHandler.swift:7996-8008 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11787-11800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:7996` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Services/Chat/ComposeRequest.swift:56— Packages/OsaurusCore/Services/Chat/ComposeRequest.swift:56-68 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:108-121 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:316— Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:316-328 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:181-194 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:316` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:197` calls `shareLinkActions` and `Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:330` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Chat/ChatView.swift:7802— Packages/OsaurusCore/Views/Chat/ChatView.swift:7802-7815 | Packages/OsaurusCore/Views/Chat/ChatView.swift:7829-7841 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatView.swift:7802` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Chat/NativeCompactionMarkerView.swift:57— Packages/OsaurusCore/Views/Chat/NativeCompactionMarkerView.swift:57-69 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:74-87 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeCompactionMarkerView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1200— Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1200-1212 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1243-1256 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1198` calls `effectiveToggleValue` and `Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1242` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:172— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:172-184 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1642-1655 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:227— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:227-239 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:233-246 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:227` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:739— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:739-752 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:866-878 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:739` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1511— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1511-1521 | Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1600-1611 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:203— Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:203-214 | Packages/OsaurusCore/Models/Template/MCPServerHint.swift:38-48 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:203` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/PluginHost/main.swift:553— Packages/OsaurusCore/PluginHost/main.swift:553-563 | Packages/OsaurusCore/Services/Plugin/PluginProcessHost.swift:303-314 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PluginHost/main.swift:553` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Services/ModelRuntime/ModelCapabilityLedger.swift:136— Packages/OsaurusCore/Services/ModelRuntime/ModelCapabilityLedger.swift:136-147 | Packages/OsaurusCore/Services/ModelRuntime/ModelPrefillTuningStore.swift:69-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime/ModelCapabilityLedger.swift:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:421— Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:421-432 | Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:319-329 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:421` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:1020— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:1020-1030 | Packages/OsaurusCore/Views/Workspaces/WorkspaceAuditView.swift:285-296 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:1020` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Common/GlassBackground.swift:305— Packages/OsaurusCore/Views/Common/GlassBackground.swift:305-316 | Packages/OsaurusCore/Views/Common/GlassBackground.swift:319-329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/GlassBackground.swift:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1639— Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1639-1649 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1948-1959 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1948` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:748— Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:748-758 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:755-766 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:748` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:387— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:387-398 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:307-317 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756-767 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:925-935 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:285— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:285-296 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:273-283 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:285` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:80— Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:80-90 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift:72-81 — before extracting anything, compare `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift` and `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:80` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:8790— Packages/OsaurusCore/Networking/HTTPHandler.swift:8790-8799 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9147-9157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9147` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:652— Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:652-661 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:667-677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:652` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3441— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3441-3451 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3552-3561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3441` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Services/MCP/MCPServerHub.swift:157— Packages/OsaurusCore/Services/MCP/MCPServerHub.swift:157-167 | Packages/OsaurusCore/Services/Provider/ProviderConnectivityCenter.swift:226-235 — before extracting anything, compare `Packages/OsaurusCore/Services/MCP/MCPServerHub.swift` and `Packages/OsaurusCore/Services/Provider/ProviderConnectivityCenter.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPServerHub.swift:157` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:436— Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:436-445 | Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:568-578 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:436` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:520— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:520-529 | Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:540-550 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:520` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:251— Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:251-260 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:117-127 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:251` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:953— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:953-963 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1087-1096 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:953` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10–11 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:349— Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:349-359 | Packages/OsaurusCore/Views/Tool/ToolPermissionBanner.swift:59-68 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10–11 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:256— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:256-266 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:221-230 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:256` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:523— Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:523-538 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2508-2521 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:523` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15159— Packages/OsaurusCore/Networking/HTTPHandler.swift:15159-15174 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15444-15457 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15159` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:60— Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:60-75 | Packages/OsaurusCore/Services/Plugin/PluginResponsesCompatibility.swift:27-40 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:60` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1641— Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1641-1654 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2053-2068 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1641` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:576— Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:576-589 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1071-1086 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:576` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:220— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:220-235 | Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:245-258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:220` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5032— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5032-5047 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5060-5073 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5032` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5219— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5219-5234 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5242-5255 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:838— Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:838-853 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1220-1233 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:838` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:305— Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:305-318 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:700-715 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:700` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:348— Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:348-360 | Packages/OsaurusCore/Services/Router/WorkspaceAgentAccessHost.swift:329-340 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:348` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:668— Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:668-680 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:703-714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4400— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4400-4411 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4613-4625 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4400` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Common/SimpleComponents.swift:310— Packages/OsaurusCore/Views/Common/SimpleComponents.swift:310-321 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:239-251 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:239` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:237— Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:237-249 | Packages/OsaurusCore/Views/Settings/AgentChannelDispatchRoutingEditor.swift:217-228 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:237` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2187— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2187-2199 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1473-1484 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2187` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:973— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:973-984 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:622-634 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:973` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:183— Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:183-195 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:104-115 — before extracting anything, compare `Packages/OsaurusCore/Views/Sandbox/SandboxView.swift` and `Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:327— Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:327-338 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:538-550 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:327` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) Packages/OsaurusCore/Views/Settings/ServerView.swift:227— Packages/OsaurusCore/Views/Settings/ServerView.swift:227-239 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:515-526 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerView.swift:227` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ServerView.swift:242` calls `Spacer` and `Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:529` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:5628— Packages/OsaurusCore/Networking/HTTPHandler.swift:5628-5635 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6859-6865 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7000-7006 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7306-7312 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5628` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:314— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:314-320 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:329-335 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:342-348 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:355-361 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:314` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) REDACTED:749— REDACTED:749-757 | REDACTED:759-765 | REDACTED:787-795 | REDACTED:857-867 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:749` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3356— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3356-3362 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:707-713 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:813-819 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:350-356 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3356` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6960— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6960-6966 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6997-7003 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:281-287 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1155-1161 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6960` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:83— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:83-89 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:614-620 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:644-650 | Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:135-141 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:83` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:273— Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:273-279 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:307-313 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:430-436 | Packages/OsaurusCore/Views/Settings/ServerView.swift:610-616 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:232— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:232-238 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:280-286 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2410-2416 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:326-332 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:737— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:737-744 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:864-870 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1042-1049 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2124-2131 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:737` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1040` calls `ProviderTextField` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:735` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 4) helpers/osaurus-wa/bridge.go:768— helpers/osaurus-wa/bridge.go:768-774 | helpers/osaurus-wa/bridge.go:779-785 | helpers/osaurus-wa/bridge.go:790-796 | helpers/osaurus-wa/bridge.go:800-806 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `helpers/osaurus-wa/bridge.go:807` calls `String`, `Base` and `helpers/osaurus-wa/bridge.go:775` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:709— Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:709-716 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1031-1038 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1069-1076 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1180-1187 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:709` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886— Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886-893 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:530-538 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:732-740 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:1056-1064 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1385— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1385-1392 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1396-1403 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1645-1652 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1923-1930 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1385` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Identity/IdentityView.swift:747— Packages/OsaurusCore/Views/Identity/IdentityView.swift:747-754 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:307-314 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2371-2378 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:164-171 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:747` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1350— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1350-1357 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:243-250 | Packages/OsaurusCore/Views/Settings/ServerView.swift:450-457 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1454-1461 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1350` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1426— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1426-1433 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:950-957 | Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:236-243 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:196-203 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1169— Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1169-1176 | Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:361-368 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2579-2586 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:733-740 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:329— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:329-336 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:442-449 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:317-324 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1805-1812 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:329` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 4) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:353— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:353-360 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:561-571 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:313-323 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:796-806 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:353` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:93— Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:93-98 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:55-60 | Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:29-34 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:161-166 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:251-256 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:93` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424-3430 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3542-3548 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3572-3578 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3587-3593 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2111-2116 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3424` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:51— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:51-56 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:539-544 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:641-646 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:750-755 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:51-56 — before extracting anything, compare `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift` and `Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 141 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1161— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1161-1166 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:195-200 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1348-1353 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:690-695 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:437-442 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1161` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:168— Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:168-173 | Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:211-218 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:923-928 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1269-1274 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:579-587 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:168` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Insights/InsightsView.swift:1027— Packages/OsaurusCore/Views/Insights/InsightsView.swift:1027-1032 | Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:118-125 | Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:112-119 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1076-1083 | Packages/OsaurusCore/Views/Settings/Shared/SettingsKit.swift:453-460 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsView.swift:1027` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/SearchView.swift:1074` calls `Spacer` and `Packages/OsaurusCore/Views/Settings/Shared/SettingsKit.swift:452` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:237— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:237-242 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:365-372 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:221-226 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:121-128 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:678-683 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:237` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:712— Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:712-718 | Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:83-89 | Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:233-239 | Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:186-191 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:188-194 — before extracting anything, compare `Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:1018— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:1018-1023 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1401-1406 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1496-1501 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1183-1188 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1529-1534 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:325— Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:325-342 | Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:376-394 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:69— Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:69-86 | Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:301-319 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:301` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:10049— Packages/OsaurusCore/Networking/HTTPHandler.swift:10049-10067 | Packages/OsaurusCore/Networking/HTTPHandler.swift:10072-10089 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:10072` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15184— Packages/OsaurusCore/Networking/HTTPHandler.swift:15184-15202 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15467-15484 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15184` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:113— Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:113-130 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:485-503 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:485` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3092— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3092-3110 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9008-9025 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3092` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:56— Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:56-73 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:76-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:56` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18–19 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:775— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:775-793 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:901-918 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:775` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Identity/MasterKey.swift:400— Packages/OsaurusCore/Identity/MasterKey.swift:400-416 | Packages/OsaurusCore/Identity/MasterMnemonicStore.swift:82-99 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11762— Packages/OsaurusCore/Networking/HTTPHandler.swift:11762-11779 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11810-11826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11762` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:16048— Packages/OsaurusCore/Networking/HTTPHandler.swift:16048-16065 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16119-16135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16048` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:801— Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:801-817 | Packages/OsaurusCore/Services/Documents/RichDocumentAdapter.swift:386-403 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1269— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1269-1286 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1449-1465 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1269` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:704— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:704-721 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:903-919 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:704` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:285— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:285-301 | Packages/OsaurusCore/Views/Settings/ServerView.swift:587-604 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:285` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (17–18 lines × 2) Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2313— Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2313-2329 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2351-2368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2351` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Models/Chat/RequestLog.swift:176— Packages/OsaurusCore/Models/Chat/RequestLog.swift:176-190 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:194-208 | Packages/OsaurusCore/Services/FeatureTelemetry.swift:760-774 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/RequestLog.swift:176` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:10292— Packages/OsaurusCore/Networking/HTTPHandler.swift:10292-10306 | Packages/OsaurusCore/Networking/HTTPHandler.swift:10332-10346 | Packages/OsaurusCore/Networking/HTTPHandler.swift:10382-10396 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:10292` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:14017— Packages/OsaurusCore/Networking/HTTPHandler.swift:14017-14031 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14065-14079 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14476-14490 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14017` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:14013— Packages/OsaurusCore/Networking/HTTPHandler.swift:14013-14027 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14037-14051 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14061-14075 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14013` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:197— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:197-211 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:266-280 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:329-343 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:197` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:244— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:244-258 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:265-279 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:328-342 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:244` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Tools/AgentChannelTools.swift:134— Packages/OsaurusCore/Tools/AgentChannelTools.swift:134-148 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:206-220 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:301-315 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/AgentChannelTools.swift:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1127— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1127-1141 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1572-1586 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1812-1826 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1126` calls `frame` and `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1571` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2474— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2474-2487 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1758-1772 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2474` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1755` calls `isMissingRequiredAgentActionError` and `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2473` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:640— Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:640-653 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:667-681 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:14473— Packages/OsaurusCore/Networking/HTTPHandler.swift:14473-14486 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14499-14513 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14473` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:732— Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:732-746 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:827-840 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6163— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6163-6177 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:245-258 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:500— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:500-513 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:324-338 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:500` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:271— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:271-284 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:868-882 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:868` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1634— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1634-1648 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1788-1801 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1634` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Folder/FolderContext.swift:71— Packages/OsaurusCore/Folder/FolderContext.swift:71-83 | Packages/OsaurusCore/Models/Memory/MemoryConfiguration.swift:134-146 | Packages/OsaurusCore/Services/Plugin/InstalledClaudePluginsAggregator.swift:152-164 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderContext.swift:71` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:101— Packages/OsaurusCore/Models/API/AnthropicAPI.swift:101-113 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:155-167 | Packages/OsaurusCore/Models/API/AnthropicAPI.swift:364-376 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Models/Agent/Agent.swift:891— Packages/OsaurusCore/Models/Agent/Agent.swift:891-903 | Packages/OsaurusCore/Models/Agent/Agent.swift:1313-1325 | Packages/OsaurusCore/Services/Chat/AgentConfigSnapshot.swift:253-265 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:86— Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:86-98 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:48-60 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:244-256 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:86` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:5996— Packages/OsaurusCore/Networking/HTTPHandler.swift:5996-6008 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8195-8207 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8282-8294 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5996` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055-6067 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6121-6133 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:195-207 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:208` calls `accessibilityIdentifier` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8349— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8349-8361 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8526-8538 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:578-590 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8349` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1301— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1301-1313 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1310-1322 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1480-1492 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `IMessageConnectionConfiguration` in one and `TelegramConnectionConfiguration` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:9728— Packages/OsaurusCore/Networking/HTTPHandler.swift:9728-9738 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12036-12046 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12114-12124 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12192-12202 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9728` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:103— Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:103-113 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:99-109 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:137-147 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:195-205 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:103` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:7235— Packages/OsaurusCore/Views/Agent/AgentsView.swift:7235-7245 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:163-173 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1563-1573 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:779-789 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:7235` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:174` calls `localizedHelp`, `Spacer` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:7246` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1032— Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1032-1042 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1070-1080 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1141-1151 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1181-1191 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1032` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:238— Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:238-248 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:884-894 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1436-1446 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:555-565 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:238` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:145— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:145-155 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:61-71 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:78-88 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:169-179 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:145` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:156` calls `localizedHelp` and `Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:73` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:88— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:88-98 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:114-124 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:329-339 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1833-1843 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:88` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 4) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:110— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:110-120 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:326-336 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1419-1429 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1830-1840 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:110` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 4) Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:181— Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:181-189 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:214-222 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:241-249 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:276-284 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:181` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:191` calls `boolean` and `Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:224` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:165— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:165-173 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:641-649 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:939-947 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1273-1281 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:165` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:162` calls `add` and `Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:638` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:9603— Packages/OsaurusCore/Networking/HTTPHandler.swift:9603-9611 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16044-16052 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16115-16123 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16461-16469 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9603` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:98— Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:98-106 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:768-776 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:110-118 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:87-95 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentSheetChrome.swift:98` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:157— Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:157-165 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:723-732 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:642-651 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:782-791 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:157` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `alignment` to `.firstTextBaseline` in one and `.top` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47— Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47-55 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:47-55 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:67-75 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:81-89 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:695— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:695-703 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1408-1416 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1190-1198 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1536-1544 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 4) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:257— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:257-265 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:263-271 | Packages/OsaurusCore/Storage/MethodDatabase.swift:131-139 | Packages/OsaurusCore/Storage/ToolDatabase.swift:187-195 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Storage/ToolDatabase.swift:184` calls `migrateToV2` and `Packages/OsaurusCore/Storage/MethodDatabase.swift:128` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:654— Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:654-659 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3355-3360 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8385-8390 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:706-711 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:812-817 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:376-381 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8392` calls `contentShape`, `Rectangle` and `Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:713` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:32— Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:32-37 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:40-45 | Packages/OsaurusCore/Storage/MethodDatabase.swift:24-29 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:30-35 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:33-38 | Packages/OsaurusCore/Storage/ToolDatabase.swift:24-29 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 6 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:32` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:120— Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:120-125 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1817-1823 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1981-1987 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2019-2025 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1010-1015 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:297-303 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018` calls `VStack` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1980` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2322— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2322-2327 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2414-2419 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2464-2469 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2533-2538 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2568-2573 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3160-3165 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2322` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3168` calls `constraint` and `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2328` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Views/Identity/IdentityView.swift:882— Packages/OsaurusCore/Views/Identity/IdentityView.swift:882-888 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:264-270 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:280-286 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1434-1440 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:316-321 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:275-281 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:882` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106— Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106-114 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:67-75 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:130-138 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:200-208 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:312-317 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:416-421 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:216— Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:216-221 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:779-784 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:725-730 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1028-1033 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2110-2115 | Packages/OsaurusCore/Views/Settings/SearchView.swift:326-331 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:216` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `5` in one and `10` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/SearchView.swift:333` calls `textCase` and `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:223` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:1111— Packages/OsaurusCore/Models/AgentChannel/AgentChannelConfiguration.swift:1111-1116 | Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:151-156 | Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:328-333 | Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:266-271 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:235-240 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:284-289 — before extracting anything, compare `Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Models/Channels/ChannelRemoteSafetyPolicy.swift:137— Packages/OsaurusCore/Models/Channels/ChannelRemoteSafetyPolicy.swift:137-142 | Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:96-101 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:58-63 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:264-269 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Channels/ChannelRemoteSafetyPolicy.swift:137` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Models/Chat/RequestLog.swift:998— Packages/OsaurusCore/Models/Chat/RequestLog.swift:998-1003 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1009-1014 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1027-1035 | Packages/OsaurusCore/Models/Chat/RequestLog.swift:1048-1056 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/RequestLog.swift:998` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468-3475 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3568-3573 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2071-2080 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3109-3114 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:7230— Packages/OsaurusCore/Views/Agent/AgentsView.swift:7230-7235 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:656-661 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1530-1535 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:397-402 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:7230` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Theme/ThemesView.swift:403` calls `fixedSize`, `Image`, `font` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:7236` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:460— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:460-467 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1187-1192 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:354-359 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:467-472 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:460` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Views/Settings/PermissionsView.swift:217— Packages/OsaurusCore/Views/Settings/PermissionsView.swift:217-222 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1780-1785 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1939-1944 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1978-1983 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (6 lines × 4) Packages/OsaurusCore/ComputerUse/Telemetry/AxResolvableSweep.swift:37— Packages/OsaurusCore/ComputerUse/Telemetry/AxResolvableSweep.swift:37-42 | Packages/OsaurusCore/Services/Context/ContextAttribution.swift:55-65 | Packages/OsaurusCore/Services/Skill/ClaudePluginManifestStore.swift:56-61 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:131-141 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
Duplicated block (6 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1172— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1172-1177 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1359-1364 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:701-706 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:448-453 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×7
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:171— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:171-194 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:199-225 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:292-340 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:342-396 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:431-462 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:468-512 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:1493— Packages/OsaurusCore/Networking/HTTPHandler.swift:1493-1781 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1787-1852 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1860-1926 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1934-2185 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2221-2544 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15856-16039 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:5226— Packages/OsaurusCore/Networking/HTTPHandler.swift:5226-5271 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6827-6917 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6968-7039 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7095-7190 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7274-7355 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7848-8028 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:488— Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:488-547 | Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:855-912 | Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:110-144 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:519-557 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:721-759 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:1043-1083 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1161— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1161-1170 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:195-204 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1348-1357 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:690-699 | Packages/OsaurusCore/Views/Template/TemplateImportReviewView.swift:165-171 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:437-446 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2298— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2298-2399 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2403-2449 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2453-2495 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2499-2555 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2559-2598 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3138-3181 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:945— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:945-973 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1332-1360 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1777-1812 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1415-1443 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1120-1148 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1460-1488 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15207— Packages/OsaurusCore/Networking/HTTPHandler.swift:15207-15234 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15489-15516 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15207` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:134— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:134-161 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:116-143 — before extracting anything, compare `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift` and `Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:134` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3043— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3043-3070 | Packages/OsaurusCore/Views/Chat/ChatTabStripView.swift:1197-1224 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3043` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:324— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:324-351 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:437-464 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:324` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:874— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:874-901 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:1022-1049 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:874` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:301— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:301-328 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:287-314 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (28 lines × 2) Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:209— Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:209-236 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:254-281 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:209` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:532— Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:532-556 | Packages/OsaurusCore/Services/LocalReasoningCapability.swift:713-737 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:50— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:50-74 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:50-74 — before extracting anything, compare `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift` and `Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 141 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8399— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8399-8423 | Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:467-491 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8399` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:339— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:339-363 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:335-359 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:527— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:527-551 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:729-753 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:527` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3276— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3276-3300 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1000-1024 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (25 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:608— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:608-632 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:745-769 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:608` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1608— Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1608-1629 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:349-370 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1608` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11695— Packages/OsaurusCore/Networking/HTTPHandler.swift:11695-11716 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12198-12219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1582— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1582-1603 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1609-1630 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:637— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:637-658 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:830-851 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:660` calls `validateCompleteOutput` and `Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:853` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:279— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:279-300 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:274-295 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:279` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:514— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:514-535 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:720-741 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:514` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (22 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1660— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1660-1681 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1959-1980 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1660` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:622— Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:622-636 | Packages/OsaurusCore/Views/Settings/SearchView.swift:893-907 | Packages/OsaurusCore/Views/Settings/Shared/SettingsKit.swift:457-471 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:408-422 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:622` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:81— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:81-95 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:107-121 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2402-2416 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:592-606 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:81` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:215— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:215-229 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:262-276 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1280-1294 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2393-2407 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:215` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1317— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1317-1331 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1445-1459 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1728-1742 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1966-1980 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1317` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:526— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:526-540 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:795-809 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:732-746 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1011-1025 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:526` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:922— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:922-936 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1305-1319 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1097-1111 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1433-1447 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:922` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (15 lines × 4) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:358— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:358-372 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1847-1861 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1463-1477 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1861-1875 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:358` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89— Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89-98 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:51-60 | Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:20-29 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:247-256 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:81— Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:81-90 | Packages/OsaurusCore/Models/Project/ProjectStore.swift:43-52 | Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:80-89 | Packages/OsaurusCore/Models/Watcher/WatcherStore.swift:74-83 — before extracting anything, compare `Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift` and `Packages/OsaurusCore/Models/Watcher/WatcherStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:81` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:79` calls `ensureExistsSilent`, `deletingLastPathComponent` and `Packages/OsaurusCore/Models/Watcher/WatcherStore.swift:72` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Services/SystemPermissionService.swift:912— Packages/OsaurusCore/Services/SystemPermissionService.swift:912-921 | Packages/OsaurusCore/Services/SystemPermissionService.swift:946-955 | Packages/OsaurusCore/Services/SystemPermissionService.swift:978-987 | Packages/OsaurusCore/Services/SystemPermissionService.swift:1033-1042 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/SystemPermissionService.swift:912` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:87— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:87-96 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:188-198 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:445-455 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:181-191 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:87` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Views/Identity/IdentityView.swift:740— Packages/OsaurusCore/Views/Identity/IdentityView.swift:740-749 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:300-309 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1019-1028 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:157-166 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:740` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:304— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:304-313 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:464-473 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1018-1027 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:299-308 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:304` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 4) Packages/OsaurusCore/Storage/MemoryDatabase.swift:184— Packages/OsaurusCore/Storage/MemoryDatabase.swift:184-193 | Packages/OsaurusCore/Storage/MethodDatabase.swift:102-111 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:243-252 | Packages/OsaurusCore/Storage/ToolDatabase.swift:157-166 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:259— Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:259-266 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:282-288 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Services/HuggingFaceService.swift:472— Packages/OsaurusCore/Services/HuggingFaceService.swift:472-478 | Packages/OsaurusCore/Services/HuggingFaceService.swift:788-795 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/HuggingFaceService.swift:472` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/HuggingFaceService.swift:787` calls `URLQueryItem` and `Packages/OsaurusCore/Services/HuggingFaceService.swift:471` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Services/MCP/MCPProviderErrorPresenter.swift:38— Packages/OsaurusCore/Services/MCP/MCPProviderErrorPresenter.swift:38-44 | Packages/OsaurusCore/Services/MCP/MCPProviderErrorPresenter.swift:49-56 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPProviderErrorPresenter.swift:38` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:109— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:109-115 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:111-118 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:66— Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:66-72 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:875-882 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018-2025 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1009-1015 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–8 lines × 2) Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:561— Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:561-568 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:578-584 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:561` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834-5840 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:519-528 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:558-567 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1055-1061 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:415-422 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1319— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1319-1325 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:339-345 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsBanners.swift:22-28 | Packages/OsaurusCore/Views/Settings/ServerView.swift:362-368 | Packages/OsaurusCore/Views/Settings/ServerView.swift:424-430 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1319` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `10` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:347` calls `Spacer` and `Packages/OsaurusCore/Views/Settings/ServerView.swift:370` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351-1357 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:244-250 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1956-1962 | Packages/OsaurusCore/Views/Settings/ServerView.swift:451-457 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1455-1461 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:548— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:548-554 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:650-656 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:745-751 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:114-120 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:145-152 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:548` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:198— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:198-204 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:105-111 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1673-1679 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:133-142 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1114-1120 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:593— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:593-599 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:729-735 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1032-1038 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2037-2043 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2114-2120 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:593` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1040` calls `ProviderTextField` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:737` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 5) Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:240— Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:240-246 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:254-260 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:274-280 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:304-310 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:321-327 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:272` calls `HStack` and `Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:238` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Change coupling: SystemPermission.swift ↔ ConfigurationView.swift Packages/OsaurusCore/Models/SystemPermission.swift:1— `Packages/OsaurusCore/Models/SystemPermission.swift` and `Packages/OsaurusCore/Views/Settings/ConfigurationView.swift` change together 64% of the time (7 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `b9dfd795` mic configurations (at that commit the file was still `Packages/OsaurusCore/Views/ConfigurationView.swift`); `ac495606` added whisper support (at that commit the file was still `Packages/OsaurusCore/Views/ConfigurationView.swift`); `29f43307` added location, notes, reminders permissions (at that commit the file was still `Packages/OsaurusCore/Views/ConfigurationView.swift`) — run `git show` on any of them.
Change coupling: NativeBlockViews.swift ↔ NativeThinkingView.swift Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:1— `Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` change together 64% of the time (7 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `03ea4c93` resolved crashes and hangs (#1575); `10dd0e91` chat improvements (#1259); `d011207d` performance improvements (#914) — run `git show` on any of them.
Change coupling: ChatConfiguration.swift ↔ ChatView.swift Packages/OsaurusCore/Models/Chat/ChatConfiguration.swift:1— `Packages/OsaurusCore/Models/Chat/ChatConfiguration.swift` and `Packages/OsaurusCore/Views/Chat/ChatView.swift` change together 57% of the time (23 of the 40 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 23 shared commits counted here, the most recent 3 are `a4eb0bb4` Lazy chat model loading: selecting a model records the choice; the fi…; `5523962d` revamped settings (#2517); `64f54a67` Delete the persisted global Disable Tools switch; tool availability i… — run `git show` on any of them.
Change coupling: ChatView.swift ↔ NativeThinkingView.swift Packages/OsaurusCore/Views/Chat/ChatView.swift:1— `Packages/OsaurusCore/Views/Chat/ChatView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in the same directory, and in this ecosystem sibling files there normally share one namespace/package — so a direct reference between them needs no import and this pass cannot see whether one exists. Read the pair before acting: if one file only DECLARES what the other consumes (a constants/types file beside its user), the co-change is definitional and the question is whether the split earns its keep; if they duplicate structure, extract the common part into a shared function or type they both call; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `5ca01d42` added option to expand thinking while streaming (#1871); `10dd0e91` chat improvements (#1259); `d011207d` performance improvements (#914) — run `git show` on any of them.
Change coupling: MemoryConfiguration.swift ↔ MemorySearchService.swift Packages/OsaurusCore/Models/Memory/MemoryConfiguration.swift:1— `Packages/OsaurusCore/Models/Memory/MemoryConfiguration.swift` and `Packages/OsaurusCore/Services/Memory/MemorySearchService.swift` change together 50% of the time (7 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `0f26f944` updated memory results (at that commit the files were still `Packages/OsaurusCore/Models/MemoryConfiguration.swift` and `Packages/OsaurusCore/Services/MemorySearchService.swift`); `af37b227` tuning optimization for locomo benchmark (at that commit the files were still `Packages/OsaurusCore/Models/MemoryConfiguration.swift` and `Packages/OsaurusCore/Services/MemorySearchService.swift`); `e99759f5` updated memory implementation (at that commit the files were still `Packages/OsaurusCore/Models/MemoryConfiguration.swift` and `Packages/OsaurusCore/Services/MemorySearchService.swift`) — run `git show` on any of them.
Change coupling: SettingsSearchIndex.swift ↔ AgentChannelConnectionCenterView.swift Packages/OsaurusCore/Models/Configuration/SettingsSearchIndex.swift:1— `Packages/OsaurusCore/Models/Configuration/SettingsSearchIndex.swift` and `Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `a2dd43d3` Keep channel chat tab live across follow-ups; add Focus Chat on Incom…; `33842593` Guide n8n setup so pairing codes only issue when they can work (#2775); `2fa86dbb` Redesign channels UX: name-first destinations, DM identity, intent-ba… — run `git show` on any of them.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17180— Packages/OsaurusCore/Networking/HTTPHandler.swift:17180-17205 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17957-17982 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17180` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Views/Chat/ChatView.swift:4981— Packages/OsaurusCore/Views/Chat/ChatView.swift:4981-5006 | Packages/OsaurusCore/Views/Chat/ChatView.swift:5010-5035 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatView.swift:4981` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Views/Common/SimpleComponents.swift:125— Packages/OsaurusCore/Views/Common/SimpleComponents.swift:125-150 | Packages/OsaurusCore/Views/Common/SimpleComponents.swift:194-219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SimpleComponents.swift:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:446— Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:446-471 | Packages/OsaurusCore/Views/Model/ModelListRow.swift:119-144 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:446` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:143— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:143-168 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1613-1638 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:143` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:27— Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift:27-52 | Packages/OsaurusCore/Models/Watcher/WatcherStore.swift:27-52 — before extracting anything, compare `Packages/OsaurusCore/Models/Schedule/ScheduleStore.swift` and `Packages/OsaurusCore/Models/Watcher/WatcherStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1786— Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1786-1809 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:7348-7371 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1786` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Storage/AgentDatabase.swift:1611— Packages/OsaurusCore/Storage/AgentDatabase.swift:1611-1634 | Packages/OsaurusCore/Storage/AgentDatabase.swift:1688-1711 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentDatabase.swift:1611` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8338— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8338-8361 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8515-8538 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8338` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1359— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1359-1382 | Packages/OsaurusCore/Views/Settings/ServerView.swift:473-496 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1359` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:119— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:119-142 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:110-133 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:119` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 2) Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:114— Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:114-137 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1078-1101 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift` and `Packages/OsaurusCore/Views/Settings/SearchView.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 75 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:114` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:11808— Packages/OsaurusCore/Networking/HTTPHandler.swift:11808-11819 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11837-11850 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11808` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468-3481 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3572-3583 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3468` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Subagent/SubagentSession.swift:548— Packages/OsaurusCore/Subagent/SubagentSession.swift:548-559 | Packages/OsaurusCore/Subagent/SubagentSession.swift:608-621 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:208— Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:208-219 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:323-336 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:89— Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:89-100 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1093-1106 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1011— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1011-1022 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1025-1038 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1025` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:444— Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:444-454 | Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:461-471 | Packages/OsaurusCore/Managers/Chat/ChatWindowManager.swift:493-504 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:4718— Packages/OsaurusCore/Networking/HTTPHandler.swift:4718-4728 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4815-4825 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4882-4893 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4718` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:11344— Packages/OsaurusCore/Networking/HTTPHandler.swift:11344-11354 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11363-11373 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11432-11443 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11344` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:16045— Packages/OsaurusCore/Networking/HTTPHandler.swift:16045-16055 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16116-16126 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16462-16473 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16045` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1210— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1210-1221 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1297-1308 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1348-1358 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1210` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1479— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1479-1489 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:867-878 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2885-2896 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1479` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2884` calls `background` and `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1478` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1707— Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1707-1717 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:7148-7156 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1707` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:754— Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:754-764 | Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:766-774 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:668— Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:668-676 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:730-740 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:730` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/Subagent/Kinds/BrowserUseKind.swift:240— Packages/OsaurusCore/Subagent/Kinds/BrowserUseKind.swift:240-248 | Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:1065-1075 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/Kinds/BrowserUseKind.swift:240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5288— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5288-5298 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5303-5311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5301` calls `hasItemConformingToTypeIdentifier` and `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5286` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9–11 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:459— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:459-469 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1186-1194 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:459` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:75— Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:75-82 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:241-248 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:318-325 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:381-388 | Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:482-489 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:75` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:379` calls `SearchRequestParam` and `Packages/OsaurusCore/Models/Configuration/SearchProviderCatalog.swift:239` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:142— Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift:142-149 | Packages/OsaurusCore/Models/IMessage/IMessageConnectionConfiguration.swift:319-326 | Packages/OsaurusCore/Models/Slack/SlackConnectionConfiguration.swift:257-264 | Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift:226-233 | Packages/OsaurusCore/Models/WhatsApp/WhatsAppConnectionConfiguration.swift:275-282 — before extracting anything, compare `Packages/OsaurusCore/Models/Discord/DiscordConnectionConfiguration.swift` and `Packages/OsaurusCore/Models/Telegram/TelegramConnectionConfiguration.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:4611— Packages/OsaurusCore/Networking/HTTPHandler.swift:4611-4618 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12368-12375 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14000-14007 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15304-15311 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16924-16931 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4611` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:281— Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:281-288 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:582-589 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:693-700 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:138-145 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1630-1637 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:281` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:550— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:550-557 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:652-659 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:772-779 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:747-754 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:754-762 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 5) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:824— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:824-831 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:978-985 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:764-771 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:628-635 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:235-242 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:824` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:233` calls `fixedSize` and `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:976` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication· Members sharing a duplicated core (8 members, 50+ identical tokens) · ×5
Members sharing a duplicated core (8 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:843— Packages/OsaurusCore/Views/Agent/AgentsView.swift:843-1063 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:162-212 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:160-206 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:207-283 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1266-1344 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:365-528 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:209-350 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:727-772 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Members sharing a duplicated core (8 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:2711— Packages/OsaurusCore/Views/Agent/AgentsView.swift:2711-2737 | Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:418-486 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2460-2524 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2716-2744 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2826-2875 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2883-2895 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2903-2915 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2931-2963 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Members sharing a duplicated core (8 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3133— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3133-3201 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3440-3513 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8848-8894 | Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:463-519 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:117-167 | Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:361-428 | Packages/OsaurusCore/Views/Settings/ConfigurationView.swift:633-704 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:504-639 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Members sharing a duplicated core (8 members, 50+ identical tokens) Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:96— Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:96-128 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:56-93 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:119-160 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:189-232 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:297-340 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:407-476 | Packages/OsaurusCore/Views/Settings/OsaurusConnectView.swift:207-216 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:199-245 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Members sharing a duplicated core (8 members, 50+ identical tokens) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:545— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:545-592 | Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:622-657 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:708-746 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:796-851 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:916-959 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:363-401 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:447-481 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:924-962 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Duplicated block (16–17 lines × 2) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:379— Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:379-394 | Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:529-545 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:379` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16–17 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:1994— Packages/OsaurusCore/Networking/HTTPHandler.swift:1994-2009 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2061-2077 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1994` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–17 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:476— Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:476-492 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:567-582 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:476` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:474` calls `bump` and `Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:565` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16–17 lines × 2) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:198— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:198-214 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:351-366 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–17 lines × 2) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:691— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:691-707 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:451-466 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:691` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (14 lines × 3) Packages/OsaurusCore/Models/Chat/DispatchRequest.swift:167— Packages/OsaurusCore/Models/Chat/DispatchRequest.swift:167-180 | Packages/OsaurusCore/Models/Schedule/Schedule.swift:561-574 | Packages/OsaurusCore/Models/Watcher/Watcher.swift:152-165 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/DispatchRequest.swift:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:8369— Packages/OsaurusCore/Networking/HTTPHandler.swift:8369-8382 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8805-8818 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9167-9180 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:8369` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:16699— Packages/OsaurusCore/Networking/HTTPHandler.swift:16699-16712 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16845-16858 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16881-16894 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16699` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6521— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6521-6534 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8038-8051 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:295-308 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6521` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:40— Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:40-53 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3238-3251 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:378-391 — before extracting anything, compare `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift` and `Packages/OsaurusCore/Views/Settings/ProvidersView.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:40` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 5) Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206— Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206-216 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:138-148 | Packages/OsaurusCore/Services/Search/SearchTypes.swift:32-42 | Packages/OsaurusCore/Subagent/SubagentCapabilityRegistry.swift:160-170 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2882-2892 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:206` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 5) Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:236— Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:236-246 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:254-264 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:273-283 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:554-564 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:572-582 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `provider` to `RemoteProvider` in one and `MCPProvider` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11 lines × 5) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1015— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1015-1025 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:77-87 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceCard.swift:109-119 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:47-57 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1175-1185 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1015` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1014` calls `overlay` and `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:46` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 5) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6056— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6056-6066 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6122-6132 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6474-6484 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:196-206 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:416-426 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6056` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:208` calls `accessibilityIdentifier` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 5) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1466— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1466-1476 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2193-2203 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:578-588 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1478-1488 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsHelpers.swift:53-63 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1466` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1156— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1156-1165 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1244-1253 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1311-1319 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1351— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1351-1360 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1417-1426 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1535-1543 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1351` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 3) Packages/OsaurusCore/Services/ModelRuntime.swift:1405— Packages/OsaurusCore/Services/ModelRuntime.swift:1405-1413 | Packages/OsaurusCore/Services/ModelRuntime.swift:1461-1469 | Packages/OsaurusCore/Services/ModelRuntime.swift:2877-2886 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 3) Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:267— Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:267-276 | Packages/OsaurusCore/Views/Plugin/MCPElicitationView.swift:326-335 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:448-456 — before extracting anything, compare `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift` and `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 126 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:267` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 3) Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1286— Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1286-1295 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsBanners.swift:40-49 | Packages/OsaurusCore/Views/Settings/ServerView.swift:384-392 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1286` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–10 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:532— Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:532-541 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:182-188 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:220-226 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (7–10 lines × 3) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:612— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:612-618 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:322-328 | Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:2044-2053 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:2044` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:609` calls `constraint` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:319` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–10 lines × 3) Packages/OsaurusCore/Views/Sandbox/ProvisioningJourneyView.swift:183— Packages/OsaurusCore/Views/Sandbox/ProvisioningJourneyView.swift:183-192 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1648-1657 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:358-364 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Sandbox/ProvisioningJourneyView.swift:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–10 lines × 3) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:784— Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:784-793 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:797-806 | Packages/OsaurusCore/Views/Settings/SearchView.swift:941-947 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:784` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (7–10 lines × 3) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:937— Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:937-943 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1743-1752 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:2225-2234 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8–10 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:14730— Packages/OsaurusCore/Networking/HTTPHandler.swift:14730-14737 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14833-14842 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14730` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 2) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5193— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5193-5202 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5427-5434 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5193` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 2) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:137— Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:137-146 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:831-838 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4370— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4370-4379 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4584-4591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4370` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 2) Packages/OsaurusCore/Views/Identity/IdentityView.swift:853— Packages/OsaurusCore/Views/Identity/IdentityView.swift:853-862 | Packages/OsaurusCore/Views/Settings/ConfigurationView.swift:314-321 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (6–7 lines × 2) Packages/OsaurusCore/Services/Documents/BusinessDocumentStudioService.swift:648— Packages/OsaurusCore/Services/Documents/BusinessDocumentStudioService.swift:648-653 | Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:301-307 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1362— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1362-1368 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1552-1557 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1552` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 2) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4620— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4620-4626 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4648-4653 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4620` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 2) Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:329— Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:329-335 | Packages/OsaurusCore/Views/Settings/ServerView.swift:963-968 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:329` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 2) Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:449— Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:449-454 | Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:673-679 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Theme/ThemeEditorView.swift:449` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication· Members sharing a duplicated core (9 members, 50+ identical tokens) · ×4
Members sharing a duplicated core (9 members, 50+ identical tokens) Packages/OsaurusCore/AppleApps/AppleAppsPluginMigration.swift:73— Packages/OsaurusCore/AppleApps/AppleAppsPluginMigration.swift:73-84 | Packages/OsaurusCore/Browser/BrowserConfigurationStore.swift:67-80 | Packages/OsaurusCore/ComputerUse/Policy/ComputerUsePolicyStore.swift:106-115 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:453-463 | Packages/OsaurusCore/Models/Configuration/RelayConfiguration.swift:48-58 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:472-482 | Packages/OsaurusCore/Models/Tool/ToolConfigurationStore.swift:106-115 | Packages/OsaurusCore/Models/Voice/SpeechConfiguration.swift:254-264 | Packages/OsaurusCore/Models/Voice/TTSConfiguration.swift:175-185 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
Members sharing a duplicated core (9 members, 50+ identical tokens) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:209— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:209-241 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:847-945 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:948-1046 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1050-1125 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1129-1204 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1207-1286 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1289-1357 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1360-1448 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1451-1540 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
Members sharing a duplicated core (9 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:5470— Packages/OsaurusCore/Networking/HTTPHandler.swift:5470-5585 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6047-6087 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6768-6824 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6922-6960 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7044-7082 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7219-7271 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7399-7464 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7481-7528 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7639-7731 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
Members sharing a duplicated core (9 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:9358— Packages/OsaurusCore/Views/Agent/AgentsView.swift:9358-9385 | Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:802-819 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:796-889 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1444-1462 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:569-629 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1007-1060 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1566-1593 | Packages/OsaurusCore/Views/Settings/ServerView.swift:193-278 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:634-671 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication· Members sharing a duplicated core (7 members, 50+ identical tokens) · ×4
Members sharing a duplicated core (7 members, 50+ identical tokens) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1378— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1378-1463 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1693-1734 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1736-1780 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1994-2131 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2186-2298 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2355-2427 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2440-2522 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
Members sharing a duplicated core (7 members, 50+ identical tokens) Packages/OsaurusCore/Networking/HTTPHandler.swift:3962— Packages/OsaurusCore/Networking/HTTPHandler.swift:3962-3999 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4602-4896 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14320-14341 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14446-14949 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17176-17322 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17954-18074 | Packages/OsaurusCore/Networking/HTTPLoopHelpers.swift:160-186 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
Members sharing a duplicated core (7 members, 50+ identical tokens) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1607— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1607-1661 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1710-1728 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1730-1755 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1174-1198 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1218-1242 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1258-1282 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1302-1326 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
Members sharing a duplicated core (7 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/AgentsView.swift:404— Packages/OsaurusCore/Views/Agent/AgentsView.swift:404-496 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplatesView.swift:94-117 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:71-382 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:29-201 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandsView.swift:21-89 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1004-1048 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:106-167 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
Duplicated block (31 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:220— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:220-250 | Packages/OsaurusCore/Services/HuggingFaceService.swift:975-1005 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (31 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228-258 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:222-252 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:254` calls `reloadAuthentication` and `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:260` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (31 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1188— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1188-1218 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1872-1902 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (31 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:638— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:638-668 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:775-805 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:638` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (29 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1038— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1038-1066 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1145-1173 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1038` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) Packages/OsaurusCore/Views/Chat/ChatView.swift:11486— Packages/OsaurusCore/Views/Chat/ChatView.swift:11486-11514 | Packages/OsaurusCore/Views/Chat/MessageThreadView.swift:110-138 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatView.swift:11486` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2210— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2210-2238 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1296-1324 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2210` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:18— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:18-46 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:18-46 — before extracting anything, compare `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift` and `Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 141 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (18 lines × 3) Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:32— Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:32-49 | Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:72-89 | Packages/OsaurusCore/Models/Configuration/ProviderPresets.swift:112-129 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (18 lines × 3) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:530— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:530-547 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:840-857 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:629-646 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:530` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 3) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:245— Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:245-262 | Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:333-350 | Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:382-399 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (18 lines × 3) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:540— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:540-557 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:742-759 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:1066-1083 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:540` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–18 lines × 2) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:346— Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:346-360 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:942-959 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:346` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–18 lines × 2) Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:489— Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:489-506 | Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:617-631 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:489` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15–18 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:8010— Packages/OsaurusCore/Services/ModelRuntime.swift:8010-8024 | Packages/OsaurusCore/Services/ModelRuntime.swift:8026-8043 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:8010` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15–18 lines × 2) Packages/OsaurusCore/Views/Common/SimpleComponents.swift:722— Packages/OsaurusCore/Views/Common/SimpleComponents.swift:722-739 | Packages/OsaurusCore/Views/Toast/ToastView.swift:225-239 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (15–17 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:939— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:939-955 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:990-1004 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:939` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–17 lines × 2) Packages/OsaurusCore/Models/Schedule/Schedule.swift:731— Packages/OsaurusCore/Models/Schedule/Schedule.swift:731-747 | Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:323-337 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Schedule/Schedule.swift:731` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15–17 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:4770— Packages/OsaurusCore/Services/ModelRuntime.swift:4770-4784 | Packages/OsaurusCore/Services/ModelRuntime.swift:4802-4818 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:4770` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–17 lines × 2) Packages/OsaurusCore/Views/Common/CircularIconButton.swift:48— Packages/OsaurusCore/Views/Common/CircularIconButton.swift:48-62 | Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:226-242 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/CircularIconButton.swift:48` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 3) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:476— Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:476-491 | Packages/OsaurusCore/Managers/InsightsService.swift:730-745 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:1016-1031 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:476` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Managers/InsightsService.swift:746` calls `log` and `Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:1032` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:16338— Packages/OsaurusCore/Networking/HTTPHandler.swift:16338-16353 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16420-16435 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16746-16761 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16338` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 3) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:151— Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:151-166 | Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:239-254 | Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:376-391 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1315— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1315-1330 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1760-1775 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1443-1458 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1315` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1759` calls `reloadPendingContacts` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1314` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–15 lines × 2) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6321— Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6321-6333 | Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6452-6466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6321` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–15 lines × 2) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:613— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:613-625 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:712-726 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:613` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–15 lines × 2) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:79— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:79-93 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1940-1952 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:79` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:94` calls `lineLimit` and `Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1953` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–15 lines × 2) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:110— Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:110-122 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:30-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:110` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11–14 lines × 2) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1573— Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1573-1586 | Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1816-1826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–14 lines × 2) Packages/OsaurusCore/Tools/KnowledgeTools.swift:364— Packages/OsaurusCore/Tools/KnowledgeTools.swift:364-374 | Packages/OsaurusCore/Tools/KnowledgeTools.swift:776-789 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/KnowledgeTools.swift:364` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–14 lines × 2) Packages/OsaurusCore/Views/Memory/MemoryView.swift:519— Packages/OsaurusCore/Views/Memory/MemoryView.swift:519-532 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1055-1065 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryView.swift:519` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–14 lines × 2) Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:373— Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:373-386 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:485-495 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:373` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–13 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446-3458 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:109-119 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–13 lines × 2) Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:458— Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:458-470 | Packages/OsaurusCore/Storage/ToolDatabase.swift:389-399 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:458` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11–13 lines × 2) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:214— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:214-224 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:774-786 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:214` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–13 lines × 2) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:533— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:533-545 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1069-1079 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:533` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–12 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:313— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:313-324 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:363-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:313` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–12 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:235— Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:235-246 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:580-589 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–12 lines × 2) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1200— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1200-1211 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1329-1338 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1200` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–12 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:186— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:186-195 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1658-1669 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–12 lines × 2) Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:184— Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:184-195 | Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:209-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:184` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–12 lines × 2) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:383— Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:383-391 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:632-643 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:383` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9–12 lines × 2) Packages/OsaurusCore/Views/Settings/SearchView.swift:952— Packages/OsaurusCore/Views/Settings/SearchView.swift:952-960 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1192-1203 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/SearchView.swift:952` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–12 lines × 2) Packages/OsaurusCore/Views/Voice/TranscriptionSettingsTab.swift:390— Packages/OsaurusCore/Views/Voice/TranscriptionSettingsTab.swift:390-401 | Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:313-321 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Voice/TranscriptionSettingsTab.swift:390` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 3) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:602— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:602-612 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:687-696 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:805-814 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:602` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:13100— Packages/OsaurusCore/Networking/HTTPHandler.swift:13100-13110 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13184-13194 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13287-13296 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13100` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:13286` calls `VideoJobResponseDTO`, `String` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:13100` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–11 lines × 3) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1731— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1731-1740 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1218-1228 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1302-1312 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1218` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 3) Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:123— Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:123-133 | Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:136-145 | Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:269-279 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:280` calls `opacity` and `Packages/OsaurusCore/Views/Agent/Database/DatabaseHistoryView.swift:134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 5) Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:150— Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:150-158 | Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift:142-150 | Packages/OsaurusCore/Managers/TTSService.swift:762-770 | Packages/OsaurusCore/Services/ModelRuntime/PrefillDebugLog.swift:89-97 | Packages/OsaurusCore/Utils/KnowledgeLogger.swift:69-77 — before extracting anything, compare `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift` and `Packages/OsaurusCore/ComputerUse/Loop/ComputerUseTraceLog.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptTraceLog.swift:150` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (9 lines × 5) Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89— Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89-97 | Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:51-59 | Packages/OsaurusCore/Services/Documents/BusinessDocumentStudioService.swift:45-53 | Packages/OsaurusCore/Services/Documents/CSVTableWorkflowService.swift:20-28 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:247-255 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:89` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 5) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:33— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:33-41 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:332-340 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:998-1006 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:1058-1066 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:1196-1204 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:33` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `24` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:181— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:181-189 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:188-196 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:198-206 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:180-188 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:199-207 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:193` calls `stopPairing` and `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:171` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–9 lines × 3) Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:469— Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:469-477 | Packages/OsaurusCore/Services/Provider/ProviderReplayDiagnostics.swift:239-246 | Packages/OsaurusCore/Services/Provider/XAIOAuthService.swift:332-340 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:469` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `maxLength` to `Int = 240` in one and `Int = 700` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8–9 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8402— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8402-8410 | Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:470-478 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1959-1966 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (8–9 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:567— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:567-575 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1158-1165 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1193-1201 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:567` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:90— Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:90-97 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:183-190 | Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:277-285 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:16336— Packages/OsaurusCore/Networking/HTTPHandler.swift:16336-16343 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16418-16425 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16525-16532 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16697-16704 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16744-16751 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16843-16850 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16879-16886 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16336` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1017— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1017-1025 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:79-87 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:109-116 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceCard.swift:111-119 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:49-57 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1177-1185 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:686-695 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1017` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1014` calls `overlay` and `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:46` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104-3113 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5789-5798 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9019-9027 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2652-2662 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:532-539 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:186-195 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:809-818 — there are 7 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 7) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:537— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:537-544 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:165-172 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:195-202 | Packages/OsaurusCore/Storage/MethodDatabase.swift:115-122 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:224-231 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:256-263 | Packages/OsaurusCore/Storage/ToolDatabase.swift:170-177 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 7 call sites, so a change lands once.
Duplicated block (6–7 lines × 3) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:154— Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:154-160 | Packages/OsaurusCore/Tools/ConfigurationTools.swift:426-431 | Packages/OsaurusCore/Tools/ConfigurationTools.swift:1176-1181 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 3) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:722— Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:722-728 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:755-760 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:772-778 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:722` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3855— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3855-3860 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1634-1639 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:368-374 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3855` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 3) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:804— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:804-810 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:868-873 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:923-929 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:868` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 6) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1163— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1163-1170 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:197-204 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1350-1357 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:692-699 | Packages/OsaurusCore/Views/Template/TemplateImportReviewView.swift:167-171 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:439-446 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1163` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 6) Packages/OsaurusCore/Views/Agent/AgentsView.swift:2711— Packages/OsaurusCore/Views/Agent/AgentsView.swift:2711-2715 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2716-2720 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2826-2830 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2883-2887 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2903-2907 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2931-2935 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:2711` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 6) Packages/OsaurusCore/Views/Identity/IdentityView.swift:967— Packages/OsaurusCore/Views/Identity/IdentityView.swift:967-974 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:67-72 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:660-667 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2065-2069 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2501-2506 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:746-753 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:967` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 6) Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:419— Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:419-423 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2717-2721 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2827-2831 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2884-2888 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2904-2908 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2932-2936 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:419` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `16` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 5) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:178— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:178-182 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:217-221 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:299-304 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:349-353 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:491-495 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:299` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 5) Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:465— Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:465-469 | Packages/OsaurusCore/Services/HuggingFaceService.swift:474-478 | Packages/OsaurusCore/Services/HuggingFaceService.swift:790-795 | Packages/OsaurusCore/Services/HuggingFaceService.swift:885-889 | Packages/OsaurusCore/Services/HuggingFaceService.swift:1029-1033 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:465` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/HuggingFaceService.swift:787` calls `URLQueryItem` and `Packages/OsaurusCore/Services/HuggingFaceService.swift:471` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 5) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:225— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:225-229 | Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:248-252 | Packages/OsaurusCore/Views/Chat/ProjectInspectorPanel.swift:143-148 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:574-579 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:581-586 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 5) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:105— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:105-109 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:124-128 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:142-146 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:155-159 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:173-177 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Sync-over-async blocking Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/AppControl.swift:23— `launchAppIfNeeded` is async and calls .waitUntilExit() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs.
Sync-over-async blocking Packages/OsaurusCore/Models/Plugin/ExternalPlugin.swift:863— `shutdown` is async and calls .wait() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs.
Sync-over-async blocking Packages/OsaurusCore/Services/AgentChannel/AgentChannelTransportRuntime.swift:80— `sleep` is async and calls sleep — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs.
Sync-over-async blocking Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:2646— `extractKernel` is async and calls .waitUntilExit() — a blocking call inside async code stalls the cooperative pool's thread — one per core — and every task scheduled on it for as long as it runs.
ChatSession.dispatchSend::runTurn (cyclomatic 109) Packages/OsaurusCore/Views/Chat/ChatView.swift:6728— ChatSession.dispatchSend::runTurn has cyclomatic complexity 109 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn::postProcessToolResult, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ChatSession.dispatchSend::runTurn::postProcessToolResult (cyclomatic 36) Packages/OsaurusCore/Views/Chat/ChatView.swift:7357— ChatSession.dispatchSend::runTurn::postProcessToolResult has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ChatSession.dispatchSend::runTurn::executeToolBatch (cyclomatic 29) Packages/OsaurusCore/Views/Chat/ChatView.swift:7765— ChatSession.dispatchSend::runTurn::executeToolBatch has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::postProcessToolResult) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ChatSession.dispatchSend::runTurn (cognitive 215) Packages/OsaurusCore/Views/Chat/ChatView.swift:6728— ChatSession.dispatchSend::runTurn has cognitive complexity 215 (threshold 15). Drivers by points: if/else 62 (129 pts), ternaries 17 (44 pts), boolean chains 26, loops 4 (11 pts), error handling 4 (5 pts) (nesting depth added 102). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn::postProcessToolResult, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ChatSession.dispatchSend::runTurn::postProcessToolResult (cognitive 48) Packages/OsaurusCore/Views/Chat/ChatView.swift:7357— ChatSession.dispatchSend::runTurn::postProcessToolResult has cognitive complexity 48 (threshold 15). Drivers by points: if/else 24 (35 pts), boolean chains 10, ternaries 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ChatSession.dispatchSend::runTurn::executeToolBatch (cognitive 47) Packages/OsaurusCore/Views/Chat/ChatView.swift:7765— ChatSession.dispatchSend::runTurn::executeToolBatch has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (30 pts), boolean chains 8, loops 4 (7 pts), error handling 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend, ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::postProcessToolResult) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Duplicated block (34 lines × 2) Packages/OsaurusCore/Models/SystemPermission.swift:45— Packages/OsaurusCore/Models/SystemPermission.swift:45-78 | Packages/OsaurusCore/Models/SystemPermission.swift:81-114 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (34 lines × 2) Packages/OsaurusCore/Models/SystemPermission.swift:117— Packages/OsaurusCore/Models/SystemPermission.swift:117-150 | Packages/OsaurusCore/Models/SystemPermission.swift:153-186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (34 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1084— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1084-1117 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1163-1196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1084` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (33 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66-98 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:67-99 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (33 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:748— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:748-780 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:964-996 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (33 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1125— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1125-1157 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2227-2259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2262` calls `VStack` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1160` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21–24 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:9207— Packages/OsaurusCore/Networking/HTTPHandler.swift:9207-9227 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9432-9455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9207` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (21–24 lines × 2) Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:179— Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:179-199 | Packages/OsaurusCore/Views/Onboarding/OnboardingWelcomeView.swift:48-71 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:179` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:172` calls `contentShape`, `Rectangle` and `Packages/OsaurusCore/Views/Onboarding/OnboardingWelcomeView.swift:42` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21–24 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2639— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2639-2659 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:793-816 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2639` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–23 lines × 2) Packages/OsaurusCore/Services/Chat/ChatTitleService.swift:88— Packages/OsaurusCore/Services/Chat/ChatTitleService.swift:88-110 | Packages/OsaurusCore/Services/Chat/FollowUpSuggestionService.swift:117-137 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/ChatTitleService.swift:88` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–23 lines × 2) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:222— Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:222-244 | Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:328-348 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:222` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21–23 lines × 2) Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:217— Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:217-239 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:278-298 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:217` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:240` calls `frame` and `Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:299` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17–19 lines × 2) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2371— Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2371-2389 | Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2470-2486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2371` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–19 lines × 2) Packages/OsaurusCore/Storage/AgentDatabase.swift:1108— Packages/OsaurusCore/Storage/AgentDatabase.swift:1108-1126 | Packages/OsaurusCore/Storage/AgentDatabase.swift:1270-1286 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentDatabase.swift:1108` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (17–19 lines × 2) Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:60— Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:60-78 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:39-55 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:60` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–19 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1089— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1089-1107 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1646-1661 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1089` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–19 lines × 2) Packages/OsaurusCore/Views/Credits/CreditsView.swift:198— Packages/OsaurusCore/Views/Credits/CreditsView.swift:198-213 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:227-245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:198` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (16–19 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:461— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:461-476 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:669-687 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:461` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (18 lines × 4) Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:92— Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:92-109 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:142-159 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:163-180 | Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:184-201 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPProtocolErrors.swift:92` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:124— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:124-141 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:158-175 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2439-2456 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:637-654 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:124` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2461` calls `ScheduleEditorSection`, `L`, `VStack` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift:659` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (18 lines × 4) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:142— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:142-159 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:146-163 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:141-158 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:167-184 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:142` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 3) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1099— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1099-1115 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1178-1194 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1336-1352 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1099` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:197— Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:197-213 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:257-273 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:411-427 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:197` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1191— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1191-1207 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:883-899 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1319-1335 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 306 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–16 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:443— Packages/OsaurusCore/Managers/MCPProviderManager.swift:443-458 | Packages/OsaurusCore/Managers/MCPProviderManager.swift:1446-1458 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/MCPProviderManager.swift:443` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–16 lines × 2) REDACTED:936— REDACTED:936-948 | REDACTED:1046-1061 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:936` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–16 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:862— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:862-874 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:996-1011 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:996` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 2) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:507— Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:507-521 | Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:546-561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 2) Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:90— Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:90-104 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:158-173 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:157` calls `foregroundColor` and `Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:89` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15–16 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1272— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1272-1286 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2384-2399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1272` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:11718— Packages/OsaurusCore/Networking/HTTPHandler.swift:11718-11730 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11866-11879 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11884-11896 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:11718` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:95— Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:95-107 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:126-139 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1596-1609 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:95` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:191— Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:191-204 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3342-3354 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1065-1078 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:191` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–13 lines × 3) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:308— Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:308-320 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:338-348 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:351-361 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:308` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–13 lines × 3) Packages/OsaurusCore/Services/Channels/ChannelSecurityDiagnostics.swift:99— Packages/OsaurusCore/Services/Channels/ChannelSecurityDiagnostics.swift:99-109 | Packages/OsaurusCore/Services/SupportDiagnosticsBundle.swift:468-478 | Packages/OsaurusCore/Services/Voice/MarkdownStripper.swift:47-59 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Channels/ChannelSecurityDiagnostics.swift:99` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–13 lines × 3) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:951— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:951-961 | Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift:237-249 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:197-209 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:951` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11 lines × 6) Packages/OsaurusCore/Networking/HTTPHandler.swift:1500— Packages/OsaurusCore/Networking/HTTPHandler.swift:1500-1510 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1794-1804 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1867-1877 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1941-1951 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2230-2240 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15863-15873 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1500` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 6) Packages/OsaurusCore/Networking/HTTPHandler.swift:16338— Packages/OsaurusCore/Networking/HTTPHandler.swift:16338-16348 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16420-16430 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16699-16709 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16746-16756 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16845-16855 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16881-16891 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 6) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:760— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:760-770 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:137-147 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:896-906 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:359-369 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1451-1461 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1849-1859 — there are 6 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:757` calls `lineLimit` and `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–11 lines × 2) Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:41— Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:41-51 | Packages/OsaurusCore/Services/Plugin/PluginResponsesCompatibility.swift:17-24 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/ResponsesEvaluationStep.swift:41` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–11 lines × 2) Packages/OsaurusCore/Services/Sandbox/SandboxPackageManifest.swift:134— Packages/OsaurusCore/Services/Sandbox/SandboxPackageManifest.swift:134-141 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:469-479 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–11 lines × 2) Packages/OsaurusCore/Views/Chat/ChatView.swift:12111— Packages/OsaurusCore/Views/Chat/ChatView.swift:12111-12118 | Packages/OsaurusCore/Views/Chat/ChatView.swift:12163-12173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatView.swift:12111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 3) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446-3455 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1841-1848 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:109-116 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–10 lines × 3) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1148— Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1148-1157 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1243-1250 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1277-1284 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1148` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8–10 lines × 3) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:556— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:556-565 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:686-695 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2756-2763 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:556` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:698` calls `install` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:568` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3190— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3190-3197 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3495-3502 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6962-6969 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6999-7006 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1386-1393 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:566-573 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1157-1164 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1192-1199 — there are 8 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3190` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:574` calls `help`, `L` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3198` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 8) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:20— Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:20-27 | Packages/OsaurusCore/Views/Settings/ServerView.swift:145-152 | Packages/OsaurusCore/Views/Settings/ServerView.swift:193-200 | Packages/OsaurusCore/Views/Settings/ServerView.swift:731-738 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1037-1044 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1334-1341 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1432-1439 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2451-2458 — there are 8 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:20` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `24` in one and `16` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ServerView.swift:203` calls `HStack` and `Packages/OsaurusCore/Views/Settings/ServerView.swift:2461` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 8) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:247— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:247-254 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:155-162 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:178-185 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:159-166 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:380-387 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:752-759 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:320-327 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalScoreboard.swift:46-53 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 8 call sites, so a change lands once.
Duplicated block (7–8 lines × 3) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/List.swift:22— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/List.swift:22-28 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:38-44 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Show.swift:115-122 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (7–8 lines × 3) Packages/OsaurusCore/Views/Agent/NextRunPanelView.swift:256— Packages/OsaurusCore/Views/Agent/NextRunPanelView.swift:256-262 | Packages/OsaurusCore/Views/Chat/ProjectNamePromptSheet.swift:127-134 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:469-475 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/NextRunPanelView.swift:256` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `2` in one and `1` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–8 lines × 3) Packages/OsaurusCore/Views/Chat/RedactionHoverController.swift:260— Packages/OsaurusCore/Views/Chat/RedactionHoverController.swift:260-266 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:181-188 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:102-108 — before extracting anything, compare `Packages/OsaurusCore/Views/Sandbox/SandboxView.swift` and `Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/RedactionHoverController.swift:260` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `alignment` to `.leading` in one and `.top` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7 lines × 8) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1639— Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1639-1645 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1817-1823 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2051-2057 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3101-3107 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3434-3440 | Packages/OsaurusCore/Tools/SandboxPluginRegisterTool.swift:27-33 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:23-29 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:95-101 — there are 8 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1639` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3108` calls `array` and `Packages/OsaurusCore/Tools/SandboxSecretTools.swift:102` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 8) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:610— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:610-616 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5682-5688 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6662-6668 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7087-7093 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7889-7895 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:99-105 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:130-136 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1600-1606 — there are 8 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:610` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 8) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:560— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:560-566 | Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:632-638 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:722-728 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:811-817 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:926-932 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:377-383 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:456-462 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:938-944 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:560` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 6) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1697— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1697-1703 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1741-1747 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1998-2004 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2193-2199 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2360-2366 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2445-2451 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1697` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 6) Packages/OsaurusCore/Views/Credits/CreditsView.swift:707— Packages/OsaurusCore/Views/Credits/CreditsView.swift:707-715 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:367-375 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:223-229 | Packages/OsaurusCore/Views/Settings/SearchView.swift:533-541 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:123-131 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:680-686 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:707` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:221` calls `VStack` and `Packages/OsaurusCore/Views/Credits/CreditsView.swift:705` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 6) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:550— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:550-556 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:652-658 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:772-778 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:747-753 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:471-478 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:754-761 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (6 lines × 16) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3394— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3394-3399 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3445-3452 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3459-3466 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3490-3495 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3536-3541 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3557-3562 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3570-3575 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3585-3590 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1650-1655 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1851-1858 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2062-2069 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2075-2082 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2109-2114 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2626-2631 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3111-3116 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:100-105 — there are 16 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 16 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3118` calls `number` and `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3401` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 16) Packages/OsaurusCore/Views/Common/SectionHeader.swift:61— Packages/OsaurusCore/Views/Common/SectionHeader.swift:61-66 | Packages/OsaurusCore/Views/Credits/CreditsRedeemCodeCard.swift:129-134 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:201-206 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:514-519 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:531-536 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:552-557 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1156-1161 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:201-206 | Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:417-422 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1402-1407 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1428-1433 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:194-199 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:724-729 | Packages/OsaurusCore/Views/Settings/ServerView.swift:255-260 | Packages/OsaurusCore/Views/Settings/ServerView.swift:329-334 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:274-279 — before extracting anything, compare `Packages/OsaurusCore/Views/Common/SectionHeader.swift` and `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 16) Packages/OsaurusCore/Views/Common/SectionHeader.swift:61— Packages/OsaurusCore/Views/Common/SectionHeader.swift:61-66 | Packages/OsaurusCore/Views/Credits/CreditsRedeemCodeCard.swift:129-134 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:201-206 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:514-519 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:531-536 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:552-557 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1156-1161 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:201-206 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1402-1407 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1428-1433 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:194-199 | Packages/OsaurusCore/Views/Settings/ExternalModelsSettingsView.swift:89-94 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:724-729 | Packages/OsaurusCore/Views/Settings/ServerView.swift:255-260 | Packages/OsaurusCore/Views/Settings/ServerView.swift:329-334 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:274-279 — before extracting anything, compare `Packages/OsaurusCore/Views/Common/SectionHeader.swift` and `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 12) Packages/OsaurusCore/Views/Agent/AgentsView.swift:4137— Packages/OsaurusCore/Views/Agent/AgentsView.swift:4137-4145 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5834-5839 | Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:532-540 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:371-376 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:182-187 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:220-225 | Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:414-422 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:519-527 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:558-566 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1055-1060 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2576-2581 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:415-421 — there are 12 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 12 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:4146` calls `fixedSize`, `Spacer` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5840` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 12) Packages/OsaurusCore/Views/Agent/AgentsView.swift:7231— Packages/OsaurusCore/Views/Agent/AgentsView.swift:7231-7236 | Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:164-169 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1347-1352 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:57-62 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:74-79 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:165-170 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:657-662 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:794-799 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1531-1536 | Packages/OsaurusCore/Views/Settings/ServerView.swift:447-452 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1451-1456 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:141-146 — there are 12 copies across 10 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 12 sites; resolving a subset leaves the remainder to drift apart. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `4` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6 lines × 12) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:117— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:117-122 | Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:107-112 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:148-156 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:765-770 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2429-2437 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:142-147 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:901-906 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:324-329 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:364-369 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1456-1461 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1854-1859 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:627-635 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (6 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019-1026 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:112-117 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceCard.swift:113-120 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:51-58 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1179-1186 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:506-513 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:331-338 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:689-696 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 8 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (6 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:9374— Packages/OsaurusCore/Views/Agent/AgentsView.swift:9374-9381 | Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:806-811 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:849-856 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:617-624 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1039-1046 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1575-1582 | Packages/OsaurusCore/Views/Settings/ServerView.swift:212-219 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:640-645 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 8 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:9374` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 8) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:765— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:765-770 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:142-147 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:901-906 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:364-369 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:349-355 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1838-1844 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1456-1461 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1854-1859 — there are 8 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (6 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:5606— Packages/OsaurusCore/Networking/HTTPHandler.swift:5606-5611 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6356-6361 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6649-6654 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6839-6844 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6980-6985 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7107-7112 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7286-7291 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5606` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 7) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1495— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1495-1500 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1526-1531 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1910-1915 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1941-1946 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2290-2295 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2386-2391 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2414-2419 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1495` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `limit` to `Int = MemoryConfiguration.fallbackSearchLimit` in one and `Int = 200` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Storage/MemoryDatabase.swift:2385` calls `sqlite3_bind_int`, `Int32` and `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1494` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 7) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:842— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:842-847 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:60-65 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:542-547 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:644-649 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:753-758 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228-236 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:222-230 — there are 7 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:842` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 10) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:123— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:123-127 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5681-5685 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6049-6053 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6661-6665 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7086-7090 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7888-7892 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:208-212 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:437-441 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:678-682 | Packages/OsaurusCore/Views/Settings/SearchView.swift:978-982 — there are 10 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `3` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:213` calls `Image`, `font`, `system` and `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:128` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 10) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8401— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8401-8407 | Packages/OsaurusCore/Views/Agent/ShareAgentSheet.swift:469-475 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:258-264 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1735-1739 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1751-1755 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1780-1784 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1844-1848 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1878-1882 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1958-1963 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1999-2003 — there are 10 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8401` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `6` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 10) Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:332— Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:332-336 | Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:194-201 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:103-107 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:198-202 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:105-109 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1109-1113 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1673-1677 | Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:653-657 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:133-140 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1114-1118 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:332` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 9) Packages/OsaurusCore/Networking/HTTPHandler.swift:5570— Packages/OsaurusCore/Networking/HTTPHandler.swift:5570-5574 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6072-6076 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6808-6812 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6945-6949 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7067-7071 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7256-7260 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7449-7453 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7513-7517 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7716-7720 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5570` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 9) Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:536— Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:536-540 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:218-222 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:781-785 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:591-595 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:727-731 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:847-851 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1030-1034 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2035-2039 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2112-2116 — there are 9 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:536` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 9) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:218— Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:218-222 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:781-785 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:591-595 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:727-731 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:847-851 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1030-1034 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2035-2039 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2112-2116 | Packages/OsaurusCore/Views/Settings/SearchView.swift:328-332 — there are 9 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:218` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/SearchView.swift:333` calls `textCase` and `Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:223` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 8) Packages/OsaurusCore/Networking/HTTPHandler.swift:5610— Packages/OsaurusCore/Networking/HTTPHandler.swift:5610-5614 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6360-6364 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6477-6481 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6653-6657 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6843-6847 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6984-6988 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7111-7115 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7290-7294 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5610` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 8) Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:121— Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:121-125 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:219-223 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:717-721 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1818-1823 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1982-1987 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2020-2025 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1011-1015 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:298-303 — there are 8 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:121` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `1` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018` calls `VStack` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1980` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 8) Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106— Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106-113 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:67-74 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:130-137 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:200-207 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:312-316 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:416-420 | Packages/OsaurusCore/Views/Settings/OsaurusConnectView.swift:209-213 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:228-232 — there are 8 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
FunctionTooLong: MarkdownBlockParsing.swift.parseBlocks Packages/OsaurusCore/Utils/MarkdownBlockParsing.swift:121— FunctionTooLong — parseBlocks runs 199 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 99 over it, 1.99× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pi-harness-runner.runCase scripts/evals/pi-harness-runner.mjs:171— FunctionTooLong — runCase runs 148 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 48 over it, 1.48× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Near-duplicate member pair (64 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:13148— Packages/OsaurusCore/Networking/HTTPHandler.swift:13148-13231 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13233-13333 — These two members are variants of one another: 64 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (64 shared lines) Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:100— Packages/OsaurusCore/Services/IMessage/IMessageWatchTransportRuntime.swift:100-208 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppWatchTransportRuntime.swift:85-187 — These two members are variants of one another: 64 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (40 shared lines) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3683— Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3683-3762 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3766-3857 — These two members are variants of one another: 40 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (40 shared lines) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:167— Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:167-213 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:381-427 — These two members are variants of one another: 40 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (34 shared lines) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4381— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4381-4447 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4595-4685 — These two members are variants of one another: 34 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (34 shared lines) Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:210— Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:210-291 | Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:537-590 — These two members are variants of one another: 34 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (26 corresponding lines) · ×2
Edited copy of a member (26 corresponding lines) Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:588— Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:588-620 | Packages/OsaurusCore/Services/Documents/XLSXEmitter.swift:325-354 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (26 corresponding lines) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1546— Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1546-1775 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:336-399 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (53 lines × 2) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1880— Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1880-1932 | Packages/OsaurusCore/Services/Chat/ChatEngine.swift:2030-2082 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (53 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:4543— Packages/OsaurusCore/Services/ModelRuntime.swift:4543-4595 | Packages/OsaurusCore/Services/ModelRuntime.swift:4645-4697 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:4543` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:129— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:129-173 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:128-172 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 354 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:129` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:554— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:554-598 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:789-833 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (40 lines × 2) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:702— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:702-741 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:769-808 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (40 lines × 2) Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:80— Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:80-119 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:141-180 — before extracting anything, compare `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift` and `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 126 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:80` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:138` calls `offset` and `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:78` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (39 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:708— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:708-746 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:924-962 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (39 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1186— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1186-1224 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1314-1352 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1186` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (37 lines × 2) Packages/OsaurusCore/Models/Agent/Skill.swift:171— Packages/OsaurusCore/Models/Agent/Skill.swift:171-207 | Packages/OsaurusCore/Models/Agent/Skill.swift:336-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Skill.swift:171` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (37 lines × 2) Packages/OsaurusCore/Subagent/SubagentSession.swift:777— Packages/OsaurusCore/Subagent/SubagentSession.swift:777-813 | Packages/OsaurusCore/Subagent/SubagentSession.swift:843-879 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/SubagentSession.swift:777` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29–31 lines × 2) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:335— Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:335-365 | Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:491-519 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:335` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:490` calls `LanguageModelSession`, `makeStream` and `Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:335` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (29–31 lines × 2) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:142— Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:142-172 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:496-524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (30 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:15236— Packages/OsaurusCore/Networking/HTTPHandler.swift:15236-15265 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15518-15547 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:15236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8056— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8056-8085 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1214-1243 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (27 lines × 2) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:36— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:36-62 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:37-63 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:36` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (27 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:339— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:339-365 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1828-1854 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:339` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–26 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:17361— Packages/OsaurusCore/Networking/HTTPHandler.swift:17361-17386 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17392-17415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17361` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24–26 lines × 2) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:346— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:346-369 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:306-331 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 354 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:346` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–25 lines × 2) Packages/OsaurusCore/Storage/MemoryDatabase.swift:2378— Packages/OsaurusCore/Storage/MemoryDatabase.swift:2378-2398 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2402-2426 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21–25 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:201— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:201-221 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:244-268 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:201` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–23 lines × 2) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1936— Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1936-1957 | Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1961-1983 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1936` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (22–23 lines × 2) Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:303— Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:303-325 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:82-103 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/ImageGeneration/ImageGenerationView.swift:303` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:782— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:782-803 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:686-707 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:998-1019 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 306 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:782` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:708` calls `HStack` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:804` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (22 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1111— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1111-1132 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:799-820 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1231-1252 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 306 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (21–22 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:310— Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:310-331 | Packages/OsaurusCore/ComputerUse/Driver/Mac/InputController.swift:66-86 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–22 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptTemplates.swift:1751— Packages/OsaurusCore/Services/Chat/SystemPromptTemplates.swift:1751-1771 | Packages/OsaurusCore/Services/Chat/SystemPromptTemplates.swift:1888-1909 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptTemplates.swift:1888` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–22 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:735— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:735-756 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2932-2949 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:735` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `20` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (18–22 lines × 2) Packages/OsaurusCore/Views/Theme/ThemesView.swift:1523— Packages/OsaurusCore/Views/Theme/ThemesView.swift:1523-1544 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:2079-2096 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Theme/ThemesView.swift:1523` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Theme/ThemesView.swift:1545` calls `task`, `image` and `Packages/OsaurusCore/Views/Theme/ThemesView.swift:2097` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17–20 lines × 2) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:971— Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:971-990 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:1005-1021 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:971` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–20 lines × 2) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:545— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:545-561 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:261-280 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (14–20 lines × 2) REDACTED:784— REDACTED:784-797 | REDACTED:850-869 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–20 lines × 2) Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:424— Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:424-443 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1799-1812 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (19 lines × 3) Packages/OsaurusCore/Services/Chat/GroundedConfigClaimCheck.swift:270— Packages/OsaurusCore/Services/Chat/GroundedConfigClaimCheck.swift:270-288 | Packages/OsaurusCore/Services/Chat/GroundedFileSideEffectCheck.swift:145-163 | Packages/OsaurusCore/Services/Chat/GroundedKnowledgeClaimCheck.swift:196-214 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (19 lines × 3) Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:208— Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:208-226 | Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:118-136 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1082-1100 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:207` calls `contentShape`, `RoundedRectangle` and `Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:117` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15–19 lines × 2) Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:120— Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:120-138 | Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:344-358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/RedactionReviewSheet.swift:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–19 lines × 2) Packages/OsaurusCore/Services/MCP/MCPElicitationPromptService.swift:194— Packages/OsaurusCore/Services/MCP/MCPElicitationPromptService.swift:194-208 | Packages/OsaurusCore/Services/ToolPermissionPromptService.swift:592-610 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPElicitationPromptService.swift:194` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–18 lines × 2) Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:474— Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:474-491 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1837-1845 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:474` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–18 lines × 2) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:470— Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:470-478 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:208-225 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:470` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:467` calls `fixedSize` and `Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:205` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–17 lines × 2) Packages/OsaurusCore/Views/Chat/EditableTextView.swift:101— Packages/OsaurusCore/Views/Chat/EditableTextView.swift:101-117 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1310-1322 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (13–17 lines × 2) Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:138— Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:138-154 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:259-271 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `14` in one and `8` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (16 lines × 5) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:759— Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:759-774 | Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:537-552 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1117-1132 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:847-862 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:636-651 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:759` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:125— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:125-140 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:138-153 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:129-144 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:124-139 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:150-165 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–16 lines × 4) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1485— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1485-1500 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1519-1531 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1903-1915 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1934-1946 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1485` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–16 lines × 4) Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:131— Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:131-143 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:887-902 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2065-2078 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1843-1855 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift` and `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 129 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:145` calls `frame`, `background`, `Circle` and `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2080` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15–16 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:681— Packages/OsaurusCore/Networking/HTTPHandler.swift:681-696 | Packages/OsaurusCore/Networking/HTTPHandler.swift:737-752 | Packages/OsaurusCore/Networking/HTTPHandler.swift:860-874 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:681` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:9862— Packages/OsaurusCore/Networking/HTTPHandler.swift:9862-9876 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16087-16102 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16195-16210 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9862` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–15 lines × 3) Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:455— Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:455-469 | Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:503-517 | Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:546-557 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:455` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:470` calls `sqlite3_bind_int`, `Int32` and `Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:558` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–15 lines × 3) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:275— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:275-289 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:980-991 | Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:115-128 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:275` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:271` calls `fetchSkills` and `Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:111` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–15 lines × 2) Packages/OsaurusCore/Models/Chat/ChatSessionStore.swift:48— Packages/OsaurusCore/Models/Chat/ChatSessionStore.swift:48-62 | Packages/OsaurusCore/Models/Chat/ChatSessionStore.swift:92-102 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ChatSessionStore.swift:48` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–15 lines × 2) Packages/OsaurusCore/Views/Chat/ToolDisplayName.swift:149— Packages/OsaurusCore/Views/Chat/ToolDisplayName.swift:149-163 | Packages/OsaurusCore/Views/Chat/ToolDisplayName.swift:167-177 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9–15 lines × 2) Packages/OsaurusCore/Services/GitHubSkillService.swift:1867— Packages/OsaurusCore/Services/GitHubSkillService.swift:1867-1875 | Packages/OsaurusCore/Services/GitHubSkillService.swift:1959-1973 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–15 lines × 2) Packages/OsaurusCore/Tools/OsaurusTool.swift:218— Packages/OsaurusCore/Tools/OsaurusTool.swift:218-226 | Packages/OsaurusCore/Tools/OsaurusTool.swift:261-275 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/OsaurusTool.swift:218` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 6) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66-79 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:91-105 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2387-2400 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1403-1416 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1827 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:577-590 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `20` in one and `24` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2382` calls `endObserving` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:86` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 6) Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:59— Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:59-72 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3256-3269 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:3309-3322 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:195-208 | Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:433-446 | Packages/OsaurusCore/Views/Skill/SkillEditorSheet.swift:595-608 — before extracting anything, compare `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift` and `Packages/OsaurusCore/Views/Settings/ProvidersView.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:59` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Provider/ProviderInputFields.swift:58` calls `padding` and `Packages/OsaurusCore/Views/Settings/Shared/SettingsPrimitives.swift:432` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:1494— Packages/OsaurusCore/Networking/HTTPHandler.swift:1494-1507 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1788-1801 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1861-1874 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1935-1948 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15857-15870 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1494` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:553— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:553-566 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:715-728 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:804-817 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:370-383 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:931-944 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:553` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–14 lines × 2) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:112— Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:112-125 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:457-465 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:112` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–14 lines × 2) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3257— Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3257-3265 | Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3301-3314 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 5) Packages/OsaurusCore/Identity/IdentityModels.swift:188— Packages/OsaurusCore/Identity/IdentityModels.swift:188-200 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:807-819 | Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationTypes.swift:171-183 | Packages/OsaurusCore/Services/ModelRuntime.swift:436-448 | Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:68-80 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Identity/IdentityModels.swift:188` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (13 lines × 5) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:105— Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:105-117 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:136-148 | Packages/OsaurusCore/Services/Search/SearchTypes.swift:82-94 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:101-113 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:197-209 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:105` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–13 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:9865— Packages/OsaurusCore/Networking/HTTPHandler.swift:9865-9875 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13378-13389 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16089-16101 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16197-16209 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13378` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–13 lines × 4) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1577— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1577-1589 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1984-1996 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2852-2862 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2873-2883 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1577` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:12462— Packages/OsaurusCore/Networking/HTTPHandler.swift:12462-12474 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16338-16350 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16420-16432 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16746-16758 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12462` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:16340— Packages/OsaurusCore/Networking/HTTPHandler.swift:16340-16352 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16422-16434 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16748-16760 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17472-17485 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16340` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10–13 lines × 3) Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:335— Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:335-347 | Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:382-391 | Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:449-458 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:335` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–13 lines × 3) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:264— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:264-273 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:259-268 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:523-535 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:264` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/Configuration.swift:29— Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/Configuration.swift:29-41 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/Configuration.swift:61-70 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/Configuration.swift:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 2) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1041— Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1041-1050 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1079-1091 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1041` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–13 lines × 2) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:106— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:106-113 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:818-830 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–13 lines × 2) Packages/OsaurusCore/Views/Common/SectionHeader.swift:65— Packages/OsaurusCore/Views/Common/SectionHeader.swift:65-77 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1883-1890 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SectionHeader.swift:65` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 17) Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66— Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66-77 | Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:69-80 | Packages/OsaurusCore/Models/Agent/Agent.swift:885-896 | Packages/OsaurusCore/Models/Agent/Agent.swift:1303-1314 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:133-144 | Packages/OsaurusCore/Models/Template/Template.swift:119-130 | Packages/OsaurusCore/Services/Chat/AgentConfigSnapshot.swift:239-250 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:56-67 | Packages/OsaurusCore/Services/FileHistory/FileChangeModels.swift:230-241 | Packages/OsaurusCore/Services/GitHubSkillService.swift:466-477 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:193-204 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:254-265 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofMatrixReporter.swift:83-94 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:206-217 | Packages/OsaurusCore/Services/Plugin/InstalledClaudePluginsAggregator.swift:264-275 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:77-88 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:93-104 — there are 17 copies across 15 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 17 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/FileHistory/FileChangeModels.swift:228` calls `Date` and `Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:64` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 17) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:147— Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:147-158 | Packages/OsaurusCore/Models/Agent/DefaultAgentConfiguration.swift:105-116 | Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:74-85 | Packages/OsaurusCore/Models/Agent/Skill.swift:73-84 | Packages/OsaurusCore/Models/Configuration/MLXModel.swift:80-91 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:213-224 | Packages/OsaurusCore/Models/Plugin/ProvisioningJourney.swift:104-115 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:59-70 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:195-206 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:104-115 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:193-204 | Packages/OsaurusCore/Services/Context/ContextAttribution.swift:110-121 | Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:149-160 | Packages/OsaurusCore/Services/GitHubSkillService.swift:228-239 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:156-167 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:876-887 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2941-2952 — there are 17 copies across 14 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 17 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:147` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 6) Packages/OsaurusCore/Models/Knowledge/KnowledgeCollection.swift:60— Packages/OsaurusCore/Models/Knowledge/KnowledgeCollection.swift:60-71 | Packages/OsaurusCore/Models/Method/Method.swift:42-53 | Packages/OsaurusCore/Models/Project/Project.swift:47-58 | Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift:113-124 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:380-391 | Packages/OsaurusCore/Storage/ToolDatabase.swift:57-68 — before extracting anything, compare `Packages/OsaurusCore/Models/Method/Method.swift` and `Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Knowledge/KnowledgeCollection.swift:60` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 6) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:758— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:758-769 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2295-2306 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:148-159 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:185-196 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:126-137 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:404-415 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:758` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:125` calls `fixedSize` and `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:757` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 5) Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72— Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72-83 | Packages/OsaurusCore/Models/Configuration/SettingsSearchIndex.swift:47-58 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:57-68 | Packages/OsaurusCore/Services/Search/SearchTypes.swift:33-44 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2939-2950 — before extracting anything, compare `Packages/OsaurusCore/Models/Agent/RemoteAgent.swift` and `Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 5) Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:104— Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:104-116 | Packages/OsaurusCore/Models/SlashCommand/SlashCommand.swift:49-61 | Packages/OsaurusCore/Models/Template/MCPServerHint.swift:39-50 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:59-71 | Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:149-161 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Evidence/EvidenceReportRegistry.swift:104` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:6812— Packages/OsaurusCore/Networking/HTTPHandler.swift:6812-6824 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7260-7271 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7453-7464 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7720-7731 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6812` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055-6066 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6121-6132 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6473-6484 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:195-206 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6055` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:208` calls `accessibilityIdentifier` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–12 lines × 2) Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1667— Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1667-1678 | Packages/OsaurusCore/Tools/SchemaValidator.swift:845-851 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1667` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–12 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:2243— Packages/OsaurusCore/Networking/HTTPHandler.swift:2243-2254 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2574-2580 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:2243` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–12 lines × 2) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:85— Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:85-96 | Packages/OsaurusCore/Models/Plugin/PluginHTTP.swift:127-134 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:85` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8–12 lines × 2) Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:193— Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:193-204 | Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:208-215 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:193` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 6) Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72— Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72-82 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:139-149 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:57-67 | Packages/OsaurusCore/Services/Search/SearchTypes.swift:33-43 | Packages/OsaurusCore/Subagent/SubagentCapabilityRegistry.swift:161-170 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2939-2949 — before extracting anything, compare `Packages/OsaurusCore/Models/Agent/RemoteAgent.swift` and `Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:72` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10–11 lines × 6) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:34— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:34-44 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1202-1212 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:1330-1339 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:35-45 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:115-124 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:36-46 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:34` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (6–11 lines × 2) Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:584— Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:584-589 | Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:608-618 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Slack/SlackAPIClient.swift:584` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–11 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:263— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:263-273 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1740-1745 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:263` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10 lines × 7) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54-63 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1824-1833 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1988-1997 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:130-139 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2064-2074 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:54-63 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1842-1851 — there are 7 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:8640— Packages/OsaurusCore/Views/Agent/AgentsView.swift:8640-8649 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:49-58 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:72-81 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2362-2371 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:251-260 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1759-1768 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:552-561 — there are 7 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:8640` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:9605— Packages/OsaurusCore/Networking/HTTPHandler.swift:9605-9614 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9731-9740 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12039-12048 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12117-12126 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12195-12204 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9605` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 5) Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:109— Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:109-118 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:325-334 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1813-1822 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1418-1427 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1829-1838 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:109` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–10 lines × 2) Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:200— Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:200-206 | Packages/OsaurusCore/Views/Agent/Database/DatabaseTablesView.swift:320-329 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `5` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–10 lines × 2) Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:81— Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:81-87 | Packages/OsaurusCore/Views/Chat/ImportGuideSheet.swift:93-102 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ExportChooserSheet.swift:81` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `0` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6–9 lines × 9) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyCustomRuleEditor.swift:215— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyCustomRuleEditor.swift:215-223 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6034-6042 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:600-606 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:1049-1057 | Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:188-196 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:469-474 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1239-1244 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2351-2356 | Packages/OsaurusCore/Views/Voice/VoiceComponents.swift:636-641 — there are 9 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyCustomRuleEditor.swift:215` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:198` calls `fixedSize` and `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyCustomRuleEditor.swift:225` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–9 lines × 9) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6053— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6053-6060 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6118-6126 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:798-805 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2158-2163 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2645-2652 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:193-200 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:710-717 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:728-735 | Packages/OsaurusCore/Views/Tool/ToolPermissionBanner.swift:79-86 — there are 9 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6053` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 6) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:144— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:144-152 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:765-773 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:60-68 | Packages/OsaurusCore/Views/Identity/MasterMnemonicCard.swift:77-85 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:168-176 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1534-1542 — there are 6 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:144` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 6) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:563— Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:563-571 | Packages/OsaurusCore/Storage/AgentDatabase.swift:492-500 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:291-299 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:165-173 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:256-264 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:272-280 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 6 call sites, so a change lands once.
Duplicated block (8–9 lines × 4) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66-74 | Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift:683-690 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1280-1288 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:67-75 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:66` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:297— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:297-304 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:173-181 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1921-1929 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2058-2065 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:297` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–9 lines × 2) Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:56— Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:56-62 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1116-1124 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:56` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `14` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–9 lines × 2) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2343— Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2343-2351 | Packages/OsaurusCore/Views/Template/TemplateImportSheet.swift:230-236 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2343` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 6) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:35— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:35-42 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:334-341 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:1000-1007 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:1060-1067 | Packages/OsaurusCore/PrivacyFilter/Views/PrivacyView.swift:1198-1205 | Packages/OsaurusCore/Views/Settings/SearchView.swift:725-732 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:35` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 6) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:97— Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:97-107 | Packages/OsaurusCore/AppleApps/Contacts/ContactsTools.swift:168-177 | Packages/OsaurusCore/AppleApps/Mail/MailTools.swift:38-45 | Packages/OsaurusCore/AppleApps/Music/MusicTools.swift:25-32 | Packages/OsaurusCore/AppleApps/Notes/NotesTools.swift:44-51 | Packages/OsaurusCore/AppleApps/Reminders/RemindersTools.swift:47-57 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `service` to `CalendarServicing` in one and `ContactsServicing` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6–8 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6471— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6471-6478 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1027-1034 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1785-1790 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:380-387 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6471` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–8 lines × 4) Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:49— Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:49-55 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:126-131 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:332-339 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1836-1843 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:49` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–8 lines × 2) Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:271— Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:271-278 | Packages/OsaurusCore/Services/Router/WorkspaceAgentAccessHost.swift:259-264 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:271` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–8 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5568— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5568-5575 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1749-1754 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5568` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 12) Packages/OsaurusCore/Networking/HTTPHandler.swift:3993— Packages/OsaurusCore/Networking/HTTPHandler.swift:3993-3998 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4717-4721 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4814-4818 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4881-4885 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14337-14341 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14859-14864 | Packages/OsaurusCore/Networking/HTTPHandler.swift:14924-14929 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17255-17259 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17304-17308 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18007-18011 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18056-18060 | Packages/OsaurusCore/Networking/HTTPLoopHelpers.swift:181-185 — there are 12 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 12 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:3993` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 12) Packages/OsaurusCore/Storage/ActivityLogStore.swift:38— Packages/OsaurusCore/Storage/ActivityLogStore.swift:38-42 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:19-26 | Packages/OsaurusCore/Storage/AgentDatabase.swift:48-52 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:29-33 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:29-33 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:37-41 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:35-39 | Packages/OsaurusCore/Storage/MethodDatabase.swift:21-25 | Packages/OsaurusCore/Storage/PluginDatabase.swift:18-22 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:27-31 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:30-34 | Packages/OsaurusCore/Storage/ToolDatabase.swift:21-25 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 12 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/ActivityLogStore.swift:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:16` calls `invalidReceiveEvent` and `Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:26` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Swallowed exception (empty catch) scripts/evals/pi-harness-runner.mjs:235— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) scripts/evals/pi-harness-runner.mjs:241— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
HTTPHandler.channelRead (cyclomatic 249) Packages/OsaurusCore/Networking/HTTPHandler.swift:489— HTTPHandler.channelRead has cyclomatic complexity 249 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.validate (cyclomatic 184) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:400— ConfigPlanner.validate has cyclomatic complexity 184 (threshold 15). Of this number, 182 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AppleScriptLoop.run (cyclomatic 172) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:310— AppleScriptLoop.run has cyclomatic complexity 172 (threshold 15). Of this number, 170 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleAgentRunEndpoint (cyclomatic 161) Packages/OsaurusCore/Networking/HTTPHandler.swift:9936— HTTPHandler.handleAgentRunEndpoint has cyclomatic complexity 161 (threshold 15). Of this number, 156 points are the body's own statements and 5 belong to 3 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentToolLoop.run (cyclomatic 155) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2334— AgentToolLoop.run has cyclomatic complexity 155 (threshold 15). Of this number, 149 points are the body's own statements and 6 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SubagentSession.runPrepared (cyclomatic 124) Packages/OsaurusCore/Subagent/SubagentSession.swift:519— SubagentSession.runPrepared has cyclomatic complexity 124 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TokenizerBridge.applyChatTemplate (cyclomatic 114) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:211— TokenizerBridge.applyChatTemplate has cyclomatic complexity 114 (threshold 15). Of this number, 112 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
XLSXEditor.shiftRows (cyclomatic 112) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:328— XLSXEditor.shiftRows has cyclomatic complexity 112 (threshold 15). Of this number, 109 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ContentBlock.generateBlocks (cyclomatic 111) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:591— ContentBlock.generateBlocks has cyclomatic complexity 111 (threshold 15). Of this number, 110 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runAgentLoopCaseWithSettings (cyclomatic 109) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:33— EvalRunner.runAgentLoopCaseWithSettings has cyclomatic complexity 109 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SystemPromptComposer.resolveTools (cyclomatic 102) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:2713— SystemPromptComposer.resolveTools has cyclomatic complexity 102 (threshold 15). Of this number, 99 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusBundle.load (cyclomatic 93) Packages/OsaurusRepository/OsaurusBundle.swift:356— OsaurusBundle.load has cyclomatic complexity 93 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Functions.call (cyclomatic 87) Packages/OsaurusCore/Utils/CalculatorEngine.swift:700— Functions.call has cyclomatic complexity 87 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SystemPromptComposer.appendGatedSections (cyclomatic 86) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:968— SystemPromptComposer.appendGatedSections has cyclomatic complexity 86 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentLoopEvaluator.runConversation (cyclomatic 86) Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:702— AgentLoopEvaluator.runConversation has cyclomatic complexity 86 (threshold 15). Of this number, 58 points are the body's own statements and 28 belong to 7 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.runCacheProofCase (cyclomatic 84) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerCacheProof.swift:158— EvalRunner.runCacheProofCase has cyclomatic complexity 84 (threshold 15). Of this number, 80 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSession.processStreamDeltas (cyclomatic 81) Packages/OsaurusCore/Views/Chat/ChatView.swift:5189— ChatSession.processStreamDeltas has cyclomatic complexity 81 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ComputerUseLoop.run (cyclomatic 76) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:209— ComputerUseLoop.run has cyclomatic complexity 76 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatView.chatModeContent (cyclomatic 76) Packages/OsaurusCore/Views/Chat/ChatView.swift:10106— ChatView.chatModeContent has cyclomatic complexity 76 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentTaskState.record (cyclomatic 74) Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:662— AgentTaskState.record has cyclomatic complexity 74 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileReadTool.readResolved (cyclomatic 69) Packages/OsaurusCore/Folder/FolderTools.swift:1175— FileReadTool.readResolved has cyclomatic complexity 69 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService._streamRemote (cyclomatic 69) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2851— RemoteProviderService._streamRemote has cyclomatic complexity 69 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyMCPServers (cyclomatic 67) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1352— ConfigApplier.applyMCPServers has cyclomatic complexity 67 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelDownloadService.runOrchestration (cyclomatic 66) Packages/OsaurusCore/Services/ModelDownloadService.swift:376— ModelDownloadService.runOrchestration has cyclomatic complexity 66 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteChatRequest.toOpenResponsesRequest (cyclomatic 62) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5754— RemoteChatRequest.toOpenResponsesRequest has cyclomatic complexity 62 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRowCellView.configure (cyclomatic 62) Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:510— ModelRowCellView.configure has cyclomatic complexity 62 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ClaudePluginInstaller.install (cyclomatic 60) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:221— ClaudePluginInstaller.install has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pi-harness-runner.runCase (cyclomatic 59) scripts/evals/pi-harness-runner.mjs:171— pi-harness-runner.runCase has cyclomatic complexity 59 (threshold 15). Of this number, 58 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.loadContainer (cyclomatic 58) Packages/OsaurusCore/Services/ModelRuntime.swift:4520— ModelRuntime.loadContainer has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CalculatorNode.exactInteger (cyclomatic 58) Packages/OsaurusCore/Utils/CalculatorEngine.swift:360— CalculatorNode.exactInteger has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LocalVisionEvidence.read (cyclomatic 58) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:118— LocalVisionEvidence.read has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusInspectTool.describeItem (cyclomatic 56) Packages/OsaurusCore/Tools/ConfigurationTools.swift:1301— OsaurusInspectTool.describeItem has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CapabilityClaimsEvaluator.runConversation (cyclomatic 56) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:209— CapabilityClaimsEvaluator.runConversation has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalMatrixBuilder.build (cyclomatic 55) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:811— EvalMatrixBuilder.build has cyclomatic complexity 55 (threshold 15). Of this number, 54 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleChatCompletions (cyclomatic 55) Packages/OsaurusCore/Networking/HTTPHandler.swift:14446— HTTPHandler.handleChatCompletions has cyclomatic complexity 55 (threshold 15). Of this number, 52 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PendingImportProcessor.install (cyclomatic 55) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:515— PendingImportProcessor.install has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImageGenerationService.drive (cyclomatic 55) Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationService.swift:690— ImageGenerationService.drive has cyclomatic complexity 55 (threshold 15). Of this number, 51 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MLXBatchAdapter.additionalContext (cyclomatic 55) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:1259— MLXBatchAdapter.additionalContext has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleOpenResponsesStreaming (cyclomatic 54) Packages/OsaurusCore/Networking/HTTPHandler.swift:17694— HTTPHandler.handleOpenResponsesStreaming has cyclomatic complexity 54 (threshold 15). Of this number, 51 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RenderChartTool.execute (cyclomatic 54) Packages/OsaurusCore/Tools/RenderChartTool.swift:141— RenderChartTool.execute has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AppDelegate.applicationDidFinishLaunching (cyclomatic 53) Packages/OsaurusCore/AppDelegate.swift:172— AppDelegate.applicationDidFinishLaunching has cyclomatic complexity 53 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BoundedArchiveExtractor.inspect (cyclomatic 53) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:139— BoundedArchiveExtractor.inspect has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolRegistry.execute (cyclomatic 53) Packages/OsaurusCore/Tools/ToolRegistry.swift:1117— ToolRegistry.execute has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeMessageCellView.configureAsUserMessage (cyclomatic 53) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2602— NativeMessageCellView.configureAsUserMessage has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeCellHeightEstimator.estimatedHeight (cyclomatic 52) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3702— NativeCellHeightEstimator.estimatedHeight has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteAnthropicNativeStream.consume (cyclomatic 51) Packages/OsaurusCore/Services/Provider/RemoteAnthropicNativeStream.swift:38— RemoteAnthropicNativeStream.consume has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteChatRequest.toGeminiRequest (cyclomatic 51) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5352— RemoteChatRequest.toGeminiRequest has cyclomatic complexity 51 (threshold 15). Of this number, 50 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteResponsesNativeStream.consume (cyclomatic 51) Packages/OsaurusCore/Services/Provider/RemoteResponsesNativeStream.swift:26— RemoteResponsesNativeStream.consume has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusTool.agentChannelFailure (cyclomatic 50) Packages/OsaurusCore/Tools/AgentChannelTools.swift:21— OsaurusTool.agentChannelFailure has cyclomatic complexity 50 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
RemoteProviderService.buildChatRequest (cyclomatic 50) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3371— RemoteProviderService.buildChatRequest has cyclomatic complexity 50 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handlePluginRoute (cyclomatic 49) Packages/OsaurusCore/Networking/HTTPHandler.swift:2873— HTTPHandler.handlePluginRoute has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RequestLog.title (cyclomatic 49) Packages/OsaurusCore/Models/Chat/RequestLog.swift:761— RequestLog.title has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatEngine.wrapStreamWithLogging (cyclomatic 49) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1312— ChatEngine.wrapStreamWithLogging has cyclomatic complexity 49 (threshold 15). Of this number, 47 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.handleOpenResponsesEvent (cyclomatic 49) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2332— RemoteProviderService.handleOpenResponsesEvent has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ComputerUseLoop.act (cyclomatic 47) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1334— ComputerUseLoop.act has cyclomatic complexity 47 (threshold 15). Of this number, 46 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MarkdownBlockParsing.swift.parseBlocks (cyclomatic 47) Packages/OsaurusCore/Utils/MarkdownBlockParsing.swift:121— MarkdownBlockParsing.swift.parseBlocks has cyclomatic complexity 47 (threshold 15). Of this number, 40 points are the body's own statements and 7 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.unloadClaimed (cyclomatic 46) Packages/OsaurusCore/Services/ModelRuntime.swift:2303— ModelRuntime.unloadClaimed has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ContentBlockKind.== (cyclomatic 46) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:147— ContentBlockKind.== has cyclomatic complexity 46 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ChatEngine.completeChat (cyclomatic 46) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1743— ChatEngine.completeChat has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runToolResultGroundingCase (cyclomatic 45) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerToolResultGrounding.swift:14— EvalRunner.runToolResultGroundingCase has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileSearchTool.execute (cyclomatic 45) Packages/OsaurusCore/Folder/FolderTools.swift:4468— FileSearchTool.execute has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleConfigAdminEndpoint (cyclomatic 45) Packages/OsaurusCore/Networking/HTTPHandler.swift:2221— HTTPHandler.handleConfigAdminEndpoint has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SafeDiskCachePurge.clear (cyclomatic 45) Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:13— SafeDiskCachePurge.clear has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CacheProofEvaluator.runConversation (cyclomatic 45) Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:281— CacheProofEvaluator.runConversation has cyclomatic complexity 45 (threshold 15). Of this number, 41 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSession.init (cyclomatic 45) Packages/OsaurusCore/Views/Chat/ChatView.swift:964— ChatSession.init has cyclomatic complexity 45 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ToolRegistry.runPermissionGate (cyclomatic 44) Packages/OsaurusCore/Tools/ToolRegistry.swift:877— ToolRegistry.runPermissionGate has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.score (cyclomatic 43) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:858— EvalRunner.score has cyclomatic complexity 43 (threshold 15). Of this number, 41 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RedactFileTool.execute (cyclomatic 43) Packages/OsaurusCore/Folder/RedactionTools.swift:272— RedactFileTool.execute has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Solver.polynomial (cyclomatic 43) Packages/OsaurusCore/Utils/CalculatorEngine.swift:892— Solver.polynomial has cyclomatic complexity 43 (threshold 15). Of this number, 39 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.planMCPServers (cyclomatic 43) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1994— ConfigPlanner.planMCPServers has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentDelegationDispatcher.run (cyclomatic 43) Packages/OsaurusCore/Services/AgentDelegation/AgentDelegationDispatcher.swift:506— AgentDelegationDispatcher.run has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.decodeWAVAudioSamples (cyclomatic 42) Packages/OsaurusCore/Services/ModelRuntime.swift:7385— ModelRuntime.decodeWAVAudioSamples has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Tokenizer.tokenize (cyclomatic 42) Packages/OsaurusCore/Utils/CalculatorEngine.swift:201— Tokenizer.tokenize has cyclomatic complexity 42 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
PrivacyFilterPipeline.applyOutbound (cyclomatic 42) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:333— PrivacyFilterPipeline.applyOutbound has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatEngine.prepareDispatch (cyclomatic 42) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:187— ChatEngine.prepareDispatch has cyclomatic complexity 42 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PluginHostContext.completeStream (cyclomatic 42) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1807— PluginHostContext.completeStream has cyclomatic complexity 42 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SchemaValidator.validateValue (cyclomatic 41) Packages/OsaurusCore/Tools/SchemaValidator.swift:178— SchemaValidator.validateValue has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MLXModel.localBundleWeightSizeBytes (cyclomatic 41) Packages/OsaurusCore/Models/Configuration/MLXModel.swift:158— MLXModel.localBundleWeightSizeBytes has cyclomatic complexity 41 (threshold 15). Of this number, 29 points are the body's own statements and 12 belong to 3 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelCustomJSONRunner.execute (cyclomatic 41) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:533— AgentChannelCustomJSONRunner.execute has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AccessibilityManager.traverseElement (cyclomatic 41) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:769— AccessibilityManager.traverseElement has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.scoreSpawnWave (cyclomatic 40) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1609— EvalRunner.scoreSpawnWave has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusBundle.select (cyclomatic 40) Packages/OsaurusRepository/OsaurusBundle.swift:897— OsaurusBundle.select has cyclomatic complexity 40 (threshold 15). Of this number, 37 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusConfigTool.handleApply (cyclomatic 40) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:396— OsaurusConfigTool.handleApply has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PDFEditor.fillForm (cyclomatic 40) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:346— PDFEditor.fillForm has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GenerationEventMapper.map (cyclomatic 40) Packages/OsaurusCore/Services/ModelRuntime/GenerationEventMapper.swift:41— GenerationEventMapper.map has cyclomatic complexity 40 (threshold 15). Of this number, 34 points are the body's own statements and 6 belong to 3 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.body (cyclomatic 40) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:908— FloatingInputCard.body has cyclomatic complexity 40 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.runAppleScriptCase (cyclomatic 39) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAppleScript.swift:36— EvalRunner.runAppleScriptCase has cyclomatic complexity 39 (threshold 15). Of this number, 37 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusInspectTool.resolvedListEnvelope (cyclomatic 39) Packages/OsaurusCore/Tools/ConfigurationTools.swift:732— OsaurusInspectTool.resolvedListEnvelope has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Tokenizer.number (cyclomatic 39) Packages/OsaurusCore/Utils/CalculatorEngine.swift:277— Tokenizer.number has cyclomatic complexity 39 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PendingImportProcessor.prepare (cyclomatic 39) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:251— PendingImportProcessor.prepare has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.buildURLRequest (cyclomatic 39) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3892— RemoteProviderService.buildURLRequest has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelPublishService.publish (cyclomatic 38) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:186— AgentChannelPublishService.publish has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolCategory.from (cyclomatic 38) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:141— ToolCategory.from has cyclomatic complexity 38 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
NativeToolCallRowView.configure (cyclomatic 38) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:1044— NativeToolCallRowView.configure has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImportCommand.parse (cyclomatic 37) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:179— ImportCommand.parse has cyclomatic complexity 37 (threshold 15). Of this number, 35 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BlockMemoizer.blocks (cyclomatic 37) Packages/OsaurusCore/Managers/BlockMemoizer.swift:119— BlockMemoizer.blocks has cyclomatic complexity 37 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
RemoteProviderManager.testConnection (cyclomatic 37) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1546— RemoteProviderManager.testConnection has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigScheduleFrequency.parse (cyclomatic 37) Packages/OsaurusCore/Configuration/Declarative/ConfigScheduleFrequency.swift:21— ConfigScheduleFrequency.parse has cyclomatic complexity 37 (threshold 15). Of this number, 31 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
CompatibilityReport.formatMarkdown (cyclomatic 36) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:187— CompatibilityReport.formatMarkdown has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalCaseTelemetry.isEmpty (cyclomatic 36) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:240— EvalCaseTelemetry.isEmpty has cyclomatic complexity 36 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
EvalRunner.runPromptSurfaceCase (cyclomatic 36) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerPromptSurface.swift:19— EvalRunner.runPromptSurfaceCase has cyclomatic complexity 36 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PromotionGate.evaluate (cyclomatic 36) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/PromotionGate.swift:47— PromotionGate.evaluate has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.estimatedArchitectureKVHeadroomBytes (cyclomatic 36) Packages/OsaurusCore/Services/ModelRuntime.swift:3341— ModelRuntime.estimatedArchitectureKVHeadroomBytes has cyclomatic complexity 36 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ReadKnowledgeTool.execute (cyclomatic 36) Packages/OsaurusCore/Tools/KnowledgeTools.swift:451— ReadKnowledgeTool.execute has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ActivityExportService.renderMarkdown (cyclomatic 36) Packages/OsaurusCore/Services/Insights/ActivityExportService.swift:210— ActivityExportService.renderMarkdown has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Options.parse (cyclomatic 35) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:886— Options.parse has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileWriteTool.execute (cyclomatic 35) Packages/OsaurusCore/Folder/FolderTools.swift:2403— FileWriteTool.execute has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteChatRequest.toAnthropicRequest (cyclomatic 35) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5108— RemoteChatRequest.toAnthropicRequest has cyclomatic complexity 35 (threshold 15). Of this number, 34 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSession.finalizeRun (cyclomatic 35) Packages/OsaurusCore/Views/Chat/ChatView.swift:4904— ChatSession.finalizeRun has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSession.runHarnessTurn (cyclomatic 35) Packages/OsaurusCore/Views/Chat/ChatSession+Harness.swift:23— ChatSession.runHarnessTurn has cyclomatic complexity 35 (threshold 15). Of this number, 31 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runComputerUseLoopCase (cyclomatic 34) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:21— EvalRunner.runComputerUseLoopCase has cyclomatic complexity 34 (threshold 15). Of this number, 32 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OpenAICompatibleStreamParser.processChoice (cyclomatic 34) Packages/OsaurusCore/Services/Provider/OpenAICompatibleStreamParser.swift:636— OpenAICompatibleStreamParser.processChoice has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SearchDiagnostics.classifyFailure (cyclomatic 34) Packages/OsaurusCore/Services/Search/SearchTypes.swift:180— SearchDiagnostics.classifyFailure has cyclomatic complexity 34 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigCommand.runPlanOrApply (cyclomatic 33) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:149— ConfigCommand.runPlanOrApply has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.attentionLayerMix (cyclomatic 33) Packages/OsaurusCore/Services/ModelRuntime.swift:3556— ModelRuntime.attentionLayerMix has cyclomatic complexity 33 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ConfigChannelPlatform.apply (cyclomatic 33) Packages/OsaurusCore/Configuration/Declarative/ConfigChannelDetails.swift:102— ConfigChannelPlatform.apply has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelConnectionService.actionStatus (cyclomatic 33) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1554— AgentChannelConnectionService.actionStatus has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SessionRow.body (cyclomatic 33) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2300— SessionRow.body has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatModelPickerCard.modelColumn (cyclomatic 33) Packages/OsaurusCore/Views/Model/ChatModelPickerCard.swift:484— ChatModelPickerCard.modelColumn has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ContextOptimizerSearch.plan (cyclomatic 32) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:105— ContextOptimizerSearch.plan has cyclomatic complexity 32 (threshold 15). Of this number, 28 points are the body's own statements and 4 belong to 3 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.runCapabilityClaimsCase (cyclomatic 32) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1380— EvalRunner.runCapabilityClaimsCase has cyclomatic complexity 32 (threshold 15). Of this number, 31 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FileEditTool.editDocument (cyclomatic 32) Packages/OsaurusCore/Folder/FolderTools.swift:3621— FileEditTool.editDocument has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BackgroundTaskManager.dispatchChat (cyclomatic 32) REDACTED:1001— BackgroundTaskManager.dispatchChat has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ZipArchive.entries (cyclomatic 32) Packages/OsaurusCore/Utils/ZipArchive.swift:67— ZipArchive.entries has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LocalVisionEvidence.tensorPayloadSizes (cyclomatic 32) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:341— LocalVisionEvidence.tensorPayloadSizes has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MLXBatchAdapter.generate (cyclomatic 32) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:1562— MLXBatchAdapter.generate has cyclomatic complexity 32 (threshold 15). Of this number, 31 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.parseResponse (cyclomatic 32) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:4616— RemoteProviderService.parseResponse has cyclomatic complexity 32 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
SlackConnectionService.diagnostics (cyclomatic 32) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:583— SlackConnectionService.diagnostics has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceAuditRow.subtitle (cyclomatic 32) Packages/OsaurusCore/Views/Workspaces/WorkspaceAuditView.swift:402— WorkspaceAuditRow.subtitle has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Solver.solve (cyclomatic 31) Packages/OsaurusCore/Utils/CalculatorEngine.swift:1042— Solver.solve has cyclomatic complexity 31 (threshold 15). Of this number, 23 points are the body's own statements and 8 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MCPElicitationForm.convert (cyclomatic 31) Packages/OsaurusCore/Services/MCP/MCPElicitation.swift:186— MCPElicitationForm.convert has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MemoryManagementConsoleService.diagnoseStorage (cyclomatic 31) Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:325— MemoryManagementConsoleService.diagnoseStorage has cyclomatic complexity 31 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TelegramConnectionService.diagnostics (cyclomatic 31) Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:523— TelegramConnectionService.diagnostics has cyclomatic complexity 31 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DBImportTool.execute (cyclomatic 31) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1239— DBImportTool.execute has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MCPOAuthService.signIn (cyclomatic 31) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthService.swift:109— MCPOAuthService.signIn has cyclomatic complexity 31 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ServeCommand.execute (cyclomatic 30) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Serve.swift:13— ServeCommand.execute has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusEvalsCLI.runCaptureScreen (cyclomatic 30) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCaptureScreenCLI.swift:39— OsaurusEvalsCLI.runCaptureScreen has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runDefaultAgentCase (cyclomatic 30) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1748— EvalRunner.runDefaultAgentCase has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FileCopyTool.execute (cyclomatic 30) Packages/OsaurusCore/Folder/FileCopyTool.swift:80— FileCopyTool.execute has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handlePairInviteEndpoint (cyclomatic 30) Packages/OsaurusCore/Networking/HTTPHandler.swift:9109— HTTPHandler.handlePairInviteEndpoint has cyclomatic complexity 30 (threshold 15). Of this number, 27 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelRuntime.isKnownHybridModel (cyclomatic 30) Packages/OsaurusCore/Services/ModelRuntime.swift:5753— ModelRuntime.isKnownHybridModel has cyclomatic complexity 30 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SearchAndExtractTool.enrichedResults (cyclomatic 30) Packages/OsaurusCore/Tools/WebSearchTools.swift:612— SearchAndExtractTool.enrichedResults has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SharedArtifact.resolveSourcePathDetailed (cyclomatic 30) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:764— SharedArtifact.resolveSourcePathDetailed has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: SharedArtifact.mimeType (cyclomatic 41) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
ResponsesItemPayload.transform (cyclomatic 30) Packages/OsaurusCore/PrivacyFilter/Core/MessageScrubbing.swift:488— ResponsesItemPayload.transform has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelInboundActivityPresentation.guidance (cyclomatic 30) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundActivity.swift:139— AgentChannelInboundActivityPresentation.guidance has cyclomatic complexity 30 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ResponsesGenerationStream.compatibility (cyclomatic 30) Packages/OsaurusCore/Services/Inference/ResponsesCompatibilityStream.swift:19— ResponsesGenerationStream.compatibility has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PluginHostContext.complete (cyclomatic 30) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1520— PluginHostContext.complete has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSession.dispatchSend (cyclomatic 30) Packages/OsaurusCore/Views/Chat/ChatView.swift:6498— ChatSession.dispatchSend has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::postProcessToolResult, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
NativeMarkdownView.applyMixedSegments (cyclomatic 30) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:944— NativeMarkdownView.applyMixedSegments has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ShowCommand.printFormattedOutput (cyclomatic 29) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Show.swift:166— ShowCommand.printFormattedOutput has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OsaurusEvalsCLI.runCommand (cyclomatic 29) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:150— OsaurusEvalsCLI.runCommand has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileEditTool.normalizingEditShapes (cyclomatic 29) Packages/OsaurusCore/Folder/FolderTools.swift:3258— FileEditTool.normalizingEditShapes has cyclomatic complexity 29 (threshold 15). Of this number, 26 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.bridgeToolEventStream (cyclomatic 29) Packages/OsaurusCore/Services/ModelRuntime.swift:6361— ModelRuntime.bridgeToolEventStream has cyclomatic complexity 29 (threshold 15). Of this number, 26 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolEnvelope.fromError (cyclomatic 29) Packages/OsaurusCore/Tools/ToolEnvelope.swift:222— ToolEnvelope.fromError has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CNContactsService.search (cyclomatic 29) Packages/OsaurusCore/AppleApps/Contacts/ContactsService.swift:187— CNContactsService.search has cyclomatic complexity 29 (threshold 15). Of this number, 28 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyProviders (cyclomatic 29) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1777— ConfigApplier.applyProviders has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentTaskState.nextStepBias (cyclomatic 29) Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:1022— AgentTaskState.nextStepBias has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FoundationModelService.dynamicSchema (cyclomatic 29) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:628— FoundationModelService.dynamicSchema has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImageModelRequestPolicy.validate (cyclomatic 29) Packages/OsaurusCore/Services/ModelRuntime/ImageModelRequestPolicy.swift:54— ImageModelRequestPolicy.validate has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginHostContext.httpRequest (cyclomatic 29) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2647— PluginHostContext.httpRequest has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalMatrix.formatMarkdown (cyclomatic 28) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:389— EvalMatrix.formatMarkdown has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Skill.parseYaml (cyclomatic 28) Packages/OsaurusCore/Models/Agent/Skill.swift:671— Skill.parseYaml has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleAnthropicMessagesStreaming (cyclomatic 28) Packages/OsaurusCore/Networking/HTTPHandler.swift:17026— HTTPHandler.handleAnthropicMessagesStreaming has cyclomatic complexity 28 (threshold 15). Of this number, 22 points are the body's own statements and 6 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ListKnowledgeTool.execute (cyclomatic 28) Packages/OsaurusCore/Tools/KnowledgeTools.swift:726— ListKnowledgeTool.execute has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyAgents (cyclomatic 28) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:387— ConfigApplier.applyAgents has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeImageJobCoordinator.runJob (cyclomatic 28) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:560— NativeImageJobCoordinator.runJob has cyclomatic complexity 28 (threshold 15). Of this number, 27 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImageComposerRequestBuilder.build (cyclomatic 28) Packages/OsaurusCore/Services/ModelRuntime/ImageComposerRequestBuilder.swift:81— ImageComposerRequestBuilder.build has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.processEventPayload (cyclomatic 28) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1731— RemoteProviderService.processEventPayload has cyclomatic complexity 28 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ChatView.setupKeyMonitor (cyclomatic 28) Packages/OsaurusCore/Views/Chat/ChatView.swift:11878— ChatView.setupKeyMonitor has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusCLI.parseCommand (cyclomatic 27) Packages/OsaurusCLI/Sources/OsaurusCLI/OsaurusCLI.swift:35— OsaurusCLI.parseCommand has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
EvalRunner.runMicroPerfCase (cyclomatic 27) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMicroPerf.swift:26— EvalRunner.runMicroPerfCase has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runScreenContextCase (cyclomatic 27) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerScreenContext.swift:29— EvalRunner.runScreenContextCase has cyclomatic complexity 27 (threshold 15). Of this number, 25 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ShellMutationPlanner.targets (cyclomatic 27) Packages/OsaurusCore/Folder/ShellMutationPlanner.swift:33— ShellMutationPlanner.targets has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InsightsService.filterInMemory (cyclomatic 27) Packages/OsaurusCore/Managers/InsightsService.swift:450— InsightsService.filterInMemory has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handlePairEndpoint (cyclomatic 27) Packages/OsaurusCore/Networking/HTTPHandler.swift:8742— HTTPHandler.handlePairEndpoint has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ExternalModelLocator.bundleDiagnostic (cyclomatic 27) Packages/OsaurusCore/Services/ExternalModelLocator.swift:793— ExternalModelLocator.bundleDiagnostic has cyclomatic complexity 27 (threshold 15). Of this number, 23 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LocalGenerationDefaults.repairLagunaXS21TopKIfNeeded (cyclomatic 27) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:143— LocalGenerationDefaults.repairLagunaXS21TopKIfNeeded has cyclomatic complexity 27 (threshold 15). Of this number, 24 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CapabilitiesDiscoverTool.execute (cyclomatic 27) Packages/OsaurusCore/Tools/CapabilityTools.swift:396— CapabilitiesDiscoverTool.execute has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CalculatorNode.evaluate (cyclomatic 27) Packages/OsaurusCore/Utils/CalculatorEngine.swift:430— CalculatorNode.evaluate has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyDelegation (cyclomatic 27) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:932— ConfigApplier.applyDelegation has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DispatchEnvelope.badges (cyclomatic 27) Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:432— DispatchEnvelope.badges has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiff.partialToolName (cyclomatic 27) Packages/OsaurusCore/Models/Chat/FileDiff.swift:261— FileDiff.partialToolName has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelConnectionService.authorizeInboundMessage (cyclomatic 27) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1032— AgentChannelConnectionService.authorizeInboundMessage has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ImageGenerationService.generateVideo (cyclomatic 27) Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationService.swift:313— ImageGenerationService.generateVideo has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
State.consume (cyclomatic 27) Packages/OsaurusCore/Services/Provider/RemoteResponsesPrivacyStream.swift:72— State.consume has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspacesService.refreshSelectedWorkspace (cyclomatic 27) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:525— WorkspacesService.refreshSelectedWorkspace has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: WorkspacesService.message (cyclomatic 30) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
ChatSession.runVideoGeneration (cyclomatic 27) Packages/OsaurusCore/Views/Chat/ChatView.swift:6150— ChatSession.runVideoGeneration has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImageGenerationPanelView.run (cyclomatic 27) Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift:728— ImageGenerationPanelView.run has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginCard.body (cyclomatic 27) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1076— PluginCard.body has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OOXMLText.replace (cyclomatic 27) Packages/OsaurusCore/Services/Documents/OOXML/OOXMLText.swift:269— OOXMLText.replace has cyclomatic complexity 27 (threshold 15). Of this number, 20 points are the body's own statements and 7 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
apply-ko.main (cyclomatic 27) scripts/i18n/apply-ko.py:85— apply-ko.main has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
run-local-family-multiturn-tool-cache-proof.cache_evidence_checks (cyclomatic 27) scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:139— run-local-family-multiturn-tool-cache-proof.cache_evidence_checks has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
run-post1266-family-cache-tool-matrix.cache_counters (cyclomatic 27) scripts/live-proof/run-post1266-family-cache-tool-matrix.py:188— run-post1266-family-cache-tool-matrix.cache_counters has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
BenchCommand.parseOptions (cyclomatic 26) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift:507— BenchCommand.parseOptions has cyclomatic complexity 26 (threshold 15). Of this number, 25 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalMatrixBuilder.errorCategory (cyclomatic 26) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:741— EvalMatrixBuilder.errorCategory has cyclomatic complexity 26 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
EvalRunner.scoreSpawnResidencyLane (cyclomatic 26) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:323— EvalRunner.scoreSpawnResidencyLane has cyclomatic complexity 26 (threshold 15). Of this number, 24 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileUndoTool.execute (cyclomatic 26) Packages/OsaurusCore/Folder/FolderTools.swift:4218— FileUndoTool.execute has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderManager.connect (cyclomatic 26) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:387— RemoteProviderManager.connect has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SpeechService.startStreamingTranscription (cyclomatic 26) Packages/OsaurusCore/Managers/SpeechService.swift:906— SpeechService.startStreamingTranscription has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleModelOptionsEndpoint (cyclomatic 26) Packages/OsaurusCore/Networking/HTTPHandler.swift:5787— HTTPHandler.handleModelOptionsEndpoint has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleSessionEndpoint (cyclomatic 26) Packages/OsaurusCore/Networking/HTTPHandler.swift:7848— HTTPHandler.handleSessionEndpoint has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.computeWeightsSizeBytes (cyclomatic 26) Packages/OsaurusCore/Services/ModelRuntime.swift:7617— ModelRuntime.computeWeightsSizeBytes has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SpawnPermissionGate.authorize (cyclomatic 26) Packages/OsaurusCore/Subagent/SpawnPermissionGate.swift:85— SpawnPermissionGate.authorize has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AppleScriptToolDispatch.literalsForDispatch (cyclomatic 26) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:413— AppleScriptToolDispatch.literalsForDispatch has cyclomatic complexity 26 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigPlanner.diffPortableSettings (cyclomatic 26) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1237— ConfigPlanner.diffPortableSettings has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BoundedZipReader.parseEntries (cyclomatic 26) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1504— BoundedZipReader.parseEntries has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PPTXEmitter.slides (cyclomatic 26) Packages/OsaurusCore/Services/Documents/PPTXEmitter.swift:55— PPTXEmitter.slides has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiffEngine.diff (cyclomatic 26) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:75— FileDiffEngine.diff has cyclomatic complexity 26 (threshold 15). Of this number, 22 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LocalVideoRequestPolicy.init (cyclomatic 26) Packages/OsaurusCore/Services/MediaGeneration/LocalVideoRequestPolicy.swift:13— LocalVideoRequestPolicy.init has cyclomatic complexity 26 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ImageSubagentKind.resolveModel (cyclomatic 26) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:85— ImageSubagentKind.resolveModel has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSession.runImageGeneration (cyclomatic 26) Packages/OsaurusCore/Views/Chat/ChatView.swift:5913— ChatSession.runImageGeneration has cyclomatic complexity 26 (threshold 15). Of this number, 24 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OverviewTab.summaryHeadline (cyclomatic 26) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1182— OverviewTab.summaryHeadline has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXFormula.scan (cyclomatic 26) Packages/OsaurusCore/Services/Documents/OOXML/XLSXFormula.swift:69— XLSXFormula.scan has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (XLSXFormula.scan::readCell) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
MCPCommand.execute (cyclomatic 25) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/MCPCommand.swift:14— MCPCommand.execute has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalReport.formatTelemetryLine (cyclomatic 25) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:894— EvalReport.formatTelemetryLine has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AppDelegate.presentAnnouncementIfEligible (cyclomatic 25) Packages/OsaurusCore/AppDelegate.swift:2864— AppDelegate.presentAnnouncementIfEligible has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OpenAICompatibleTTSClient.synthesizeStreaming (cyclomatic 25) Packages/OsaurusCore/Managers/OpenAICompatibleTTSClient.swift:234— OpenAICompatibleTTSClient.synthesizeStreaming has cyclomatic complexity 25 (threshold 15). Of this number, 24 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleChatNDJSON (cyclomatic 25) Packages/OsaurusCore/Networking/HTTPHandler.swift:15001— HTTPHandler.handleChatNDJSON has cyclomatic complexity 25 (threshold 15). Of this number, 24 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatHistoryDatabase.contentHash (cyclomatic 25) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1918— ChatHistoryDatabase.contentHash has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ScreenContextDistiller.sampledItem (cyclomatic 25) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:507— ScreenContextDistiller.sampledItem has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OpenResponsesRequest.toChatCompletionRequest (cyclomatic 25) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1508— OpenResponsesRequest.toChatCompletionRequest has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LocalVisionEvidence.mimoAudioEvidence (cyclomatic 25) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:286— LocalVisionEvidence.mimoAudioEvidence has cyclomatic complexity 25 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ScheduleFrequency.nextRunDate (cyclomatic 25) Packages/OsaurusCore/Models/Schedule/Schedule.swift:111— ScheduleFrequency.nextRunDate has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LocalAgentBridge.scheduleNextRun (cyclomatic 25) Packages/OsaurusCore/Services/AgentBridge/LocalAgentBridge.swift:513— LocalAgentBridge.scheduleNextRun has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentSubagentRunner.run (cyclomatic 25) Packages/OsaurusCore/Services/AgentDelegation/AgentSubagentRunner.swift:159— AgentSubagentRunner.run has cyclomatic complexity 25 (threshold 15). Of this number, 22 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ResponsesGenerationAccumulator.consume (cyclomatic 25) Packages/OsaurusCore/Services/Inference/ResponsesGenerationAccumulator.swift:42— ResponsesGenerationAccumulator.consume has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
WorkspaceAgentRunClient.prepare (cyclomatic 25) Packages/OsaurusCore/Services/Router/WorkspaceAgentRunClient.swift:154— WorkspaceAgentRunClient.prepare has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CapabilityRowBuilder.build (cyclomatic 25) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:149— CapabilityRowBuilder.build has cyclomatic complexity 25 (threshold 15). Of this number, 24 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnchoredCardCoordinator.updatePresentation (cyclomatic 25) Packages/OsaurusCore/Views/Common/AnchoredCardPresenter.swift:257— AnchoredCardCoordinator.updatePresentation has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ToolsManagerView.updateFilteredLists (cyclomatic 25) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:402— ToolsManagerView.updateFilteredLists has cyclomatic complexity 25 (threshold 15). Of this number, 23 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXEditor.renameSheet (cyclomatic 25) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:725— XLSXEditor.renameSheet has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AppDelegate.updateStatusItemAndMenu (cyclomatic 24) Packages/OsaurusCore/AppDelegate.swift:1877— AppDelegate.updateStatusItemAndMenu has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileEditTool.execute (cyclomatic 24) Packages/OsaurusCore/Folder/FolderTools.swift:3377— FileEditTool.execute has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MCPProviderManager.performConnect (cyclomatic 24) Packages/OsaurusCore/Managers/MCPProviderManager.swift:252— MCPProviderManager.performConnect has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToastAction.from (cyclomatic 24) Packages/OsaurusCore/Models/Toast.swift:376— ToastAction.from has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleCompletions (cyclomatic 24) Packages/OsaurusCore/Networking/HTTPHandler.swift:13991— HTTPHandler.handleCompletions has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EventKitCalendarService.update (cyclomatic 24) Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:324— EventKitCalendarService.update has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AppleScriptToolDispatch.exactReplacementLiterals (cyclomatic 24) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:519— AppleScriptToolDispatch.exactReplacementLiterals has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
BrowserToolExecutor.batchDo (cyclomatic 24) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:491— BrowserToolExecutor.batchDo has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginManager.loadPluginWithError (cyclomatic 24) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1222— PluginManager.loadPluginWithError has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnthropicMessagesRequest.toChatCompletionRequest (cyclomatic 24) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:966— AnthropicMessagesRequest.toChatCompletionRequest has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OpenResponsesRequest.toResponsesInferenceRequest (cyclomatic 24) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1298— OpenResponsesRequest.toResponsesInferenceRequest has cyclomatic complexity 24 (threshold 15). Of this number, 23 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ServerRuntimeSettingsStore.shouldRepairPagedCacheDefault (cyclomatic 24) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:531— ServerRuntimeSettingsStore.shouldRepairPagedCacheDefault has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PrivacyFilterEngine.detect (cyclomatic 24) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterEngine.swift:176— PrivacyFilterEngine.detect has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ContextBudgetManager.trimMessagesReportingOverflow (cyclomatic 24) Packages/OsaurusCore/Services/Chat/ContextBudgetManager.swift:355— ContextBudgetManager.trimMessagesReportingOverflow has cyclomatic complexity 24 (threshold 15). Of this number, 21 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ContextBudgetManager.summarizeToolResult (cyclomatic 24) Packages/OsaurusCore/Services/Chat/ContextBudgetManager.swift:741— ContextBudgetManager.summarizeToolResult has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OpenAIPromptBuilder.buildPrompt (cyclomatic 24) Packages/OsaurusCore/Services/Chat/PromptBuilder.swift:13— OpenAIPromptBuilder.buildPrompt has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiffEngine.canonicalLines (cyclomatic 24) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:494— FileDiffEngine.canonicalLines has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 9 of the 24 points are its own statements and the rest belongs to 2 function items inside it that branch (walk, textLines). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
MemoryService.performDistillSession (cyclomatic 24) Packages/OsaurusCore/Services/Memory/MemoryService.swift:811— MemoryService.performDistillSession has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RuntimeProofValidator.appendProvenClaimIssues (cyclomatic 24) Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:310— RuntimeProofValidator.appendProvenClaimIssues has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OpenAICompatibleToolCallAccumulator.validateToolCallJSON (cyclomatic 24) Packages/OsaurusCore/Services/Provider/OpenAICompatibleStreamParser.swift:320— OpenAICompatibleToolCallAccumulator.validateToolCallJSON has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TextSubagentKind.run (cyclomatic 24) Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:979— TextSubagentKind.run has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatHistoryFilterPicker.passes (cyclomatic 24) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:412— ChatHistoryFilterPicker.passes has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
EvalRunner.prefillProgressAccountingProblem (cyclomatic 23) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerCacheProof.swift:705— EvalRunner.prefillProgressAccountingProblem has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RunEnvironment.summary (cyclomatic 23) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/RunEnvironment.swift:281— RunEnvironment.summary has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Lines.replace (cyclomatic 23) Packages/OsaurusCore/Folder/FileEditMatcher.swift:234— Lines.replace has cyclomatic complexity 23 (threshold 15). Of this number, 21 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FolderContextService.buildFileTree::traverse (cyclomatic 23) Packages/OsaurusCore/Folder/FolderContextService.swift:266— FolderContextService.buildFileTree::traverse has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileWriteTool.writeDocument (cyclomatic 23) Packages/OsaurusCore/Folder/FolderTools.swift:2891— FileWriteTool.writeDocument has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BackgroundTaskManager.lookupReattachableSession (cyclomatic 23) REDACTED:1286— BackgroundTaskManager.lookupReattachableSession has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TranscriptionWorker.runLoop (cyclomatic 23) Packages/OsaurusCore/Managers/SpeechService.swift:1495— TranscriptionWorker.runLoop has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelDownloadService.transferFile (cyclomatic 23) Packages/OsaurusCore/Services/ModelDownloadService.swift:821— ModelDownloadService.transferFile has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.mapOpenAIChatToMLX (cyclomatic 23) Packages/OsaurusCore/Services/ModelRuntime.swift:7079— ModelRuntime.mapOpenAIChatToMLX has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SandboxReadFileTool.execute (cyclomatic 23) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1673— SandboxReadFileTool.execute has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MCPProviderTool.convertMCPContent (cyclomatic 23) Packages/OsaurusCore/Tools/MCPProviderTool.swift:483— MCPProviderTool.convertMCPContent has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SchemaValidator.validateObject (cyclomatic 23) Packages/OsaurusCore/Tools/SchemaValidator.swift:69— SchemaValidator.validateObject has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ShareArtifactTool.execute (cyclomatic 23) Packages/OsaurusCore/Tools/ShareArtifactTool.swift:90— ShareArtifactTool.execute has cyclomatic complexity 23 (threshold 15). Of this number, 21 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AppleJSON.serializable (cyclomatic 23) Packages/OsaurusCore/AppleApps/Support/AppleToolBase.swift:328— AppleJSON.serializable has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
BrowserSnapshotFormatter.format (cyclomatic 23) Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:172— BrowserSnapshotFormatter.format has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentAction.argumentsJSON (cyclomatic 23) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:224— AgentAction.argumentsJSON has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ContentBlock.knownFileContents (cyclomatic 23) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:1225— ContentBlock.knownFileContents has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MTPLayoutAdvisory.evaluate (cyclomatic 23) Packages/OsaurusCore/Models/Chat/MTPLayoutAdvisory.swift:135— MTPLayoutAdvisory.evaluate has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ServerRuntimeSettingsStore.shouldRepairLegacyCacheDefaults (cyclomatic 23) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:492— ServerRuntimeSettingsStore.shouldRepairLegacyCacheDefaults has cyclomatic complexity 23 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AgentSubagentRunner.consumeStream (cyclomatic 23) Packages/OsaurusCore/Services/AgentDelegation/AgentSubagentRunner.swift:515— AgentSubagentRunner.consumeStream has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.dispatchFinal (cyclomatic 23) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2739— RemoteProviderService.dispatchFinal has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteResponsesNativeStream.capture (cyclomatic 23) Packages/OsaurusCore/Services/Provider/RemoteResponsesNativeStream.swift:133— RemoteResponsesNativeStream.capture has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DatabaseImport.parseXLSX (cyclomatic 23) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:253— DatabaseImport.parseXLSX has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
N8nSettingsView.body (cyclomatic 23) Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:78— N8nSettingsView.body has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ShellArgs.split (cyclomatic 23) Packages/OsaurusCore/Services/MCP/Stdio/ShellArgs.swift:35— ShellArgs.split has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RunCommand.execute (cyclomatic 22) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:13— RunCommand.execute has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImportCommand.render (cyclomatic 22) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:694— ImportCommand.render has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CentralRepositoryManager.mapFailure (cyclomatic 22) Packages/OsaurusRepository/CentralRepositoryManager.swift:444— CentralRepositoryManager.mapFailure has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
HTTPHandler.handleListSessionsEndpoint::matches (cyclomatic 22) Packages/OsaurusCore/Networking/HTTPHandler.swift:7682— HTTPHandler.handleListSessionsEndpoint::matches has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.decodeOllamaChatRequest (cyclomatic 22) Packages/OsaurusCore/Networking/HTTPHandler.swift:14953— HTTPHandler.decodeOllamaChatRequest has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleOllamaGenerate (cyclomatic 22) Packages/OsaurusCore/Networking/HTTPHandler.swift:15295— HTTPHandler.handleOllamaGenerate has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RequestValidator.rawResponseSchemaReason (cyclomatic 22) Packages/OsaurusCore/Networking/RequestValidator.swift:19— RequestValidator.rawResponseSchemaReason has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
SpawnResultCompaction.modelVisible (cyclomatic 22) Packages/OsaurusCore/Subagent/SpawnResultCompaction.swift:54— SpawnResultCompaction.modelVisible has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SpawnAgentTool.execute (cyclomatic 22) Packages/OsaurusCore/Tools/SpawnAgentTool.swift:123— SpawnAgentTool.execute has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EventKitRemindersService.update (cyclomatic 22) Packages/OsaurusCore/AppleApps/Reminders/RemindersService.swift:219— EventKitRemindersService.update has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BrowserSnapshotFormatter.line (cyclomatic 22) Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:249— BrowserSnapshotFormatter.line has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentAction.semanticProblem (cyclomatic 22) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:535— AgentAction.semanticProblem has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyChannels (cyclomatic 22) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1179— ConfigApplier.applyChannels has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentTargetResolver.resolve (cyclomatic 22) Packages/OsaurusCore/Models/Agent/AgentDispatchTarget.swift:205— AgentTargetResolver.resolve has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProvider.resolvedHeaders (cyclomatic 22) Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:336— RemoteProvider.resolvedHeaders has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RegexEntityDetector.detect (cyclomatic 22) Packages/OsaurusCore/PrivacyFilter/Core/RegexEntityDetector.swift:126— RegexEntityDetector.detect has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PiRPCCodec.decode (cyclomatic 22) Packages/OsaurusCore/Services/Harness/PiRPCAdapter.swift:104— PiRPCCodec.decode has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
StreamingStatsHint.decode (cyclomatic 22) Packages/OsaurusCore/Services/Inference/ModelService.swift:573— StreamingStatsHint.decode has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
KnowledgeCurationService.approve (cyclomatic 22) Packages/OsaurusCore/Services/Knowledge/KnowledgeCurationService.swift:47— KnowledgeCurationService.approve has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RemoteProviderService.handleAnthropicEvent (cyclomatic 22) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2166— RemoteProviderService.handleAnthropicEvent has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceAgentAccessHost.redeem (cyclomatic 22) Packages/OsaurusCore/Services/Router/WorkspaceAgentAccessHost.swift:355— WorkspaceAgentAccessHost.redeem has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SetupChecker.check (cyclomatic 22) Packages/OsaurusCore/Services/Template/SetupChecker.swift:101— SetupChecker.check has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DatabaseImport.detectFormat (cyclomatic 22) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:88— DatabaseImport.detectFormat has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
XLSXEditor.setCells (cyclomatic 22) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:175— XLSXEditor.setCells has cyclomatic complexity 22 (threshold 15). Of this number, 14 points are the body's own statements and 8 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MCPOAuthURLPolicy.isLocalOrPrivateHost (cyclomatic 22) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthHTTPTransport.swift:122— MCPOAuthURLPolicy.isLocalOrPrivateHost has cyclomatic complexity 22 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
bridge.handleLoginEvent (cyclomatic 22) helpers/osaurus-wa/bridge.go:350— bridge.handleLoginEvent has cyclomatic complexity 22 (threshold 15). Of this number, 20 points are the body's own statements and 2 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ManifestValidate.validate (cyclomatic 21) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:72— ManifestValidate.validate has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ToolsInstall.installManual (cyclomatic 21) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:72— ToolsInstall.installManual has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
OsaurusEvalsCLI.runDiff (cyclomatic 21) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:24— OsaurusEvalsCLI.runDiff has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runHTTPAPICase (cyclomatic 21) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerHTTPAPI.swift:181— EvalRunner.runHTTPAPICase has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
EvalRunner.runReasoningChannelCase (cyclomatic 21) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerReasoningChannel.swift:43— EvalRunner.runReasoningChannelCase has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.runSubagentCase (cyclomatic 21) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:37— EvalRunner.runSubagentCase has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WatcherManager.processCurrentState (cyclomatic 21) Packages/OsaurusCore/Managers/WatcherManager.swift:495— WatcherManager.processCurrentState has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleModelPickerEndpoint (cyclomatic 21) Packages/OsaurusCore/Networking/HTTPHandler.swift:5470— HTTPHandler.handleModelPickerEndpoint has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
RelayTunnelManager.connect (cyclomatic 21) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:413— RelayTunnelManager.connect has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelSSDResidency.remoteNGramBytes (cyclomatic 21) Packages/OsaurusCore/Services/ModelSSDResidency.swift:69— ModelSSDResidency.remoteNGramBytes has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SubagentSession.prepare (cyclomatic 21) Packages/OsaurusCore/Subagent/SubagentSession.swift:348— SubagentSession.prepare has cyclomatic complexity 21 (threshold 15). Of this number, 19 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ToolRegistry.availability (cyclomatic 21) Packages/OsaurusCore/Tools/ToolRegistry.swift:2892— ToolRegistry.availability has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
InlineMathScanner.split (cyclomatic 21) Packages/OsaurusCore/Utils/InlineMathScanner.swift:86— InlineMathScanner.split has cyclomatic complexity 21 (threshold 15). Of this number, 19 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentView.renderForModel (cyclomatic 21) Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:244— AgentView.renderForModel has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EffectClassifier.classify (cyclomatic 21) Packages/OsaurusCore/ComputerUse/Policy/EffectClassifier.swift:32— EffectClassifier.classify has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigYAML.checkMapping (cyclomatic 21) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:207— ConfigYAML.checkMapping has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSessionExporter.timingSuffix (cyclomatic 21) Packages/OsaurusCore/Managers/Chat/ChatSessionExporter.swift:238— ChatSessionExporter.timingSuffix has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelManager.fetchRemoteMLXModels (cyclomatic 21) Packages/OsaurusCore/Managers/Model/ModelManager.swift:379— ModelManager.fetchRemoteMLXModels has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelPublishService.classifyProviderFailure (cyclomatic 21) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:1127— AgentChannelPublishService.classifyProviderFailure has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DocumentEditService.structure (cyclomatic 21) Packages/OsaurusCore/Services/Documents/DocumentEditService.swift:237— DocumentEditService.structure has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MarkdownRichTextRenderer.blockDescriptor (cyclomatic 21) Packages/OsaurusCore/Services/Documents/MarkdownRichTextRenderer.swift:228— MarkdownRichTextRenderer.blockDescriptor has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PDFAdapter.selectionRange (cyclomatic 21) Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:231— PDFAdapter.selectionRange has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FileDiffEngine.collapse (cyclomatic 21) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:312— FileDiffEngine.collapse has cyclomatic complexity 21 (threshold 15). Of this number, 14 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ClaudeCodeHarnessAdapter.launchPlan (cyclomatic 21) Packages/OsaurusCore/Services/Harness/ClaudeCodeHarnessAdapter.swift:38— ClaudeCodeHarnessAdapter.launchPlan has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
IMessageConnectionService.diagnostics (cyclomatic 21) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:310— IMessageConnectionService.diagnostics has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PendingImportProcessor.removeItem (cyclomatic 21) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:862— PendingImportProcessor.removeItem has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ResponsesGenerationStream.native (cyclomatic 21) Packages/OsaurusCore/Services/Inference/ResponsesGenerationEvent.swift:100— ResponsesGenerationStream.native has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
KnowledgeIndexService.scanIndexableFiles (cyclomatic 21) Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:343— KnowledgeIndexService.scanIndexableFiles has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
KnowledgeSearchService.search (cyclomatic 21) Packages/OsaurusCore/Services/Knowledge/KnowledgeSearchService.swift:186— KnowledgeSearchService.search has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MediaGenerationCoordinator.validateImageRequest (cyclomatic 21) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:579— MediaGenerationCoordinator.validateImageRequest has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MediaGenerationCoordinator.validateVideoRequest (cyclomatic 21) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:630— MediaGenerationCoordinator.validateVideoRequest has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RemoteProviderService.handleGeminiEvent (cyclomatic 21) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2086— RemoteProviderService.handleGeminiEvent has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InboundSharedRunBridge.mergeCompletedTurn (cyclomatic 21) Packages/OsaurusCore/Services/Router/InboundSharedRunBridge.swift:393— InboundSharedRunBridge.mergeCompletedTurn has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SharedAgentStatus.derive (cyclomatic 21) Packages/OsaurusCore/Services/Router/SharedAgentIdentity.swift:260— SharedAgentStatus.derive has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SlackConnectionService.classifyInboundEvent (cyclomatic 21) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1489— SlackConnectionService.classifyInboundEvent has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ToolIndexService.exposureDiagnostic (cyclomatic 21) Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:176— ToolIndexService.exposureDiagnostic has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentDetailView.bodyCore (cyclomatic 21) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1875— AgentDetailView.bodyCore has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatHistoryList.filteredSessions (cyclomatic 21) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3233— ChatHistoryList.filteredSessions has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatSession.send (cyclomatic 21) Packages/OsaurusCore/Views/Chat/ChatView.swift:6353— ChatSession.send has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FloatingInputCard.sandboxToggleChip (cyclomatic 21) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:3875— FloatingInputCard.sandboxToggleChip has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PluginDetailView.heroHeader (cyclomatic 21) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1642— PluginDetailView.heroHeader has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolPermissionView.body (cyclomatic 21) Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:83— ToolPermissionView.body has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ProviderCardView.body (cyclomatic 21) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:688— ProviderCardView.body has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
XLSXEditor.deleteSheet (cyclomatic 21) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:776— XLSXEditor.deleteSheet has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Accessibility.swift.computeFocusedContent (cyclomatic 21) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1123— Accessibility.swift.computeFocusedContent has cyclomatic complexity 21 (threshold 15). Of this number, 18 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
bridge.handleSendAttachment (cyclomatic 21) helpers/osaurus-wa/bridge.go:707— bridge.handleSendAttachment has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
bridge.emitMessage (cyclomatic 21) helpers/osaurus-wa/bridge.go:1134— bridge.emitMessage has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BenchCommand.measureOnce (cyclomatic 20) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift:378— BenchCommand.measureOnce has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImportCommand.loadAndCheck (cyclomatic 20) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:306— ImportCommand.loadAndCheck has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusEvalsCLI.runOptimizeContext (cyclomatic 20) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/ContextOptimizeCLI.swift:37— OsaurusEvalsCLI.runOptimizeContext has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
BoundedArchiveExtractor.validateLocalHeader (cyclomatic 20) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:486— BoundedArchiveExtractor.validateLocalHeader has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ShellRunTool.execute (cyclomatic 20) Packages/OsaurusCore/Folder/FolderTools.swift:5347— ShellRunTool.execute has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleDispatchEndpoint (cyclomatic 20) Packages/OsaurusCore/Networking/HTTPHandler.swift:11676— HTTPHandler.handleDispatchEndpoint has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DeclaredReasoningEffort.nativeThinkingModes (cyclomatic 20) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:274— DeclaredReasoningEffort.nativeThinkingModes has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelDownloadService.makeAlert (cyclomatic 20) Packages/OsaurusCore/Services/ModelDownloadService.swift:102— ModelDownloadService.makeAlert has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelRuntime.generateEventStream (cyclomatic 20) Packages/OsaurusCore/Services/ModelRuntime.swift:5889— ModelRuntime.generateEventStream has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MemoryDatabase.searchPinnedFactsText (cyclomatic 20) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1468— MemoryDatabase.searchPinnedFactsText has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (MemoryDatabase.searchEpisodesText) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
MemoryDatabase.searchEpisodesText (cyclomatic 20) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1889— MemoryDatabase.searchEpisodesText has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (MemoryDatabase.searchPinnedFactsText) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
SandboxWriteFileTool.execute (cyclomatic 20) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2122— SandboxWriteFileTool.execute has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SandboxInstallTool.execute (cyclomatic 20) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3466— SandboxInstallTool.execute has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SearchAndExtractTool.execute (cyclomatic 20) Packages/OsaurusCore/Tools/WebSearchTools.swift:394— SearchAndExtractTool.execute has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyDefaultAgent (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:285— ConfigApplier.applyDefaultAgent has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.patchToolSelection (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:699— ConfigApplier.patchToolSelection has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigApplier.addProvider (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2032— ConfigApplier.addProvider has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ConfigApplier.applyWatchers (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2414— ConfigApplier.applyWatchers has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.plan (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:167— ConfigPlanner.plan has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigYAML.walk (cyclomatic 20) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:145— ConfigYAML.walk has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatWindowState.setupNotificationObservers (cyclomatic 20) Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:2579— ChatWindowState.setupNotificationObservers has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FileDiff.partialPythonStringValue (cyclomatic 20) Packages/OsaurusCore/Models/Chat/FileDiff.swift:404— FileDiff.partialPythonStringValue has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiff.stringValue (cyclomatic 20) Packages/OsaurusCore/Models/Chat/FileDiff.swift:468— FileDiff.stringValue has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
OpenResponsesSSEWriter.writeProviderEvent (cyclomatic 20) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1627— OpenResponsesSSEWriter.writeProviderEvent has cyclomatic complexity 20 (threshold 15). Of this number, 15 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelPickerItem.generateMockModels (cyclomatic 20) Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1010— ModelPickerItem.generateMockModels has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CodeBlockMasker.mask (cyclomatic 20) Packages/OsaurusCore/PrivacyFilter/Core/CodeBlockMasker.swift:42— CodeBlockMasker.mask has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelWebhookIngress.handleTaskPoll (cyclomatic 20) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:465— AgentChannelWebhookIngress.handleTaskPoll has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MicroPerfEvaluator.runCancellation (cyclomatic 20) Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:316— MicroPerfEvaluator.runCancellation has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXPackageArchive.readCentralDirectory (cyclomatic 20) Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:1012— XLSXPackageArchive.readCentralDirectory has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileChangeJournal.importLegacyIfNeeded (cyclomatic 20) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal.swift:961— FileChangeJournal.importLegacyIfNeeded has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PhoneAgentEditing.apply (cyclomatic 20) Packages/OsaurusCore/Services/MobileConnect/PhoneAgentEditing.swift:173— PhoneAgentEditing.apply has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TokenizerBridge.applyDeepseekV4NativeTemplate (cyclomatic 20) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1067— TokenizerBridge.applyDeepseekV4NativeTemplate has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TokenizerBridge.compactCompletedDSV4ToolHistory (cyclomatic 20) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1185— TokenizerBridge.compactCompletedDSV4ToolHistory has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SearchReadability.fetchAndExtract (cyclomatic 20) Packages/OsaurusCore/Services/Search/SearchReadability.swift:95— SearchReadability.fetchAndExtract has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ClaudePluginInstaller.fetchArtifacts (cyclomatic 20) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:868— ClaudePluginInstaller.fetchArtifacts has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ClaudePluginInstaller.rewriteSkillBody (cyclomatic 20) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1197— ClaudePluginInstaller.rewriteSkillBody has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WhatsAppConnectionService.startPairing (cyclomatic 20) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:310— WhatsAppConnectionService.startPairing has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BrowserUseKind.run (cyclomatic 20) Packages/OsaurusCore/Subagent/Kinds/BrowserUseKind.swift:162— BrowserUseKind.run has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ImageSubagentKind.run (cyclomatic 20) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:326— ImageSubagentKind.run has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.handleFileDrop (cyclomatic 20) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5259— FloatingInputCard.handleFileDrop has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeMarkdownTableView.updateCells (cyclomatic 20) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:1143— NativeMarkdownTableView.updateCells has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginConfigView.validateField (cyclomatic 20) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:667— PluginConfigView.validateField has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SkillRow.body (cyclomatic 20) Packages/OsaurusCore/Views/Skill/SkillsView.swift:537— SkillRow.body has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXEditor.dropCachedFormulaResults (cyclomatic 20) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:88— XLSXEditor.dropCachedFormulaResults has cyclomatic complexity 20 (threshold 15). Of this number, 17 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MCPWWWAuthenticate.parseParams (cyclomatic 20) Packages/OsaurusCore/Services/MCP/OAuth/MCPWWWAuthenticate.swift:80— MCPWWWAuthenticate.parseParams has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
plan-installed-vision.metadata (cyclomatic 20) scripts/evals/plan-installed-vision.py:39— plan-installed-vision.metadata has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusEvalsCLI.runMatrix (cyclomatic 19) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:132— OsaurusEvalsCLI.runMatrix has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalReport.formatAggregatedTelemetry (cyclomatic 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:966— EvalReport.formatAggregatedTelemetry has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.scoreTranscriptAssertions (cyclomatic 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1336— EvalRunner.scoreTranscriptAssertions has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OsaurusBundle.contentHash (cyclomatic 19) Packages/OsaurusRepository/ImportQueue.swift:378— OsaurusBundle.contentHash has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.decryptSecureCall (cyclomatic 19) Packages/OsaurusCore/Networking/HTTPHandler.swift:8477— HTTPHandler.decryptSecureCall has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SecureChannelResponseEncryptor.write (cyclomatic 19) Packages/OsaurusCore/Networking/SecureChannelResponseEncryptor.swift:65— SecureChannelResponseEncryptor.write has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DeclaredReasoningEffort.parseReasoningModes (cyclomatic 19) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:312— DeclaredReasoningEffort.parseReasoningModes has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GitHubSkillService.buildManifest (cyclomatic 19) Packages/OsaurusCore/Services/GitHubSkillService.swift:1559— GitHubSkillService.buildManifest has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LocalGenerationDefaults.repairOrnith15A3BManualMTPBlockIfNeeded (cyclomatic 19) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:316— LocalGenerationDefaults.repairOrnith15A3BManualMTPBlockIfNeeded has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SubagentAdmissionLease.suspending (cyclomatic 19) Packages/OsaurusCore/Subagent/SubagentAdmissionLease.swift:32— SubagentAdmissionLease.suspending has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SubagentSession.localInPlaceCapacityDecision (cyclomatic 19) Packages/OsaurusCore/Subagent/SubagentSession.swift:1392— SubagentSession.localInPlaceCapacityDecision has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CapabilitiesLoadTool.loadTool (cyclomatic 19) Packages/OsaurusCore/Tools/CapabilityTools.swift:1232— CapabilitiesLoadTool.loadTool has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
UpdateKnowledgeTicketTool.execute (cyclomatic 19) Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:330— UpdateKnowledgeTicketTool.execute has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CronParser.nextDate (cyclomatic 19) Packages/OsaurusCore/Utils/CronParser.swift:48— CronParser.nextDate has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MockAppleScriptWorld.handle (cyclomatic 19) Packages/OsaurusCore/AppleScript/Exec/MockAppleScriptWorld.swift:81— MockAppleScriptWorld.handle has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AppleScriptToolDispatch.literalContractViolation (cyclomatic 19) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:659— AppleScriptToolDispatch.literalContractViolation has cyclomatic complexity 19 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ScreenContextDistiller.focusedElement (cyclomatic 19) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:290— ScreenContextDistiller.focusedElement has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatWindowState.loadSession (cyclomatic 19) Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:1324— ChatWindowState.loadSession has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelManager.refreshAutomaticModelUpdates (cyclomatic 19) Packages/OsaurusCore/Managers/Model/ModelUpdatePolling.swift:127— ModelManager.refreshAutomaticModelUpdates has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentCapabilityReadiness.subagent (cyclomatic 19) Packages/OsaurusCore/Models/Agent/AgentCapabilityReadiness.swift:133— AgentCapabilityReadiness.subagent has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelCustomHTTPResponseMapping.validatePath (cyclomatic 19) Packages/OsaurusCore/Models/AgentChannel/AgentChannelCustomJSONModels.swift:86— AgentChannelCustomHTTPResponseMapping.validatePath has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelCustomJSONRunner.prepareRequest (cyclomatic 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:858— AgentChannelCustomJSONRunner.prepareRequest has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: AgentChannelCustomJSONRunnerError.errorDescription (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentChannelCustomJSONRunner.renderedURL (cyclomatic 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1717— AgentChannelCustomJSONRunner.renderedURL has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: AgentChannelCustomJSONRunnerError.errorDescription (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentChannelCustomJSONRunner.blockedHostReason (cyclomatic 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1842— AgentChannelCustomJSONRunner.blockedHostReason has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: AgentChannelCustomJSONRunnerError.errorDescription (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentChannelInboundRelay.submit (cyclomatic 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:135— AgentChannelInboundRelay.submit has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OwnerDeviceAccessHost.redeem (cyclomatic 19) Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:375— OwnerDeviceAccessHost.redeem has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
SystemPromptComposer.appendProjectMemory (cyclomatic 19) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:397— SystemPromptComposer.appendProjectMemory has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolResultMediaBridge.mime (cyclomatic 19) Packages/OsaurusCore/Services/Chat/ToolResultMediaBridge.swift:204— ToolResultMediaBridge.mime has cyclomatic complexity 19 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
CSVRowParser.parseRows (cyclomatic 19) Packages/OsaurusCore/Services/Documents/CSVRowParser.swift:22— CSVRowParser.parseRows has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ResponsesToolChoiceContract.validate (cyclomatic 19) Packages/OsaurusCore/Services/Inference/ResponsesToolChoiceContract.swift:78— ResponsesToolChoiceContract.validate has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ResponsesToolChoiceContract.enforce (cyclomatic 19) Packages/OsaurusCore/Services/Inference/ResponsesToolChoiceContract.swift:115— ResponsesToolChoiceContract.enforce has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PhoneAgentEditing.patch (cyclomatic 19) Packages/OsaurusCore/Services/MobileConnect/PhoneAgentEditing.swift:121— PhoneAgentEditing.patch has cyclomatic complexity 19 (threshold 15). Of this number, 14 points are the body's own statements and 5 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RemoteProviderService.enforcingToolUseResultPairing (cyclomatic 19) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:4326— RemoteProviderService.enforcingToolUseResultPairing has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InboundSharedRunBridge.resolveHostedSession (cyclomatic 19) Packages/OsaurusCore/Services/Router/InboundSharedRunBridge.swift:141— InboundSharedRunBridge.resolveHostedSession has cyclomatic complexity 19 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SearchEngine.raceFree (cyclomatic 19) Packages/OsaurusCore/Services/Search/SearchEngine.swift:242— SearchEngine.raceFree has cyclomatic complexity 19 (threshold 15). Of this number, 14 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WhatsAppConnectionService.normalizeInbound (cyclomatic 19) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1330— WhatsAppConnectionService.normalizeInbound has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DatabaseImport.parseDelimited (cyclomatic 19) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:176— DatabaseImport.parseDelimited has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.startVoiceInput (cyclomatic 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:1404— FloatingInputCard.startVoiceInput has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.catalogMediaComposerChips (cyclomatic 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5401— FloatingInputCard.catalogMediaComposerChips has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ContextBreakdownPopover.color (cyclomatic 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:7000— ContextBreakdownPopover.color has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingCreditsChip.body (cyclomatic 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8891— FloatingCreditsChip.body has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NativeMarkdownView.scheduleImageLoad (cyclomatic 19) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:1323— NativeMarkdownView.scheduleImageLoad has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NativeToolCallRowView.markdownForConfigResult (cyclomatic 19) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:1681— NativeToolCallRowView.markdownForConfigResult has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SelectableTextView.applyThemeStyling (cyclomatic 19) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:821— SelectableTextView.applyThemeStyling has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelDetailView.detailsCard (cyclomatic 19) Packages/OsaurusCore/Views/Model/ModelDetailView.swift:595— ModelDetailView.detailsCard has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SkillsView.body (cyclomatic 19) Packages/OsaurusCore/Views/Skill/SkillsView.swift:69— SkillsView.body has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AccessibilityManager.traverse (cyclomatic 19) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:592— AccessibilityManager.traverse has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DOCXEditor.applyParagraphRun (cyclomatic 19) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:611— DOCXEditor.applyParagraphRun has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DOCXEditor.insertParagraph (cyclomatic 19) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:761— DOCXEditor.insertParagraph has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PPTXEditor.deleteSlide (cyclomatic 19) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:354— PPTXEditor.deleteSlide has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
lint-zh-style.main (cyclomatic 19) scripts/i18n/lint-zh-style.py:105— lint-zh-style.main has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
run-local-family-chat-tool-proof.run (cyclomatic 19) scripts/live-proof/run-local-family-chat-tool-proof.py:90— run-local-family-chat-tool-proof.run has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
OsaurusEvalsCLI.forensicsLabel (cyclomatic 18) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:752— OsaurusEvalsCLI.forensicsLabel has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.runComputerUseCase (cyclomatic 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1095— EvalRunner.runComputerUseCase has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: EvalRunner.dispatchCase (cyclomatic 27) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
EvalRunner.scoreBrowserUseLane (cyclomatic 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:678— EvalRunner.scoreBrowserUseLane has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BoundedArchiveExtractor.validatedPath (cyclomatic 18) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:419— BoundedArchiveExtractor.validatedPath has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MinisignVerifier.parseSignature (cyclomatic 18) Packages/OsaurusRepository/MinisignVerifier.swift:95— MinisignVerifier.parseSignature has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
FileWriteDocumentRouting.workbook (cyclomatic 18) Packages/OsaurusCore/Folder/FileWriteDocumentRouting.swift:323— FileWriteDocumentRouting.workbook has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleMemoryIngest (cyclomatic 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:4602— HTTPHandler.handleMemoryIngest has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleMCPCallTool (cyclomatic 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:16550— HTTPHandler.handleMCPCallTool has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DirectDownloader.download (cyclomatic 18) Packages/OsaurusCore/Services/ModelDownloadService.swift:1824— DirectDownloader.download has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelSSDResidency.fetch (cyclomatic 18) Packages/OsaurusCore/Services/ModelSSDResidency.swift:135— ModelSSDResidency.fetch has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatHistoryWriter.persist (cyclomatic 18) Packages/OsaurusCore/Storage/ChatHistoryWriter.swift:61— ChatHistoryWriter.persist has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SubagentBatchAdmissionPlanner.planInternal (cyclomatic 18) Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:471— SubagentBatchAdmissionPlanner.planInternal has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CapabilitiesLoadTool.execute (cyclomatic 18) Packages/OsaurusCore/Tools/CapabilityTools.swift:1012— CapabilitiesLoadTool.execute has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ScreenContextSnapshot.render (cyclomatic 18) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextSnapshot.swift:131— ScreenContextSnapshot.render has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.applyLocked (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:85— ConfigApplier.applyLocked has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigApplier.applySchedules (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2324— ConfigApplier.applySchedules has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.planDelegation (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1595— ConfigPlanner.planDelegation has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OsaurusConfigDocument.declaredSections (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigDocument.swift:136— OsaurusConfigDocument.declaredSections has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (OsaurusConfigDocument.filtered) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
OsaurusConfigDocument.filtered (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigDocument.swift:159— OsaurusConfigDocument.filtered has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (OsaurusConfigDocument.declaredSections) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
OsaurusConfigTool.handleTemplates (cyclomatic 18) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:612— OsaurusConfigTool.handleTemplates has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelWebhookIngress.handleInbound (cyclomatic 18) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:207— AgentChannelWebhookIngress.handleInbound has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
WorkspaceDelegationEvaluator.run (cyclomatic 18) Packages/OsaurusCore/Services/AgentDelegation/WorkspaceDelegationEvaluator.swift:92— WorkspaceDelegationEvaluator.run has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AppleScriptEvaluator.run (cyclomatic 18) Packages/OsaurusCore/Services/Context/AppleScriptEvaluator.swift:226— AppleScriptEvaluator.run has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DocumentEditService.prepare (cyclomatic 18) Packages/OsaurusCore/Services/Documents/DocumentEditService.swift:114— DocumentEditService.prepare has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
FileChangeJournal.apply (cyclomatic 18) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal+Revert.swift:426— FileChangeJournal.apply has cyclomatic complexity 18 (threshold 15). Of this number, 15 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiffEngine.lineDiff (cyclomatic 18) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:195— FileDiffEngine.lineDiff has cyclomatic complexity 18 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
IMessageHelperInstaller.machOArchitectures (cyclomatic 18) Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:325— IMessageHelperInstaller.machOArchitectures has cyclomatic complexity 18 (threshold 15). Of this number, 15 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MCPProviderProbeService.mapFailure (cyclomatic 18) Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:441— MCPProviderProbeService.mapFailure has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
PluginProcessHostCallbacks.handle (cyclomatic 18) Packages/OsaurusCore/Services/Plugin/PluginProcessHost.swift:386— PluginProcessHostCallbacks.handle has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.streamResponses (cyclomatic 18) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:742— RemoteProviderService.streamResponses has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceSyncService.receive (cyclomatic 18) Packages/OsaurusCore/Services/Router/WorkspaceSyncService.swift:265— WorkspaceSyncService.receive has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ClaudePluginInstaller.extractSiblingSkillNames (cyclomatic 18) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1367— ClaudePluginInstaller.extractSiblingSkillNames has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DatabaseImport.isDecimalLiteral (cyclomatic 18) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:590— DatabaseImport.isDecimalLiteral has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AgentCard.body (cyclomatic 18) Packages/OsaurusCore/Views/Agent/AgentsView.swift:843— AgentCard.body has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSession.maybeGenerateFollowUps (cyclomatic 18) Packages/OsaurusCore/Views/Chat/ChatView.swift:4692— ChatSession.maybeGenerateFollowUps has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatSession.runRemoteImageGeneration (cyclomatic 18) Packages/OsaurusCore/Views/Chat/ChatView.swift:6041— ChatSession.runRemoteImageGeneration has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeMarkdownTableView.relayoutImpl (cyclomatic 18) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:1297— NativeMarkdownTableView.relayoutImpl has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OverviewTab.commonFacts (cyclomatic 18) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1143— OverviewTab.commonFacts has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: OverviewTab.systemDetailLabel (cyclomatic 23) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
OverviewTab.whereRows (cyclomatic 18) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1249— OverviewTab.whereRows has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: OverviewTab.systemDetailLabel (cyclomatic 23) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
KnowledgeView.body (cyclomatic 18) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:71— KnowledgeView.body has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MemoryView.diagnosticHeadline (cyclomatic 18) Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:1001— MemoryView.diagnosticHeadline has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatPickerOptionsSnapshot.make (cyclomatic 18) Packages/OsaurusCore/Views/Model/ChatModelPickerCard.swift:73— ChatPickerOptionsSnapshot.make has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRowCellView.layout (cyclomatic 18) Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:795— ModelRowCellView.layout has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ToolsManagerView.allToolsTabContent (cyclomatic 18) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:187— ToolsManagerView.allToolsTabContent has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DOCXEditor.replaceText (cyclomatic 18) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:190— DOCXEditor.replaceText has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PPTXEditor.replaceText (cyclomatic 18) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:119— PPTXEditor.replaceText has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXEditor.setCell (cyclomatic 18) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:231— XLSXEditor.setCell has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XLSXEditor.shiftAnnotations (cyclomatic 18) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:628— XLSXEditor.shiftAnnotations has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InstallationDiagnostics.classify (cyclomatic 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift:281— InstallationDiagnostics.classify has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalDiff.classifyPerf (cyclomatic 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:447— EvalDiff.classifyPerf has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.scoreDbState (cyclomatic 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1775— EvalRunner.scoreDbState has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalRunner.scoreComputerUseLane (cyclomatic 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:548— EvalRunner.scoreComputerUseLane has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRemoteProviderBootstrap.preset (cyclomatic 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/RemoteProviderBootstrap.swift:93— EvalRemoteProviderBootstrap.preset has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FileTreeTool.buildTree (cyclomatic 17) Packages/OsaurusCore/Folder/FolderTools.swift:775— FileTreeTool.buildTree has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to one function item inside it that branches (traverse). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
SkillArchiveProcessRunner.run (cyclomatic 17) Packages/OsaurusCore/Managers/SkillImportPolicy.swift:306— SkillArchiveProcessRunner.run has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ToastManager.handleBuiltInAction (cyclomatic 17) Packages/OsaurusCore/Managers/ToastManager.swift:354— ToastManager.handleBuiltInAction has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleUpdateAgentToolEndpoint (cyclomatic 17) Packages/OsaurusCore/Networking/HTTPHandler.swift:6344— HTTPHandler.handleUpdateAgentToolEndpoint has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleAnthropicMessagesNonStreaming (cyclomatic 17) Packages/OsaurusCore/Networking/HTTPHandler.swift:17176— HTTPHandler.handleAnthropicMessagesNonStreaming has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.parseMultipartFormData (cyclomatic 17) Packages/OsaurusCore/Networking/HTTPHandler.swift:18101— HTTPHandler.parseMultipartFormData has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BundledModelSeeder.seed (cyclomatic 17) Packages/OsaurusCore/Services/BundledModelSeeder.swift:231— BundledModelSeeder.seed has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelCompatibilityDiagnostics.evidenceRows (cyclomatic 17) Packages/OsaurusCore/Services/ModelCompatibilityDiagnostics.swift:660— ModelCompatibilityDiagnostics.evidenceRows has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentDatabase.createTable (cyclomatic 17) Packages/OsaurusCore/Storage/AgentDatabase.swift:636— AgentDatabase.createTable has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentDatabase.forbiddenReason (cyclomatic 17) Packages/OsaurusCore/Storage/AgentDatabase.swift:2364— AgentDatabase.forbiddenReason has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OsaurusInspectTool.statusEnvelope (cyclomatic 17) Packages/OsaurusCore/Tools/ConfigurationTools.swift:449— OsaurusInspectTool.statusEnvelope has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SearchKnowledgeTool.execute (cyclomatic 17) Packages/OsaurusCore/Tools/KnowledgeTools.swift:287— SearchKnowledgeTool.execute has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CNContactsService.apply (cyclomatic 17) Packages/OsaurusCore/AppleApps/Contacts/ContactsService.swift:351— CNContactsService.apply has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MapsToolFactory.placeReference (cyclomatic 17) Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:84— MapsToolFactory.placeReference has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ScreenContextDistiller.statusToken (cyclomatic 17) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:781— ScreenContextDistiller.statusToken has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatSessionImporter.parse (cyclomatic 17) Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:88— ChatSessionImporter.parse has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelManager.mergeAvailable (cyclomatic 17) Packages/OsaurusCore/Managers/Model/ModelManager.swift:1723— ModelManager.mergeAvailable has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginManager._loadAll (cyclomatic 17) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:238— PluginManager._loadAll has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginManager.deliverInitialConfig (cyclomatic 17) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:602— PluginManager.deliverInitialConfig has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ServerRuntimeSettingsStore.shouldRepairMemorySafetyOwnedCacheDefaults (cyclomatic 17) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:570— ServerRuntimeSettingsStore.shouldRepairMemorySafetyOwnedCacheDefaults has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SpokenDigitRuns.find (cyclomatic 17) Packages/OsaurusCore/PrivacyFilter/Core/SpokenNumberDetector.swift:81— SpokenDigitRuns.find has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentBundleService.resolveImportIdentity (cyclomatic 17) Packages/OsaurusCore/Services/AgentBridge/AgentBundleService.swift:255— AgentBundleService.resolveImportIdentity has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AgentChannelCustomJSONRunner.mapResult (cyclomatic 17) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:983— AgentChannelCustomJSONRunner.mapResult has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: AgentChannelCustomJSONRunnerError.errorDescription (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentChannelInboundRelay.deliverReply (cyclomatic 17) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:584— AgentChannelInboundRelay.deliverReply has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentLoopModelStep.classifyTerminal (cyclomatic 17) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:207— AgentLoopModelStep.classifyTerminal has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentToolLoop.completedDesktopSummaryBeforeMalformedRepeat (cyclomatic 17) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:1627— AgentToolLoop.completedDesktopSummaryBeforeMalformedRepeat has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MicroPerfEvaluator.measureRep (cyclomatic 17) Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:497— MicroPerfEvaluator.measureRep has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkbookWorkflowValidator.validateCell (cyclomatic 17) Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:445— WorkbookWorkflowValidator.validateCell has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PendingImportProcessor.decideSetting (cyclomatic 17) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:435— PendingImportProcessor.decideSetting has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ClaudeCodeStreamDecoder.decodeStreamEvent (cyclomatic 17) Packages/OsaurusCore/Services/Inference/ClaudeCodeStreamDecoder.swift:103— ClaudeCodeStreamDecoder.decodeStreamEvent has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MemorySearchService.searchTranscript (cyclomatic 17) Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:443— MemorySearchService.searchTranscript has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Registry.snapshotDiagnostics (cyclomatic 17) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:656— Registry.snapshotDiagnostics has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InstalledClaudePluginsAggregator.buildPlugins (cyclomatic 17) Packages/OsaurusCore/Services/Plugin/InstalledClaudePluginsAggregator.swift:494— InstalledClaudePluginsAggregator.buildPlugins has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginHostContext.ssrfBlockedIPv4 (cyclomatic 17) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:3053— PluginHostContext.ssrfBlockedIPv4 has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ProviderNetworkDiagnostics.remoteModelDiscoveryRow (cyclomatic 17) Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:319— ProviderNetworkDiagnostics.remoteModelDiscoveryRow has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderService.geminiImageGenerateContent (cyclomatic 17) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3740— RemoteProviderService.geminiImageGenerateContent has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceAgentLiveness.classify (cyclomatic 17) Packages/OsaurusCore/Services/Router/WorkspaceAgentLiveness.swift:78— WorkspaceAgentLiveness.classify has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceSyncService.startStream (cyclomatic 17) Packages/OsaurusCore/Services/Router/WorkspaceSyncService.swift:181— WorkspaceSyncService.startStream has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SearchHTML.blockedIPv4Reason (cyclomatic 17) Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:361— SearchHTML.blockedIPv4Reason has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TextSubagentKind.matchesApprovedAuthority (cyclomatic 17) Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:861— TextSubagentKind.matchesApprovedAuthority has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatCrossSelection.updateSelection (cyclomatic 17) Packages/OsaurusCore/Views/Chat/ChatCrossSelection.swift:187— ChatCrossSelection.updateSelection has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentSidebarRow.body (cyclomatic 17) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1303— AgentSidebarRow.body has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSession.modelVisibleAssistantMessage (cyclomatic 17) Packages/OsaurusCore/Views/Chat/ChatView.swift:2489— ChatSession.modelVisibleAssistantMessage has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FloatingInputCard.refreshMTPLayoutAdvisory (cyclomatic 17) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4495— FloatingInputCard.refreshMTPLayoutAdvisory has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
VoiceStateSyncObservers.body (cyclomatic 17) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:9482— VoiceStateSyncObservers.body has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeActivityGroupView.configure (cyclomatic 17) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:90— NativeActivityGroupView.configure has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NativeMarkdownView.measureMixedSegmentHeight (cyclomatic 17) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:747— NativeMarkdownView.measureMixedSegmentHeight has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeMessageCellView.configureAsParagraph (cyclomatic 17) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2298— NativeMessageCellView.configureAsParagraph has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: ContentBlockKind.kindTag (cyclomatic 18) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
PreviewGenerator.resultPreview (cyclomatic 17) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:246— PreviewGenerator.resultPreview has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnchoredCardCoordinator.handle (cyclomatic 17) Packages/OsaurusCore/Views/Common/AnchoredCardPresenter.swift:517— AnchoredCardCoordinator.handle has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SettingsEmptyState.body (cyclomatic 17) Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:55— SettingsEmptyState.body has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MemoryConsoleInspectSheet.metadataGrid (cyclomatic 17) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:789— MemoryConsoleInspectSheet.metadataGrid has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelDetailView.manifestStatus (cyclomatic 17) Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1188— ModelDetailView.manifestStatus has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CommandLineToolSection.resolveCLIExecutableURL (cyclomatic 17) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:122— CommandLineToolSection.resolveCLIExecutableURL has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SystemPermissionRow.body (cyclomatic 17) Packages/OsaurusCore/Views/Settings/PermissionsView.swift:120— SystemPermissionRow.body has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspaceDetailView.poolSection (cyclomatic 17) Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:404— WorkspaceDetailView.poolSection has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ScreenshotController.capture (cyclomatic 17) Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:151— ScreenshotController.capture has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
XLSXEditor.expandSharedFormulas (cyclomatic 17) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:586— XLSXEditor.expandSharedFormulas has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
main.swift.buildHelperHostAPI (cyclomatic 17) Packages/OsaurusCore/PluginHost/main.swift:269— main.swift.buildHelperHostAPI has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MarkdownMessageView.swift.groupBlocksIntoSegments::emitBlock (cyclomatic 17) Packages/OsaurusCore/Views/Chat/MarkdownMessageView.swift:316— MarkdownMessageView.swift.groupBlocksIntoSegments::emitBlock has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Accessibility.swift.focusedViewport (cyclomatic 17) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1217— Accessibility.swift.focusedViewport has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Accessibility.swift.listWindowsForPid (cyclomatic 17) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1651— Accessibility.swift.listWindowsForPid has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
plan-installed-vision.main (cyclomatic 17) scripts/evals/plan-installed-vision.py:105— plan-installed-vision.main has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CoordCommand.runLock (cyclomatic 16) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Coord/CoordCommand.swift:115— CoordCommand.runLock has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
OsaurusEvalsCLI.runCompat (cyclomatic 16) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:210— OsaurusEvalsCLI.runCompat has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EvalBootstrap.applyKVRegimeOverrideIfRequested (cyclomatic 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalBootstrap.swift:737— EvalBootstrap.applyKVRegimeOverrideIfRequested has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalMatrix.comparabilityWarnings (cyclomatic 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:310— EvalMatrix.comparabilityWarnings has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GlobalProxyConfiguration.init (cyclomatic 16) Packages/OsaurusNetworking/Sources/GlobalProxyConfiguration.swift:67— GlobalProxyConfiguration.init has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BundleSetting.originProblem (cyclomatic 16) Packages/OsaurusRepository/BundleSettings.swift:144— BundleSetting.originProblem has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FileReadImageSupport.load (cyclomatic 16) Packages/OsaurusCore/Folder/FileReadImageSupport.swift:54— FileReadImageSupport.load has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
OpenAICompatibleTTSClient.decodeCompressedAudio (cyclomatic 16) Packages/OsaurusCore/Managers/OpenAICompatibleTTSClient.swift:164— OpenAICompatibleTTSClient.decodeCompressedAudio has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HTTPHandler.handleWorkspaceAgentRunEndpoint (cyclomatic 16) Packages/OsaurusCore/Networking/HTTPHandler.swift:6461— HTTPHandler.handleWorkspaceAgentRunEndpoint has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleAnswerPhonePromptEndpoint (cyclomatic 16) Packages/OsaurusCore/Networking/HTTPHandler.swift:7095— HTTPHandler.handleAnswerPhonePromptEndpoint has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleImageGenerations (cyclomatic 16) Packages/OsaurusCore/Networking/HTTPHandler.swift:12757— HTTPHandler.handleImageGenerations has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RelayTunnelManager.relayStreamingResponse (cyclomatic 16) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:939— RelayTunnelManager.relayStreamingResponse has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SchemaJSONSlices.valueEnd (cyclomatic 16) Packages/OsaurusCore/Networking/RequestValidator.swift:138— SchemaJSONSlices.valueEnd has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DeclaredReasoningEffort.fixedNativeEffort (cyclomatic 16) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:355— DeclaredReasoningEffort.fixedNativeEffort has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
GitHubSkillService.detectDefaultBranch (cyclomatic 16) Packages/OsaurusCore/Services/GitHubSkillService.swift:1929— GitHubSkillService.detectDefaultBranch has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelRuntime.resolveLocalModelDirectory (cyclomatic 16) Packages/OsaurusCore/Services/ModelRuntime.swift:8306— ModelRuntime.resolveLocalModelDirectory has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 3 of the 16 points are its own statements and the rest belongs to 3 function items inside it that branch (scan, loadableBundle, withoutCrackSuffix). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
ActivityLogStore.verify (cyclomatic 16) Packages/OsaurusCore/Storage/ActivityLogStore.swift:491— ActivityLogStore.verify has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ActivityLogStore.whereClause (cyclomatic 16) Packages/OsaurusCore/Storage/ActivityLogStore.swift:895— ActivityLogStore.whereClause has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MemoryDatabase.searchTranscriptText (cyclomatic 16) Packages/OsaurusCore/Storage/MemoryDatabase.swift:2359— MemoryDatabase.searchTranscriptText has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SandboxExecTool.execute (cyclomatic 16) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2665— SandboxExecTool.execute has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CapabilitiesLoadTool.loadSkill (cyclomatic 16) Packages/OsaurusCore/Tools/CapabilityTools.swift:1540— CapabilitiesLoadTool.loadSkill has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EditKnowledgeTool.execute (cyclomatic 16) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:822— EditKnowledgeTool.execute has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RenderChartTool.unwrapQuotedDelimitedPayload (cyclomatic 16) Packages/OsaurusCore/Tools/RenderChartTool.swift:802— RenderChartTool.unwrapQuotedDelimitedPayload has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SandboxSecretSetTool.execute (cyclomatic 16) Packages/OsaurusCore/Tools/SandboxSecretTools.swift:125— SandboxSecretSetTool.execute has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SecretArgumentScrubber.scrubForPersistence (cyclomatic 16) Packages/OsaurusCore/Tools/SandboxSecretTools.swift:337— SecretArgumentScrubber.scrubForPersistence has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoginShellPath.probe (cyclomatic 16) Packages/OsaurusCore/Utils/LoginShellPath.swift:60— LoginShellPath.probe has cyclomatic complexity 16 (threshold 15). Of this number, 13 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CalendarUpdateEventTool.run (cyclomatic 16) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:297— CalendarUpdateEventTool.run has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatDBMessagesService.send (cyclomatic 16) Packages/OsaurusCore/AppleApps/Messages/MessagesService.swift:490— ChatDBMessagesService.send has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeMacDriver.perform (cyclomatic 16) Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:192— NativeMacDriver.perform has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentToolSelectionResolver.apply (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/AgentToolSelectionResolver.swift:124— AgentToolSelectionResolver.apply has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigApplier.patchCapabilities (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:859— ConfigApplier.patchCapabilities has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigPlanner.validatePruneAgentReferences (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:266— ConfigPlanner.validatePruneAgentReferences has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.summarizePortableSettings (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1352— ConfigPlanner.summarizePortableSettings has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ConfigPlanner.planAgents (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1378— ConfigPlanner.planAgents has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
OsaurusConfigTool.loadDocument (cyclomatic 16) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:744— OsaurusConfigTool.loadDocument has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSessionImportCoordinator.run (cyclomatic 16) Packages/OsaurusCore/Managers/Chat/ChatSessionImportCoordinator.swift:120— ChatSessionImportCoordinator.run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelManager.scanLocalModels::scanDir (cyclomatic 16) Packages/OsaurusCore/Managers/Model/ModelManager.swift:2428— ModelManager.scanLocalModels::scanDir has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelLiveProofReadiness.telegram (cyclomatic 16) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:40— AgentChannelLiveProofReadiness.telegram has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelLiveProofReadiness.imessage (cyclomatic 16) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:203— AgentChannelLiveProofReadiness.imessage has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelInfo.findModelDirectory (cyclomatic 16) Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:324— ModelInfo.findModelDirectory has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Template.document (cyclomatic 16) Packages/OsaurusCore/Models/Template/Template+Agent.swift:77— Template.document has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelConnectionService.diagnostics (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:98— AgentChannelConnectionService.diagnostics has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelCustomJSONRunner.blockedIPv4Reason (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1896— AgentChannelCustomJSONRunner.blockedIPv4Reason has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: AgentChannelCustomJSONRunnerError.errorDescription (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentChannelDispatchRouter.resolve (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelDispatchRouter.swift:32— AgentChannelDispatchRouter.resolve has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentChannelMessageFormatter.stripInlineMarkdown (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:124— AgentChannelMessageFormatter.stripInlineMarkdown has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (AgentChannelMessageFormatter.telegramInlineHTML) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
AgentChannelMessageFormatter.markdownBlocks (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:181— AgentChannelMessageFormatter.markdownBlocks has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AgentChannelMessageFormatter.telegramInlineHTML (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:330— AgentChannelMessageFormatter.telegramInlineHTML has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (AgentChannelMessageFormatter.stripInlineMarkdown) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
AgentChannelPublishService.operatorSend (cyclomatic 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:594— AgentChannelPublishService.operatorSend has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OwnerDeviceAccessHost.handle (cyclomatic 16) Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:286— OwnerDeviceAccessHost.handle has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChannelReplyTokenService.validateToken (cyclomatic 16) Packages/OsaurusCore/Services/Channels/ChannelReplyTokenService.swift:96— ChannelReplyTokenService.validateToken has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DiscordConnectionService.diagnostics (cyclomatic 16) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:527— DiscordConnectionService.diagnostics has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DiscordGatewayPresenceRuntime.runSession (cyclomatic 16) Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:193— DiscordGatewayPresenceRuntime.runSession has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PDFAdapter.glyphs (cyclomatic 16) Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:182— PDFAdapter.glyphs has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PPTXAdapter.securityMetadata (cyclomatic 16) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:714— PPTXAdapter.securityMetadata has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileChangeJournal.markEntries (cyclomatic 16) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal+Revert.swift:343— FileChangeJournal.markEntries has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FileDiffEngine.wordRanges (cyclomatic 16) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:412— FileDiffEngine.wordRanges has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentDescriptionBackfill.run (cyclomatic 16) Packages/OsaurusCore/Services/Inference/AgentDescriptionBackfill.swift:114— AgentDescriptionBackfill.run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DecisionService.execute (cyclomatic 16) Packages/OsaurusCore/Services/Inference/DecisionService.swift:132— DecisionService.execute has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
StreamingStatsHint.encode (cyclomatic 16) Packages/OsaurusCore/Services/Inference/ModelService.swift:523— StreamingStatsHint.encode has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MediaJob.finish (cyclomatic 16) Packages/OsaurusCore/Services/Insights/MediaActivityLogger.swift:249— MediaJob.finish has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MediaGenerationCoordinator.scheduleRecovery (cyclomatic 16) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:390— MediaGenerationCoordinator.scheduleRecovery has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginHostContext.taskStateDict (cyclomatic 16) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:3187— PluginHostContext.taskStateDict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteChatRequest.isStrictResponsesToolSchema::isStrict (cyclomatic 16) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5704— RemoteChatRequest.isStrictResponsesToolSchema::isStrict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InboundSharedRunBridge.isUnchangedPrefix (cyclomatic 16) Packages/OsaurusCore/Services/Router/InboundSharedRunBridge.swift:257— InboundSharedRunBridge.isUnchangedPrefix has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
WorkspaceRosterStore.refresh (cyclomatic 16) Packages/OsaurusCore/Services/Router/WorkspaceRosterStore.swift:287— WorkspaceRosterStore.refresh has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
WorkspacesService.migrateShares (cyclomatic 16) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:1021— WorkspacesService.migrateShares has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: WorkspacesService.message (cyclomatic 30) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
WorkspacesService.pollConfirmation (cyclomatic 16) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:1607— WorkspacesService.pollConfirmation has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: WorkspacesService.message (cyclomatic 30) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentsView.body (cyclomatic 16) Packages/OsaurusCore/Views/Agent/AgentsView.swift:113— AgentsView.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSessionSidebar.workspaceSections (cyclomatic 16) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:787— ChatSessionSidebar.workspaceSections has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatTabContextMenu.makeMenu (cyclomatic 16) Packages/OsaurusCore/Views/Chat/ChatTabStripView.swift:821— ChatTabContextMenu.makeMenu has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatSession.applyPickerItems (cyclomatic 16) Packages/OsaurusCore/Views/Chat/ChatView.swift:1736— ChatSession.applyPickerItems has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatView.pinRemoteAgentModelAfterConnect (cyclomatic 16) Packages/OsaurusCore/Views/Chat/ChatView.swift:10916— ChatView.pinRemoteAgentModelAfterConnect has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.checkForSilenceTimeout (cyclomatic 16) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:1633— FloatingInputCard.checkForSilenceTimeout has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FloatingInputCard.handleBuiltInSlashAction (cyclomatic 16) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:2154— FloatingInputCard.handleBuiltInSlashAction has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FloatingInputCard.modelPickerOptionsControl (cyclomatic 16) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:3343— FloatingInputCard.modelPickerOptionsControl has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PasteMonitorView.handlePasteIfImage (cyclomatic 16) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:6626— PasteMonitorView.handlePasteIfImage has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NativeArtifactCardView.minimumHeightWithFooterChrome (cyclomatic 16) Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:168— NativeArtifactCardView.minimumHeightWithFooterChrome has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
NativeCodeBlockView.configure (cyclomatic 16) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:522— NativeCodeBlockView.configure has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NativeToolCallGroupView.configure (cyclomatic 16) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:702— NativeToolCallGroupView.configure has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CreditsView.webSearchCard (cyclomatic 16) Packages/OsaurusCore/Views/Credits/CreditsView.swift:432— CreditsView.webSearchCard has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatPickerRow.body (cyclomatic 16) Packages/OsaurusCore/Views/Model/ChatModelPickerCard.swift:759— ChatPickerRow.body has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelDownloadView.body (cyclomatic 16) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:163— ModelDownloadView.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelDownloadView.makeGridLists::applySort (cyclomatic 16) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1700— ModelDownloadView.makeGridLists::applySort has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PluginDetailView.body (cyclomatic 16) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1469— PluginDetailView.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelConnectionCenterView.applyNativeBadges (cyclomatic 16) Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:798— AgentChannelConnectionCenterView.applyNativeBadges has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators. This is NOT this file's highest cyclomatic complexity: AgentChannelConnectionCenterView.body (cyclomatic 18) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
VADModeSettingsTab.testAreaCard (cyclomatic 16) Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:313— VADModeSettingsTab.testAreaCard has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
WorkspaceSharedAgentRow.statusText (cyclomatic 16) Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:1623— WorkspaceSharedAgentRow.statusText has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CreateWorkspaceSheet.body (cyclomatic 16) Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:232— CreateWorkspaceSheet.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ActivateWorkspaceSheet.body (cyclomatic 16) Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:482— ActivateWorkspaceSheet.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
XLSXFormula.scan::readCell (cyclomatic 16) Packages/OsaurusCore/Services/Documents/OOXML/XLSXFormula.swift:79— XLSXFormula.scan::readCell has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators. This shape REPEATS in the file: one other method here (XLSXFormula.scan) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
MCPOAuthService.performRefresh (cyclomatic 16) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthService.swift:327— MCPOAuthService.performRefresh has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: MCPOAuthError.errorDescription (cyclomatic 19) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
AgentTemplateCard.body (cyclomatic 16) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:35— AgentTemplateCard.body has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SaveAgentTemplateSheet.preview (cyclomatic 16) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:237— SaveAgentTemplateSheet.preview has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
main.swift.handleRequest (cyclomatic 16) Packages/OsaurusCore/PluginHost/main.swift:473— main.swift.handleRequest has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RemoteProviderEditSheet.swift.parsePastedEndpoint (cyclomatic 16) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:52— RemoteProviderEditSheet.swift.parsePastedEndpoint has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Repeated repair: Packages/OsaurusCore/Views/Common/CodeBlockView.swift Packages/OsaurusCore/Views/Common/CodeBlockView.swift:524— Packages/OsaurusCore/Views/Common/CodeBlockView.swift changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is CodeNSTextView.draw at line 524), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix right-click copy dropping the chat drag selection (#2899)”; “fix theme editor color picker jitter and hex input (#2673)”; “fixed main thread hangs (#2619)”; “fixed text selection in agent responses (#2247)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-28..2026-10-26, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-28 04:00:54 -07:00' --until='2026-10-26 04:00:54 -07:00' --full-history --no-merges -- Packages/OsaurusCore/Views/Common/CodeBlockView.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
HackComment Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalBootstrap.swift:779— // hack the resolved plan can undo. — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
ConfigPlanner.validate (cognitive 452) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:400— ConfigPlanner.validate has cognitive complexity 452 (threshold 15). Drivers by points: if/else 123 (356 pts), loops 20 (50 pts), boolean chains 39, match/switch 2 (7 pts) (nesting depth added 268). Of this number, 449 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
AgentToolLoop.run (cognitive 411) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:2334— AgentToolLoop.run has cognitive complexity 411 (threshold 15). Drivers by points: if/else 89 (333 pts), boolean chains 51, loops 6 (21 pts), ternaries 1 (4 pts), match/switch 1 (2 pts) (nesting depth added 263). Of this number, 402 points are the body's own statements and 9 belong to 4 function items inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
AppleScriptLoop.run (cognitive 307) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:310— AppleScriptLoop.run has cognitive complexity 307 (threshold 15). Drivers by points: if/else 82 (176 pts), boolean chains 66, ternaries 20 (51 pts), match/switch 4 (11 pts), error handling 1 (2 pts), loops 1 (nesting depth added 133). Of this number, 305 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.channelRead (cognitive 295) Packages/OsaurusCore/Networking/HTTPHandler.swift:489— HTTPHandler.channelRead has cognitive complexity 295 (threshold 15). Drivers by points: if/else 111 (150 pts), boolean chains 130, ternaries 2 (8 pts), match/switch 2 (5 pts), loops 1 (2 pts) (nesting depth added 49). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SubagentSession.runPrepared (cognitive 292) Packages/OsaurusCore/Subagent/SubagentSession.swift:519— SubagentSession.runPrepared has cognitive complexity 292 (threshold 15). Drivers by points: if/else 75 (189 pts), ternaries 17 (54 pts), boolean chains 20, error handling 8 (16 pts), match/switch 4 (13 pts) (nesting depth added 168). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
HTTPHandler.handleAgentRunEndpoint (cognitive 221) Packages/OsaurusCore/Networking/HTTPHandler.swift:9936— HTTPHandler.handleAgentRunEndpoint has cognitive complexity 221 (threshold 15). Drivers by points: if/else 99 (138 pts), ternaries 24 (36 pts), boolean chains 28, loops 7 (11 pts), error handling 3 (4 pts), match/switch 3 (4 pts) (nesting depth added 57). Of this number, 216 points are the body's own statements and 5 belong to 3 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.processStreamDeltas (cognitive 211) Packages/OsaurusCore/Views/Chat/ChatView.swift:5189— ChatSession.processStreamDeltas has cognitive complexity 211 (threshold 15). Drivers by points: if/else 58 (155 pts), ternaries 7 (21 pts), boolean chains 14, match/switch 3 (12 pts), loops 2 (8 pts), error handling 1 (nesting depth added 126). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ClaudePluginInstaller.install (cognitive 206) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:221— ClaudePluginInstaller.install has cognitive complexity 206 (threshold 15). Drivers by points: if/else 24 (110 pts), loops 11 (48 pts), ternaries 4 (18 pts), match/switch 4 (14 pts), boolean chains 12, error handling 1 (4 pts) (nesting depth added 150). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ConfigApplier.applyMCPServers (cognitive 199) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1352— ConfigApplier.applyMCPServers has cognitive complexity 199 (threshold 15). Drivers by points: if/else 46 (140 pts), ternaries 8 (28 pts), loops 6 (17 pts), boolean chains 11, match/switch 1 (3 pts) (nesting depth added 127). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RemoteProviderService._streamRemote (cognitive 188) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2851— RemoteProviderService._streamRemote has cognitive complexity 188 (threshold 15). Drivers by points: if/else 45 (143 pts), boolean chains 18, loops 5 (16 pts), error handling 3 (9 pts), ternaries 2 (nesting depth added 115). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
XLSXEditor.shiftRows (cognitive 185) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:328— XLSXEditor.shiftRows has cognitive complexity 185 (threshold 15). Drivers by points: if/else 54 (105 pts), loops 26 (40 pts), boolean chains 30, ternaries 7 (10 pts) (nesting depth added 68). Of this number, 182 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ComputerUseLoop.run (cognitive 172) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:209— ComputerUseLoop.run has cognitive complexity 172 (threshold 15). Drivers by points: if/else 51 (132 pts), match/switch 4 (14 pts), boolean chains 9, error handling 4 (9 pts), ternaries 3 (7 pts), loops 1 (nesting depth added 100). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPromptComposer.resolveTools (cognitive 166) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:2713— SystemPromptComposer.resolveTools has cognitive complexity 166 (threshold 15). Drivers by points: if/else 56 (97 pts), loops 19 (41 pts), boolean chains 24, match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 65). Of this number, 162 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusBundle.load (cognitive 164) Packages/OsaurusRepository/OsaurusBundle.swift:356— OsaurusBundle.load has cognitive complexity 164 (threshold 15). Drivers by points: if/else 63 (120 pts), loops 14 (21 pts), boolean chains 13, error handling 5 (7 pts), match/switch 1 (2 pts), ternaries 1 (nesting depth added 67). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContentBlock.generateBlocks (cognitive 156) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:591— ContentBlock.generateBlocks has cognitive complexity 156 (threshold 15). Drivers by points: boolean chains 71, if/else 30 (61 pts), ternaries 7 (17 pts), loops 3 (7 pts) (nesting depth added 45). Of this number, 153 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runAgentLoopCaseWithSettings (cognitive 138) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:33— EvalRunner.runAgentLoopCaseWithSettings has cognitive complexity 138 (threshold 15). Drivers by points: if/else 54 (77 pts), boolean chains 27, loops 15 (20 pts), ternaries 5 (7 pts), match/switch 2 (4 pts), error handling 2 (3 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenizerBridge.applyChatTemplate (cognitive 135) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:211— TokenizerBridge.applyChatTemplate has cognitive complexity 135 (threshold 15). Drivers by points: boolean chains 74, if/else 30 (40 pts), ternaries 4 (10 pts), error handling 5 (9 pts), loops 1 (2 pts) (nesting depth added 21). Of this number, 133 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
CapabilityClaimsEvaluator.runConversation (cognitive 132) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:209— CapabilityClaimsEvaluator.runConversation has cognitive complexity 132 (threshold 15). Drivers by points: if/else 26 (80 pts), ternaries 11 (19 pts), boolean chains 15, loops 3 (8 pts), error handling 3 (7 pts), match/switch 1 (3 pts) (nesting depth added 73). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPromptComposer.appendGatedSections (cognitive 126) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:968— SystemPromptComposer.appendGatedSections has cognitive complexity 126 (threshold 15). Drivers by points: if/else 46 (71 pts), boolean chains 32, ternaries 8 (21 pts), loops 1 (2 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDownloadService.runOrchestration (cognitive 125) Packages/OsaurusCore/Services/ModelDownloadService.swift:376— ModelDownloadService.runOrchestration has cognitive complexity 125 (threshold 15). Drivers by points: if/else 35 (80 pts), ternaries 7 (17 pts), boolean chains 12, loops 3 (7 pts), match/switch 2 (6 pts), error handling 3 (nesting depth added 63). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
HTTPHandler.handleChatCompletions (cognitive 123) Packages/OsaurusCore/Networking/HTTPHandler.swift:14446— HTTPHandler.handleChatCompletions has cognitive complexity 123 (threshold 15). Drivers by points: if/else 35 (87 pts), loops 4 (12 pts), boolean chains 8, match/switch 2 (7 pts), ternaries 2 (5 pts), error handling 2 (4 pts) (nesting depth added 70). Of this number, 119 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ImageGenerationService.drive (cognitive 118) Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationService.swift:690— ImageGenerationService.drive has cognitive complexity 118 (threshold 15). Drivers by points: if/else 35 (92 pts), boolean chains 8, error handling 4 (7 pts), loops 2 (5 pts), match/switch 1 (4 pts), ternaries 1 (2 pts) (nesting depth added 67). Of this number, 114 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
MarkdownBlockParsing.swift.parseBlocks (cognitive 117) Packages/OsaurusCore/Utils/MarkdownBlockParsing.swift:121— MarkdownBlockParsing.swift.parseBlocks has cognitive complexity 117 (threshold 15). Drivers by points: if/else 31 (84 pts), loops 8 (22 pts), boolean chains 7, ternaries 2 (4 pts) (nesting depth added 69). Of this number, 107 points are the body's own statements and 10 belong to 4 function items inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
HTTPHandler.handleOpenResponsesStreaming (cognitive 115) Packages/OsaurusCore/Networking/HTTPHandler.swift:17694— HTTPHandler.handleOpenResponsesStreaming has cognitive complexity 115 (threshold 15). Drivers by points: if/else 28 (78 pts), boolean chains 11, ternaries 4 (10 pts), match/switch 2 (6 pts), error handling 2 (5 pts), loops 2 (5 pts) (nesting depth added 66). Of this number, 112 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatEngine.completeChat (cognitive 114) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1743— ChatEngine.completeChat has cognitive complexity 114 (threshold 15). Drivers by points: if/else 17 (62 pts), ternaries 8 (25 pts), boolean chains 14, error handling 2 (6 pts), loops 2 (6 pts), match/switch 1 (nesting depth added 70). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.loadContainer (cognitive 113) Packages/OsaurusCore/Services/ModelRuntime.swift:4520— ModelRuntime.loadContainer has cognitive complexity 113 (threshold 15). Drivers by points: if/else 37 (81 pts), error handling 8 (16 pts), boolean chains 10, ternaries 2 (4 pts), loops 2 (nesting depth added 54). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatEngine.wrapStreamWithLogging (cognitive 108) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:1312— ChatEngine.wrapStreamWithLogging has cognitive complexity 108 (threshold 15). Drivers by points: if/else 34 (88 pts), boolean chains 10, ternaries 2 (4 pts), error handling 3, loops 1 (2 pts), match/switch 1 (nesting depth added 57). Of this number, 106 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ConfigPlanner.planMCPServers (cognitive 107) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1994— ConfigPlanner.planMCPServers has cognitive complexity 107 (threshold 15). Drivers by points: if/else 22 (71 pts), loops 6 (18 pts), boolean chains 12, match/switch 1 (3 pts), ternaries 1 (3 pts) (nesting depth added 65). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CalculatorNode.exactInteger (cognitive 106) Packages/OsaurusCore/Utils/CalculatorEngine.swift:360— CalculatorNode.exactInteger has cognitive complexity 106 (threshold 15). Drivers by points: if/else 19 (51 pts), ternaries 11 (32 pts), loops 4 (11 pts), boolean chains 7, match/switch 3 (5 pts) (nesting depth added 62). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AgentLoopEvaluator.runConversation (cognitive 106) Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:702— AgentLoopEvaluator.runConversation has cognitive complexity 106 (threshold 15). Drivers by points: if/else 40 (56 pts), boolean chains 20, ternaries 17, error handling 4 (6 pts), loops 3 (4 pts), match/switch 2 (3 pts) (nesting depth added 20). Of this number, 77 points are the body's own statements and 29 belong to 7 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AgentTaskState.record (cognitive 105) Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:662— AgentTaskState.record has cognitive complexity 105 (threshold 15). Drivers by points: if/else 40 (58 pts), boolean chains 29, ternaries 8 (15 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteChatRequest.toOpenResponsesRequest (cognitive 104) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5754— RemoteChatRequest.toOpenResponsesRequest has cognitive complexity 104 (threshold 15). Drivers by points: if/else 28 (64 pts), boolean chains 16, loops 3 (9 pts), match/switch 3 (9 pts), ternaries 5 (6 pts) (nesting depth added 49). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runCacheProofCase (cognitive 101) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerCacheProof.swift:158— EvalRunner.runCacheProofCase has cognitive complexity 101 (threshold 15). Drivers by points: if/else 45 (52 pts), boolean chains 29, ternaries 8 (14 pts), loops 5, match/switch 1 (nesting depth added 13). Of this number, 98 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FileReadTool.readResolved (cognitive 96) Packages/OsaurusCore/Folder/FolderTools.swift:1175— FileReadTool.readResolved has cognitive complexity 96 (threshold 15). Drivers by points: if/else 48 (65 pts), boolean chains 18, ternaries 2 (5 pts), error handling 2 (4 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatView.chatModeContent (cognitive 93) Packages/OsaurusCore/Views/Chat/ChatView.swift:10106— ChatView.chatModeContent has cognitive complexity 93 (threshold 15). Drivers by points: if/else 45 (64 pts), ternaries 7 (14 pts), boolean chains 13, loops 1, match/switch 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runToolResultGroundingCase (cognitive 91) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerToolResultGrounding.swift:14— EvalRunner.runToolResultGroundingCase has cognitive complexity 91 (threshold 15). Drivers by points: if/else 34 (73 pts), loops 7 (13 pts), boolean chains 3, ternaries 2 (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMessageCellView.configureAsUserMessage (cognitive 90) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2602— NativeMessageCellView.configureAsUserMessage has cognitive complexity 90 (threshold 15). Drivers by points: if/else 32 (54 pts), boolean chains 16, loops 6 (12 pts), ternaries 4 (8 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handlePluginRoute (cognitive 89) Packages/OsaurusCore/Networking/HTTPHandler.swift:2873— HTTPHandler.handlePluginRoute has cognitive complexity 89 (threshold 15). Drivers by points: if/else 32 (64 pts), boolean chains 11, ternaries 2 (8 pts), loops 2 (4 pts), error handling 1, match/switch 1 (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RemoteChatRequest.toGeminiRequest (cognitive 89) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5352— RemoteChatRequest.toGeminiRequest has cognitive complexity 89 (threshold 15). Drivers by points: if/else 23 (57 pts), boolean chains 16, loops 3 (9 pts), match/switch 2 (4 pts), ternaries 3 (nesting depth added 42). Of this number, 88 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRowCellView.configure (cognitive 83) Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:510— ModelRowCellView.configure has cognitive complexity 83 (threshold 15). Drivers by points: if/else 36 (46 pts), boolean chains 23, ternaries 5 (10 pts), match/switch 2 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Functions.call (cognitive 80) Packages/OsaurusCore/Utils/CalculatorEngine.swift:700— Functions.call has cognitive complexity 80 (threshold 15). Drivers by points: if/else 24 (49 pts), ternaries 10 (18 pts), loops 3 (8 pts), boolean chains 4, match/switch 1 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFEditor.fillForm (cognitive 80) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:346— PDFEditor.fillForm has cognitive complexity 80 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 8 (23 pts), ternaries 6 (19 pts), boolean chains 7, match/switch 3 (7 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolRegistry.runPermissionGate (cognitive 79) Packages/OsaurusCore/Tools/ToolRegistry.swift:877— ToolRegistry.runPermissionGate has cognitive complexity 79 (threshold 15). Drivers by points: if/else 28 (54 pts), boolean chains 9, loops 2 (6 pts), match/switch 2 (6 pts), ternaries 1 (4 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolRegistry.execute (cognitive 79) Packages/OsaurusCore/Tools/ToolRegistry.swift:1117— ToolRegistry.execute has cognitive complexity 79 (threshold 15). Drivers by points: if/else 26 (41 pts), boolean chains 19, ternaries 6 (18 pts), match/switch 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Solver.polynomial (cognitive 79) Packages/OsaurusCore/Utils/CalculatorEngine.swift:892— Solver.polynomial has cognitive complexity 79 (threshold 15). Drivers by points: if/else 18 (45 pts), loops 4 (11 pts), boolean chains 10, ternaries 3 (10 pts), match/switch 2 (3 pts) (nesting depth added 42). Of this number, 75 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CompatibilityReport.formatMarkdown (cognitive 78) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:187— CompatibilityReport.formatMarkdown has cognitive complexity 78 (threshold 15). Drivers by points: if/else 20 (49 pts), loops 8 (16 pts), ternaries 3 (8 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusInspectTool.describeItem (cognitive 77) Packages/OsaurusCore/Tools/ConfigurationTools.swift:1301— OsaurusInspectTool.describeItem has cognitive complexity 77 (threshold 15). Drivers by points: if/else 35 (58 pts), boolean chains 12, match/switch 3 (4 pts), ternaries 1 (2 pts), error handling 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RenderChartTool.execute (cognitive 77) Packages/OsaurusCore/Tools/RenderChartTool.swift:141— RenderChartTool.execute has cognitive complexity 77 (threshold 15). Drivers by points: if/else 33 (45 pts), ternaries 6 (13 pts), boolean chains 12, loops 3 (4 pts), match/switch 1 (2 pts), error handling 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXFormula.scan (cognitive 77) Packages/OsaurusCore/Services/Documents/OOXML/XLSXFormula.swift:69— XLSXFormula.scan has cognitive complexity 77 (threshold 15). Drivers by points: if/else 17 (40 pts), boolean chains 25, loops 6 (12 pts) (nesting depth added 29). Of this number, 54 points are the body's own statements and 23 belong to 3 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ZipArchive.entries (cognitive 75) Packages/OsaurusCore/Utils/ZipArchive.swift:67— ZipArchive.entries has cognitive complexity 75 (threshold 15). Drivers by points: if/else 19 (61 pts), boolean chains 9, loops 3 (5 pts) (nesting depth added 44). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PendingImportProcessor.install (cognitive 75) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:515— PendingImportProcessor.install has cognitive complexity 75 (threshold 15). Drivers by points: if/else 17 (33 pts), ternaries 11 (21 pts), boolean chains 13, error handling 3 (4 pts), match/switch 3 (4 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchAndExtractTool.enrichedResults (cognitive 74) Packages/OsaurusCore/Tools/WebSearchTools.swift:612— SearchAndExtractTool.enrichedResults has cognitive complexity 74 (threshold 15). Drivers by points: if/else 18 (55 pts), boolean chains 12, ternaries 1 (6 pts), loops 1 (nesting depth added 42). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RemoteAnthropicNativeStream.consume (cognitive 74) Packages/OsaurusCore/Services/Provider/RemoteAnthropicNativeStream.swift:38— RemoteAnthropicNativeStream.consume has cognitive complexity 74 (threshold 15). Drivers by points: if/else 24 (53 pts), boolean chains 9, match/switch 4 (7 pts), loops 2 (5 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Skill.parseYaml (cognitive 73) Packages/OsaurusCore/Models/Agent/Skill.swift:671— Skill.parseYaml has cognitive complexity 73 (threshold 15). Drivers by points: if/else 20 (53 pts), loops 4 (12 pts), boolean chains 8 (nesting depth added 41). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RemoteResponsesNativeStream.consume (cognitive 73) Packages/OsaurusCore/Services/Provider/RemoteResponsesNativeStream.swift:26— RemoteResponsesNativeStream.consume has cognitive complexity 73 (threshold 15). Drivers by points: if/else 27 (53 pts), boolean chains 10, loops 2 (6 pts), ternaries 1 (3 pts), match/switch 1 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pi-harness-runner.runCase (cognitive 73) scripts/evals/pi-harness-runner.mjs:171— pi-harness-runner.runCase has cognitive complexity 73 (threshold 15). Drivers by points: if/else 22 (35 pts), boolean chains 16, loops 11, ternaries 5 (7 pts), error handling 2 (4 pts) (nesting depth added 17). Of this number, 72 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BoundedArchiveExtractor.inspect (cognitive 72) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:139— BoundedArchiveExtractor.inspect has cognitive complexity 72 (threshold 15). Drivers by points: if/else 29 (49 pts), boolean chains 20, error handling 2, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileSearchTool.execute (cognitive 72) Packages/OsaurusCore/Folder/FolderTools.swift:4468— FileSearchTool.execute has cognitive complexity 72 (threshold 15). Drivers by points: if/else 31 (52 pts), ternaries 4 (7 pts), boolean chains 6, match/switch 2 (5 pts), loops 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SafeDiskCachePurge.clear (cognitive 72) Packages/OsaurusCore/Services/SafeDiskCachePurge.swift:13— SafeDiskCachePurge.clear has cognitive complexity 72 (threshold 15). Drivers by points: if/else 18 (42 pts), boolean chains 21, loops 4 (8 pts), error handling 1 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CacheProofEvaluator.runConversation (cognitive 72) Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:281— CacheProofEvaluator.runConversation has cognitive complexity 72 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 10, ternaries 5 (10 pts), match/switch 3 (8 pts), error handling 2 (5 pts), loops 1 (nesting depth added 31). Of this number, 67 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SharedArtifact.resolveSourcePathDetailed (cognitive 71) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:764— SharedArtifact.resolveSourcePathDetailed has cognitive complexity 71 (threshold 15). Drivers by points: if/else 20 (57 pts), loops 2 (6 pts), ternaries 1 (4 pts), boolean chains 3, match/switch 1 (nesting depth added 44). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
PrivacyFilterPipeline.applyOutbound (cognitive 71) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:333— PrivacyFilterPipeline.applyOutbound has cognitive complexity 71 (threshold 15). Drivers by points: if/else 27 (44 pts), error handling 3 (11 pts), loops 4 (7 pts), match/switch 3 (4 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MLXBatchAdapter.additionalContext (cognitive 71) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:1259— MLXBatchAdapter.additionalContext has cognitive complexity 71 (threshold 15). Drivers by points: if/else 35 (46 pts), boolean chains 10, match/switch 3 (8 pts), ternaries 2 (4 pts), loops 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppDelegate.applicationDidFinishLaunching (cognitive 70) Packages/OsaurusCore/AppDelegate.swift:172— AppDelegate.applicationDidFinishLaunching has cognitive complexity 70 (threshold 15). Drivers by points: if/else 40 (49 pts), boolean chains 8, loops 4 (7 pts), error handling 3 (4 pts), ternaries 1 (2 pts) (nesting depth added 14). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
RemoteProviderManager.testConnection (cognitive 70) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1546— RemoteProviderManager.testConnection has cognitive complexity 70 (threshold 15). Drivers by points: if/else 22 (48 pts), error handling 7 (15 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaValidator.validateValue (cognitive 70) Packages/OsaurusCore/Tools/SchemaValidator.swift:178— SchemaValidator.validateValue has cognitive complexity 70 (threshold 15). Drivers by points: if/else 25 (56 pts), boolean chains 8, loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalVisionEvidence.read (cognitive 69) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:118— LocalVisionEvidence.read has cognitive complexity 69 (threshold 15). Drivers by points: if/else 24 (32 pts), boolean chains 29, ternaries 4 (7 pts), error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalMatrixBuilder.build (cognitive 68) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:811— EvalMatrixBuilder.build has cognitive complexity 68 (threshold 15). Drivers by points: ternaries 21 (23 pts), boolean chains 18, if/else 8 (15 pts), loops 8 (12 pts) (nesting depth added 13). Of this number, 67 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalRunner.scoreSpawnWave (cognitive 68) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1609— EvalRunner.scoreSpawnWave has cognitive complexity 68 (threshold 15). Drivers by points: if/else 23 (47 pts), boolean chains 14, loops 3 (7 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleConfigAdminEndpoint (cognitive 68) Packages/OsaurusCore/Networking/HTTPHandler.swift:2221— HTTPHandler.handleConfigAdminEndpoint has cognitive complexity 68 (threshold 15). Drivers by points: if/else 22 (39 pts), error handling 5 (10 pts), boolean chains 9, match/switch 4 (9 pts), ternaries 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GenerationEventMapper.map (cognitive 68) Packages/OsaurusCore/Services/ModelRuntime/GenerationEventMapper.swift:41— GenerationEventMapper.map has cognitive complexity 68 (threshold 15). Drivers by points: if/else 27 (57 pts), boolean chains 7, match/switch 1 (2 pts), loops 1, ternaries 1 (nesting depth added 31). Of this number, 61 points are the body's own statements and 7 belong to 3 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteChatRequest.toAnthropicRequest (cognitive 67) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5108— RemoteChatRequest.toAnthropicRequest has cognitive complexity 67 (threshold 15). Drivers by points: if/else 17 (41 pts), match/switch 3 (9 pts), loops 3 (8 pts), boolean chains 5, ternaries 3 (4 pts) (nesting depth added 36). Of this number, 66 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runAppleScriptCase (cognitive 65) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAppleScript.swift:36— EvalRunner.runAppleScriptCase has cognitive complexity 65 (threshold 15). Drivers by points: if/else 20 (35 pts), loops 10 (13 pts), ternaries 7 (13 pts), boolean chains 4 (nesting depth added 24). Of this number, 63 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.unloadClaimed (cognitive 65) Packages/OsaurusCore/Services/ModelRuntime.swift:2303— ModelRuntime.unloadClaimed has cognitive complexity 65 (threshold 15). Drivers by points: if/else 32 (49 pts), boolean chains 16 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomJSONRunner.execute (cognitive 65) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:533— AgentChannelCustomJSONRunner.execute has cognitive complexity 65 (threshold 15). Drivers by points: if/else 22 (37 pts), ternaries 9 (18 pts), error handling 5, boolean chains 3, match/switch 1 (2 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apply-ko.main (cognitive 65) scripts/i18n/apply-ko.py:85— apply-ko.main has cognitive complexity 65 (threshold 15). Drivers by points: if/else 22 (54 pts), loops 3 (7 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusBundle.select (cognitive 63) Packages/OsaurusRepository/OsaurusBundle.swift:897— OsaurusBundle.select has cognitive complexity 63 (threshold 15). Drivers by points: if/else 16 (34 pts), boolean chains 12, loops 6 (10 pts), match/switch 2 (6 pts), ternaries 1 (nesting depth added 26). Of this number, 58 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ActivityExportService.renderMarkdown (cognitive 63) Packages/OsaurusCore/Services/Insights/ActivityExportService.swift:210— ActivityExportService.renderMarkdown has cognitive complexity 63 (threshold 15). Drivers by points: if/else 15 (30 pts), ternaries 6 (13 pts), loops 6 (12 pts), boolean chains 8 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenAICompatibleStreamParser.processChoice (cognitive 63) Packages/OsaurusCore/Services/Provider/OpenAICompatibleStreamParser.swift:636— OpenAICompatibleStreamParser.processChoice has cognitive complexity 63 (threshold 15). Drivers by points: if/else 16 (41 pts), boolean chains 11, match/switch 2 (6 pts), loops 2 (5 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RedactFileTool.execute (cognitive 62) Packages/OsaurusCore/Folder/RedactionTools.swift:272— RedactFileTool.execute has cognitive complexity 62 (threshold 15). Drivers by points: if/else 28 (44 pts), boolean chains 8, loops 5 (7 pts), match/switch 2, ternaries 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyAgents (cognitive 62) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:387— ConfigApplier.applyAgents has cognitive complexity 62 (threshold 15). Drivers by points: if/else 17 (39 pts), ternaries 4 (12 pts), boolean chains 5, loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MLXModel.localBundleWeightSizeBytes (cognitive 61) Packages/OsaurusCore/Models/Configuration/MLXModel.swift:158— MLXModel.localBundleWeightSizeBytes has cognitive complexity 61 (threshold 15). Drivers by points: if/else 17 (36 pts), boolean chains 16, loops 4 (6 pts), ternaries 2, match/switch 1 (nesting depth added 21). Of this number, 49 points are the body's own statements and 12 belong to 3 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDelegationDispatcher.run (cognitive 61) Packages/OsaurusCore/Services/AgentDelegation/AgentDelegationDispatcher.swift:506— AgentDelegationDispatcher.run has cognitive complexity 61 (threshold 15). Drivers by points: if/else 19 (42 pts), ternaries 6, match/switch 3 (5 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeSearchService.search (cognitive 61) Packages/OsaurusCore/Services/Knowledge/KnowledgeSearchService.swift:186— KnowledgeSearchService.search has cognitive complexity 61 (threshold 15). Drivers by points: if/else 11 (36 pts), loops 5 (18 pts), error handling 2 (4 pts), boolean chains 3 (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ConfigApplier.applyProviders (cognitive 60) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1777— ConfigApplier.applyProviders has cognitive complexity 60 (threshold 15). Drivers by points: if/else 14 (44 pts), boolean chains 10, loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeCellHeightEstimator.estimatedHeight (cognitive 60) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:3702— NativeCellHeightEstimator.estimatedHeight has cognitive complexity 60 (threshold 15). Drivers by points: if/else 20 (37 pts), boolean chains 10, ternaries 3 (8 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 24). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
OsaurusEvalsCLI.runCommand (cognitive 59) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:150— OsaurusEvalsCLI.runCommand has cognitive complexity 59 (threshold 15). Drivers by points: if/else 19 (39 pts), error handling 5 (10 pts), loops 2 (6 pts), boolean chains 3, ternaries 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.handleOpenResponsesEvent (cognitive 59) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2332— RemoteProviderService.handleOpenResponsesEvent has cognitive complexity 59 (threshold 15). Drivers by points: if/else 18 (37 pts), boolean chains 14, match/switch 3 (6 pts), ternaries 1 (2 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.buildURLRequest (cognitive 57) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3892— RemoteProviderService.buildURLRequest has cognitive complexity 57 (threshold 15). Drivers by points: if/else 31 (45 pts), boolean chains 5, ternaries 3 (5 pts), loops 1, match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeToolCallRowView.configure (cognitive 57) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:1044— NativeToolCallRowView.configure has cognitive complexity 57 (threshold 15). Drivers by points: if/else 25 (36 pts), boolean chains 14, ternaries 2 (5 pts), match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.prepare (cognitive 56) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:251— PendingImportProcessor.prepare has cognitive complexity 56 (threshold 15). Drivers by points: if/else 12 (23 pts), error handling 6 (12 pts), ternaries 5 (11 pts), boolean chains 7, match/switch 2 (3 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RunCommand.execute (cognitive 55) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Run.swift:13— RunCommand.execute has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 3 (9 pts), error handling 3 (8 pts), boolean chains 4 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenAICompatibleTTSClient.synthesizeStreaming (cognitive 55) Packages/OsaurusCore/Managers/OpenAICompatibleTTSClient.swift:234— OpenAICompatibleTTSClient.synthesizeStreaming has cognitive complexity 55 (threshold 15). Drivers by points: if/else 13 (37 pts), loops 3 (8 pts), boolean chains 5, match/switch 1 (4 pts), error handling 1 (nesting depth added 32). Of this number, 53 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigChannelPlatform.apply (cognitive 55) Packages/OsaurusCore/Configuration/Declarative/ConfigChannelDetails.swift:102— ConfigChannelPlatform.apply has cognitive complexity 55 (threshold 15). Drivers by points: if/else 27 (54 pts), match/switch 1 (nesting depth added 27). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AgentChannelConnectionService.actionStatus (cognitive 55) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1554— AgentChannelConnectionService.actionStatus has cognitive complexity 55 (threshold 15). Drivers by points: if/else 16 (42 pts), match/switch 3 (5 pts), boolean chains 4, ternaries 1 (4 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DBImportTool.execute (cognitive 55) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1239— DBImportTool.execute has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (35 pts), error handling 3 (6 pts), boolean chains 5, ternaries 2 (5 pts), loops 1 (3 pts), match/switch 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PromotionGate.evaluate (cognitive 54) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/PromotionGate.swift:47— PromotionGate.evaluate has cognitive complexity 54 (threshold 15). Drivers by points: if/else 18 (31 pts), boolean chains 15, ternaries 3 (7 pts), loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.decodeWAVAudioSamples (cognitive 54) Packages/OsaurusCore/Services/ModelRuntime.swift:7385— ModelRuntime.decodeWAVAudioSamples has cognitive complexity 54 (threshold 15). Drivers by points: if/else 16 (26 pts), boolean chains 22, loops 3 (4 pts), match/switch 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ComputerUseLoop.act (cognitive 54) Packages/OsaurusCore/ComputerUse/Loop/ComputerUseLoop.swift:1334— ComputerUseLoop.act has cognitive complexity 54 (threshold 15). Drivers by points: if/else 26 (36 pts), match/switch 4 (7 pts), ternaries 4 (6 pts), boolean chains 5 (nesting depth added 15). Of this number, 52 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SessionRow.body (cognitive 54) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2300— SessionRow.body has cognitive complexity 54 (threshold 15). Drivers by points: if/else 17 (33 pts), ternaries 5 (11 pts), boolean chains 8, match/switch 1 (2 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FolderContextService.buildFileTree::traverse (cognitive 53) Packages/OsaurusCore/Folder/FolderContextService.swift:266— FolderContextService.buildFileTree::traverse has cognitive complexity 53 (threshold 15). Drivers by points: if/else 15 (29 pts), ternaries 5 (15 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleCompletions (cognitive 53) Packages/OsaurusCore/Networking/HTTPHandler.swift:13991— HTTPHandler.handleCompletions has cognitive complexity 53 (threshold 15). Drivers by points: if/else 17 (41 pts), loops 2 (5 pts), error handling 2 (3 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.bridgeToolEventStream (cognitive 53) Packages/OsaurusCore/Services/ModelRuntime.swift:6361— ModelRuntime.bridgeToolEventStream has cognitive complexity 53 (threshold 15). Drivers by points: if/else 16 (43 pts), match/switch 1 (3 pts), boolean chains 2, error handling 2, loops 1 (2 pts), ternaries 1 (nesting depth added 30). Of this number, 50 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RequestLog.title (cognitive 53) Packages/OsaurusCore/Models/Chat/RequestLog.swift:761— RequestLog.title has cognitive complexity 53 (threshold 15). Drivers by points: if/else 12 (23 pts), ternaries 9 (19 pts), match/switch 3 (6 pts), boolean chains 5 (nesting depth added 24). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
NativeMarkdownView.applyMixedSegments (cognitive 53) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:944— NativeMarkdownView.applyMixedSegments has cognitive complexity 53 (threshold 15). Drivers by points: if/else 21 (41 pts), boolean chains 6, ternaries 1 (3 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditTool.editDocument (cognitive 52) Packages/OsaurusCore/Folder/FolderTools.swift:3621— FileEditTool.editDocument has cognitive complexity 52 (threshold 15). Drivers by points: if/else 14 (20 pts), ternaries 6 (17 pts), boolean chains 10, loops 1 (3 pts), error handling 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginHostContext.httpRequest (cognitive 52) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2647— PluginHostContext.httpRequest has cognitive complexity 52 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 3 (7 pts), boolean chains 4, error handling 2, match/switch 1 (2 pts) (nesting depth added 25). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RemoteProviderService.buildChatRequest (cognitive 52) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3371— RemoteProviderService.buildChatRequest has cognitive complexity 52 (threshold 15). Drivers by points: boolean chains 20, if/else 16 (18 pts), ternaries 14 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MCPProviderManager.performConnect (cognitive 51) Packages/OsaurusCore/Managers/MCPProviderManager.swift:252— MCPProviderManager.performConnect has cognitive complexity 51 (threshold 15). Drivers by points: if/else 14 (36 pts), boolean chains 6, error handling 2 (5 pts), loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
HTTPHandler.handleAnthropicMessagesStreaming (cognitive 51) Packages/OsaurusCore/Networking/HTTPHandler.swift:17026— HTTPHandler.handleAnthropicMessagesStreaming has cognitive complexity 51 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 4 (11 pts), match/switch 2 (5 pts), boolean chains 4, ternaries 2 (4 pts), error handling 1 (nesting depth added 25). Of this number, 41 points are the body's own statements and 10 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelPickerItem.generateMockModels (cognitive 51) Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:1010— ModelPickerItem.generateMockModels has cognitive complexity 51 (threshold 15). Drivers by points: if/else 6 (21 pts), loops 9 (18 pts), ternaries 2 (10 pts), boolean chains 2 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalMatrix.formatMarkdown (cognitive 50) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:389— EvalMatrix.formatMarkdown has cognitive complexity 50 (threshold 15). Drivers by points: if/else 17 (33 pts), loops 7 (14 pts), boolean chains 3 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatEngine.prepareDispatch (cognitive 50) Packages/OsaurusCore/Services/Chat/ChatEngine.swift:187— ChatEngine.prepareDispatch has cognitive complexity 50 (threshold 15). Drivers by points: if/else 19 (24 pts), boolean chains 20, ternaries 4 (6 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ConfigCommand.runPlanOrApply (cognitive 49) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:149— ConfigCommand.runPlanOrApply has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (33 pts), loops 4 (7 pts), boolean chains 3, ternaries 2 (3 pts), match/switch 1 (2 pts), error handling 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppDelegate.updateStatusItemAndMenu (cognitive 49) Packages/OsaurusCore/AppDelegate.swift:1877— AppDelegate.updateStatusItemAndMenu has cognitive complexity 49 (threshold 15). Drivers by points: if/else 15 (40 pts), match/switch 2 (5 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 30). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PluginHostContext.completeStream (cognitive 49) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1807— PluginHostContext.completeStream has cognitive complexity 49 (threshold 15). Drivers by points: if/else 29 (35 pts), boolean chains 4, ternaries 2 (4 pts), loops 3, match/switch 1 (2 pts), error handling 1 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatSession.init (cognitive 49) Packages/OsaurusCore/Views/Chat/ChatView.swift:964— ChatSession.init has cognitive complexity 49 (threshold 15). Drivers by points: if/else 30 (33 pts), boolean chains 14, loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatSession.runHarnessTurn (cognitive 49) Packages/OsaurusCore/Views/Chat/ChatSession+Harness.swift:23— ChatSession.runHarnessTurn has cognitive complexity 49 (threshold 15). Drivers by points: if/else 17 (34 pts), boolean chains 4, ternaries 2 (4 pts), match/switch 1 (3 pts), error handling 2, loops 1 (2 pts) (nesting depth added 22). Of this number, 45 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AccessibilityManager.traverseElement (cognitive 49) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:769— AccessibilityManager.traverseElement has cognitive complexity 49 (threshold 15). Drivers by points: boolean chains 23, if/else 14 (19 pts), ternaries 3 (5 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderManager.connect (cognitive 48) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:387— RemoteProviderManager.connect has cognitive complexity 48 (threshold 15). Drivers by points: if/else 18 (37 pts), boolean chains 6, error handling 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Tokenizer.number (cognitive 48) Packages/OsaurusCore/Utils/CalculatorEngine.swift:277— Tokenizer.number has cognitive complexity 48 (threshold 15). Drivers by points: boolean chains 23, if/else 12 (18 pts), loops 3 (6 pts), ternaries 1 (nesting depth added 9). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigApplier.applyChannels (cognitive 48) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1179— ConfigApplier.applyChannels has cognitive complexity 48 (threshold 15). Drivers by points: if/else 15 (34 pts), ternaries 2 (6 pts), error handling 2 (4 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageGenerationService.generateVideo (cognitive 48) Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationService.swift:313— ImageGenerationService.generateVideo has cognitive complexity 48 (threshold 15). Drivers by points: if/else 13 (31 pts), ternaries 2 (7 pts), boolean chains 4, match/switch 1 (3 pts), loops 1 (2 pts), error handling 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SlackConnectionService.diagnostics (cognitive 48) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:583— SlackConnectionService.diagnostics has cognitive complexity 48 (threshold 15). Drivers by points: if/else 18 (21 pts), ternaries 5 (12 pts), boolean chains 8, loops 2 (4 pts), error handling 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FloatingInputCard.body (cognitive 48) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:908— FloatingInputCard.body has cognitive complexity 48 (threshold 15). Drivers by points: if/else 27 (33 pts), boolean chains 15 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DispatchEnvelope.badges (cognitive 47) Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:432— DispatchEnvelope.badges has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (24 pts), ternaries 9 (22 pts), match/switch 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.parseResponse (cognitive 47) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:4616— RemoteProviderService.parseResponse has cognitive complexity 47 (threshold 15). Drivers by points: match/switch 5 (16 pts), ternaries 6 (12 pts), loops 4 (11 pts), if/else 3 (8 pts) (nesting depth added 29). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SpeechService.startStreamingTranscription (cognitive 46) Packages/OsaurusCore/Managers/SpeechService.swift:906— SpeechService.startStreamingTranscription has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (34 pts), boolean chains 7, error handling 2 (4 pts), ternaries 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalGenerationDefaults.repairLagunaXS21TopKIfNeeded (cognitive 46) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:143— LocalGenerationDefaults.repairLagunaXS21TopKIfNeeded has cognitive complexity 46 (threshold 15). Drivers by points: if/else 21 (38 pts), error handling 3 (5 pts), boolean chains 2, loops 1 (nesting depth added 19). Of this number, 42 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolEnvelope.fromError (cognitive 46) Packages/OsaurusCore/Tools/ToolEnvelope.swift:222— ToolEnvelope.fromError has cognitive complexity 46 (threshold 15). Drivers by points: if/else 15 (31 pts), match/switch 4 (8 pts), ternaries 2 (7 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusConfigTool.handleApply (cognitive 46) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:396— OsaurusConfigTool.handleApply has cognitive complexity 46 (threshold 15). Drivers by points: if/else 22 (26 pts), boolean chains 10, ternaries 2 (6 pts), error handling 2, match/switch 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PrivacyFilterEngine.detect (cognitive 46) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterEngine.swift:176— PrivacyFilterEngine.detect has cognitive complexity 46 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 6 (13 pts), error handling 1 (4 pts), match/switch 2 (4 pts), boolean chains 2, ternaries 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.renameSheet (cognitive 46) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:725— XLSXEditor.renameSheet has cognitive complexity 46 (threshold 15). Drivers by points: if/else 11 (28 pts), loops 7 (12 pts), ternaries 4, boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.score (cognitive 45) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:858— EvalRunner.score has cognitive complexity 45 (threshold 15). Drivers by points: if/else 27 (29 pts), boolean chains 11, loops 2 (3 pts), ternaries 2 (nesting depth added 3). Of this number, 43 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ReadKnowledgeTool.execute (cognitive 45) Packages/OsaurusCore/Tools/KnowledgeTools.swift:451— ReadKnowledgeTool.execute has cognitive complexity 45 (threshold 15). Drivers by points: if/else 24 (32 pts), boolean chains 8, ternaries 2 (3 pts), loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FoundationModelService.dynamicSchema (cognitive 45) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:628— FoundationModelService.dynamicSchema has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (31 pts), match/switch 3 (6 pts), boolean chains 4, loops 1 (4 pts) (nesting depth added 23). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
MemorySearchService.searchTranscript (cognitive 45) Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:443— MemorySearchService.searchTranscript has cognitive complexity 45 (threshold 15). Drivers by points: if/else 9 (29 pts), loops 3 (11 pts), error handling 2 (3 pts), boolean chains 2 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDownloadView.makeGridLists (cognitive 45) Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1659— ModelDownloadView.makeGridLists has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (24 pts), match/switch 6 (7 pts), boolean chains 5, ternaries 3 (5 pts), loops 4 (nesting depth added 13). Most of this is not in the body itself: 15 of the 45 points are its own statements and the rest belongs to 8 function items inside it that branch (applySort, sortedSuggested, newestFirst, …). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
ServeCommand.execute (cognitive 44) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Serve.swift:13— ServeCommand.execute has cognitive complexity 44 (threshold 15). Drivers by points: if/else 20 (34 pts), boolean chains 8, loops 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runComputerUseLoopCase (cognitive 44) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:21— EvalRunner.runComputerUseLoopCase has cognitive complexity 44 (threshold 15). Drivers by points: if/else 20 (24 pts), ternaries 7 (12 pts), loops 5, boolean chains 3 (nesting depth added 9). Of this number, 42 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runPromptSurfaceCase (cognitive 44) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerPromptSurface.swift:19— EvalRunner.runPromptSurfaceCase has cognitive complexity 44 (threshold 15). Drivers by points: if/else 25 (30 pts), ternaries 4 (6 pts), loops 5, boolean chains 2, error handling 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MLXBatchAdapter.generate (cognitive 44) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:1562— MLXBatchAdapter.generate has cognitive complexity 44 (threshold 15). Drivers by points: if/else 23 (31 pts), boolean chains 5, error handling 4, ternaries 2 (3 pts), loops 1 (nesting depth added 9). Of this number, 42 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.finalizeRun (cognitive 44) Packages/OsaurusCore/Views/Chat/ChatView.swift:4904— ChatSession.finalizeRun has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 18, error handling 2 (6 pts), ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatView.setupKeyMonitor (cognitive 44) Packages/OsaurusCore/Views/Chat/ChatView.swift:11878— ChatView.setupKeyMonitor has cognitive complexity 44 (threshold 15). Drivers by points: if/else 18 (34 pts), boolean chains 8, loops 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsInstall.installManual (cognitive 43) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:72— ToolsInstall.installManual has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (19 pts), error handling 7 (14 pts), loops 2 (7 pts), boolean chains 3 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runCapabilityClaimsCase (cognitive 43) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1380— EvalRunner.runCapabilityClaimsCase has cognitive complexity 43 (threshold 15). Drivers by points: if/else 26 (32 pts), boolean chains 7, ternaries 2 (3 pts), loops 1 (nesting depth added 7). Of this number, 42 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ModelRuntime.attentionLayerMix (cognitive 43) Packages/OsaurusCore/Services/ModelRuntime.swift:3556— ModelRuntime.attentionLayerMix has cognitive complexity 43 (threshold 15). Drivers by points: if/else 14 (17 pts), boolean chains 14, match/switch 2 (6 pts), loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ListKnowledgeTool.execute (cognitive 43) Packages/OsaurusCore/Tools/KnowledgeTools.swift:726— ListKnowledgeTool.execute has cognitive complexity 43 (threshold 15). Drivers by points: if/else 16 (28 pts), ternaries 5 (9 pts), boolean chains 5, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyWatchers (cognitive 43) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2414— ConfigApplier.applyWatchers has cognitive complexity 43 (threshold 15). Drivers by points: if/else 16 (37 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnthropicMessagesRequest.toChatCompletionRequest (cognitive 43) Packages/OsaurusCore/Models/API/AnthropicAPI.swift:966— AnthropicMessagesRequest.toChatCompletionRequest has cognitive complexity 43 (threshold 15). Drivers by points: ternaries 5 (16 pts), if/else 7 (12 pts), match/switch 3 (8 pts), loops 3 (7 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalVisionEvidence.tensorPayloadSizes (cognitive 43) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:341— LocalVisionEvidence.tensorPayloadSizes has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 19, loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResponsesItemPayload.transform (cognitive 43) Packages/OsaurusCore/PrivacyFilter/Core/MessageScrubbing.swift:488— ResponsesItemPayload.transform has cognitive complexity 43 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 17, loops 1 (2 pts), match/switch 1 (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ImageGenerationPanelView.run (cognitive 43) Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift:728— ImageGenerationPanelView.run has cognitive complexity 43 (threshold 15). Drivers by points: ternaries 16 (30 pts), if/else 6 (8 pts), boolean chains 5 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OOXMLText.replace (cognitive 43) Packages/OsaurusCore/Services/Documents/OOXML/OOXMLText.swift:269— OOXMLText.replace has cognitive complexity 43 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 7 (12 pts), boolean chains 4, ternaries 2 (3 pts) (nesting depth added 16). Of this number, 34 points are the body's own statements and 9 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileWriteTool.execute (cognitive 42) Packages/OsaurusCore/Folder/FolderTools.swift:2403— FileWriteTool.execute has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (31 pts), match/switch 3 (6 pts), boolean chains 4, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.parseMultipartFormData (cognitive 42) Packages/OsaurusCore/Networking/HTTPHandler.swift:18101— HTTPHandler.parseMultipartFormData has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (37 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelInboundRelay.deliverReply (cognitive 42) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:584— AgentChannelInboundRelay.deliverReply has cognitive complexity 42 (threshold 15). Drivers by points: ternaries 5 (15 pts), if/else 4 (13 pts), error handling 2 (7 pts), loops 1 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 27). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
OpenAIPromptBuilder.buildPrompt (cognitive 42) Packages/OsaurusCore/Services/Chat/PromptBuilder.swift:13— OpenAIPromptBuilder.buildPrompt has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 4 (9 pts), boolean chains 7, match/switch 1 (2 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DocumentEditService.structure (cognitive 42) Packages/OsaurusCore/Services/Documents/DocumentEditService.swift:237— DocumentEditService.structure has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (32 pts), loops 2 (7 pts), boolean chains 2, match/switch 1 (nesting depth added 24). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
OsaurusEvalsCLI.runCaptureScreen (cognitive 41) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCaptureScreenCLI.swift:39— OsaurusEvalsCLI.runCaptureScreen has cognitive complexity 41 (threshold 15). Drivers by points: if/else 21 (33 pts), boolean chains 3, loops 2, match/switch 1 (2 pts), error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planAgents (cognitive 41) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1378— ConfigPlanner.planAgents has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (37 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContentBlock.knownFileContents (cognitive 41) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:1225— ContentBlock.knownFileContents has cognitive complexity 41 (threshold 15). Drivers by points: if/else 5 (15 pts), boolean chains 12, ternaries 2 (8 pts), loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileChangeJournal.importLegacyIfNeeded (cognitive 41) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal.swift:961— FileChangeJournal.importLegacyIfNeeded has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (26 pts), ternaries 2 (6 pts), boolean chains 4, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DecisionService.execute (cognitive 41) Packages/OsaurusCore/Services/Inference/DecisionService.swift:132— DecisionService.execute has cognitive complexity 41 (threshold 15). Drivers by points: error handling 6 (18 pts), if/else 4 (17 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPElicitationForm.convert (cognitive 41) Packages/OsaurusCore/Services/MCP/MCPElicitation.swift:186— MCPElicitationForm.convert has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (22 pts), ternaries 4 (9 pts), boolean chains 6, match/switch 2 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageModelRequestPolicy.validate (cognitive 41) Packages/OsaurusCore/Services/ModelRuntime/ImageModelRequestPolicy.swift:54— ImageModelRequestPolicy.validate has cognitive complexity 41 (threshold 15). Drivers by points: if/else 16 (28 pts), boolean chains 10, loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatModelPickerCard.modelColumn (cognitive 41) Packages/OsaurusCore/Views/Model/ChatModelPickerCard.swift:484— ChatModelPickerCard.modelColumn has cognitive complexity 41 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 13, ternaries 7 (13 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditTool.normalizingEditShapes (cognitive 40) Packages/OsaurusCore/Folder/FolderTools.swift:3258— FileEditTool.normalizingEditShapes has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 15, loops 2 (3 pts) (nesting depth added 12). Of this number, 36 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDownloadService.transferFile (cognitive 40) Packages/OsaurusCore/Services/ModelDownloadService.swift:821— ModelDownloadService.transferFile has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (24 pts), boolean chains 8, error handling 3 (7 pts), loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiffEngine.canonicalLines (cognitive 40) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:494— FileDiffEngine.canonicalLines has cognitive complexity 40 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 4 (10 pts), ternaries 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 20). Of this number, 22 points are the body's own statements and 18 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspacesService.refreshSelectedWorkspace (cognitive 40) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:525— WorkspacesService.refreshSelectedWorkspace has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (26 pts), boolean chains 7, error handling 4, match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BenchCommand.parseOptions (cognitive 39) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift:507— BenchCommand.parseOptions has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (28 pts), boolean chains 6, match/switch 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 20). Of this number, 37 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runDefaultAgentCase (cognitive 39) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1748— EvalRunner.runDefaultAgentCase has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (21 pts), boolean chains 9, loops 3 (5 pts), ternaries 3 (4 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalRunner.runMicroPerfCase (cognitive 39) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMicroPerf.swift:26— EvalRunner.runMicroPerfCase has cognitive complexity 39 (threshold 15). Drivers by points: if/else 24 (33 pts), boolean chains 2, match/switch 1 (2 pts), ternaries 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runScreenContextCase (cognitive 39) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerScreenContext.swift:29— EvalRunner.runScreenContextCase has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 7 (9 pts), ternaries 3 (6 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 14). Of this number, 37 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BackgroundTaskManager.dispatchChat (cognitive 39) REDACTED:1001— BackgroundTaskManager.dispatchChat has cognitive complexity 39 (threshold 15). Drivers by points: if/else 19 (21 pts), boolean chains 9, ternaries 4 (5 pts), error handling 2 (4 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
TranscriptionWorker.runLoop (cognitive 39) Packages/OsaurusCore/Managers/SpeechService.swift:1495— TranscriptionWorker.runLoop has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (27 pts), boolean chains 6, error handling 2 (5 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleChatNDJSON (cognitive 39) Packages/OsaurusCore/Networking/HTTPHandler.swift:15001— HTTPHandler.handleChatNDJSON has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (27 pts), boolean chains 4, match/switch 1 (3 pts), loops 1 (2 pts), ternaries 1 (2 pts), error handling 1 (nesting depth added 14). Of this number, 38 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.estimatedArchitectureKVHeadroomBytes (cognitive 39) Packages/OsaurusCore/Services/ModelRuntime.swift:3341— ModelRuntime.estimatedArchitectureKVHeadroomBytes has cognitive complexity 39 (threshold 15). Drivers by points: boolean chains 20, if/else 12 (13 pts), ternaries 5 (6 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Tokenizer.tokenize (cognitive 39) Packages/OsaurusCore/Utils/CalculatorEngine.swift:201— Tokenizer.tokenize has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 14, loops 2 (4 pts), match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResponsesGenerationStream.compatibility (cognitive 39) Packages/OsaurusCore/Services/Inference/ResponsesCompatibilityStream.swift:19— ResponsesGenerationStream.compatibility has cognitive complexity 39 (threshold 15). Drivers by points: if/else 21 (25 pts), ternaries 2 (5 pts), error handling 4, loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
KnowledgeIndexService.scanIndexableFiles (cognitive 39) Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:343— KnowledgeIndexService.scanIndexableFiles has cognitive complexity 39 (threshold 15). Drivers by points: if/else 16 (34 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceAuditRow.subtitle (cognitive 39) Packages/OsaurusCore/Views/Workspaces/WorkspaceAuditView.swift:402— WorkspaceAuditRow.subtitle has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (24 pts), boolean chains 10, ternaries 2 (4 pts), match/switch 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.shiftAnnotations (cognitive 39) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:628— XLSXEditor.shiftAnnotations has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 8 (15 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ShellArgs.split (cognitive 39) Packages/OsaurusCore/Services/MCP/Stdio/ShellArgs.swift:35— ShellArgs.split has cognitive complexity 39 (threshold 15). Drivers by points: if/else 16 (29 pts), match/switch 2 (5 pts), boolean chains 4, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BlockMemoizer.blocks (cognitive 38) Packages/OsaurusCore/Managers/BlockMemoizer.swift:119— BlockMemoizer.blocks has cognitive complexity 38 (threshold 15). Drivers by points: boolean chains 31, if/else 7. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
HTTPHandler.handleSessionEndpoint (cognitive 38) Packages/OsaurusCore/Networking/HTTPHandler.swift:7848— HTTPHandler.handleSessionEndpoint has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (25 pts), ternaries 5 (9 pts), boolean chains 4 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.decodeOllamaChatRequest (cognitive 38) Packages/OsaurusCore/Networking/HTTPHandler.swift:14953— HTTPHandler.decodeOllamaChatRequest has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 3 (8 pts), boolean chains 7 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.computeWeightsSizeBytes (cognitive 38) Packages/OsaurusCore/Services/ModelRuntime.swift:7617— ModelRuntime.computeWeightsSizeBytes has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 10, loops 5 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilitiesDiscoverTool.execute (cognitive 38) Packages/OsaurusCore/Tools/CapabilityTools.swift:396— CapabilitiesDiscoverTool.execute has cognitive complexity 38 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 5 (6 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BrowserSnapshotFormatter.format (cognitive 38) Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:172— BrowserSnapshotFormatter.format has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (6 pts), ternaries 2 (6 pts), boolean chains 3, match/switch 1 (nesting depth added 18). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
FileDiffEngine.collapse (cognitive 38) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:312— FileDiffEngine.collapse has cognitive complexity 38 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 7 (16 pts), boolean chains 2, match/switch 1 (2 pts), ternaries 2 (nesting depth added 17). Of this number, 27 points are the body's own statements and 11 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResponsesToolChoiceContract.enforce (cognitive 38) Packages/OsaurusCore/Services/Inference/ResponsesToolChoiceContract.swift:115— ResponsesToolChoiceContract.enforce has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (27 pts), error handling 2 (5 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.consume (cognitive 38) Packages/OsaurusCore/Services/Provider/RemoteResponsesPrivacyStream.swift:72— State.consume has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 2 (6 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.dropCachedFormulaResults (cognitive 38) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:88— XLSXEditor.dropCachedFormulaResults has cognitive complexity 38 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 5 (11 pts), boolean chains 7, ternaries 1 (4 pts) (nesting depth added 19). Of this number, 34 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPCommand.execute (cognitive 37) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/MCPCommand.swift:14— MCPCommand.execute has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (22 pts), ternaries 2 (5 pts), boolean chains 4, error handling 4, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaValidator.validateObject (cognitive 37) Packages/OsaurusCore/Tools/SchemaValidator.swift:69— SchemaValidator.validateObject has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 6, loops 3 (4 pts), ternaries 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigScheduleFrequency.parse (cognitive 37) Packages/OsaurusCore/Configuration/Declarative/ConfigScheduleFrequency.swift:21— ConfigScheduleFrequency.parse has cognitive complexity 37 (threshold 15). Drivers by points: boolean chains 19, if/else 10 (17 pts), match/switch 1 (nesting depth added 7). Of this number, 31 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
RuntimeProofValidator.appendProvenClaimIssues (cognitive 37) Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:310— RuntimeProofValidator.appendProvenClaimIssues has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (33 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelegramConnectionService.diagnostics (cognitive 37) Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:523— TelegramConnectionService.diagnostics has cognitive complexity 37 (threshold 15). Drivers by points: if/else 20 (25 pts), boolean chains 9, error handling 2 (3 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
NativeMarkdownTableView.updateCells (cognitive 37) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:1143— NativeMarkdownTableView.updateCells has cognitive complexity 37 (threshold 15). Drivers by points: loops 8 (16 pts), if/else 7 (14 pts), ternaries 3 (5 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolCategory.from (cognitive 37) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:141— ToolCategory.from has cognitive complexity 37 (threshold 15). Drivers by points: boolean chains 31, if/else 6. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MCPWWWAuthenticate.parseParams (cognitive 37) Packages/OsaurusCore/Services/MCP/OAuth/MCPWWWAuthenticate.swift:80— MCPWWWAuthenticate.parseParams has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 5 (11 pts), boolean chains 7 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportCommand.parse (cognitive 36) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:179— ImportCommand.parse has cognitive complexity 36 (threshold 15). Drivers by points: if/else 16 (25 pts), boolean chains 6, match/switch 3 (4 pts), loops 1 (nesting depth added 10). Of this number, 34 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportCommand.render (cognitive 36) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:694— ImportCommand.render has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 7 (11 pts), boolean chains 1, match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextOptimizerSearch.plan (cognitive 36) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:105— ContextOptimizerSearch.plan has cognitive complexity 36 (threshold 15). Drivers by points: if/else 18 (20 pts), ternaries 6 (9 pts), loops 5, boolean chains 2 (nesting depth added 5). Of this number, 32 points are the body's own statements and 4 belong to 3 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
FileWriteDocumentRouting.workbook (cognitive 36) Packages/OsaurusCore/Folder/FileWriteDocumentRouting.swift:323— FileWriteDocumentRouting.workbook has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WatcherManager.processCurrentState (cognitive 36) Packages/OsaurusCore/Managers/WatcherManager.swift:495— WatcherManager.processCurrentState has cognitive complexity 36 (threshold 15). Drivers by points: if/else 18 (31 pts), boolean chains 4, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Solver.solve (cognitive 36) Packages/OsaurusCore/Utils/CalculatorEngine.swift:1042— Solver.solve has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 13, loops 3 (4 pts), ternaries 3 (nesting depth added 6). Of this number, 28 points are the body's own statements and 8 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InlineMathScanner.split (cognitive 36) Packages/OsaurusCore/Utils/InlineMathScanner.swift:86— InlineMathScanner.split has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 8, loops 2 (4 pts), ternaries 1 (nesting depth added 15). Of this number, 34 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScreenContextDistiller.sampledItem (cognitive 36) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:507— ScreenContextDistiller.sampledItem has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (25 pts), ternaries 3 (6 pts), boolean chains 4, match/switch 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ConfigApplier.applySchedules (cognitive 36) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2324— ConfigApplier.applySchedules has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (28 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiff.partialToolName (cognitive 36) Packages/OsaurusCore/Models/Chat/FileDiff.swift:261— FileDiff.partialToolName has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 12, loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScheduleFrequency.nextRunDate (cognitive 36) Packages/OsaurusCore/Models/Schedule/Schedule.swift:111— ScheduleFrequency.nextRunDate has cognitive complexity 36 (threshold 15). Drivers by points: if/else 16 (33 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 18). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
NativeImageJobCoordinator.runJob (cognitive 36) Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:560— NativeImageJobCoordinator.runJob has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 5, ternaries 2 (4 pts), error handling 2 (3 pts), match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 15). Of this number, 35 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FoundationModelService.streamWithTools (cognitive 36) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:464— FoundationModelService.streamWithTools has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (28 pts), error handling 2 (4 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryService.performDistillSession (cognitive 36) Packages/OsaurusCore/Services/Memory/MemoryService.swift:811— MemoryService.performDistillSession has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (17 pts), error handling 5 (7 pts), match/switch 2 (5 pts), ternaries 2 (5 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilityRowBuilder.build (cognitive 36) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:149— CapabilityRowBuilder.build has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 7, ternaries 2 (5 pts), loops 3 (4 pts) (nesting depth added 12). Of this number, 35 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.dispatchSend (cognitive 36) Packages/OsaurusCore/Views/Chat/ChatView.swift:6498— ChatSession.dispatchSend has cognitive complexity 36 (threshold 15). Drivers by points: if/else 131 (283 pts), ternaries 25 (64 pts), boolean chains 58, loops 9 (24 pts), error handling 7 (12 pts), match/switch 1 (2 pts) (nesting depth added 212). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 3 other methods here (ChatSession.dispatchSend::runTurn, ChatSession.dispatchSend::runTurn::postProcessToolResult, ChatSession.dispatchSend::runTurn::executeToolBatch) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
PreviewGenerator.resultPreview (cognitive 36) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:246— PreviewGenerator.resultPreview has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (21 pts), ternaries 5 (14 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ShowCommand.printFormattedOutput (cognitive 35) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Show.swift:166— ShowCommand.printFormattedOutput has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (21 pts), boolean chains 9, loops 4 (5 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalCaseTelemetry.isEmpty (cognitive 35) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:240— EvalCaseTelemetry.isEmpty has cognitive complexity 35 (threshold 15). Drivers by points: boolean chains 35. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
EvalRunner.scoreSpawnResidencyLane (cognitive 35) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:323— EvalRunner.scoreSpawnResidencyLane has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 10, ternaries 3 (4 pts), loops 1 (nesting depth added 9). Of this number, 32 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileCopyTool.execute (cognitive 35) Packages/OsaurusCore/Folder/FileCopyTool.swift:80— FileCopyTool.execute has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (22 pts), boolean chains 4, error handling 2 (4 pts), ternaries 3, match/switch 2 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
OsaurusInspectTool.resolvedListEnvelope (cognitive 35) Packages/OsaurusCore/Tools/ConfigurationTools.swift:732— OsaurusInspectTool.resolvedListEnvelope has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (16 pts), match/switch 6 (10 pts), ternaries 3 (6 pts), boolean chains 2, error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CNContactsService.search (cognitive 35) Packages/OsaurusCore/AppleApps/Contacts/ContactsService.swift:187— CNContactsService.search has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 13, match/switch 1 (2 pts), loops 1 (nesting depth added 11). Of this number, 34 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigYAML.walk (cognitive 35) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:145— ConfigYAML.walk has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (9 pts), boolean chains 3, match/switch 1 (nesting depth added 19). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ContentBlockKind.== (cognitive 35) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:147— ContentBlockKind.== has cognitive complexity 35 (threshold 15). Drivers by points: boolean chains 23, if/else 6 (11 pts), match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AgentChannelPublishService.publish (cognitive 35) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:186— AgentChannelPublishService.publish has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (20 pts), boolean chains 5, match/switch 3 (4 pts), ternaries 2 (4 pts), error handling 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryConsolidator.mergeNearDuplicateEpisodes (cognitive 35) Packages/OsaurusCore/Services/Memory/MemoryConsolidator.swift:233— MemoryConsolidator.mergeNearDuplicateEpisodes has cognitive complexity 35 (threshold 15). Drivers by points: if/else 5 (14 pts), ternaries 2 (10 pts), loops 3 (6 pts), error handling 1 (5 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.handleGeminiEvent (cognitive 35) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2086— RemoteProviderService.handleGeminiEvent has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (23 pts), match/switch 3 (8 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageSubagentKind.resolveModel (cognitive 35) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:85— ImageSubagentKind.resolveModel has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 12, ternaries 4 (8 pts), error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusEvalsCLI.computeFloorBreaches (cognitive 34) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:582— OsaurusEvalsCLI.computeFloorBreaches has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (28 pts), loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalScoreboardBuilder.loadEvidenceSummariesRecursively (cognitive 34) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalScoreboard.swift:521— EvalScoreboardBuilder.loadEvidenceSummariesRecursively has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (7 pts), error handling 2 (6 pts), ternaries 1 (5 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileUndoTool.execute (cognitive 34) Packages/OsaurusCore/Folder/FolderTools.swift:4218— FileUndoTool.execute has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (26 pts), boolean chains 6, ternaries 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleOllamaGenerate (cognitive 34) Packages/OsaurusCore/Networking/HTTPHandler.swift:15295— HTTPHandler.handleOllamaGenerate has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 3, match/switch 1 (3 pts), ternaries 2 (3 pts), loops 1 (2 pts), error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ExternalModelLocator.bundleDiagnostic (cognitive 34) Packages/OsaurusCore/Services/ExternalModelLocator.swift:793— ExternalModelLocator.bundleDiagnostic has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 11, loops 1 (2 pts), ternaries 1 (nesting depth added 7). Of this number, 30 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilitiesLoadTool.loadMethod (cognitive 34) Packages/OsaurusCore/Tools/CapabilityTools.swift:1136— CapabilitiesLoadTool.loadMethod has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (6 pts), boolean chains 1, error handling 1 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
AgentView.renderForModel (cognitive 34) Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:244— AgentView.renderForModel has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (17 pts), ternaries 4 (12 pts), boolean chains 4, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyDelegation (cognitive 34) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:932— ConfigApplier.applyDelegation has cognitive complexity 34 (threshold 15). Drivers by points: if/else 16 (20 pts), loops 6 (9 pts), match/switch 1 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ConfigPlanner.diffPortableSettings (cognitive 34) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1237— ConfigPlanner.diffPortableSettings has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 3, ternaries 1 (3 pts), match/switch 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginManager.loadPluginWithError (cognitive 34) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1222— PluginManager.loadPluginWithError has cognitive complexity 34 (threshold 15). Drivers by points: if/else 19 (24 pts), boolean chains 3, ternaries 1 (3 pts), error handling 1 (2 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelInfo.findModelDirectory (cognitive 34) Packages/OsaurusCore/Models/Configuration/ModelInfo.swift:324— ModelInfo.findModelDirectory has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (27 pts), loops 2 (6 pts), boolean chains 1 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
CodeBlockMasker.appendIndentedCodeSpans (cognitive 34) Packages/OsaurusCore/PrivacyFilter/Core/CodeBlockMasker.swift:225— CodeBlockMasker.appendIndentedCodeSpans has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (24 pts), boolean chains 5, loops 2 (5 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPTXEmitter.slides (cognitive 34) Packages/OsaurusCore/Services/Documents/PPTXEmitter.swift:55— PPTXEmitter.slides has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 9, ternaries 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryManagementConsoleService.diagnoseStorage (cognitive 34) Packages/OsaurusCore/Services/Memory/MemoryManagementConsoleService.swift:325— MemoryManagementConsoleService.diagnoseStorage has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14, boolean chains 12, ternaries 5 (8 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PluginHostContext.complete (cognitive 34) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1520— PluginHostContext.complete has cognitive complexity 34 (threshold 15). Drivers by points: if/else 22 (27 pts), boolean chains 6, error handling 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
OpenAICompatibleToolCallAccumulator.validateToolCallJSON (cognitive 34) Packages/OsaurusCore/Services/Provider/OpenAICompatibleStreamParser.swift:320— OpenAICompatibleToolCallAccumulator.validateToolCallJSON has cognitive complexity 34 (threshold 15). Drivers by points: if/else 20 (29 pts), loops 3, boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.geminiImageGenerateContent (cognitive 34) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:3740— RemoteProviderService.geminiImageGenerateContent has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (24 pts), match/switch 1 (4 pts), error handling 2 (3 pts), loops 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceSyncService.startStream (cognitive 34) Packages/OsaurusCore/Services/Router/WorkspaceSyncService.swift:181— WorkspaceSyncService.startStream has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (24 pts), boolean chains 3, error handling 1 (3 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageSubagentKind.run (cognitive 34) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:326— ImageSubagentKind.run has cognitive complexity 34 (threshold 15). Drivers by points: ternaries 7 (14 pts), if/else 7 (13 pts), error handling 3 (4 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseImport.parseXLSX (cognitive 34) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:253— DatabaseImport.parseXLSX has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (20 pts), loops 4 (6 pts), ternaries 2 (4 pts), boolean chains 3, error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bridge.emitMessage (cognitive 34) helpers/osaurus-wa/bridge.go:1134— bridge.emitMessage has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (28 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ManifestValidate.validateRoutes (cognitive 33) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:342— ManifestValidate.validateRoutes has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ShellMutationPlanner.targets (cognitive 33) Packages/OsaurusCore/Folder/ShellMutationPlanner.swift:33— ShellMutationPlanner.targets has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 7, loops 4 (5 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiff.partialPythonStringValue (cognitive 33) Packages/OsaurusCore/Models/Chat/FileDiff.swift:404— FileDiff.partialPythonStringValue has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 4 (7 pts), boolean chains 5, match/switch 1 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MTPLayoutAdvisory.evaluate (cognitive 33) Packages/OsaurusCore/Models/Chat/MTPLayoutAdvisory.swift:135— MTPLayoutAdvisory.evaluate has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 8, loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentSubagentRunner.run (cognitive 33) Packages/OsaurusCore/Services/AgentDelegation/AgentSubagentRunner.swift:159— AgentSubagentRunner.run has cognitive complexity 33 (threshold 15). Drivers by points: if/else 15, ternaries 7 (14 pts), error handling 3, loops 1 (nesting depth added 7). Of this number, 30 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MemorySearchService.searchEpisodes (cognitive 33) Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:377— MemorySearchService.searchEpisodes has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 2 (7 pts), error handling 2 (3 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchDiagnostics.classifyFailure (cognitive 33) Packages/OsaurusCore/Services/Search/SearchTypes.swift:180— SearchDiagnostics.classifyFailure has cognitive complexity 33 (threshold 15). Drivers by points: boolean chains 23, if/else 10. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ClaudePluginInstaller.rewriteSkillBody (cognitive 33) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1197— ClaudePluginInstaller.rewriteSkillBody has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 4 (7 pts), ternaries 1 (2 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.runImageGeneration (cognitive 33) Packages/OsaurusCore/Views/Chat/ChatView.swift:5913— ChatSession.runImageGeneration has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (21 pts), match/switch 2 (5 pts), error handling 3, boolean chains 2, loops 1 (2 pts) (nesting depth added 14). Of this number, 31 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FloatingInputCard.handleFileDrop (cognitive 33) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5259— FloatingInputCard.handleFileDrop has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (24 pts), boolean chains 8, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchAndExtractTool.execute (cognitive 32) Packages/OsaurusCore/Tools/WebSearchTools.swift:394— SearchAndExtractTool.execute has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 1 (4 pts), boolean chains 3, ternaries 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CronParser.nextDate (cognitive 32) Packages/OsaurusCore/Utils/CronParser.swift:48— CronParser.nextDate has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 6, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProvider.resolvedHeaders (cognitive 32) Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:336— RemoteProvider.resolvedHeaders has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (24 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RegexEntityDetector.detect (cognitive 32) Packages/OsaurusCore/PrivacyFilter/Core/RegexEntityDetector.swift:126— RegexEntityDetector.detect has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 8, loops 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalAgentBridge.scheduleNextRun (cognitive 32) Packages/OsaurusCore/Services/AgentBridge/LocalAgentBridge.swift:513— LocalAgentBridge.scheduleNextRun has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 10 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CSVRowParser.parseRows (cognitive 32) Packages/OsaurusCore/Services/Documents/CSVRowParser.swift:22— CSVRowParser.parseRows has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 9, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BoundedZipReader.parseEntries (cognitive 32) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1504— BoundedZipReader.parseEntries has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 12, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageComposerRequestBuilder.build (cognitive 32) Packages/OsaurusCore/Services/ModelRuntime/ImageComposerRequestBuilder.swift:81— ImageComposerRequestBuilder.build has cognitive complexity 32 (threshold 15). Drivers by points: ternaries 14 (19 pts), boolean chains 7, if/else 4 (5 pts), match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteResponsesNativeStream.capture (cognitive 32) Packages/OsaurusCore/Services/Provider/RemoteResponsesNativeStream.swift:133— RemoteResponsesNativeStream.capture has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 6, loops 3 (6 pts), match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseImport.scanDelimited (cognitive 32) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:371— DatabaseImport.scanDelimited has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (27 pts), boolean chains 4, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SkillRow.body (cognitive 32) Packages/OsaurusCore/Views/Skill/SkillsView.swift:537— SkillRow.body has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (17 pts), ternaries 8 (14 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
run_disconnect_ab.stream (cognitive 32) docs/internal/evidence/2026-08-30-inference-activity-ownership/run_disconnect_ab.py:42— run_disconnect_ab.stream has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (23 pts), loops 2 (5 pts), boolean chains 3, ternaries 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
check-swift-catalog-keys.referenced_keys (cognitive 32) scripts/i18n/check-swift-catalog-keys.py:147— check-swift-catalog-keys.referenced_keys has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (22 pts), loops 4 (10 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleModelOptionsEndpoint (cognitive 31) Packages/OsaurusCore/Networking/HTTPHandler.swift:5787— HTTPHandler.handleModelOptionsEndpoint has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10, boolean chains 8, error handling 4 (8 pts), ternaries 3 (5 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HuggingFaceService.downloadMetadata (cognitive 31) Packages/OsaurusCore/Services/HuggingFaceService.swift:301— HuggingFaceService.downloadMetadata has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (5 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPProviderTool.convertMCPContent (cognitive 31) Packages/OsaurusCore/Tools/MCPProviderTool.swift:483— MCPProviderTool.convertMCPContent has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 6, match/switch 1 (2 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CalculatorEngine.evaluate (cognitive 31) Packages/OsaurusCore/Utils/CalculatorEngine.swift:56— CalculatorEngine.evaluate has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (25 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EventKitRemindersService.update (cognitive 31) Packages/OsaurusCore/AppleApps/Reminders/RemindersService.swift:219— EventKitRemindersService.update has cognitive complexity 31 (threshold 15). Drivers by points: if/else 20 (27 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planSchedules (cognitive 31) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2355— ConfigPlanner.planSchedules has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (24 pts), match/switch 1 (4 pts), loops 2 (3 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelOptionsSnapshot.apply (cognitive 31) Packages/OsaurusCore/Models/Configuration/ModelOptionsSnapshot.swift:215— ModelOptionsSnapshot.apply has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 3, match/switch 1 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelConnectionService.authorizeInboundMessage (cognitive 31) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:1032— AgentChannelConnectionService.authorizeInboundMessage has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 10, error handling 2 (3 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
MicroPerfEvaluator.runCancellation (cognitive 31) Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:316— MicroPerfEvaluator.runCancellation has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (17 pts), error handling 4 (5 pts), loops 3 (5 pts), boolean chains 3, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResponsesGenerationStream.native (cognitive 31) Packages/OsaurusCore/Services/Inference/ResponsesGenerationEvent.swift:100— ResponsesGenerationStream.native has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (20 pts), match/switch 2 (7 pts), loops 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenizerBridge.normalizeChatTemplateSchemaValue (cognitive 31) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:770— TokenizerBridge.normalizeChatTemplateSchemaValue has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2 (7 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.handleAnthropicEvent (cognitive 31) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2166— RemoteProviderService.handleAnthropicEvent has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (24 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
RemoteProviderService.enforcingToolUseResultPairing (cognitive 31) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:4326— RemoteProviderService.enforcingToolUseResultPairing has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 6, loops 3 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchReadability.fetchAndExtract (cognitive 31) Packages/OsaurusCore/Services/Search/SearchReadability.swift:95— SearchReadability.fetchAndExtract has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (17 pts), ternaries 2 (5 pts), boolean chains 4, error handling 3, loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportCommand.runRemove (cognitive 30) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:483— ImportCommand.runRemove has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (8 pts), match/switch 1 (3 pts), boolean chains 1, error handling 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ManifestValidate.validate (cognitive 30) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:72— ManifestValidate.validate has cognitive complexity 30 (threshold 15). Drivers by points: if/else 17 (21 pts), boolean chains 5, loops 1 (3 pts), error handling 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
OsaurusEvalsCLI.runDiff (cognitive 30) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:24— OsaurusEvalsCLI.runDiff has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 3, match/switch 1 (2 pts), error handling 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusEvalsCLI.runMatrix (cognitive 30) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:132— OsaurusEvalsCLI.runMatrix has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (26 pts), match/switch 1 (2 pts), error handling 1, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppDelegate.presentAnnouncementIfEligible (cognitive 30) Packages/OsaurusCore/AppDelegate.swift:2864— AppDelegate.presentAnnouncementIfEligible has cognitive complexity 30 (threshold 15). Drivers by points: if/else 19 (21 pts), boolean chains 3, loops 2 (3 pts), ternaries 2 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
HTTPHandler.handleAnthropicMessagesNonStreaming (cognitive 30) Packages/OsaurusCore/Networking/HTTPHandler.swift:17176— HTTPHandler.handleAnthropicMessagesNonStreaming has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 4 (9 pts), ternaries 2 (4 pts), boolean chains 2, error handling 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RequestValidator.rawResponseSchemaReason (cognitive 30) Packages/OsaurusCore/Networking/RequestValidator.swift:19— RequestValidator.rawResponseSchemaReason has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 8, loops 3 (6 pts), error handling 1 (4 pts), ternaries 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CronParser.parseField (cognitive 30) Packages/OsaurusCore/Utils/CronParser.swift:141— CronParser.parseField has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 4 (10 pts), ternaries 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BrowserToolExecutor.batchDo (cognitive 30) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:491— BrowserToolExecutor.batchDo has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (20 pts), match/switch 3 (5 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelManager.mergeAvailable (cognitive 30) Packages/OsaurusCore/Managers/Model/ModelManager.swift:1723— ModelManager.mergeAvailable has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 4, loops 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelManager.refreshAutomaticModelUpdates (cognitive 30) Packages/OsaurusCore/Managers/Model/ModelUpdatePolling.swift:127— ModelManager.refreshAutomaticModelUpdates has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (25 pts), boolean chains 4, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentSubagentRunner.consumeStream (cognitive 30) Packages/OsaurusCore/Services/AgentDelegation/AgentSubagentRunner.swift:515— AgentSubagentRunner.consumeStream has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 2, loops 2, match/switch 1 (2 pts), error handling 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FoundationModelService.streamDeltas (cognitive 30) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:316— FoundationModelService.streamDeltas has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 1 (3 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.extractErrorMessage (cognitive 30) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:7329— RemoteProviderService.extractErrorMessage has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (27 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
InsightsDetailPane.copyMenu (cognitive 30) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:176— InsightsDetailPane.copyMenu has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (17 pts), ternaries 2 (8 pts), boolean chains 5 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PluginCard.body (cognitive 30) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1076— PluginCard.body has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (17 pts), ternaries 7, boolean chains 5, error handling 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ToolPermissionView.body (cognitive 30) Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:83— ToolPermissionView.body has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 15 (25 pts), if/else 5 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DOCXEditor.applyParagraphRun (cognitive 30) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:611— DOCXEditor.applyParagraphRun has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 5 (8 pts), ternaries 3 (5 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DOCXEditor.insertParagraph (cognitive 30) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:761— DOCXEditor.insertParagraph has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (13 pts), loops 5 (11 pts), boolean chains 3, ternaries 2 (3 pts) (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
XLSXEditor.deleteSheet (cognitive 30) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:776— XLSXEditor.deleteSheet has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 7 (12 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
plan-installed-vision.metadata (cognitive 30) scripts/evals/plan-installed-vision.py:39— plan-installed-vision.metadata has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (16 pts), ternaries 4 (5 pts), boolean chains 4, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BenchCommand.measureOnce (cognitive 29) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift:378— BenchCommand.measureOnce has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 6, ternaries 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Options.parse (cognitive 29) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:886— Options.parse has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (21 pts), ternaries 1 (3 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalReport.formatTelemetryLine (cognitive 29) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:894— EvalReport.formatTelemetryLine has cognitive complexity 29 (threshold 15). Drivers by points: if/else 19 (22 pts), boolean chains 6, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
OsaurusBundle.risks (cognitive 29) Packages/OsaurusRepository/OsaurusBundle.swift:979— OsaurusBundle.risks has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.isKnownHybridModel (cognitive 29) Packages/OsaurusCore/Services/ModelRuntime.swift:5753— ModelRuntime.isKnownHybridModel has cognitive complexity 29 (threshold 15). Drivers by points: boolean chains 16, if/else 13. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelRuntime.mapOpenAIChatToMLX (cognitive 29) Packages/OsaurusCore/Services/ModelRuntime.swift:7079— ModelRuntime.mapOpenAIChatToMLX has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 6, ternaries 2 (6 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EventKitCalendarService.update (cognitive 29) Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift:324— EventKitCalendarService.update has cognitive complexity 29 (threshold 15). Drivers by points: if/else 18 (23 pts), boolean chains 5, ternaries 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AppleScriptToolDispatch.literalsForDispatch (cognitive 29) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:413— AppleScriptToolDispatch.literalsForDispatch has cognitive complexity 29 (threshold 15). Drivers by points: boolean chains 15, if/else 10 (14 pts) (nesting depth added 4). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelManager.fetchRemoteMLXModels (cognitive 29) Packages/OsaurusCore/Managers/Model/ModelManager.swift:379— ModelManager.fetchRemoteMLXModels has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 5 (7 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginManager._loadAll (cognitive 29) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:238— PluginManager._loadAll has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 6 (11 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenResponsesRequest.toChatCompletionRequest (cognitive 29) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1508— OpenResponsesRequest.toChatCompletionRequest has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 3 (7 pts), match/switch 3 (6 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Template.document (cognitive 29) Packages/OsaurusCore/Models/Template/Template+Agent.swift:77— Template.document has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (27 pts), ternaries 1 (2 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SpokenDigitRuns.find (cognitive 29) Packages/OsaurusCore/PrivacyFilter/Core/SpokenNumberDetector.swift:81— SpokenDigitRuns.find has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 7, ternaries 2 (7 pts), loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextBudgetManager.trimMessagesReportingOverflow (cognitive 29) Packages/OsaurusCore/Services/Chat/ContextBudgetManager.swift:355— ContextBudgetManager.trimMessagesReportingOverflow has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 6 (9 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 8). Of this number, 26 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.removeItem (cognitive 29) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:862— PendingImportProcessor.removeItem has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 7, match/switch 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Registry.snapshotDiagnostics (cognitive 29) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:656— Registry.snapshotDiagnostics has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 3, boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.dispatchFinal (cognitive 29) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:2739— RemoteProviderService.dispatchFinal has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 8, match/switch 2 (4 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsManagerView.updateFilteredLists (cognitive 29) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:402— ToolsManagerView.updateFilteredLists has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 11, loops 1 (nesting depth added 5). Of this number, 27 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPOAuthService.signIn (cognitive 29) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthService.swift:109— MCPOAuthService.signIn has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10, error handling 6 (8 pts), boolean chains 5, ternaries 3 (4 pts), match/switch 2 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ImportCommand.loadAndCheck (cognitive 28) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:306— ImportCommand.loadAndCheck has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (17 pts), error handling 4, loops 2, match/switch 1 (2 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalDiff.classifyPerf (cognitive 28) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift:447— EvalDiff.classifyPerf has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 6 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Lines.replace (cognitive 28) Packages/OsaurusCore/Folder/FileEditMatcher.swift:234— Lines.replace has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 7, loops 3, match/switch 1 (2 pts), ternaries 1 (nesting depth added 6). Of this number, 26 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditTool.applyEdits (cognitive 28) Packages/OsaurusCore/Folder/FolderTools.swift:3895— FileEditTool.applyEdits has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 5 (14 pts), if/else 3 (11 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handlePairInviteEndpoint (cognitive 28) Packages/OsaurusCore/Networking/HTTPHandler.swift:9109— HTTPHandler.handlePairInviteEndpoint has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (15 pts), match/switch 3 (5 pts), boolean chains 4, error handling 2, ternaries 1 (2 pts) (nesting depth added 6). Of this number, 24 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
SpawnPermissionGate.authorize (cognitive 28) Packages/OsaurusCore/Subagent/SpawnPermissionGate.swift:85— SpawnPermissionGate.authorize has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 5, error handling 2 (3 pts), match/switch 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxReadFileTool.execute (cognitive 28) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1673— SandboxReadFileTool.execute has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (16 pts), ternaries 4 (8 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ToolWirePropertyOrder.orderSchema (cognitive 28) Packages/OsaurusCore/Tools/ToolWirePropertyOrder.swift:102— ToolWirePropertyOrder.orderSchema has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (22 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentAction.argumentsJSON (cognitive 28) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:224— AgentAction.argumentsJSON has cognitive complexity 28 (threshold 15). Drivers by points: if/else 21 (27 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ConfigApplier.applyDefaultAgent (cognitive 28) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:285— ConfigApplier.applyDefaultAgent has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (19 pts), ternaries 2 (4 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentTargetResolver.resolve (cognitive 28) Packages/OsaurusCore/Models/Agent/AgentDispatchTarget.swift:205— AgentTargetResolver.resolve has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (16 pts), match/switch 3 (5 pts), boolean chains 4, ternaries 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaSnapshot.renderFull (cognitive 28) Packages/OsaurusCore/Services/AgentBridge/SchemaSnapshot.swift:102— SchemaSnapshot.renderFull has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (7 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomJSONRunner.prepareRequest (cognitive 28) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:858— AgentChannelCustomJSONRunner.prepareRequest has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomJSONRunner.blockedHostReason (cognitive 28) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1842— AgentChannelCustomJSONRunner.blockedHostReason has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 6, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentTaskState.nextStepBias (cognitive 28) Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:1022— AgentTaskState.nextStepBias has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 6, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextBudgetManager.summarizeToolResult (cognitive 28) Packages/OsaurusCore/Services/Chat/ContextBudgetManager.swift:741— ContextBudgetManager.summarizeToolResult has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 11, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiffEngine.diff (cognitive 28) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:75— FileDiffEngine.diff has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 12, ternaries 2 (nesting depth added 3). Of this number, 23 points are the body's own statements and 5 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
RemoteProviderService.processEventPayload (cognitive 28) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1731— RemoteProviderService.processEventPayload has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 12, if/else 9 (12 pts), ternaries 1 (2 pts), loops 1, match/switch 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SetupChecker.check (cognitive 28) Packages/OsaurusCore/Services/Template/SetupChecker.swift:101— SetupChecker.check has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 5, match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeToolCallRowView.markdownForConfigResult (cognitive 28) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:1681— NativeToolCallRowView.markdownForConfigResult has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 9, loops 2 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRowCellView.layout (cognitive 28) Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:795— ModelRowCellView.layout has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 2, ternaries 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginDetailView.heroHeader (cognitive 28) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1642— PluginDetailView.heroHeader has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (14 pts), ternaries 3 (7 pts), error handling 2 (4 pts), boolean chains 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelDestinationEditorSheet.discoverRooms (cognitive 28) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1540— AgentChannelDestinationEditorSheet.discoverRooms has cognitive complexity 28 (threshold 15). Drivers by points: if/else 3 (11 pts), ternaries 3 (8 pts), loops 2 (5 pts), boolean chains 3, error handling 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPTXEditor.replaceText (cognitive 28) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:119— PPTXEditor.replaceText has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (12 pts), error handling 2 (6 pts), loops 4 (5 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPTXEditor.setText (cognitive 28) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:213— PPTXEditor.setText has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (5 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
lint-zh-style.main (cognitive 28) scripts/i18n/lint-zh-style.py:105— lint-zh-style.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 4, loops 3 (4 pts), error handling 1 (3 pts), ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runReasoningChannelCase (cognitive 27) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerReasoningChannel.swift:43— EvalRunner.runReasoningChannelCase has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 5 (8 pts), ternaries 3, boolean chains 2, match/switch 1 (nesting depth added 6). Of this number, 25 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FileWriteTool.writeDocument (cognitive 27) Packages/OsaurusCore/Folder/FolderTools.swift:2891— FileWriteTool.writeDocument has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 6 (10 pts), if/else 8 (9 pts), error handling 4, boolean chains 2, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InsightsService.filterInMemory (cognitive 27) Packages/OsaurusCore/Managers/InsightsService.swift:450— InsightsService.filterInMemory has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 10, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
TTSService.startPocketPlayback (cognitive 27) Packages/OsaurusCore/Managers/TTSService.swift:447— TTSService.startPocketPlayback has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (13 pts), ternaries 4 (6 pts), loops 2 (5 pts), error handling 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleMemoryIngest (cognitive 27) Packages/OsaurusCore/Networking/HTTPHandler.swift:4602— HTTPHandler.handleMemoryIngest has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (15 pts), loops 5 (10 pts), boolean chains 1, error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handlePairEndpoint (cognitive 27) Packages/OsaurusCore/Networking/HTTPHandler.swift:8742— HTTPHandler.handlePairEndpoint has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (17 pts), boolean chains 7, ternaries 2, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleMCPCallTool (cognitive 27) Packages/OsaurusCore/Networking/HTTPHandler.swift:16550— HTTPHandler.handleMCPCallTool has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 3, error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SecureChannelResponseEncryptor.write (cognitive 27) Packages/OsaurusCore/Networking/SecureChannelResponseEncryptor.swift:65— SecureChannelResponseEncryptor.write has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (5 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DeclaredReasoningEffort.parseReasoningModes (cognitive 27) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:312— DeclaredReasoningEffort.parseReasoningModes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, loops 2 (3 pts), ternaries 3, match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusTool.agentChannelFailure (cognitive 27) Packages/OsaurusCore/Tools/AgentChannelTools.swift:21— OsaurusTool.agentChannelFailure has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 9 (18 pts), if/else 9 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SpawnAgentTool.execute (cognitive 27) Packages/OsaurusCore/Tools/SpawnAgentTool.swift:123— SpawnAgentTool.execute has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (22 pts), boolean chains 4, match/switch 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
CalculatorNode.evaluate (cognitive 27) Packages/OsaurusCore/Utils/CalculatorEngine.swift:430— CalculatorNode.evaluate has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (13 pts), ternaries 3 (8 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ConfigPlanner.validatePruneAgentReferences (cognitive 27) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:266— ConfigPlanner.validatePruneAgentReferences has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 3, loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planWatchers (cognitive 27) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2440— ConfigPlanner.planWatchers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigYAML.checkMapping (cognitive 27) Packages/OsaurusCore/Configuration/Declarative/ConfigYAML.swift:207— ConfigYAML.checkMapping has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 7, loops 1, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionExporter.markdown (cognitive 27) Packages/OsaurusCore/Managers/Chat/ChatSessionExporter.swift:34— ChatSessionExporter.markdown has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenResponsesRequest.toResponsesInferenceRequest (cognitive 27) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1298— OpenResponsesRequest.toResponsesInferenceRequest has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 3 (6 pts), boolean chains 2, loops 1 (2 pts), ternaries 2 (nesting depth added 11). Of this number, 26 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CodeBlockMasker.findCodeSpans (cognitive 27) Packages/OsaurusCore/PrivacyFilter/Core/CodeBlockMasker.swift:151— CodeBlockMasker.findCodeSpans has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 2 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelMessageFormatter.stripInlineMarkdown (cognitive 27) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:124— AgentChannelMessageFormatter.stripInlineMarkdown has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 4, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (AgentChannelMessageFormatter.telegramInlineHTML) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
AgentChannelMessageFormatter.telegramInlineHTML (cognitive 27) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:330— AgentChannelMessageFormatter.telegramInlineHTML has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 4, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (AgentChannelMessageFormatter.stripInlineMarkdown) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
DocumentEditService.prepare (cognitive 27) Packages/OsaurusCore/Services/Documents/DocumentEditService.swift:114— DocumentEditService.prepare has cognitive complexity 27 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 8 (9 pts), error handling 3, match/switch 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenizerBridge.applyDeepseekV4NativeTemplate (cognitive 27) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1067— TokenizerBridge.applyDeepseekV4NativeTemplate has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 7, ternaries 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatSession.runVideoGeneration (cognitive 27) Packages/OsaurusCore/Views/Chat/ChatView.swift:6150— ChatSession.runVideoGeneration has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, ternaries 3 (4 pts), error handling 3, match/switch 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMarkdownTableView.relayoutImpl (cognitive 27) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:1297— NativeMarkdownTableView.relayoutImpl has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 4 (6 pts), boolean chains 5 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnchoredCardCoordinator.updatePresentation (cognitive 27) Packages/OsaurusCore/Views/Common/AnchoredCardPresenter.swift:257— AnchoredCardCoordinator.updatePresentation has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 12 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatPickerOptionsSnapshot.make (cognitive 27) Packages/OsaurusCore/Views/Model/ChatModelPickerCard.swift:73— ChatPickerOptionsSnapshot.make has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 8 (17 pts), if/else 4 (5 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelConnectionDraft.validationFindings (cognitive 27) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:1227— AgentChannelConnectionDraft.validationFindings has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 2 (5 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SkillsView.body (cognitive 27) Packages/OsaurusCore/Views/Skill/SkillsView.swift:69— SkillsView.body has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (15 pts), ternaries 5 (9 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DOCXEditor.expandIntoParagraphs (cognitive 27) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:275— DOCXEditor.expandIntoParagraphs has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (6 pts), ternaries 2 (6 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPTXEditor.deleteSlide (cognitive 27) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:354— PPTXEditor.deleteSlide has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 5 (7 pts), boolean chains 3, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.setCells (cognitive 27) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:175— XLSXEditor.setCells has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 3 (5 pts), ternaries 3, boolean chains 1, match/switch 1 (nesting depth added 6). Of this number, 19 points are the body's own statements and 8 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
run-post1266-family-cache-tool-matrix.cache_counters (cognitive 27) scripts/live-proof/run-post1266-family-cache-tool-matrix.py:188— run-post1266-family-cache-tool-matrix.cache_counters has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 24, if/else 1 (2 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
OsaurusEvalsCLI.loadFloors (cognitive 26) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:500— OsaurusEvalsCLI.loadFloors has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 3 (5 pts) (nesting depth added 12). Of this number, 13 points are the body's own statements and 13 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.prefillProgressAccountingProblem (cognitive 26) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerCacheProof.swift:705— EvalRunner.prefillProgressAccountingProblem has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 9, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusLocalClient.runAgent (cognitive 26) Packages/OsaurusCore/AppIntents/OsaurusLocalClient.swift:72— OsaurusLocalClient.runAgent has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditMatcher.relaxedMatches (cognitive 26) Packages/OsaurusCore/Folder/FileEditMatcher.swift:386— FileEditMatcher.relaxedMatches has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (11 pts), boolean chains 2, match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
HTTPHandler.handleListSessionsEndpoint::matches (cognitive 26) Packages/OsaurusCore/Networking/HTTPHandler.swift:7682— HTTPHandler.handleListSessionsEndpoint::matches has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 7, ternaries 2 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RelayTunnelManager.connect (cognitive 26) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:413— RelayTunnelManager.connect has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 4 (6 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ModelRuntime.generateEventStream (cognitive 26) Packages/OsaurusCore/Services/ModelRuntime.swift:5889— ModelRuntime.generateEventStream has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 5, ternaries 2 (3 pts), error handling 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelSSDResidency.remoteNGramBytes (cognitive 26) Packages/OsaurusCore/Services/ModelSSDResidency.swift:69— ModelSSDResidency.remoteNGramBytes has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 11, if/else 5 (9 pts), loops 2 (3 pts), ternaries 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppleScriptToolDispatch.exactReplacementLiterals (cognitive 26) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:519— AppleScriptToolDispatch.exactReplacementLiterals has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 16, if/else 5 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigPlanner.planHarnessRuntimes (cognitive 26) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1932— ConfigPlanner.planHarnessRuntimes has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planProviders (cognitive 26) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2186— ConfigPlanner.planProviders has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 1 (4 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelManager.scanLocalModels::scanDir (cognitive 26) Packages/OsaurusCore/Managers/Model/ModelManager.swift:2428— ModelManager.scanLocalModels::scanDir has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (19 pts), ternaries 1 (3 pts), boolean chains 2, loops 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SharedArtifact.processToolResultDetailed (cognitive 26) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:306— SharedArtifact.processToolResultDetailed has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 2 (6 pts), error handling 1 (3 pts), match/switch 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelConnectionService.diagnostics (cognitive 26) Packages/OsaurusCore/Services/AgentChannel/AgentChannelConnectionService.swift:98— AgentChannelConnectionService.diagnostics has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (19 pts), if/else 2 (4 pts), match/switch 1 (2 pts), error handling 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelPublishService.classifyProviderFailure (cognitive 26) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:1127— AgentChannelPublishService.classifyProviderFailure has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (16 pts), match/switch 4 (8 pts), ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DiscordConnectionService.pollInboundMessages (cognitive 26) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:307— DiscordConnectionService.pollInboundMessages has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 2 (3 pts), match/switch 1 (3 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IMessageHelperInstaller.machOArchitectures (cognitive 26) Packages/OsaurusCore/Services/IMessage/IMessageHelperInstaller.swift:325— IMessageHelperInstaller.machOArchitectures has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (2 pts), match/switch 2 (nesting depth added 10). Of this number, 22 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchEngine.raceFree (cognitive 26) Packages/OsaurusCore/Services/Search/SearchEngine.swift:242— SearchEngine.raceFree has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 6 (7 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 9). Of this number, 16 points are the body's own statements and 10 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ClaudePluginInstaller.extractSiblingSkillNames (cognitive 26) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1367— ClaudePluginInstaller.extractSiblingSkillNames has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 4 (7 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseImport.parseDelimited (cognitive 26) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:176— DatabaseImport.parseDelimited has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 5, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatCrossSelection.updateSelection (cognitive 26) Packages/OsaurusCore/Views/Chat/ChatCrossSelection.swift:187— ChatCrossSelection.updateSelection has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 5 (8 pts), boolean chains 4, loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.runRemoteImageGeneration (cognitive 26) Packages/OsaurusCore/Views/Chat/ChatView.swift:6041— ChatSession.runRemoteImageGeneration has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), ternaries 3, boolean chains 2, error handling 2, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FloatingInputCard.attachClipboardSnippet (cognitive 26) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4166— FloatingInputCard.attachClipboardSnippet has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (21 pts), error handling 1 (3 pts), boolean chains 1, match/switch 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FlowLayout.rebalanced (cognitive 26) Packages/OsaurusCore/Views/Common/FlowLayout.swift:118— FlowLayout.rebalanced has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 6 (9 pts), ternaries 2 (3 pts) (nesting depth added 13). Of this number, 25 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CreditsView.webSearchCard (cognitive 26) Packages/OsaurusCore/Views/Credits/CreditsView.swift:432— CreditsView.webSearchCard has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 4 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DOCXEditor.replaceText (cognitive 26) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:190— DOCXEditor.replaceText has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 4 (5 pts), error handling 1 (3 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
vision-bundle-evidence.inspect (cognitive 26) scripts/diagnostics/vision-bundle-evidence.py:14— vision-bundle-evidence.inspect has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 3 (6 pts), loops 3 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
plan-installed-vision.main (cognitive 26) scripts/evals/plan-installed-vision.py:105— plan-installed-vision.main has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 7 (9 pts), ternaries 3 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ManifestValidate.validateTools (cognitive 25) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:292— ManifestValidate.validateTools has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2 (5 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalMatrixBuilder.errorCategory (cognitive 25) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:741— EvalMatrixBuilder.errorCategory has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 17, if/else 7, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FileTreeTool.buildTree::traverse (cognitive 25) Packages/OsaurusCore/Folder/FolderTools.swift:785— FileTreeTool.buildTree::traverse has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (19 pts), ternaries 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditTool.execute (cognitive 25) Packages/OsaurusCore/Folder/FolderTools.swift:3377— FileEditTool.execute has cognitive complexity 25 (threshold 15). Drivers by points: if/else 17 (21 pts), match/switch 3, boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ShellRunTool.execute (cognitive 25) Packages/OsaurusCore/Folder/FolderTools.swift:5347— ShellRunTool.execute has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 3, error handling 2, loops 1 (2 pts), ternaries 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
BackgroundTaskManager.lookupReattachableSession (cognitive 25) REDACTED:1286— BackgroundTaskManager.lookupReattachableSession has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 8, error handling 1, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ToastAction.from (cognitive 25) Packages/OsaurusCore/Models/Toast.swift:376— ToastAction.from has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 6, ternaries 2 (4 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RelayTunnelManager.relayStreamingResponse (cognitive 25) Packages/OsaurusCore/Networking/RelayTunnelManager.swift:939— RelayTunnelManager.relayStreamingResponse has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, loops 1 (2 pts), error handling 1 (nesting depth added 10). Of this number, 23 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaJSONSlices.valueEnd (cognitive 25) Packages/OsaurusCore/Networking/RequestValidator.swift:138— SchemaJSONSlices.valueEnd has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 2, ternaries 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryWriter.persist (cognitive 25) Packages/OsaurusCore/Storage/ChatHistoryWriter.swift:61— ChatHistoryWriter.persist has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (13 pts), ternaries 2 (6 pts), boolean chains 2, error handling 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryDatabase.searchPinnedFactsText (cognitive 25) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1468— MemoryDatabase.searchPinnedFactsText has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (14 pts), ternaries 5 (7 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition. This shape REPEATS in the file: one other method here (MemoryDatabase.searchEpisodesText) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
MemoryDatabase.searchEpisodesText (cognitive 25) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1889— MemoryDatabase.searchEpisodesText has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (14 pts), ternaries 5 (7 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition. This shape REPEATS in the file: one other method here (MemoryDatabase.searchPinnedFactsText) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
ShareArtifactTool.execute (cognitive 25) Packages/OsaurusCore/Tools/ShareArtifactTool.swift:90— ShareArtifactTool.execute has cognitive complexity 25 (threshold 15). Drivers by points: if/else 17 (18 pts), boolean chains 5, ternaries 2 (nesting depth added 1). Of this number, 23 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LoginShellPath.probe (cognitive 25) Packages/OsaurusCore/Utils/LoginShellPath.swift:60— LoginShellPath.probe has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 3 (5 pts), ternaries 2, boolean chains 1, error handling 1 (nesting depth added 9). Of this number, 20 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppleScriptDictionaryService.distill (cognitive 25) Packages/OsaurusCore/AppleScript/Knowledge/AppleScriptDictionaryService.swift:136— AppleScriptDictionaryService.distill has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 5 (8 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScreenContextSnapshot.render (cognitive 25) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextSnapshot.swift:131— ScreenContextSnapshot.render has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyKnowledgeCollections (cognitive 25) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1114— ConfigApplier.applyKnowledgeCollections has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 2 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planTools (cognitive 25) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1552— ConfigPlanner.planTools has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), ternaries 1 (3 pts), loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.validateHarnessRuntimes (cognitive 25) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1862— ConfigPlanner.validateHarnessRuntimes has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionExporter.timingSuffix (cognitive 25) Packages/OsaurusCore/Managers/Chat/ChatSessionExporter.swift:238— ChatSessionExporter.timingSuffix has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 8, ternaries 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentCapabilityReadiness.subagent (cognitive 25) Packages/OsaurusCore/Models/Agent/AgentCapabilityReadiness.swift:133— AgentCapabilityReadiness.subagent has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (21 pts), ternaries 1 (3 pts), match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
PrivacyFilterPipeline.wrapInboundStream (cognitive 25) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:973— PrivacyFilterPipeline.wrapInboundStream has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 1 (2 pts), error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPromptComposer.appendProjectMemory (cognitive 25) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:397— SystemPromptComposer.appendProjectMemory has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFReadingOrder.resolve (cognitive 25) Packages/OsaurusCore/Services/Documents/PDFReadingOrder.swift:90— PDFReadingOrder.resolve has cognitive complexity 25 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 3 (8 pts), boolean chains 2, match/switch 1 (2 pts), ternaries 1 (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
KnowledgeDocumentParser.splitOversized (cognitive 25) Packages/OsaurusCore/Services/Knowledge/KnowledgeDocumentParser.swift:263— KnowledgeDocumentParser.splitOversized has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenizerBridge.compactCompletedDSV4ToolHistory (cognitive 25) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:1185— TokenizerBridge.compactCompletedDSV4ToolHistory has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 8, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.streamResponses (cognitive 25) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:742— RemoteProviderService.streamResponses has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 5, ternaries 2 (3 pts), loops 1 (2 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspacesService.migrateShares (cognitive 25) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:1021— WorkspacesService.migrateShares has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 2 (6 pts), error handling 2 (4 pts), boolean chains 3, loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WhatsAppConnectionService.startPairing (cognitive 25) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:310— WhatsAppConnectionService.startPairing has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 3 (5 pts), boolean chains 3, error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FloatingInputCard.startVoiceInput (cognitive 25) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:1404— FloatingInputCard.startVoiceInput has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 4, loops 1 (2 pts), error handling 1, match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OverviewTab.whereRows (cognitive 25) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1249— OverviewTab.whereRows has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 5, ternaries 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginCard.cardMenu (cognitive 25) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1266— PluginCard.cardMenu has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 3 (9 pts), boolean chains 3, ternaries 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AccessibilityManager.focusedWindowHasContent (cognitive 25) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:398— AccessibilityManager.focusedWindowHasContent has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (4 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 12). Of this number, 24 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.expandSharedFormulas (cognitive 25) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:586— XLSXEditor.expandSharedFormulas has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 7, loops 4 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusEvalsCLI.forensicsLabel (cognitive 24) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/OsaurusEvalsCLI.swift:752— OsaurusEvalsCLI.forensicsLabel has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 7 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusEvalsCLI.runCompat (cognitive 24) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalDiffMatrixCLI.swift:210— OsaurusEvalsCLI.runCompat has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 1 (2 pts), ternaries 1 (2 pts), error handling 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runComputerUseCase (cognitive 24) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1095— EvalRunner.runComputerUseCase has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 3, ternaries 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
OsaurusBundle.contentHash (cognitive 24) Packages/OsaurusRepository/ImportQueue.swift:378— OsaurusBundle.contentHash has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 4, loops 2 (4 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
DeclaredReasoningEffort.flatNativeEfforts (cognitive 24) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:202— DeclaredReasoningEffort.flatNativeEfforts has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), ternaries 2 (5 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HuggingFaceService.fetchTree (cognitive 24) Packages/OsaurusCore/Services/HuggingFaceService.swift:371— HuggingFaceService.fetchTree has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (12 pts), error handling 3 (6 pts), ternaries 1 (4 pts), boolean chains 1, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.extractImageSources (cognitive 24) Packages/OsaurusCore/Services/ModelRuntime.swift:7236— ModelRuntime.extractImageSources has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 6, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelSSDResidency.fetch (cognitive 24) Packages/OsaurusCore/Services/ModelSSDResidency.swift:135— ModelSSDResidency.fetch has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 6, loops 1 (2 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryDatabase.contentHash (cognitive 24) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1918— ChatHistoryDatabase.contentHash has cognitive complexity 24 (threshold 15). Drivers by points: if/else 21, boolean chains 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SandboxWriteFileTool.execute (cognitive 24) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2122— SandboxWriteFileTool.execute has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 7 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolRegistry.availability (cognitive 24) Packages/OsaurusCore/Tools/ToolRegistry.swift:2892— ToolRegistry.availability has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 9 (nesting depth added 3). Of this number, 23 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MapsToolFactory.placeReference (cognitive 24) Packages/OsaurusCore/AppleApps/Maps/MapsTools.swift:84— MapsToolFactory.placeReference has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 6 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMacDriver.perform (cognitive 24) Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:192— NativeMacDriver.perform has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 1, match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AgentToolSelectionResolver.apply (cognitive 24) Packages/OsaurusCore/Configuration/Declarative/AgentToolSelectionResolver.swift:124— AgentToolSelectionResolver.apply has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginManager.deliverInitialConfig (cognitive 24) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:602— PluginManager.deliverInitialConfig has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 7, loops 2 (3 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
JSONValue.normalizedChatTemplateSchemaValue (cognitive 24) Packages/OsaurusCore/Models/API/OpenAIAPI.swift:1535— JSONValue.normalizedChatTemplateSchemaValue has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 2 (4 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
LocalVisionEvidence.mimoAudioEvidence (cognitive 24) Packages/OsaurusCore/Models/Configuration/LocalVisionEvidence.swift:286— LocalVisionEvidence.mimoAudioEvidence has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 23, if/else 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
CodeBlockMasker.mask (cognitive 24) Packages/OsaurusCore/PrivacyFilter/Core/CodeBlockMasker.swift:42— CodeBlockMasker.mask has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 9, loops 3 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextCompactionService.renderTranscript (cognitive 24) Packages/OsaurusCore/Services/Chat/ContextCompactionService.swift:505— ContextCompactionService.renderTranscript has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (7 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFEditor.printedLabels (cognitive 24) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:479— PDFEditor.printedLabels has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXPackageArchive.readCentralDirectory (cognitive 24) Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:1012— XLSXPackageArchive.readCentralDirectory has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 10, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileChangeJournal.apply (cognitive 24) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal+Revert.swift:426— FileChangeJournal.apply has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (18 pts), ternaries 1 (3 pts), boolean chains 2, match/switch 1 (nesting depth added 9). Of this number, 20 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ClaudeCodeStreamDecoder.decodeStreamEvent (cognitive 24) Packages/OsaurusCore/Services/Inference/ClaudeCodeStreamDecoder.swift:103— ClaudeCodeStreamDecoder.decodeStreamEvent has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, match/switch 2 (3 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
WorkspaceSyncService.receive (cognitive 24) Packages/OsaurusCore/Services/Router/WorkspaceSyncService.swift:265— WorkspaceSyncService.receive has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 8, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspacesService.pollConfirmation (cognitive 24) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:1607— WorkspacesService.pollConfirmation has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ClaudePluginInstaller.fetchArtifacts (cognitive 24) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:868— ClaudePluginInstaller.fetchArtifacts has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (8 pts), loops 8, error handling 3 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryList.filteredSessions (cognitive 24) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3233— ChatHistoryList.filteredSessions has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 16, if/else 5 (8 pts) (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PasteMonitorView.handlePasteIfImage (cognitive 24) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:6626— PasteMonitorView.handlePasteIfImage has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ClaudePluginDetailView.installOutcomeMessages (cognitive 24) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:375— ClaudePluginDetailView.installOutcomeMessages has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 5 (13 pts), if/else 6 (10 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginConfigView.statusField (cognitive 24) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:475— PluginConfigView.statusField has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 1 (4 pts), ternaries 4, boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsManagerView.allToolsTabContent (cognitive 24) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:187— ToolsManagerView.allToolsTabContent has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 7, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPermissionRow.body (cognitive 24) Packages/OsaurusCore/Views/Settings/PermissionsView.swift:120— SystemPermissionRow.body has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 11 (15 pts), if/else 7 (9 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceDetailView.sharedAgentsSection (cognitive 24) Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:1279— WorkspaceDetailView.sharedAgentsSection has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 5 (11 pts), if/else 7 (9 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DOCXEditor.replaceAcrossParagraphs (cognitive 24) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:496— DOCXEditor.replaceAcrossParagraphs has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 4 (8 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarkdownBlockParsing.swift.tryParseBlockMath (cognitive 24) Packages/OsaurusCore/Utils/MarkdownBlockParsing.swift:437— MarkdownBlockParsing.swift.tryParseBlockMath has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalCompatBuilder.validate (cognitive 23) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCompat.swift:759— EvalCompatBuilder.validate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.scoreDbState (cognitive 23) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1775— EvalRunner.scoreDbState has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 3, loops 1 (2 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runSubagentCase (cognitive 23) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:37— EvalRunner.runSubagentCase has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 3 (6 pts), boolean chains 4, loops 1 (2 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BoundedArchiveExtractor.validateLocalHeader (cognitive 23) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:486— BoundedArchiveExtractor.validateLocalHeader has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 11 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MinisignVerifier.parseSignature (cognitive 23) Packages/OsaurusRepository/MinisignVerifier.swift:95— MinisignVerifier.parseSignature has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 9, if/else 5 (9 pts), loops 2 (4 pts), ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileWriteDocumentRouting.workbook (cognitive 23) Packages/OsaurusCore/Folder/FileWriteDocumentRouting.swift:258— FileWriteDocumentRouting.workbook has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (7 pts), loops 1 (3 pts), error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IdentityHealthCheck.diagnose (cognitive 23) Packages/OsaurusCore/Identity/IdentityHealthCheck.swift:70— IdentityHealthCheck.diagnose has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 4, error handling 2 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleDispatchEndpoint (cognitive 23) Packages/OsaurusCore/Networking/HTTPHandler.swift:11676— HTTPHandler.handleDispatchEndpoint has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 5, ternaries 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GitHubSkillService.detectDefaultBranch (cognitive 23) Packages/OsaurusCore/Services/GitHubSkillService.swift:1929— GitHubSkillService.detectDefaultBranch has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 4, error handling 3 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalGenerationDefaults.repairOrnith15A3BManualMTPBlockIfNeeded (cognitive 23) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:316— LocalGenerationDefaults.repairOrnith15A3BManualMTPBlockIfNeeded has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 5, error handling 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DirectDownloader.download (cognitive 23) Packages/OsaurusCore/Services/ModelDownloadService.swift:1824— DirectDownloader.download has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ActivityLogStore.verify (cognitive 23) Packages/OsaurusCore/Storage/ActivityLogStore.swift:491— ActivityLogStore.verify has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (19 pts), ternaries 2, boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDatabase.createTable (cognitive 23) Packages/OsaurusCore/Storage/AgentDatabase.swift:636— AgentDatabase.createTable has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 3 (4 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SubagentAdmissionLease.suspending (cognitive 23) Packages/OsaurusCore/Subagent/SubagentAdmissionLease.swift:32— SubagentAdmissionLease.suspending has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 7, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchKnowledgeTool.execute (cognitive 23) Packages/OsaurusCore/Tools/KnowledgeTools.swift:287— SearchKnowledgeTool.execute has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (17 pts), ternaries 3 (5 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentAction.semanticProblem (cognitive 23) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:535— AgentAction.semanticProblem has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 2, match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ScreenContextDistiller.focusedElement (cognitive 23) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:290— ScreenContextDistiller.focusedElement has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 8, ternaries 5 (8 pts), if/else 5 (7 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusConfigTool.loadDocument (cognitive 23) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:744— OsaurusConfigTool.loadDocument has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, ternaries 1 (3 pts), error handling 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatWindowState.loadSession (cognitive 23) Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:1324— ChatWindowState.loadSession has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatWindowState.setupNotificationObservers (cognitive 23) Packages/OsaurusCore/Managers/Chat/ChatWindowState.swift:2579— ChatWindowState.setupNotificationObservers has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 8 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PluginManager.toolsDirectoryURLsWithFailures (cognitive 23) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1841— PluginManager.toolsDirectoryURLsWithFailures has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 1 (5 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomHTTPResponseMapping.validatePath (cognitive 23) Packages/OsaurusCore/Models/AgentChannel/AgentChannelCustomJSONModels.swift:86— AgentChannelCustomHTTPResponseMapping.validatePath has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 8, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenResponsesSSEWriter.writeProviderEvent (cognitive 23) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1627— OpenResponsesSSEWriter.writeProviderEvent has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 10 (nesting depth added 4). Of this number, 18 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ServerRuntimeSettingsStore.shouldRepairPagedCacheDefault (cognitive 23) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:531— ServerRuntimeSettingsStore.shouldRepairPagedCacheDefault has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 22, if/else 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SchemaDumper.render (cognitive 23) Packages/OsaurusCore/Services/AgentBridge/SchemaDumper.swift:31— SchemaDumper.render has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (7 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelDispatchRouter.resolve (cognitive 23) Packages/OsaurusCore/Services/AgentChannel/AgentChannelDispatchRouter.swift:32— AgentChannelDispatchRouter.resolve has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 4, loops 2 (3 pts), ternaries 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelRoomDirectory.load (cognitive 23) Packages/OsaurusCore/Services/AgentChannel/AgentChannelRoomDirectory.swift:76— AgentChannelRoomDirectory.load has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 2 (5 pts), ternaries 1 (4 pts), boolean chains 2, error handling 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceDelegationEvaluator.run (cognitive 23) Packages/OsaurusCore/Services/AgentDelegation/WorkspaceDelegationEvaluator.swift:92— WorkspaceDelegationEvaluator.run has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 4 (5 pts), loops 3 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GroundedConfigClaimCheck.containsFabricatedToolCall (cognitive 23) Packages/OsaurusCore/Services/Chat/GroundedConfigClaimCheck.swift:137— GroundedConfigClaimCheck.containsFabricatedToolCall has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarkdownRichTextRenderer.blockDescriptor (cognitive 23) Packages/OsaurusCore/Services/Documents/MarkdownRichTextRenderer.swift:228— MarkdownRichTextRenderer.blockDescriptor has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (19 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileChangeJournal.revert (cognitive 23) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal+Revert.swift:253— FileChangeJournal.revert has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 3 (5 pts), error handling 1 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeCurationService.approve (cognitive 23) Packages/OsaurusCore/Services/Knowledge/KnowledgeCurationService.swift:47— KnowledgeCurationService.approve has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 6, match/switch 1 (2 pts), error handling 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
KnowledgeIndexService.indexCollection (cognitive 23) Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift:80— KnowledgeIndexService.indexCollection has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 3, boolean chains 2, error handling 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MLXBatchAdapter.prepareInput (cognitive 23) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:2355— MLXBatchAdapter.prepareInput has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), error handling 2 (4 pts), boolean chains 3 (nesting depth added 7). Of this number, 21 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteChatRequest.isStrictResponsesToolSchema::isStrict (cognitive 23) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:5704— RemoteChatRequest.isStrictResponsesToolSchema::isStrict has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 4, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceAgentAccessHost.redeem (cognitive 23) Packages/OsaurusCore/Services/Router/WorkspaceAgentAccessHost.swift:355— WorkspaceAgentAccessHost.redeem has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 10, error handling 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
WorkspaceAgentLiveness.classify (cognitive 23) Packages/OsaurusCore/Services/Router/WorkspaceAgentLiveness.swift:78— WorkspaceAgentLiveness.classify has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
WorkspaceAgentRunClient.prepare (cognitive 23) Packages/OsaurusCore/Services/Router/WorkspaceAgentRunClient.swift:154— WorkspaceAgentRunClient.prepare has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 4, error handling 1 (2 pts), match/switch 1, ternaries 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
TelegramConnectionService.processUpdates (cognitive 23) Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:1065— TelegramConnectionService.processUpdates has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 3 (8 pts), ternaries 1 (3 pts), loops 2, boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryFilterPicker.passes (cognitive 23) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:412— ChatHistoryFilterPicker.passes has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 15, if/else 8. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FloatingInputCard.sandboxToggleChip (cognitive 23) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:3875— FloatingInputCard.sandboxToggleChip has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 7 (10 pts), if/else 7, boolean chains 6 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
NativeMarkdownView.scheduleImageLoad (cognitive 23) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:1323— NativeMarkdownView.scheduleImageLoad has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 6, error handling 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
SelectableTextView.applyThemeStyling (cognitive 23) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:821— SelectableTextView.applyThemeStyling has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 8, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeView.body (cognitive 23) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:71— KnowledgeView.body has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9, ternaries 5 (8 pts), error handling 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ProviderCardView.body (cognitive 23) Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:688— ProviderCardView.body has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10, boolean chains 9, ternaries 3 (4 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ScreenshotController.capture (cognitive 23) Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:151— ScreenshotController.capture has cognitive complexity 23 (threshold 15). Drivers by points: if/else 16 (20 pts), boolean chains 2, ternaries 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DOCXEditor.appendMarkdown (cognitive 23) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:852— DOCXEditor.appendMarkdown has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 3 (6 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsList.execute (cognitive 22) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsList.swift:11— ToolsList.execute has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 1 (3 pts), boolean chains 1, error handling 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsUninstall.resolveTargetDirectory (cognitive 22) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsUninstall.swift:47— ToolsUninstall.resolveTargetDirectory has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusEvalsCLI.runOptimizeContext (cognitive 22) Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/ContextOptimizeCLI.swift:37— OsaurusEvalsCLI.runOptimizeContext has cognitive complexity 22 (threshold 15). Drivers by points: loops 5 (8 pts), error handling 6 (7 pts), if/else 3, ternaries 1 (2 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.scoreTranscriptAssertions (cognitive 22) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1336— EvalRunner.scoreTranscriptAssertions has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
RunEnvironment.summary (cognitive 22) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/RunEnvironment.swift:281— RunEnvironment.summary has cognitive complexity 22 (threshold 15). Drivers by points: if/else 19, boolean chains 2, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BackgroundTaskManager.markCompleted (cognitive 22) REDACTED:1736— BackgroundTaskManager.markCompleted has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 7 (15 pts), if/else 3 (4 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaJSONSlices.members (cognitive 22) Packages/OsaurusCore/Networking/RequestValidator.swift:165— SchemaJSONSlices.members has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 4, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelCompatibilityDiagnostics.evidenceRows (cognitive 22) Packages/OsaurusCore/Services/ModelCompatibilityDiagnostics.swift:660— ModelCompatibilityDiagnostics.evidenceRows has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (17 pts), ternaries 4 (5 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.ensureJANGTQSidecar (cognitive 22) Packages/OsaurusCore/Services/ModelRuntime.swift:8008— ModelRuntime.ensureJANGTQSidecar has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, error handling 2 (4 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDatabase.execute (cognitive 22) Packages/OsaurusCore/Storage/AgentDatabase.swift:1731— AgentDatabase.execute has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 3 (7 pts), boolean chains 1, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginDatabase.performQuery (cognitive 22) Packages/OsaurusCore/Storage/PluginDatabase.swift:317— PluginDatabase.performQuery has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (4 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StorageMigrationCoordinator.convergeBlobs (cognitive 22) Packages/OsaurusCore/Storage/StorageMigrationCoordinator.swift:332— StorageMigrationCoordinator.convergeBlobs has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (19 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SpawnResultCompaction.modelVisible (cognitive 22) Packages/OsaurusCore/Subagent/SpawnResultCompaction.swift:54— SpawnResultCompaction.modelVisible has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (14 pts), boolean chains 7, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SandboxPluginTool.validateArguments (cognitive 22) Packages/OsaurusCore/Tools/SandboxPluginTool.swift:124— SandboxPluginTool.validateArguments has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (19 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusPaths.migrateLegacyPersonasIfNeeded (cognitive 22) Packages/OsaurusCore/Utils/OsaurusPaths.swift:920— OsaurusPaths.migrateLegacyPersonasIfNeeded has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (9 pts), error handling 2 (8 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BrowserSnapshotFormatter.line (cognitive 22) Packages/OsaurusCore/Browser/Runtime/BrowserSupport.swift:249— BrowserSnapshotFormatter.line has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 9 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentView.build (cognitive 22) Packages/OsaurusCore/ComputerUse/Model/AgentView.swift:111— AgentView.build has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 5 (9 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EffectClassifier.classify (cognitive 22) Packages/OsaurusCore/ComputerUse/Policy/EffectClassifier.swift:32— EffectClassifier.classify has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 12, if/else 7 (9 pts), ternaries 1 (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigApplier.applyHarnessRuntimes (cognitive 22) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:617— ConfigApplier.applyHarnessRuntimes has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionImportCoordinator.run (cognitive 22) Packages/OsaurusCore/Managers/Chat/ChatSessionImportCoordinator.swift:120— ChatSessionImportCoordinator.run has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), error handling 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatMessage.appendScrubbableTexts (cognitive 22) Packages/OsaurusCore/PrivacyFilter/Core/MessageScrubbing.swift:126— ChatMessage.appendScrubbableTexts has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (9 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiff.stringValue (cognitive 22) Packages/OsaurusCore/Models/Chat/FileDiff.swift:468— FileDiff.stringValue has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (5 pts), boolean chains 2, loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ServerRuntimeSettingsStore.shouldRepairLegacyCacheDefaults (cognitive 22) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:492— ServerRuntimeSettingsStore.shouldRepairLegacyCacheDefaults has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 21, if/else 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PluginManifest.matchRouteWithParams (cognitive 22) Packages/OsaurusCore/Models/Plugin/ExternalPlugin.swift:535— PluginManifest.matchRouteWithParams has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 pts), ternaries 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelInboundRelay.submit (cognitive 22) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:135— AgentChannelInboundRelay.submit has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 7, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelPublishService.sendPolicyDenial (cognitive 22) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:763— AgentChannelPublishService.sendPolicyDenial has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, error handling 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DiscordConnectionService.diagnostics (cognitive 22) Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:527— DiscordConnectionService.diagnostics has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (13 pts), loops 2 (4 pts), error handling 2 (3 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DiscordGatewayPresenceRuntime.runSession (cognitive 22) Packages/OsaurusCore/Services/Discord/DiscordGatewayPresenceRuntime.swift:193— DiscordGatewayPresenceRuntime.runSession has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 3, error handling 3, match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFEditor.formFieldGroups (cognitive 22) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:193— PDFEditor.formFieldGroups has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (8 pts), match/switch 2 (5 pts), boolean chains 4, ternaries 1 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPTXAdapter.securityMetadata (cognitive 22) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:714— PPTXAdapter.securityMetadata has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiffEngine.wordHighlights (cognitive 22) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:382— FileDiffEngine.wordHighlights has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ClaudeCodeHarnessAdapter.launchPlan (cognitive 22) Packages/OsaurusCore/Services/Harness/ClaudeCodeHarnessAdapter.swift:38— ClaudeCodeHarnessAdapter.launchPlan has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 5, ternaries 3 (5 pts), match/switch 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FoundationModelService.respondWithTools (cognitive 22) Packages/OsaurusCore/Services/Inference/FoundationModelService.swift:408— FoundationModelService.respondWithTools has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), error handling 2 (4 pts), loops 1 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ActivityExportCoordinator.run (cognitive 22) Packages/OsaurusCore/Services/Insights/ActivityExportCoordinator.swift:17— ActivityExportCoordinator.run has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 3 (7 pts), boolean chains 1, error handling 1, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryConsolidator.runOnce (cognitive 22) Packages/OsaurusCore/Services/Memory/MemoryConsolidator.swift:134— MemoryConsolidator.runOnce has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (9 pts), error handling 4 (5 pts), loops 2 (5 pts), ternaries 1 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PhoneAgentEditing.patch (cognitive 22) Packages/OsaurusCore/Services/MobileConnect/PhoneAgentEditing.swift:121— PhoneAgentEditing.patch has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 6 (nesting depth added 2). Of this number, 17 points are the body's own statements and 5 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PluginProcessHostClient.startReader (cognitive 22) Packages/OsaurusCore/Services/Plugin/PluginProcessHost.swift:298— PluginProcessHostClient.startReader has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SSELineParser.append (cognitive 22) Packages/OsaurusCore/Services/Provider/OpenAICompatibleStreamParser.swift:37— SSELineParser.append has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (15 pts), ternaries 1 (4 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.connectWithRetry (cognitive 22) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:990— RemoteProviderService.connectWithRetry has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 3, ternaries 1 (3 pts), error handling 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DDGScrapeBackend.parseHTML (cognitive 22) Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:65— DDGScrapeBackend.parseHTML has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolIndexService.exposureDiagnostic (cognitive 22) Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:176— ToolIndexService.exposureDiagnostic has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11, boolean chains 8, ternaries 1 (2 pts), match/switch 1 (nesting depth added 1). Of this number, 21 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentDetailView.bodyCore (cognitive 22) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1875— AgentDetailView.bodyCore has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 6, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatTabContextMenu.makeMenu (cognitive 22) Packages/OsaurusCore/Views/Chat/ChatTabStripView.swift:821— ChatTabContextMenu.makeMenu has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), ternaries 3 (7 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FloatingInputCard.modelPickerOptionsControl (cognitive 22) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:3343— FloatingInputCard.modelPickerOptionsControl has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (15 pts), ternaries 3 (6 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FloatingInputCard.refreshMTPLayoutAdvisory (cognitive 22) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:4495— FloatingInputCard.refreshMTPLayoutAdvisory has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 4, match/switch 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FloatingInputCard.catalogMediaComposerChips (cognitive 22) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5401— FloatingInputCard.catalogMediaComposerChips has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (11 pts), ternaries 3 (6 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
FloatingCreditsChip.body (cognitive 22) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8891— FloatingCreditsChip.body has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 6, ternaries 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PreviewGenerator.jsonPreview (cognitive 22) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:197— PreviewGenerator.jsonPreview has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 4, loops 2 (3 pts), ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RedactionHighlighter.applyInternal (cognitive 22) Packages/OsaurusCore/Views/Chat/RedactionHighlighter.swift:174— RedactionHighlighter.applyInternal has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnchoredCardCoordinator.handle (cognitive 22) Packages/OsaurusCore/Views/Common/AnchoredCardPresenter.swift:517— AnchoredCardCoordinator.handle has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 7 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SettingsEmptyState.body (cognitive 22) Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:55— SettingsEmptyState.body has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 12 (18 pts), if/else 4 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ParsedMessage.init (cognitive 22) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:2003— ParsedMessage.init has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 1 (4 pts), loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryView.diagnosticHeadline (cognitive 22) Packages/OsaurusCore/Views/Memory/MemoryDiagnosticsViews.swift:1001— MemoryView.diagnosticHeadline has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 3, match/switch 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginConfigView.validateField (cognitive 22) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:667— PluginConfigView.validateField has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 9 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
AccessibilityManager.traverse (cognitive 22) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:592— AccessibilityManager.traverse has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Accessibility.swift.computeFocusedContent (cognitive 22) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1123— Accessibility.swift.computeFocusedContent has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 9, ternaries 2 (nesting depth added 2). Of this number, 19 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
leaderboard.locale_value_map (cognitive 22) scripts/i18n/leaderboard.py:148— leaderboard.locale_value_map has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (6 pts), boolean chains 5 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BundleLoad.run (cognitive 21) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bundle/BundleLoad.swift:53— BundleLoad.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), loops 3 (5 pts), error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsDev.runProjectMode (cognitive 21) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsDev.swift:59— ToolsDev.runProjectMode has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.parseToolResultGroundingEvents (cognitive 21) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerToolResultGrounding.swift:243— EvalRunner.parseToolResultGroundingEvents has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (16 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginInstallManager.installVerifiedArtifact (cognitive 21) Packages/OsaurusRepository/PluginInstallManager.swift:168— PluginInstallManager.installVerifiedArtifact has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SemanticVersion.comparePrerelease (cognitive 21) Packages/OsaurusRepository/SemanticVersion.swift:59— SemanticVersion.comparePrerelease has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 4 (11 pts), if/else 5 (8 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToastManager.handleBuiltInAction (cognitive 21) Packages/OsaurusCore/Managers/ToastManager.swift:354— ToastManager.handleBuiltInAction has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 1, match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
BundledModelSeeder.seed (cognitive 21) Packages/OsaurusCore/Services/BundledModelSeeder.swift:231— BundledModelSeeder.seed has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, error handling 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ExternalModelLocator.scanReport::walk (cognitive 21) Packages/OsaurusCore/Services/ExternalModelLocator.swift:718— ExternalModelLocator.scanReport::walk has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 2 (5 pts), boolean chains 3, error handling 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GitHubSkillService.buildManifest (cognitive 21) Packages/OsaurusCore/Services/GitHubSkillService.swift:1559— GitHubSkillService.buildManifest has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 6 (7 pts), boolean chains 6 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ModelRuntime.resolveLocalModelDirectory (cognitive 21) Packages/OsaurusCore/Services/ModelRuntime.swift:8306— ModelRuntime.resolveLocalModelDirectory has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 2, loops 2, ternaries 1 (nesting depth added 6). Most of this is not in the body itself: 2 of the 21 points are its own statements and the rest belongs to 3 function items inside it that branch (scan, loadableBundle, withoutCrackSuffix). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
MemoryDatabase.searchTranscriptText (cognitive 21) Packages/OsaurusCore/Storage/MemoryDatabase.swift:2359— MemoryDatabase.searchTranscriptText has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 4 (6 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StorageDatabaseCatalog.databaseTargets (cognitive 21) Packages/OsaurusCore/Storage/StorageDatabaseCatalog.swift:37— StorageDatabaseCatalog.databaseTargets has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilitiesDiscoverTool.namedToolCandidates (cognitive 21) Packages/OsaurusCore/Tools/CapabilityTools.swift:772— CapabilitiesDiscoverTool.namedToolCandidates has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (9 pts), ternaries 2 (6 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InlineThinkSplitter.process (cognitive 21) Packages/OsaurusCore/Utils/InlineThinkSplitter.swift:42— InlineThinkSplitter.process has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (10 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StringCleaning.matchingBraceIndex (cognitive 21) Packages/OsaurusCore/Utils/StringCleaning.swift:165— StringCleaning.matchingBraceIndex has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applySearchProviders (cognitive 21) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2263— ConfigApplier.applySearchProviders has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 2 (6 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planChannels (cognitive 21) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1782— ConfigPlanner.planChannels has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 5, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionImporter.parse (cognitive 21) Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:88— ChatSessionImporter.parse has cognitive complexity 21 (threshold 15). Drivers by points: if/else 18 (20 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PluginManager.compatibilityFailure (cognitive 21) Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1028— PluginManager.compatibilityFailure has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SessionCapability.derive (cognitive 21) Packages/OsaurusCore/Models/Chat/SessionCapability.swift:39— SessionCapability.derive has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (5 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SpokenEmails.find (cognitive 21) Packages/OsaurusCore/PrivacyFilter/Core/SpokenNumberDetector.swift:183— SpokenEmails.find has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelInboundRelay.waitForReply (cognitive 21) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:768— AgentChannelInboundRelay.waitForReply has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (17 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScriptedSubagentKind.run (cognitive 21) Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:1292— ScriptedSubagentKind.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFAdapter.selectionRange (cognitive 21) Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:231— PDFAdapter.selectionRange has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 17, if/else 2 (3 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FileDiffEngine.lineDiff (cognitive 21) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:195— FileDiffEngine.lineDiff has cognitive complexity 21 (threshold 15). Drivers by points: loops 7 (10 pts), boolean chains 6, match/switch 1 (3 pts), if/else 2 (nesting depth added 5). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
FileDiffEngine.myers (cognitive 21) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:236— FileDiffEngine.myers has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 6, loops 3 (6 pts) (nesting depth added 7). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.waitForServers (cognitive 21) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:731— PendingImportProcessor.waitForServers has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StreamingStatsHint.decode (cognitive 21) Packages/OsaurusCore/Services/Inference/ModelService.swift:573— StreamingStatsHint.decode has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 10, if/else 8, ternaries 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LocalVideoRequestPolicy.init (cognitive 21) Packages/OsaurusCore/Services/MediaGeneration/LocalVideoRequestPolicy.swift:13— LocalVideoRequestPolicy.init has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 14, if/else 5, match/switch 1, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MediaGenerationCoordinator.validateImageRequest (cognitive 21) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:579— MediaGenerationCoordinator.validateImageRequest has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 10, if/else 8, loops 1 (2 pts), ternaries 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MediaGenerationCoordinator.validateVideoRequest (cognitive 21) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:630— MediaGenerationCoordinator.validateVideoRequest has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 9, if/else 9, ternaries 2 (3 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PluginHostContext.applyAgentTools (cognitive 21) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:1237— PluginHostContext.applyAgentTools has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 1 (4 pts) (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
InboundSharedRunBridge.resolveHostedSession (cognitive 21) Packages/OsaurusCore/Services/Router/InboundSharedRunBridge.swift:141— InboundSharedRunBridge.resolveHostedSession has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 7, ternaries 2 (3 pts) (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SharedAgentStatus.derive (cognitive 21) Packages/OsaurusCore/Services/Router/SharedAgentIdentity.swift:260— SharedAgentStatus.derive has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 6, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
DatabaseImport.isDecimalLiteral (cognitive 21) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:590— DatabaseImport.isDecimalLiteral has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 6 (9 pts), loops 1 (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatSession.send (cognitive 21) Packages/OsaurusCore/Views/Chat/ChatView.swift:6353— ChatSession.send has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 10, if/else 9 (10 pts), ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FloatingInputCard.attachIfAllowed (cognitive 21) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:5108— FloatingInputCard.attachIfAllowed has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (20 pts), ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VoiceStateSyncObservers.body (cognitive 21) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:9482— VoiceStateSyncObservers.body has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 7 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMarkdownView.measureMixedSegmentHeight (cognitive 21) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:747— NativeMarkdownView.measureMixedSegmentHeight has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeToolCallGroupView.configure (cognitive 21) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:702— NativeToolCallGroupView.configure has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 4 (8 pts), boolean chains 5, if/else 4 (5 pts), loops 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OverviewTab.commonFacts (cognitive 21) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1143— OverviewTab.commonFacts has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 6, ternaries 2 (4 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OverviewTab.generationRows (cognitive 21) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1634— OverviewTab.generationRows has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (15 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginConfigView.loadConfig (cognitive 21) Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:598— PluginConfigView.loadConfig has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 6, loops 3 (4 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginsView.updateFilteredLists (cognitive 21) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:931— PluginsView.updateFilteredLists has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 4 (7 pts), boolean chains 6 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEditor.setCell (cognitive 21) Packages/OsaurusCore/Services/Documents/OOXML/XLSXEditor.swift:231— XLSXEditor.setCell has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (5 pts), boolean chains 2, loops 1, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPOAuthURLPolicy.isLocalOrPrivateHost (cognitive 21) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthHTTPTransport.swift:122— MCPOAuthURLPolicy.isLocalOrPrivateHost has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 16, if/else 5. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
run-local-family-multiturn-tool-cache-proof.cache_evidence_checks (cognitive 21) scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:139— run-local-family-multiturn-tool-cache-proof.cache_evidence_checks has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 10, boolean chains 7, if/else 2 (3 pts), loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
InstallationDiagnostics.classify (cognitive 20) Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift:281— InstallationDiagnostics.classify has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 5, ternaries 3 (5 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportCommand.runValidate (cognitive 20) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:388— ImportCommand.runValidate has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, ternaries 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BoundedArchiveExtractor.validatedPath (cognitive 20) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:419— BoundedArchiveExtractor.validatedPath has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 9, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BoundedArchiveExtractor.verify (cognitive 20) Packages/OsaurusRepository/BoundedArchiveExtractor.swift:960— BoundedArchiveExtractor.verify has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 1 (2 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileReadTool.loadBoundedRawText (cognitive 20) Packages/OsaurusCore/Folder/FolderTools.swift:1986— FileReadTool.loadBoundedRawText has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 4, loops 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleCacheStatsEndpoint (cognitive 20) Packages/OsaurusCore/Networking/HTTPHandler.swift:1493— HTTPHandler.handleCacheStatsEndpoint has cognitive complexity 20 (threshold 15). Drivers by points: if/else 19, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleImageGenerations (cognitive 20) Packages/OsaurusCore/Networking/HTTPHandler.swift:12757— HTTPHandler.handleImageGenerations has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 3 (4 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleAudioTranscriptions (cognitive 20) Packages/OsaurusCore/Networking/HTTPHandler.swift:17332— HTTPHandler.handleAudioTranscriptions has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 3, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDownloadService.makeAlert (cognitive 20) Packages/OsaurusCore/Services/ModelDownloadService.swift:102— ModelDownloadService.makeAlert has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, if/else 10. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelRuntime.unload (cognitive 20) Packages/OsaurusCore/Services/ModelRuntime.swift:2241— ModelRuntime.unload has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.materializeMediaDataUrlResult (cognitive 20) Packages/OsaurusCore/Services/ModelRuntime.swift:7559— ModelRuntime.materializeMediaDataUrlResult has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (13 pts), match/switch 2 (6 pts), error handling 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AgentDatabase.softDeleteMany (cognitive 20) Packages/OsaurusCore/Storage/AgentDatabase.swift:1174— AgentDatabase.softDeleteMany has cognitive complexity 20 (threshold 15). Drivers by points: loops 7 (14 pts), if/else 4 (5 pts), boolean chains 1 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
SubagentBatchAdmissionPlanner.planInternal (cognitive 20) Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:471— SubagentBatchAdmissionPlanner.planInternal has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 5, ternaries 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
SandboxExecTool.execute (cognitive 20) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2665— SandboxExecTool.execute has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 3, error handling 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxInstallTool.execute (cognitive 20) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3466— SandboxInstallTool.execute has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9, boolean chains 3, error handling 3, ternaries 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CapabilitiesLoadTool.loadTool (cognitive 20) Packages/OsaurusCore/Tools/CapabilityTools.swift:1232— CapabilitiesLoadTool.loadTool has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 5 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
UpdateKnowledgeTicketTool.execute (cognitive 20) Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:330— UpdateKnowledgeTicketTool.execute has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 6, ternaries 1 (2 pts), error handling 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
SecretArgumentScrubber.scrubForPersistence (cognitive 20) Packages/OsaurusCore/Tools/SandboxSecretTools.swift:337— SecretArgumentScrubber.scrubForPersistence has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 6, loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CNContactsService.apply (cognitive 20) Packages/OsaurusCore/AppleApps/Contacts/ContactsService.swift:351— CNContactsService.apply has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12, ternaries 4 (8 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
AppleScriptToolDispatch.literalContractViolation (cognitive 20) Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift:659— AppleScriptToolDispatch.literalContractViolation has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 11, if/else 5, ternaries 2 (4 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ScreenContextDistiller.buildWindows (cognitive 20) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:249— ScreenContextDistiller.buildWindows has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigManifest.jsonSchema (cognitive 20) Packages/OsaurusCore/Configuration/Declarative/ConfigManifest.swift:885— ConfigManifest.jsonSchema has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (10 pts), ternaries 2 (5 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AgentChannelLiveProofReadiness.imessage (cognitive 20) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:203— AgentChannelLiveProofReadiness.imessage has cognitive complexity 20 (threshold 15). Drivers by points: if/else 16 (19 pts), ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AgentChannelEvalHarness.runProactivePublish (cognitive 20) REDACTED:663— AgentChannelEvalHarness.runProactivePublish has cognitive complexity 20 (threshold 15). Drivers by points: if/else 17 (18 pts), boolean chains 2 (nesting depth added 1). Of this number, 19 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AppleScriptEvaluator.run (cognitive 20) Packages/OsaurusCore/Services/Context/AppleScriptEvaluator.swift:226— AppleScriptEvaluator.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), match/switch 3 (5 pts), boolean chains 3, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MicroPerfEvaluator.measureRep (cognitive 20) Packages/OsaurusCore/Services/Context/MicroPerfEvaluator.swift:497— MicroPerfEvaluator.measureRep has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileChangeJournal.preciseSnapshot (cognitive 20) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal.swift:343— FileChangeJournal.preciseSnapshot has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileDiffEngine.wordRanges (cognitive 20) Packages/OsaurusCore/Services/FileHistory/FileDiffEngine.swift:412— FileDiffEngine.wordRanges has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (7 pts), loops 5 (6 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.remove (cognitive 20) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:767— PendingImportProcessor.remove has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 5, ternaries 1 (3 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InstalledClaudePluginsAggregator.buildPlugins (cognitive 20) Packages/OsaurusCore/Services/Plugin/InstalledClaudePluginsAggregator.swift:494— InstalledClaudePluginsAggregator.buildPlugins has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 6, boolean chains 5 (nesting depth added 4). Of this number, 18 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InboundSharedRunBridge.mergeCompletedTurn (cognitive 20) Packages/OsaurusCore/Services/Router/InboundSharedRunBridge.swift:393— InboundSharedRunBridge.mergeCompletedTurn has cognitive complexity 20 (threshold 15). Drivers by points: if/else 19, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SlackConnectionService.classifyInboundEvent (cognitive 20) Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:1489— SlackConnectionService.classifyInboundEvent has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 13, if/else 6, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
TemplateExportSanitizer.portableArgs (cognitive 20) Packages/OsaurusCore/Services/Template/TemplateExportSanitizer.swift:89— TemplateExportSanitizer.portableArgs has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 2 (7 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseImport.detectFormat (cognitive 20) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:88— DatabaseImport.detectFormat has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 4, ternaries 2 (4 pts), match/switch 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseImport.buildRowsFromObjects (cognitive 20) Packages/OsaurusCore/Tools/Database/DatabaseImport.swift:500— DatabaseImport.buildRowsFromObjects has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentSidebarRow.body (cognitive 20) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1303— AgentSidebarRow.body has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (9 pts), ternaries 6 (9 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ChatView.pinRemoteAgentModelAfterConnect (cognitive 20) Packages/OsaurusCore/Views/Chat/ChatView.swift:10916— ChatView.pinRemoteAgentModelAfterConnect has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 5, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeActivityGroupView.configureChildren (cognitive 20) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:237— NativeActivityGroupView.configureChildren has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (9 pts), match/switch 2 (6 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMessageCellView.configureAsParagraph (cognitive 20) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:2298— NativeMessageCellView.configureAsParagraph has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 7 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
NativeToolCallRowView.hitTest (cognitive 20) Packages/OsaurusCore/Views/Chat/NativeToolCallGroupView.swift:1022— NativeToolCallRowView.hitTest has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 2 (nesting depth added 11). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
OverviewTab.summaryHeadline (cognitive 20) Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1182— OverviewTab.summaryHeadline has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 10 (19 pts), match/switch 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScreenshotController.captureWindow (cognitive 20) Packages/OsaurusCore/ComputerUse/Driver/Mac/Screenshot.swift:264— ScreenshotController.captureWindow has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (9 pts), loops 1 (2 pts) (nesting depth added 6). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PPTXEditor.duplicateSlide (cognitive 20) Packages/OsaurusCore/Services/Documents/OOXML/PPTXEditor.swift:258— PPTXEditor.duplicateSlide has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts), boolean chains 2, ternaries 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPOAuthDiscovery.fetchAuthorizationServerMetadata (cognitive 20) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:280— MCPOAuthDiscovery.fetchAuthorizationServerMetadata has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), error handling 2 (5 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseSavedViewsView.detail (cognitive 20) Packages/OsaurusCore/Views/Agent/Database/DatabaseSavedViewsView.swift:149— DatabaseSavedViewsView.detail has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 1 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Accessibility.swift.listWindowsForPid (cognitive 20) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1651— Accessibility.swift.listWindowsForPid has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 9, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
leaderboard.pr_translated_keys (cognitive 20) scripts/i18n/leaderboard.py:247— leaderboard.pr_translated_keys has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), ternaries 2 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BenchCommand.execute (cognitive 19) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift:46— BenchCommand.execute has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (10 pts), error handling 3 (6 pts), loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalMTPControlState.verdict (cognitive 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMTPControl.swift:151— EvalMTPControlState.verdict has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
EvalReport.formatHumanReadable (cognitive 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:765— EvalReport.formatHumanReadable has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.scoreComputerUseLane (cognitive 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:548— EvalRunner.scoreComputerUseLane has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 3, loops 3, ternaries 3 (nesting depth added 3). Of this number, 17 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
EvalRunner.scoreBrowserUseLane (cognitive 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:678— EvalRunner.scoreBrowserUseLane has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 5, loops 3, ternaries 2 (nesting depth added 2). Of this number, 17 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
MLXMetallibBootstrap.locateSource (cognitive 19) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/MLXMetallibBootstrap.swift:74— MLXMetallibBootstrap.locateSource has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CentralRepositoryManager.mapFailure (cognitive 19) Packages/OsaurusRepository/CentralRepositoryManager.swift:444— CentralRepositoryManager.mapFailure has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), match/switch 3 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FileTreeTool.entries::traverse (cognitive 19) Packages/OsaurusCore/Folder/FolderTools.swift:713— FileTreeTool.entries::traverse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileEditTool.noMatchDiagnosis (cognitive 19) Packages/OsaurusCore/Folder/FolderTools.swift:4008— FileEditTool.noMatchDiagnosis has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPProviderManager.connectProviderWithTransientRetry (cognitive 19) Packages/OsaurusCore/Managers/MCPProviderManager.swift:525— MCPProviderManager.connectProviderWithTransientRetry has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 2, error handling 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SkillArchiveProcessRunner.run (cognitive 19) Packages/OsaurusCore/Managers/SkillImportPolicy.swift:306— SkillArchiveProcessRunner.run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 2, match/switch 2, error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
HTTPHandler.handleModelPickerEndpoint (cognitive 19) Packages/OsaurusCore/Networking/HTTPHandler.swift:5470— HTTPHandler.handleModelPickerEndpoint has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, ternaries 3 (4 pts), error handling 1 (2 pts), if/else 2, loops 1, match/switch 1 (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
HTTPHandler.decryptSecureCall (cognitive 19) Packages/OsaurusCore/Networking/HTTPHandler.swift:8477— HTTPHandler.decryptSecureCall has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12, boolean chains 3, error handling 3, loops 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.runImageJob (cognitive 19) Packages/OsaurusCore/Networking/HTTPHandler.swift:13738— HTTPHandler.runImageJob has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 3 (9 pts), match/switch 1 (4 pts), loops 1 (3 pts), error handling 1 (2 pts), if/else 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DeclaredReasoningEffort.nativeThinkingModes (cognitive 19) Packages/OsaurusCore/Services/DeclaredReasoningEffort.swift:274— DeclaredReasoningEffort.nativeThinkingModes has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 17, if/else 1, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
GitHubSkillService.resolvePluginDependencies (cognitive 19) Packages/OsaurusCore/Services/GitHubSkillService.swift:1418— GitHubSkillService.resolvePluginDependencies has cognitive complexity 19 (threshold 15). Drivers by points: loops 8 (11 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
ModelRuntime.clearAll (cognitive 19) Packages/OsaurusCore/Services/ModelRuntime.swift:2611— ModelRuntime.clearAll has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 4, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDatabase.forbiddenReason (cognitive 19) Packages/OsaurusCore/Storage/AgentDatabase.swift:2364— AgentDatabase.forbiddenReason has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 5, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
SubagentSession.localInPlaceCapacityDecision (cognitive 19) Packages/OsaurusCore/Subagent/SubagentSession.swift:1392— SubagentSession.localInPlaceCapacityDecision has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 7, ternaries 2 (3 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CapabilitiesDiscoverTool.mergeHits (cognitive 19) Packages/OsaurusCore/Tools/CapabilityTools.swift:903— CapabilitiesDiscoverTool.mergeHits has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 4 (7 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilitiesLoadTool.execute (cognitive 19) Packages/OsaurusCore/Tools/CapabilityTools.swift:1012— CapabilitiesLoadTool.execute has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 5 (7 pts), if/else 5 (6 pts), match/switch 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
CapabilitiesLoadTool.loadSkill (cognitive 19) Packages/OsaurusCore/Tools/CapabilityTools.swift:1540— CapabilitiesLoadTool.loadSkill has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (9 pts), ternaries 3 (6 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusHelpTool.execute (cognitive 19) Packages/OsaurusCore/Tools/ConfigurationTools.swift:1176— OsaurusHelpTool.execute has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (16 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EditKnowledgeTool.execute (cognitive 19) Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:822— EditKnowledgeTool.execute has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), error handling 2 (3 pts), ternaries 1 (3 pts), boolean chains 2, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxSecretSetTool.execute (cognitive 19) Packages/OsaurusCore/Tools/SandboxSecretTools.swift:125— SandboxSecretSetTool.execute has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parser.parsePrimary (cognitive 19) Packages/OsaurusCore/Utils/CalculatorEngine.swift:630— Parser.parsePrimary has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (4 pts), match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatPerfTrace.emit (cognitive 19) Packages/OsaurusCore/Utils/ChatPerfTrace.swift:130— ChatPerfTrace.emit has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 2 (6 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatDBMessagesService.send (cognitive 19) Packages/OsaurusCore/AppleApps/Messages/MessagesService.swift:490— ChatDBMessagesService.send has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, error handling 1 (2 pts), loops 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppleScriptExecutor.renderRecord (cognitive 19) Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:597— AppleScriptExecutor.renderRecord has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MockAppleScriptWorld.handle (cognitive 19) Packages/OsaurusCore/AppleScript/Exec/MockAppleScriptWorld.swift:81— MockAppleScriptWorld.handle has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12, boolean chains 5, ternaries 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BrowserToolExecutor.cookies (cognitive 19) Packages/OsaurusCore/Browser/Tool/BrowserToolExecutor.swift:723— BrowserToolExecutor.cookies has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ConfigApplier.patchToolSelection (cognitive 19) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:699— ConfigApplier.patchToolSelection has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9, boolean chains 6, loops 4. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigPlanner.plan (cognitive 19) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:167— ConfigPlanner.plan has cognitive complexity 19 (threshold 15). Drivers by points: if/else 19. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigPlanner.summarizePortableSettings (cognitive 19) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1352— ConfigPlanner.summarizePortableSettings has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 5, ternaries 2 (4 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planDelegation (cognitive 19) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:1595— ConfigPlanner.planDelegation has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 7, loops 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
SharedArtifact.importRemoteArtifacts (cognitive 19) Packages/OsaurusCore/Services/Router/RemoteRunArtifacts.swift:198— SharedArtifact.importRemoteArtifacts has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (7 pts), boolean chains 5, ternaries 2 (4 pts), error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PrivacyFilterModelDownloader.runDownload (cognitive 19) Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelDownloader.swift:144— PrivacyFilterModelDownloader.runDownload has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 4 (6 pts), loops 2, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomJSONRunner.renderedURL (cognitive 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1717— AgentChannelCustomJSONRunner.renderedURL has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (7 pts), ternaries 3, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelInboundRelay.run (cognitive 19) Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:480— AgentChannelInboundRelay.run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 1 (4 pts), boolean chains 3, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileChangeJournal.pruneShadows (cognitive 19) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal.swift:666— FileChangeJournal.pruneShadows has cognitive complexity 19 (threshold 15). Drivers by points: loops 7 (11 pts), if/else 4 (5 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
FileChangeJournal.markEntries (cognitive 19) Packages/OsaurusCore/Services/FileHistory/FileChangeJournal+Revert.swift:343— FileChangeJournal.markEntries has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 7, loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IMessageConnectionService.runWatchSession (cognitive 19) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:847— IMessageConnectionService.runWatchSession has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelServiceRouter.resolve (cognitive 19) Packages/OsaurusCore/Services/Inference/ModelService.swift:772— ModelServiceRouter.resolve has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResponsesToolChoiceContract.validate (cognitive 19) Packages/OsaurusCore/Services/Inference/ResponsesToolChoiceContract.swift:78— ResponsesToolChoiceContract.validate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 8, match/switch 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeDiff.lcsDiff (cognitive 19) Packages/OsaurusCore/Services/Knowledge/KnowledgeDiff.swift:82— KnowledgeDiff.lcsDiff has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 5 (6 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeDocumentParser.chunk (cognitive 19) Packages/OsaurusCore/Services/Knowledge/KnowledgeDocumentParser.swift:202— KnowledgeDocumentParser.chunk has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeLinkResolver.plainTextMatches (cognitive 19) Packages/OsaurusCore/Services/Knowledge/KnowledgeLinkResolver.swift:111— KnowledgeLinkResolver.plainTextMatches has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MediaGenerationCoordinator.scheduleRecovery (cognitive 19) Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationCoordinator.swift:390— MediaGenerationCoordinator.scheduleRecovery has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 2 (4 pts), boolean chains 2, error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemorySearchService.ensureVectorDB (cognitive 19) Packages/OsaurusCore/Services/Memory/MemorySearchService.swift:181— MemorySearchService.ensureVectorDB has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 3 (10 pts), if/else 4 (6 pts), error handling 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryService.backfillFromChatHistory (cognitive 19) Packages/OsaurusCore/Services/Memory/MemoryService.swift:555— MemoryService.backfillFromChatHistory has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginHostContext.checkSSRF (cognitive 19) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2991— PluginHostContext.checkSSRF has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.extractInlineImages (cognitive 19) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:4788— RemoteProviderService.extractInlineImages has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.fetchOsaurusModels (cognitive 19) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:6865— RemoteProviderService.fetchOsaurusModels has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (4 pts), ternaries 2, boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteToolDetection.detectInlineToolCall (cognitive 19) Packages/OsaurusCore/Services/Provider/RemoteToolDetection.swift:26— RemoteToolDetection.detectInlineToolCall has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 5, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceRosterStore.refresh (cognitive 19) Packages/OsaurusCore/Services/Router/WorkspaceRosterStore.swift:287— WorkspaceRosterStore.refresh has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 3, error handling 1, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspacesService.applyDefaultBilling (cognitive 19) Packages/OsaurusCore/Services/Router/WorkspacesService.swift:1224— WorkspacesService.applyDefaultBilling has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ClaudePluginInstaller.synthesizeSkillFromFreeformMarkdown (cognitive 19) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1110— ClaudePluginInstaller.synthesizeSkillFromFreeformMarkdown has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KeyboardSimulationService.pasteText (cognitive 19) Packages/OsaurusCore/Services/Voice/KeyboardSimulationService.swift:140— KeyboardSimulationService.pasteText has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
VADService.setupObservers (cognitive 19) Packages/OsaurusCore/Services/Voice/VADService.swift:199— VADService.setupObservers has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 5 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WhatsAppConnectionService.normalizeInbound (cognitive 19) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1330— WhatsAppConnectionService.normalizeInbound has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8, ternaries 7, boolean chains 4. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TextSubagentKind.matchesApprovedAuthority (cognitive 19) Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:861— TextSubagentKind.matchesApprovedAuthority has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 12, if/else 4 (7 pts) (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
TextSubagentKind.run (cognitive 19) Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:979— TextSubagentKind.run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 2, ternaries 1 (2 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentCard.body (cognitive 19) Packages/OsaurusCore/Views/Agent/AgentsView.swift:843— AgentCard.body has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 10, if/else 8, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SpawnConfigurationEditor.allowedAgents (cognitive 19) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:134— SpawnConfigurationEditor.allowedAgents has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 2 (5 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.applyPickerItems (cognitive 19) Packages/OsaurusCore/Views/Chat/ChatView.swift:1736— ChatSession.applyPickerItems has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 6 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FloatingInputCard.handleBuiltInSlashAction (cognitive 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:2154— FloatingInputCard.handleBuiltInSlashAction has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 1, match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ContextBreakdownPopover.color (cognitive 19) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:7000— ContextBreakdownPopover.color has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 9 (18 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
NativeActivityGroupView.configure (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:90— NativeActivityGroupView.configure has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 7, if/else 6, ternaries 4 (5 pts), match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NativeActivityGroupView.stepChips (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:326— NativeActivityGroupView.stepChips has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 1 (5 pts), loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeCodeBlockView.configure (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:522— NativeCodeBlockView.configure has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 8, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DiffBackgroundView.draw (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeFileDiffView.swift:33— DiffBackgroundView.draw has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 6, if/else 3 (6 pts), ternaries 2 (6 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMarkdownView.applySearchHighlightsIfNeeded (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:353— NativeMarkdownView.applySearchHighlightsIfNeeded has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMarkdownView.configureWithBlocks (cognitive 19) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:593— NativeMarkdownView.configureWithBlocks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 7 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SelectableTextView.updateTextStorageIncrementally (cognitive 19) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:229— SelectableTextView.updateTextStorageIncrementally has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, loops 2, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageGenerationPanelView.advancedParams (cognitive 19) Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift:424— ImageGenerationPanelView.advancedParams has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (19 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDetailView.detailsCard (cognitive 19) Packages/OsaurusCore/Views/Model/ModelDetailView.swift:595— ModelDetailView.detailsCard has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14, ternaries 2 (3 pts), boolean chains 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelDetailView.manifestStatus (cognitive 19) Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1188— ModelDetailView.manifestStatus has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StorageSettingsView.applyEncryption (cognitive 19) Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:686— StorageSettingsView.applyEncryption has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 5 (13 pts), if/else 4 (5 pts), error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPOAuthDiscovery.fetchProtectedResourceMetadata (cognitive 19) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:225— MCPOAuthDiscovery.fetchProtectedResourceMetadata has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), error handling 3 (6 pts), loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applescript_capability_scoreboard.build_scoreboard (cognitive 19) scripts/evals/applescript_capability_scoreboard.py:81— applescript_capability_scoreboard.build_scoreboard has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 4, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
check-swift-catalog-keys.split_interp (cognitive 19) scripts/i18n/check-swift-catalog-keys.py:44— check-swift-catalog-keys.split_interp has cognitive complexity 19 (threshold 15). Drivers by points: loops 3 (7 pts), if/else 2 (5 pts), ternaries 1 (5 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export-untranslated.main (cognitive 19) scripts/i18n/export-untranslated.py:41— export-untranslated.main has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 2, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PullCommand.execute (cognitive 18) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:43— PullCommand.execute has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 2 (3 pts), boolean chains 2, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalBootstrap.seedHostSnapshots (cognitive 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalBootstrap.swift:280— EvalBootstrap.seedHostSnapshots has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalMatrix.formatConsole (cognitive 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:609— EvalMatrix.formatConsole has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalReport.formatAggregatedTelemetry (cognitive 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:966— EvalReport.formatAggregatedTelemetry has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11, boolean chains 7. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
EvalRunner.run (cognitive 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:48— EvalRunner.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalScoreboardBuilder.suiteScoreboard (cognitive 18) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalScoreboard.swift:669— EvalScoreboardBuilder.suiteScoreboard has cognitive complexity 18 (threshold 15). Drivers by points: loops 7 (14 pts), if/else 3 (4 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
FileEditTool.parseRequestedEdits (cognitive 18) Packages/OsaurusCore/Folder/FolderTools.swift:3778— FileEditTool.parseRequestedEdits has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileSearchTool.collectFileMatches (cognitive 18) Packages/OsaurusCore/Folder/FolderTools.swift:4804— FileSearchTool.collectFileMatches has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Keccak256.keccakF1600 (cognitive 18) Packages/OsaurusCore/Identity/CryptoHelpers.swift:91— Keccak256.keccakF1600 has cognitive complexity 18 (threshold 15). Drivers by points: loops 8 (18 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
AgentManager.migrateClaudeCodeModelsToHarness (cognitive 18) Packages/OsaurusCore/Managers/AgentManager+Harness.swift:72— AgentManager.migrateClaudeCodeModelsToHarness has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, loops 1, ternaries 1 (nesting depth added 4). Of this number, 15 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenAICompatibleTTSClient.decodeCompressedAudio (cognitive 18) Packages/OsaurusCore/Managers/OpenAICompatibleTTSClient.swift:164— OpenAICompatibleTTSClient.decodeCompressedAudio has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 6, error handling 2, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderManager.refetchModels (cognitive 18) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1061— RemoteProviderManager.refetchModels has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 5, error handling 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderManager.extractErrorMessage (cognitive 18) Packages/OsaurusCore/Managers/RemoteProviderManager.swift:1778— RemoteProviderManager.extractErrorMessage has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
SkillManager.loadReferenceContents (cognitive 18) Packages/OsaurusCore/Managers/SkillManager.swift:917— SkillManager.loadReferenceContents has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleUpdateAgentToolEndpoint (cognitive 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:6344— HTTPHandler.handleUpdateAgentToolEndpoint has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.handleWorkspaceAgentRunEndpoint (cognitive 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:6461— HTTPHandler.handleWorkspaceAgentRunEndpoint has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 6, loops 1 (2 pts), error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HTTPHandler.handleListAgents (cognitive 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:9602— HTTPHandler.handleListAgents has cognitive complexity 18 (threshold 15). Drivers by points: loops 2 (6 pts), if/else 3 (5 pts), ternaries 4, boolean chains 3 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HTTPHandler.handleRemoteImageGeneration (cognitive 18) Packages/OsaurusCore/Networking/HTTPHandler.swift:12968— HTTPHandler.handleRemoteImageGeneration has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 3 (5 pts), ternaries 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DirectDownloader.urlSession (cognitive 18) Packages/OsaurusCore/Services/ModelDownloadService.swift:2070— DirectDownloader.urlSession has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryDatabase.loadFileChangeSets (cognitive 18) Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:1499— ChatHistoryDatabase.loadFileChangeSets has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 7, if/else 2 (6 pts), loops 2 (4 pts), error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AppleScriptWarmResidencyHandoff.around (cognitive 18) Packages/OsaurusCore/Subagent/AppleScriptWarmResidency.swift:219— AppleScriptWarmResidencyHandoff.around has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (9 pts), ternaries 3 (5 pts), error handling 2 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SubagentAdmission.admit (cognitive 18) Packages/OsaurusCore/Subagent/SubagentAdmission.swift:102— SubagentAdmission.admit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CalendarCreateEventTool.run (cognitive 18) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:210— CalendarCreateEventTool.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 3 (8 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScreenContextDistiller.sampleContents (cognitive 18) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:433— ScreenContextDistiller.sampleContents has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 5, loops 2, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigPlanner.planSearchProviders (cognitive 18) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:2302— ConfigPlanner.planSearchProviders has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelManager.loadOsaurusAIOrgModels (cognitive 18) Packages/OsaurusCore/Managers/Model/ModelManager.swift:1856— ModelManager.loadOsaurusAIOrgModels has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 7 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelPickerItemCache.remoteModelItems (cognitive 18) Packages/OsaurusCore/Managers/Model/ModelPickerItemCache.swift:306— ModelPickerItemCache.remoteModelItems has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 1 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxPluginManager.install (cognitive 18) Packages/OsaurusCore/Managers/Plugin/SandboxPluginManager.swift:39— SandboxPluginManager.install has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 2 (3 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DispatchEnvelope.parseWatcher (cognitive 18) Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:322— DispatchEnvelope.parseWatcher has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FileDiff.partialDelimitedRawValue (cognitive 18) Packages/OsaurusCore/Models/Chat/FileDiff.swift:367— FileDiff.partialDelimitedRawValue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelAutoDestinationResolver.derivedBindings (cognitive 18) Packages/OsaurusCore/Services/AgentChannel/AgentChannelAutoDestinationResolver.swift:85— AgentChannelAutoDestinationResolver.derivedBindings has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelCustomJSONRunner.mapResult (cognitive 18) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:983— AgentChannelCustomJSONRunner.mapResult has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 5 (10 pts), if/else 3 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
OwnerDeviceAccessHost.redeem (cognitive 18) Packages/OsaurusCore/Services/Auth/OwnerDeviceAccessHost.swift:375— OwnerDeviceAccessHost.redeem has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 6, ternaries 2, error handling 1, loops 1. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentTaskState.classify (cognitive 18) Packages/OsaurusCore/Services/Chat/AgentTaskState.swift:1191— AgentTaskState.classify has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentLoopModelStep.classifyTerminal (cognitive 18) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:207— AgentLoopModelStep.classifyTerminal has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 8 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ChatTitleService.sanitize (cognitive 18) Packages/OsaurusCore/Services/Chat/ChatTitleService.swift:125— ChatTitleService.sanitize has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 3 (6 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPromptComposer.deriveEnabledManifest (cognitive 18) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1870— SystemPromptComposer.deriveEnabledManifest has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6, loops 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolResultMediaBridge.mime (cognitive 18) Packages/OsaurusCore/Services/Chat/ToolResultMediaBridge.swift:204— ToolResultMediaBridge.mime has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 13, if/else 5. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SubagentAdmissionEvaluator.run (cognitive 18) Packages/OsaurusCore/Services/Context/SubagentAdmissionEvaluator.swift:63— SubagentAdmissionEvaluator.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 2 (4 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SubagentJobEvaluator.waveEnvelope (cognitive 18) Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:532— SubagentJobEvaluator.waveEnvelope has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 4, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PDFEditor.closestField (cognitive 18) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:300— PDFEditor.closestField has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFEditor.highlight (cognitive 18) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:552— PDFEditor.highlight has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (6 pts), boolean chains 2, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFTableDetector.cells (cognitive 18) Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:145— PDFTableDetector.cells has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenXMLTextRunCollector.parser (cognitive 18) Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift:1201— OpenXMLTextRunCollector.parser has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 2, match/switch 1 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
WorkbookWorkflowValidator.parseCellReference (cognitive 18) Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:588— WorkbookWorkflowValidator.parseCellReference has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 7, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXAdapter.renderWorkbook (cognitive 18) Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:253— XLSXAdapter.renderWorkbook has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
XLSXEmitter.parseCellReference (cognitive 18) Packages/OsaurusCore/Services/Documents/XLSXEmitter.swift:325— XLSXEmitter.parseCellReference has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 7, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IMessageRuntimeAssets.verifyExecutableCandidates (cognitive 18) Packages/OsaurusCore/Services/IMessage/IMessageRuntimeAssets.swift:266— IMessageRuntimeAssets.verifyExecutableCandidates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDescriptionBackfill.run (cognitive 18) Packages/OsaurusCore/Services/Inference/AgentDescriptionBackfill.swift:114— AgentDescriptionBackfill.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 5, error handling 3, match/switch 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageHTTPParameterBuilder.edit (cognitive 18) Packages/OsaurusCore/Services/ModelRuntime/ImageHTTPParameterBuilder.swift:86— ImageHTTPParameterBuilder.edit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 6, ternaries 2 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginProcessHostCallbacks.handle (cognitive 18) Packages/OsaurusCore/Services/Plugin/PluginProcessHost.swift:386— PluginProcessHostCallbacks.handle has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 1, match/switch 1 (nesting depth added 6). Of this number, 16 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ProviderNetworkDiagnostics.remoteModelDiscoveryRow (cognitive 18) Packages/OsaurusCore/Services/Provider/ProviderNetworkDiagnostics.swift:319— ProviderNetworkDiagnostics.remoteModelDiscoveryRow has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 7 (14 pts), if/else 2 (3 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.makeChunkStream (cognitive 18) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:1048— RemoteProviderService.makeChunkStream has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts), boolean chains 1, error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteToolDetection.matchJSONObjectEnd (cognitive 18) Packages/OsaurusCore/Services/Provider/RemoteToolDetection.swift:84— RemoteToolDetection.matchJSONObjectEnd has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceAgentConnectService.refresh (cognitive 18) Packages/OsaurusCore/Services/Router/WorkspaceAgentConnectService.swift:353— WorkspaceAgentConnectService.refresh has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 1, error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchEngine.run (cognitive 18) Packages/OsaurusCore/Services/Search/SearchEngine.swift:102— SearchEngine.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 4, loops 2, match/switch 1 (2 pts) (nesting depth added 6). Of this number, 14 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPJSONParser.parse (cognitive 18) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1716— MCPJSONParser.parse has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 5, ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WhatsAppConnectionService.runWatchSession (cognitive 18) Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:985— WhatsAppConnectionService.runWatchSession has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WhatsAppRuntimeAssets.verifyExecutableCandidates (cognitive 18) Packages/OsaurusCore/Services/WhatsApp/WhatsAppRuntimeAssets.swift:161— WhatsAppRuntimeAssets.verifyExecutableCandidates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DBExecuteTool.execute (cognitive 18) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1079— DBExecuteTool.execute has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 2, match/switch 1 (2 pts), ternaries 1 (2 pts), error handling 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ChatEmptyState.greetingBlock (cognitive 18) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:303— ChatEmptyState.greetingBlock has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 7 (11 pts), if/else 4 (6 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionSidebar.workspaceSections (cognitive 18) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:787— ChatSessionSidebar.workspaceSections has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 6 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHistoryList.body (cognitive 18) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:3270— ChatHistoryList.body has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChangeSetRow.header (cognitive 18) Packages/OsaurusCore/Views/Chat/FileChangesPanel.swift:591— ChangeSetRow.header has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 9 (13 pts), boolean chains 3, if/else 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
N8nSettingsView.body (cognitive 18) Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:78— N8nSettingsView.body has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10, boolean chains 4, ternaries 3, match/switch 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ActivateWorkspaceSheet.body (cognitive 18) Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:482— ActivateWorkspaceSheet.body has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, boolean chains 5, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
main.swift.handleRequest (cognitive 18) Packages/OsaurusCore/PluginHost/main.swift:473— main.swift.handleRequest has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 2 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarkdownMessageView.swift.groupBlocksIntoSegments::emitBlock (cognitive 18) Packages/OsaurusCore/Views/Chat/MarkdownMessageView.swift:316— MarkdownMessageView.swift.groupBlocksIntoSegments::emitBlock has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 4 (9 pts), loops 2 (5 pts), if/else 2 (3 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Accessibility.swift.focusedViewport (cognitive 18) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1217— Accessibility.swift.focusedViewport has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 7 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
run-local-family-chat-tool-proof.run (cognitive 18) scripts/live-proof/run-local-family-chat-tool-proof.py:90— run-local-family-chat-tool-proof.run has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 7, error handling 6, if/else 3, ternaries 2. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bridge.handleLoginEvent (cognitive 18) helpers/osaurus-wa/bridge.go:350— bridge.handleLoginEvent has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 1 (nesting depth added 8). Of this number, 14 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DoctorCommand.render (cognitive 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Doctor.swift:111— DoctorCommand.render has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 3, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoordCommand.runLock (cognitive 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Coord/CoordCommand.swift:115— CoordCommand.runLock has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (5 pts), loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsDev.runLegacyWatchMode (cognitive 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsDev.swift:162— ToolsDev.runLegacyWatchMode has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 3). Of this number, 11 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ToolsDoctor.execute (cognitive 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsDoctor.swift:47— ToolsDoctor.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolsInstall.validateBundledManifestIfPresent (cognitive 17) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsInstall.swift:336— ToolsInstall.validateBundledManifestIfPresent has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.scoreToolUsageAudit (cognitive 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift:1556— EvalRunner.scoreToolUsageAudit has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalRunner.runMemoryCase (cognitive 17) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMemory.swift:24— EvalRunner.runMemoryCase has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8, loops 3 (5 pts), ternaries 2, boolean chains 1, error handling 1 (nesting depth added 2). Of this number, 15 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FileEditMatcher.apply (cognitive 17) Packages/OsaurusCore/Folder/FileEditMatcher.swift:80— FileEditMatcher.apply has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FileReadImageSupport.load (cognitive 17) Packages/OsaurusCore/Folder/FileReadImageSupport.swift:54— FileReadImageSupport.load has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 9, if/else 6 (8 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
MCPProviderManager.executeTool (cognitive 17) Packages/OsaurusCore/Managers/MCPProviderManager.swift:750— MCPProviderManager.executeTool has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), error handling 2 (3 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SkillImportPolicy.scanExtractedTree (cognitive 17) Packages/OsaurusCore/Managers/SkillImportPolicy.swift:63— SkillImportPolicy.scanExtractedTree has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.jsonNestingDepthExceedsBudget (cognitive 17) Packages/OsaurusCore/Networking/HTTPRequestParse.swift:54— HTTPHandler.jsonNestingDepthExceedsBudget has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ServerController.startServer (cognitive 17) Packages/OsaurusCore/Networking/ServerController.swift:197— ServerController.startServer has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (5 pts), error handling 2 (4 pts), ternaries 2 (4 pts), loops 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalReasoningCapability.undefinedKwargFallbackBranch (cognitive 17) Packages/OsaurusCore/Services/LocalReasoningCapability.swift:351— LocalReasoningCapability.undefinedKwargFallbackBranch has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). Of this number, 16 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelDownloadService.delete (cognitive 17) Packages/OsaurusCore/Services/ModelDownloadService.swift:1097— ModelDownloadService.delete has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelMessageStore.recordReceiveEvent (cognitive 17) Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:764— AgentChannelMessageStore.recordReceiveEvent has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (13 pts), ternaries 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDatabase.bulkWrite (cognitive 17) Packages/OsaurusCore/Storage/AgentDatabase.swift:1422— AgentDatabase.bulkWrite has cognitive complexity 17 (threshold 15). Drivers by points: loops 6 (11 pts), if/else 4 (6 pts) (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
AttachmentBlobStore.spillOne (cognitive 17) Packages/OsaurusCore/Storage/AttachmentBlobStore.swift:137— AttachmentBlobStore.spillOne has cognitive complexity 17 (threshold 15). Drivers by points: error handling 4 (8 pts), if/else 4 (8 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SubagentSession.prepare (cognitive 17) Packages/OsaurusCore/Subagent/SubagentSession.swift:348— SubagentSession.prepare has cognitive complexity 17 (threshold 15). Drivers by points: error handling 5, if/else 5, boolean chains 4, ternaries 2, match/switch 1. Of this number, 15 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxSearchFilesTool.execute (cognitive 17) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1872— SandboxSearchFilesTool.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 3 (5 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxWriteFileTool.writeWhole (cognitive 17) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2254— SandboxWriteFileTool.writeWhole has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3 (6 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SandboxProcessTool.execute (cognitive 17) Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3135— SandboxProcessTool.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 2 (4 pts), match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolWirePropertyOrder.write (cognitive 17) Packages/OsaurusCore/Tools/ToolWirePropertyOrder.swift:154— ToolWirePropertyOrder.write has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
CalendarUpdateEventTool.run (cognitive 17) Packages/OsaurusCore/AppleApps/Calendar/CalendarTools.swift:297— CalendarUpdateEventTool.run has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12, ternaries 2 (4 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
NativeMacDriver.coordinate (cognitive 17) Packages/OsaurusCore/ComputerUse/Driver/NativeMacDriver.swift:267— NativeMacDriver.coordinate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ScreenContextDistiller.statusToken (cognitive 17) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:781— ScreenContextDistiller.statusToken has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, if/else 7. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ConfigApplier.applyLocked (cognitive 17) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:85— ConfigApplier.applyLocked has cognitive complexity 17 (threshold 15). Drivers by points: if/else 17. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ConfigApplier.addProvider (cognitive 17) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:2032— ConfigApplier.addProvider has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), match/switch 3 (4 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusConfigDocument.declaredSections (cognitive 17) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigDocument.swift:136— OsaurusConfigDocument.declaredSections has cognitive complexity 17 (threshold 15). Drivers by points: if/else 17. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (OsaurusConfigDocument.filtered) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
OsaurusConfigDocument.filtered (cognitive 17) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigDocument.swift:159— OsaurusConfigDocument.filtered has cognitive complexity 17 (threshold 15). Drivers by points: if/else 17. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (OsaurusConfigDocument.declaredSections) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
OsaurusConfigTool.handleTemplates (cognitive 17) Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:612— OsaurusConfigTool.handleTemplates has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11, boolean chains 4, match/switch 1, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
OpenResponsesTool.init (cognitive 17) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:548— OpenResponsesTool.init has cognitive complexity 17 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelN8nEnvelope.parse (cognitive 17) Packages/OsaurusCore/Models/AgentChannel/AgentChannelN8nModels.swift:319— AgentChannelN8nEnvelope.parse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (14 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChannelMessageEnvelope.parse (cognitive 17) Packages/OsaurusCore/Models/Chat/DispatchEnvelope.swift:104— ChannelMessageEnvelope.parse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnthropicSSEResponseWriter.writeCompletedThinkingBlock (cognitive 17) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1058— AnthropicSSEResponseWriter.writeCompletedThinkingBlock has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PrivacyFilterPipeline.scanForLeaks (cognitive 17) Packages/OsaurusCore/PrivacyFilter/Core/PrivacyFilterPipeline.swift:839— PrivacyFilterPipeline.scanForLeaks has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (3 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelWebhookIngress.handleTaskPoll (cognitive 17) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:465— AgentChannelWebhookIngress.handleTaskPoll has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10, boolean chains 5, match/switch 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ToolResultMediaBridge.hoistingToolImagesToUserMessages (cognitive 17) Packages/OsaurusCore/Services/Chat/ToolResultMediaBridge.swift:141— ToolResultMediaBridge.hoistingToolImagesToUserMessages has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 1 (nesting depth added 5). Of this number, 13 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CapabilityClaimsEvaluator.matchedCloseIndex (cognitive 17) Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:992— CapabilityClaimsEvaluator.matchedCloseIndex has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFAdapter.glyphs (cognitive 17) Packages/OsaurusCore/Services/Documents/PDFAdapter.swift:182— PDFAdapter.glyphs has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 3 (5 pts), loops 1 (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PDFEditor.merge (cognitive 17) Packages/OsaurusCore/Services/Documents/PDFEditor.swift:131— PDFEditor.merge has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (3 pts), ternaries 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkbookWorkflowValidator.validateCell (cognitive 17) Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:445— WorkbookWorkflowValidator.validateCell has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
WorksheetParser.cellValue (cognitive 17) Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:830— WorksheetParser.cellValue has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (7 pts), ternaries 3 (7 pts), boolean chains 2, match/switch 1 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
IMessageConnectionService.diagnostics (cognitive 17) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:310— IMessageConnectionService.diagnostics has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11, boolean chains 4, match/switch 1, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PendingImportProcessor.decideSetting (cognitive 17) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:435— PendingImportProcessor.decideSetting has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, if/else 4, ternaries 2 (3 pts) (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PendingImportProcessor.announce (cognitive 17) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:923— PendingImportProcessor.announce has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StreamingStatsHint.encode (cognitive 17) Packages/OsaurusCore/Services/Inference/ModelService.swift:523— StreamingStatsHint.encode has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 6, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ResponsesGenerationAccumulator.consume (cognitive 17) Packages/OsaurusCore/Services/Inference/ResponsesGenerationAccumulator.swift:42— ResponsesGenerationAccumulator.consume has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ResponsesGenerationResult.openResponsesResponse (cognitive 17) Packages/OsaurusCore/Models/API/OpenResponsesAPI.swift:1464— ResponsesGenerationResult.openResponsesResponse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 4 (6 pts), boolean chains 2, match/switch 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
KnowledgeDiff.lines (cognitive 17) Packages/OsaurusCore/Services/Knowledge/KnowledgeDiff.swift:33— KnowledgeDiff.lines has cognitive complexity 17 (threshold 15). Drivers by points: loops 7 (10 pts), boolean chains 5, if/else 2 (nesting depth added 3). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
PhoneAgentEditing.apply (cognitive 17) Packages/OsaurusCore/Services/MobileConnect/PhoneAgentEditing.swift:173— PhoneAgentEditing.apply has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, match/switch 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Registry.capacitySnapshot (cognitive 17) Packages/OsaurusCore/Services/ModelRuntime/MLXBatchAdapter.swift:593— Registry.capacitySnapshot has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginHostContext.taskStateDict (cognitive 17) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:3187— PluginHostContext.taskStateDict has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RemoteProviderService.fetchFireworksCatalogModels (cognitive 17) Packages/OsaurusCore/Services/Provider/RemoteProviderService.swift:7269— RemoteProviderService.fetchFireworksCatalogModels has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceRosterStore.apply (cognitive 17) Packages/OsaurusCore/Services/Router/WorkspaceRosterStore.swift:388— WorkspaceRosterStore.apply has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchHTML.canonicalURL (cognitive 17) Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:175— SearchHTML.canonicalURL has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (5 pts), boolean chains 2, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchStructuredDataInspector.collectArrays (cognitive 17) Packages/OsaurusCore/Services/Search/SearchStructuredDataStore.swift:201— SearchStructuredDataInspector.collectArrays has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 1 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SlackSocketModeTransportRuntime.runStep (cognitive 17) Packages/OsaurusCore/Services/Slack/SlackSocketModeTransportRuntime.swift:189— SlackSocketModeTransportRuntime.runStep has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), error handling 4, boolean chains 2, loops 1 (2 pts), ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DBCreateTableTool.execute (cognitive 17) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321— DBCreateTableTool.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 2 (3 pts), boolean chains 2, error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DBExportTool.execute (cognitive 17) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1432— DBExportTool.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 1 (3 pts), error handling 1 (2 pts), match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDetailView.quickActionRow (cognitive 17) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6694— AgentDetailView.quickActionRow has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 6 (9 pts), if/else 5 (7 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSession.maybeGenerateFollowUps (cognitive 17) Packages/OsaurusCore/Views/Chat/ChatView.swift:4692— ChatSession.maybeGenerateFollowUps has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 5, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FloatingInputCard.checkForSilenceTimeout (cognitive 17) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:1633— FloatingInputCard.checkForSilenceTimeout has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 8 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
StreamingMarkdownBalancer.stripFreshlyOpenedTrailingMarker (cognitive 17) Packages/OsaurusCore/Views/Chat/StreamingMarkdownBalancer.swift:145— StreamingMarkdownBalancer.stripFreshlyOpenedTrailingMarker has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RelaysSectionView.relayAgentRow (cognitive 17) Packages/OsaurusCore/Views/Settings/ServerView.swift:1108— RelaysSectionView.relayAgentRow has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WhatsAppSettingsView.startPairing (cognitive 17) Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:647— WhatsAppSettingsView.startPairing has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 1 (3 pts), loops 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceDetailView.poolSection (cognitive 17) Packages/OsaurusCore/Views/Workspaces/WorkspaceDetailView.swift:404— WorkspaceDetailView.poolSection has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 6, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
NormalizedUnits.init (cognitive 17) Packages/OsaurusCore/Services/Documents/OOXML/OOXMLText.swift:157— NormalizedUnits.init has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPOAuthService.performRefresh (cognitive 17) Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthService.swift:327— MCPOAuthService.performRefresh has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 6 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RemoteProviderEditSheet.swift.parsePastedEndpoint (cognitive 17) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:52— RemoteProviderEditSheet.swift.parsePastedEndpoint has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8, boolean chains 5, loops 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
check-swift-catalog-keys.parse_swift_string_from_marker (cognitive 17) scripts/i18n/check-swift-catalog-keys.py:89— check-swift-catalog-keys.parse_swift_string_from_marker has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
lint-swift-literals.main (cognitive 17) scripts/i18n/lint-swift-literals.py:87— lint-swift-literals.main has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 3 (8 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
ConfigCommand.runExport (cognitive 16) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:56— ConfigCommand.runExport has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 1 (2 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigCommand.request (cognitive 16) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Config.swift:275— ConfigCommand.request has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PullCommand.fetchMatchingFiles (cognitive 16) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Pull.swift:266— PullCommand.fetchMatchingFiles has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ManifestValidate.validateConfigFields (cognitive 16) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:468— ManifestValidate.validateConfigFields has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ComputerUseScorecardBuilder.build (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:299— ComputerUseScorecardBuilder.build has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3, loops 2, match/switch 1 (2 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EvalBootstrap.applyKVRegimeOverrideIfRequested (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalBootstrap.swift:737— EvalBootstrap.applyKVRegimeOverrideIfRequested has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 4, match/switch 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
CacheProofDecodeGate.evaluate (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMetricGates.swift:36— CacheProofDecodeGate.evaluate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 7 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalReviewReportBuilder.loadReportsRecursively (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:733— EvalReviewReportBuilder.loadReportsRecursively has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalReviewReportBuilder.compare (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift:806— EvalReviewReportBuilder.compare has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 4, loops 3, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalRunner.runCapabilitySearchCase (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1224— EvalRunner.runCapabilitySearchCase has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 4, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
EvalRemoteProviderBootstrap.preset (cognitive 16) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/RemoteProviderBootstrap.swift:93— EvalRemoteProviderBootstrap.preset has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, if/else 2, ternaries 2. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
TextLineReader.forEachLine (cognitive 16) Packages/OsaurusPlugins/StatsPack/Sources/OsaurusStatsPack/TextLineReader.swift:9— TextLineReader.forEachLine has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WorkspaceWriteSafety.unifiedDiff (cognitive 16) Packages/OsaurusCore/Folder/WorkspaceWriteSafety.swift:459— WorkspaceWriteSafety.unifiedDiff has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 5, ternaries 2, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
AgentManager.updateAutonomousExec (cognitive 16) Packages/OsaurusCore/Managers/AgentManager.swift:1372— AgentManager.updateAutonomousExec has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WindowManager.show (cognitive 16) Packages/OsaurusCore/Managers/WindowManager.swift:170— WindowManager.show has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11, boolean chains 3, ternaries 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HTTPHandler.workspaceKeyMayReach (cognitive 16) Packages/OsaurusCore/Networking/HTTPHandler.swift:4256— HTTPHandler.workspaceKeyMayReach has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 6, match/switch 1, ternaries 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HTTPHandler.handleSecureSessionEndpoint (cognitive 16) Packages/OsaurusCore/Networking/HTTPHandler.swift:8334— HTTPHandler.handleSecureSessionEndpoint has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 2, match/switch 1 (2 pts), ternaries 1 (nesting depth added 4). Of this number, 15 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HostAPIBridgeHandler.channelRead (cognitive 16) Packages/OsaurusCore/Networking/HostAPIBridgeServer.swift:153— HostAPIBridgeHandler.channelRead has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, ternaries 1 (2 pts), match/switch 1 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
GitHubSkillService.listSkillAssets (cognitive 16) Packages/OsaurusCore/Services/GitHubSkillService.swift:1507— GitHubSkillService.listSkillAssets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.clearDiskCaches (cognitive 16) Packages/OsaurusCore/Services/ModelRuntime.swift:1674— ModelRuntime.clearDiskCaches has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, loops 2, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelRuntime.streamRawText (cognitive 16) Packages/OsaurusCore/Services/ModelRuntime.swift:6245— ModelRuntime.streamRawText has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 1 (3 pts), loops 1 (2 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OnboardingModelsProxy.resolve (cognitive 16) Packages/OsaurusCore/Services/OnboardingModelsProxy.swift:148— OnboardingModelsProxy.resolve has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 2, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SubagentChildRequestEstimate.boundedPositionBudget (cognitive 16) Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:87— SubagentChildRequestEstimate.boundedPositionBudget has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CalculatorTool.payload (cognitive 16) Packages/OsaurusCore/Tools/CalculatorTool.swift:98— CalculatorTool.payload has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 5, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OsaurusInspectTool.statusEnvelope (cognitive 16) Packages/OsaurusCore/Tools/ConfigurationTools.swift:449— OsaurusInspectTool.statusEnvelope has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
RenderChartTool.resolveJSONPath (cognitive 16) Packages/OsaurusCore/Tools/RenderChartTool.swift:576— RenderChartTool.resolveJSONPath has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RenderChartTool.unwrapQuotedDelimitedPayload (cognitive 16) Packages/OsaurusCore/Tools/RenderChartTool.swift:802— RenderChartTool.unwrapQuotedDelimitedPayload has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, if/else 5 (6 pts), ternaries 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SchemaValidator.normalizeKeySpelling (cognitive 16) Packages/OsaurusCore/Tools/SchemaValidator.swift:673— SchemaValidator.normalizeKeySpelling has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 5, loops 4 (5 pts), if/else 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ShortcutsCLIService.run (cognitive 16) Packages/OsaurusCore/AppleApps/Shortcuts/ShortcutsTools.swift:295— ShortcutsCLIService.run has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), ternaries 3 (4 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AppleJSON.serializable (cognitive 16) Packages/OsaurusCore/AppleApps/Support/AppleToolBase.swift:328— AppleJSON.serializable has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 3 (6 pts), if/else 3 (4 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BrowserSession.waitFor (cognitive 16) Packages/OsaurusCore/Browser/Runtime/BrowserSession.swift:858— BrowserSession.waitFor has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FrameScrubber.recognizeAndDetect (cognitive 16) Packages/OsaurusCore/ComputerUse/Perception/FrameScrubber.swift:261— FrameScrubber.recognizeAndDetect has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 2 (4 pts), error handling 3, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ScreenContextDistiller.statusBarSignals (cognitive 16) Packages/OsaurusCore/ComputerUse/Perception/ScreenContextDistiller.swift:747— ScreenContextDistiller.statusBarSignals has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyCommands (cognitive 16) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1067— ConfigApplier.applyCommands has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigApplier.applyPlugins (cognitive 16) Packages/OsaurusCore/Configuration/Declarative/ConfigApplier.swift:1674— ConfigApplier.applyPlugins has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), error handling 2 (5 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatSessionImporter.parseChatGPT (cognitive 16) Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift:199— ChatSessionImporter.parseChatGPT has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 4, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatMessage.substitute (cognitive 16) Packages/OsaurusCore/PrivacyFilter/Core/MessageScrubbing.swift:265— ChatMessage.substitute has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 2, loops 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelLiveProofReadiness.telegram (cognitive 16) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:40— AgentChannelLiveProofReadiness.telegram has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12, boolean chains 3, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelLiveProofReadiness.slack (cognitive 16) Packages/OsaurusCore/Models/AgentChannel/AgentChannelLiveProofReadiness.swift:98— AgentChannelLiveProofReadiness.slack has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12, loops 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ServerRuntimeSettingsStore.shouldRepairMemorySafetyOwnedCacheDefaults (cognitive 16) Packages/OsaurusCore/Models/Configuration/ServerRuntimeSettingsStore.swift:570— ServerRuntimeSettingsStore.shouldRepairMemorySafetyOwnedCacheDefaults has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 15, if/else 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Template.parseExactly (cognitive 16) Packages/OsaurusCore/Models/Template/Template.swift:473— Template.parseExactly has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
TemplateRequirements.items (cognitive 16) Packages/OsaurusCore/Models/Template/TemplateRequirements.swift:350— TemplateRequirements.items has cognitive complexity 16 (threshold 15). Drivers by points: loops 9, ternaries 2 (4 pts), if/else 2, boolean chains 1 (nesting depth added 2). Of this number, 14 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
PrivacyFilterModelBundle.verify (cognitive 16) Packages/OsaurusCore/PrivacyFilter/Model/PrivacyFilterModelBundle.swift:142— PrivacyFilterModelBundle.verify has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentBundleService.resolveImportIdentity (cognitive 16) Packages/OsaurusCore/Services/AgentBridge/AgentBundleService.swift:255— AgentBundleService.resolveImportIdentity has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, if/else 7. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AgentChannelTemplateRenderer.replacement (cognitive 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelCustomJSONRunner.swift:1644— AgentChannelTemplateRenderer.replacement has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChannelPublishService.operatorSend (cognitive 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift:594— AgentChannelPublishService.operatorSend has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 5, error handling 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AgentChannelWebhookIngress.handleInbound (cognitive 16) Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift:207— AgentChannelWebhookIngress.handleInbound has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), error handling 3, match/switch 3, ternaries 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChannelReplyTokenService.validateToken (cognitive 16) Packages/OsaurusCore/Services/Channels/ChannelReplyTokenService.swift:96— ChannelReplyTokenService.validateToken has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), match/switch 1 (2 pts), error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
AgentToolLoop.runBatchInParallel (cognitive 16) Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:1714— AgentToolLoop.runBatchInParallel has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 4 (5 pts), boolean chains 1, error handling 1 (nesting depth added 4). Of this number, 14 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextBudgetManager.countRecentMessages (cognitive 16) Packages/OsaurusCore/Services/Chat/ContextBudgetManager.swift:688— ContextBudgetManager.countRecentMessages has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemPromptComposer.compactWorkspaceSpec (cognitive 16) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3362— SystemPromptComposer.compactWorkspaceSpec has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PDFTableDetector.tables (cognitive 16) Packages/OsaurusCore/Services/Documents/PDFTableDetector.swift:201— PDFTableDetector.tables has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 4 (7 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.apply (cognitive 16) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:134— PendingImportProcessor.apply has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 2 (4 pts), error handling 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PendingImportProcessor.referencingAgents (cognitive 16) Packages/OsaurusCore/Services/Import/PendingImportProcessor.swift:826— PendingImportProcessor.referencingAgents has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), loops 3 (5 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ActivityExportService.describe (cognitive 16) Packages/OsaurusCore/Services/Insights/ActivityExportService.swift:323— ActivityExportService.describe has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12, ternaries 2 (4 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
KnowledgeDocumentParser.extraFields (cognitive 16) Packages/OsaurusCore/Services/Knowledge/KnowledgeDocumentParser.swift:84— KnowledgeDocumentParser.extraFields has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 4, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MCPProviderProbeService.mapFailure (cognitive 16) Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:441— MCPProviderProbeService.mapFailure has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 6, if/else 6, match/switch 2 (4 pts) (nesting depth added 2). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenizerBridge.deepseekV4String (cognitive 16) Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift:969— TokenizerBridge.deepseekV4String has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PluginHostContext.prepareInference (cognitive 16) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:900— PluginHostContext.prepareInference has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 6, ternaries 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PluginHostContext.ssrfBlockedIPv4 (cognitive 16) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:3053— PluginHostContext.ssrfBlockedIPv4 has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9, boolean chains 7. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SharedAgentIdentity.make (cognitive 16) Packages/OsaurusCore/Services/Router/SharedAgentIdentity.swift:113— SharedAgentIdentity.make has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8, boolean chains 5, ternaries 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
WorkspaceAuditLog.verify (cognitive 16) Packages/OsaurusCore/Services/Router/WorkspaceAuditLog.swift:302— WorkspaceAuditLog.verify has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BraveScrapeBackend.parseHTML (cognitive 16) Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:176— BraveScrapeBackend.parseHTML has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchHTML.decodeHTMLEntities (cognitive 16) Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:18— SearchHTML.decodeHTMLEntities has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchHTML.blockedIPv6Reason (cognitive 16) Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:280— SearchHTML.blockedIPv6Reason has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
SearchHTML.blockedIPv4Reason (cognitive 16) Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:361— SearchHTML.blockedIPv4Reason has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9, boolean chains 7. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ClaudePluginInstaller.inferCron (cognitive 16) Packages/OsaurusCore/Services/Skill/ClaudePluginInstaller.swift:1530— ClaudePluginInstaller.inferCron has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolIndexService.syncFromRegistry (cognitive 16) Packages/OsaurusCore/Services/Tool/ToolIndexService.swift:18— ToolIndexService.syncFromRegistry has cognitive complexity 16 (threshold 15). Drivers by points: error handling 3 (6 pts), if/else 5 (6 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolSearchService.searchHybridWithDiagnostic (cognitive 16) Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:419— ToolSearchService.searchHybridWithDiagnostic has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 3, error handling 1, loops 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentDetailSubTabPill.body (cognitive 16) Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:976— AgentDetailSubTabPill.body has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 8 (12 pts), if/else 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentsView.body (cognitive 16) Packages/OsaurusCore/Views/Agent/AgentsView.swift:113— AgentsView.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10, boolean chains 4, ternaries 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatSession.modelVisibleAssistantMessage (cognitive 16) Packages/OsaurusCore/Views/Chat/ChatView.swift:2489— ChatSession.modelVisibleAssistantMessage has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, ternaries 4, if/else 3. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ChatSession.streamMockToolTimeline (cognitive 16) Packages/OsaurusCore/Views/Chat/ChatView.swift:5781— ChatSession.streamMockToolTimeline has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeArtifactCardView.minimumHeightWithFooterChrome (cognitive 16) Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:168— NativeArtifactCardView.minimumHeightWithFooterChrome has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (7 pts), ternaries 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
NativeMarkdownView.rectOfSearchOccurrence (cognitive 16) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:290— NativeMarkdownView.rectOfSearchOccurrence has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMessageCellView.measureFittedRowHeight (cognitive 16) Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift:1988— NativeMessageCellView.measureFittedRowHeight has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, ternaries 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SelectableTextView.updateNSView (cognitive 16) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:132— SelectableTextView.updateNSView has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SidebarLensBar.segmentButton (cognitive 16) Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:267— SidebarLensBar.segmentButton has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 9 (13 pts), if/else 2, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemoryConsoleInspectSheet.metadataGrid (cognitive 16) Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:789— MemoryConsoleInspectSheet.metadataGrid has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ModelPickerView.thinkingOptionRow (cognitive 16) Packages/OsaurusCore/Views/Model/ModelPickerView.swift:1038— ModelPickerView.thinkingOptionRow has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 8 (11 pts), if/else 4, boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MCPPreviewView.body (cognitive 16) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1373— MCPPreviewView.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 4 (7 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ToolPluginCard.body (cognitive 16) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756— ToolPluginCard.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), ternaries 5 (6 pts), boolean chains 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HarnessRuntimeEditorSheet.parseEnvironment (cognitive 16) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:563— HarnessRuntimeEditorSheet.parseEnvironment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 7, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CommandLineToolSection.resolveCLIExecutableURL (cognitive 16) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:122— CommandLineToolSection.resolveCLIExecutableURL has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 8. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
N8nSettingsView.locationConsequences (cognitive 16) Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:521— N8nSettingsView.locationConsequences has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 2 (3 pts), match/switch 1 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AccessKeysSection.accessKeyRow (cognitive 16) Packages/OsaurusCore/Views/Settings/ServerView.swift:516— AccessKeysSection.accessKeyRow has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9, ternaries 5 (7 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
WorkspaceAuditCard.body (cognitive 16) Packages/OsaurusCore/Views/Workspaces/WorkspaceAuditView.swift:41— WorkspaceAuditCard.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CreateWorkspaceSheet.body (cognitive 16) Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:232— CreateWorkspaceSheet.body has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 6, if/else 5, ternaries 5. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DOCXEditor.markdownParagraph (cognitive 16) Packages/OsaurusCore/Services/Documents/OOXML/DOCXEditor.swift:371— DOCXEditor.markdownParagraph has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 6). Of this number, 14 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentTemplateCard.body (cognitive 16) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:35— AgentTemplateCard.body has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 11, if/else 4, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MTPSection.body (cognitive 16) Packages/OsaurusCore/Views/Settings/ServerSettings/MTPSection.swift:57— MTPSection.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7, loops 2 (3 pts), ternaries 2 (3 pts), boolean chains 2, match/switch 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
main.swift.buildHelperHostAPI (cognitive 16) Packages/OsaurusCore/PluginHost/main.swift:269— main.swift.buildHelperHostAPI has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Accessibility.swift.computeFocusDelta (cognitive 16) Packages/OsaurusCore/ComputerUse/Driver/Mac/Accessibility.swift:1054— Accessibility.swift.computeFocusDelta has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (5 pts), boolean chains 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applescript_capability_scoreboard.render_markdown (cognitive 16) scripts/evals/applescript_capability_scoreboard.py:141— applescript_capability_scoreboard.render_markdown has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5, boolean chains 4, ternaries 2 (4 pts), loops 2 (3 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
assert-computer-use-web-form-evidence-privacy.main (cognitive 16) scripts/evals/assert-computer-use-web-form-evidence-privacy.py:28— assert-computer-use-web-form-evidence-privacy.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities· Medium vulnerability · ×1
Change-coupling hub: Package.swift → ModelMediaCapabilities.swift, ImageGenerationService.swift, SwiftTransformersTokenizerLoader.swift, ImageGenerationPanelView.swift Packages/OsaurusCore/Package.swift— `Packages/OsaurusCore/Package.swift` changes together with 4 other files — `Packages/OsaurusCore/Models/Configuration/ModelMediaCapabilities.swift`, `Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationService.swift`, `Packages/OsaurusCore/Services/ModelRuntime/SwiftTransformersTokenizerLoader.swift`, `Packages/OsaurusCore/Views/Model/ImageGenerationPanelView.swift` — none of which declares a dependency on it: one file is the hub of 4 separate couplings, not 4 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 4.
D4 · Code Duplication· Near-duplicate member family (12 members, 24 shared lines) · ×1
Near-duplicate member family (12 members, 24 shared lines) Packages/OsaurusCore/Models/Agent/Agent.swift:331— Packages/OsaurusCore/Models/Agent/Agent.swift:331-411 | Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:83-143 | Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:159-213 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:143-203 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:131-185 | Packages/OsaurusCore/Services/GitHubSkillService.swift:441-491 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:758-806 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1091-1157 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1790-1864 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2767-2817 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3559-3617 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:162-236 — These 12 members are variants of one another: a block of 24 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication· Near-duplicate member family (6 members, 29 shared lines) · ×1
Near-duplicate member family (6 members, 29 shared lines) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66-141 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:91-175 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2387-2456 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1403-1477 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1875 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:577-654 — These 6 members are variants of one another: a block of 29 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 31 shared lines) · ×1
Near-duplicate member family (5 members, 31 shared lines) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:102— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:102-173 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:115-184 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:106-190 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:101-172 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:127-195 — These 5 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 38 shared lines) · ×1
Near-duplicate member family (4 members, 38 shared lines) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:313— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:313-372 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1787-1861 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1403-1477 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1875 — These 4 members are variants of one another: a block of 38 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 37 shared lines) · ×1
Near-duplicate member family (4 members, 37 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:5594— Packages/OsaurusCore/Networking/HTTPHandler.swift:5594-5682 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6827-6917 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6968-7039 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7274-7355 — These 4 members are variants of one another: a block of 37 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 31 shared lines) · ×1
Near-duplicate member family (4 members, 31 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:9602— Packages/OsaurusCore/Networking/HTTPHandler.swift:9602-9722 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16043-16112 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16114-16220 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16460-16548 — These 4 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 20 shared lines) · ×1
Near-duplicate member family (4 members, 20 shared lines) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:66-141 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:91-175 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:313-372 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1875 — These 4 members are variants of one another: a block of 20 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 14 shared lines) · ×1
Near-duplicate member family (4 members, 14 shared lines) Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:111— Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:111-154 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:313-372 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1787-1861 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1875 — These 4 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 13 shared lines) · ×1
Near-duplicate member family (4 members, 13 shared lines) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:179— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:179-215 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:171-208 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1812-1894 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1979-2012 — These 4 members are variants of one another: a block of 13 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 9 shared lines) · ×1
Near-duplicate member family (4 members, 9 shared lines) Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:159— Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:159-173 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:636-649 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:933-947 | Packages/OsaurusCore/Models/Chat/ResponseWriters.swift:1267-1281 — These 4 members are variants of one another: a block of 9 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 18 shared lines) · ×1
Near-duplicate member family (3 members, 18 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:5925— Packages/OsaurusCore/Networking/HTTPHandler.swift:5925-6008 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8119-8207 | Packages/OsaurusCore/Networking/HTTPHandler.swift:8215-8294 — These 3 members are variants of one another: a block of 18 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 16 shared lines) · ×1
Near-duplicate member family (3 members, 16 shared lines) Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1303— Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1303-1441 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1588-1674 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:1873-1971 — These 3 members are variants of one another: a block of 16 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 14 shared lines) · ×1
Near-duplicate member family (3 members, 14 shared lines) Packages/OsaurusCore/Folder/PromptWorkingFolderTool.swift:120— Packages/OsaurusCore/Folder/PromptWorkingFolderTool.swift:120-175 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:549-615 | Packages/OsaurusCore/Tools/WebSearchTools.swift:248-314 — These 3 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 7 shared lines) · ×1
Near-duplicate member family (3 members, 7 shared lines) Packages/OsaurusCore/Folder/FileCopyTool.swift:80— Packages/OsaurusCore/Folder/FileCopyTool.swift:80-282 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1547-1568 | Packages/OsaurusCore/Tools/VideoTool.swift:88-121 — These 3 members are variants of one another: a block of 7 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (106 shared lines) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:110— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:110-590 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:592-968 — These two members are variants of one another: 106 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (89 shared lines) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:482— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:482-637 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:214-335 — These two members are variants of one another: 89 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (76 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:15183— Packages/OsaurusCore/Networking/HTTPHandler.swift:15183-15265 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15466-15547 — These two members are variants of one another: 76 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (75 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:8742— Packages/OsaurusCore/Networking/HTTPHandler.swift:8742-9036 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9109-9474 — These two members are variants of one another: 75 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (72 shared lines) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2053— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2053-2178 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1136-1253 — These two members are variants of one another: 72 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (71 shared lines) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:219— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:219-300 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:212-295 — These two members are variants of one another: 71 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (70 shared lines) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1380— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1380-1681 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1748-1980 — These two members are variants of one another: 70 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (67 shared lines) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:548— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:548-668 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:678-805 — These two members are variants of one another: 67 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (55 shared lines) Packages/OsaurusCore/Networking/HTTPHandler.swift:16242— Packages/OsaurusCore/Networking/HTTPHandler.swift:16242-16442 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16550-16911 — These two members are variants of one another: 55 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (54 shared lines) Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:537— Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:537-620 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:639-730 — These two members are variants of one another: 54 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (52 shared lines) Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756— Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:756-901 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:925-1049 — These two members are variants of one another: 52 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (46 shared lines) Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:172— Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:172-281 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1642-1797 — These two members are variants of one another: 46 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (45 shared lines) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3362— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3362-3619 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2051-2120 — These two members are variants of one another: 45 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (36 shared lines) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6091— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6091-6156 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:167-237 — These two members are variants of one another: 36 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (18 shared lines) Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:124— Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:124-172 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelMessageFormatter.swift:330-388 — These two members are variants of one another: 18 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (30 corresponding lines) · ×1
Edited copy of a member (30 corresponding lines) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3089— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3089-3127 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9005-9038 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (42 corresponding lines) · ×1
Edited copy of a member (42 corresponding lines) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:593— Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:593-666 | Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:872-923 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (16 corresponding lines) · ×1
Edited copy of a member (16 corresponding lines) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:811— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:811-1074 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:816-849 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (36 corresponding lines) · ×1
Edited copy of a member (36 corresponding lines) Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:375— Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:375-425 | Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:432-483 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (20 corresponding lines) · ×1
Edited copy of a member (20 corresponding lines) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1265— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1265-1286 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1446-1465 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (22 corresponding lines) · ×1
Edited copy of a member (22 corresponding lines) Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:179— Packages/OsaurusCore/Views/Onboarding/OnboardingCreateAgentView.swift:179-208 | Packages/OsaurusCore/Views/Onboarding/OnboardingWelcomeView.swift:48-93 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (17 corresponding lines) · ×1
Edited copy of a member (17 corresponding lines) Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:45— Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:45-170 | Packages/OsaurusCore/Views/Template/TemplateImportReviewView.swift:95-119 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (19 corresponding lines) · ×1
Edited copy of a member (19 corresponding lines) Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2057— Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2057-2085 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1814-1875 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Members sharing a duplicated core (19 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (19 members, 50+ identical tokens) Packages/OsaurusCore/Tools/AgentChannelTools.swift:373— Packages/OsaurusCore/Tools/AgentChannelTools.swift:373-379 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:407-420 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:453-471 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:507-526 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:562-581 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:626-647 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:683-700 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:741-763 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:805-827 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:853-878 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:901-923 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:955-981 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1025-1044 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1093-1115 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1168-1193 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1238-1263 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1308-1333 | Packages/OsaurusCore/Tools/CalculatorTool.swift:58-94 | Packages/OsaurusCore/Tools/CurrentTimeTool.swift:49-100 — These 19 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 19 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 19 times.
D4 · Code Duplication· Members sharing a duplicated core (17 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (17 members, 50+ identical tokens) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321-401 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:445-498 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:534-561 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:606-660 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:699-760 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:795-835 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:861-892 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:915-944 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:987-1039 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1079-1140 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1239-1378 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1432-1513 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1572-1616 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1639-1677 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1735-1753 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:131-188 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:320-347 — These 17 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 17 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 17 times.
D4 · Code Duplication· Members sharing a duplicated core (12 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (12 members, 50+ identical tokens) Packages/OsaurusCore/Storage/ActivityLogStore.swift:38— Packages/OsaurusCore/Storage/ActivityLogStore.swift:38-47 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:19-34 | Packages/OsaurusCore/Storage/AgentDatabase.swift:48-63 | Packages/OsaurusCore/Storage/ChatHistoryDatabase.swift:29-37 | Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:29-40 | Packages/OsaurusCore/Storage/KnowledgeWriteLogDatabase.swift:37-45 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:35-46 | Packages/OsaurusCore/Storage/MethodDatabase.swift:21-29 | Packages/OsaurusCore/Storage/PluginDatabase.swift:18-25 | Packages/OsaurusCore/Storage/RouterBillingDatabase.swift:27-35 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:30-38 | Packages/OsaurusCore/Storage/ToolDatabase.swift:21-29 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication· Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (10 members, 50+ identical tokens) Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:532— Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:532-548 | Packages/OsaurusCore/Views/Memory/MemoryManagementConsoleView.swift:216-327 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:779-911 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:571-643 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:725-808 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:844-922 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1028-1084 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2025-2106 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2110-2179 | Packages/OsaurusCore/Views/Settings/SearchView.swift:326-407 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
Duplicated block (83 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1244— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1244-1326 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1655-1737 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:1244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (64 lines × 2) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:878— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:878-941 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:979-1042 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:878` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (59 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:137— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:137-195 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:615-673 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:615` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (46–53 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:75— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:75-120 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:101-153 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (52 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:607— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:607-658 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:842-893 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:607` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (34–51 lines × 2) Packages/OsaurusCore/Storage/MemoryDatabase.swift:722— Packages/OsaurusCore/Storage/MemoryDatabase.swift:722-772 | Packages/OsaurusCore/Storage/MethodDatabase.swift:166-199 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:722` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Storage/MemoryDatabase.swift:774` calls `DEFAULT`, `datetime` and `Packages/OsaurusCore/Storage/MethodDatabase.swift:199` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (47–48 lines × 2) Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:301— Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:301-348 | Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:437-483 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:301` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (48 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1220— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1220-1267 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2332-2379 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1220` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (43–44 lines × 2) Packages/OsaurusCore/Services/ModelRuntime.swift:4597— Packages/OsaurusCore/Services/ModelRuntime.swift:4597-4640 | Packages/OsaurusCore/Services/ModelRuntime.swift:4699-4741 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/ModelRuntime.swift:4597` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (44 lines × 2) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1164— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1164-1207 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2276-2319 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1164` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `16` in one and `0` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (42–43 lines × 2) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:519— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:519-561 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift:901-942 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (43 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1121— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1121-1163 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1174-1216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1121` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (39–42 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2388— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2388-2426 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:578-619 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2388` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (36–41 lines × 2) Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:385— Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:385-425 | Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:448-483 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:385` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:446` calls `OSAScript` and `Packages/OsaurusCore/AppleScript/Exec/AppleScriptExecutor.swift:383` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (33–39 lines × 2) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1111— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1111-1143 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1665-1703 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:1111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (38 lines × 2) Packages/OsaurusCore/Tools/AgentChannelTools.swift:111— Packages/OsaurusCore/Tools/AgentChannelTools.swift:111-148 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:183-220 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/AgentChannelTools.swift:111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (35–38 lines × 2) Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:629— Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:629-666 | Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:889-923 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:629` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (36 lines × 3) Packages/OsaurusCore/Models/Agent/Skill.swift:126— Packages/OsaurusCore/Models/Agent/Skill.swift:126-161 | Packages/OsaurusCore/Models/Agent/Skill.swift:292-327 | Packages/OsaurusCore/Models/Agent/Skill.swift:381-416 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Skill.swift:126` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29–36 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:8743— Packages/OsaurusCore/Networking/HTTPHandler.swift:8743-8771 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9110-9145 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:8743` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (36 lines × 2) Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1067— Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1067-1102 | Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1177-1212 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1067` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/WhatsApp/WhatsAppConnectionService.swift:1214` calls `sendReadReceiptsIfEnabled` and `Packages/OsaurusCore/Services/IMessage/IMessageConnectionService.swift:1106` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (34–36 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMemory.swift:129— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMemory.swift:129-162 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerReasoningChannel.swift:190-225 — before extracting anything, compare `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMemory.swift` and `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerReasoningChannel.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerMemory.swift:129` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (25–35 lines × 2) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:374— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:374-398 | Packages/OsaurusCore/Services/Chat/SystemPromptTemplates.swift:1096-1130 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:374` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (35 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3315— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3315-3349 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1038-1072 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3315` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–35 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1233— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1233-1254 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1387-1421 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1233` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16–34 lines × 8) Packages/OsaurusCore/Models/Agent/Skill.swift:153— Packages/OsaurusCore/Models/Agent/Skill.swift:153-168 | Packages/OsaurusCore/Models/Agent/Skill.swift:199-214 | Packages/OsaurusCore/Models/Agent/Skill.swift:219-252 | Packages/OsaurusCore/Models/Agent/Skill.swift:257-290 | Packages/OsaurusCore/Models/Agent/Skill.swift:319-334 | Packages/OsaurusCore/Models/Agent/Skill.swift:364-379 | Packages/OsaurusCore/Models/Agent/Skill.swift:408-423 | Packages/OsaurusCore/Models/Agent/Skill.swift:428-460 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Skill.swift:153` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (32–34 lines × 2) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:569— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:569-600 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:282-315 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:569` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29–32 lines × 2) Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:81— Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:81-112 | Packages/OsaurusCore/Views/Management/SharedSidebarComponents.swift:187-215 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32 lines × 2) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2091— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2091-2122 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1169-1200 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2091` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (30–32 lines × 2) Packages/OsaurusCore/Views/Voice/VoiceComponents.swift:659— Packages/OsaurusCore/Views/Voice/VoiceComponents.swift:659-690 | Packages/OsaurusCore/Views/Voice/VoiceComponents.swift:963-992 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Voice/VoiceComponents.swift:659` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–31 lines × 2) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:217— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:217-247 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:348-361 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:217` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 3) Packages/OsaurusCore/Views/Management/ManagerHeader.swift:56— Packages/OsaurusCore/Views/Management/ManagerHeader.swift:56-85 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:119-148 | Packages/OsaurusCore/Views/Management/ManagerHeader.swift:189-218 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/ManagerHeader.swift:56` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Management/ManagerHeader.swift:186` calls `tabsRow` and `Packages/OsaurusCore/Views/Management/ManagerHeader.swift:116` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (24–30 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:430— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:430-453 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:404-433 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:430` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–29 lines × 3) Packages/OsaurusCore/Services/Method/MethodSearchService.swift:57— Packages/OsaurusCore/Services/Method/MethodSearchService.swift:57-76 | Packages/OsaurusCore/Services/Skill/SkillSearchService.swift:82-101 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:165-193 — before extracting anything, compare `Packages/OsaurusCore/Services/Method/MethodSearchService.swift` and `Packages/OsaurusCore/Services/Skill/SkillSearchService.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Method/MethodSearchService.swift:57` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:195` calls `processPendingIndexEntries` and `Packages/OsaurusCore/Services/Method/MethodSearchService.swift:78` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (27–28 lines × 9) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:210— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:210-237 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:856-882 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:957-983 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1059-1085 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1138-1164 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1215-1242 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1297-1324 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1368-1395 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1459-1485 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:210` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (28 lines × 4) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:123— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:123-150 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:114-141 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:109-136 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:135-162 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:123` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16–28 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1250— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1250-1265 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:1284-1311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24–28 lines × 2) Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:492— Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift:492-515 | Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift:228-255 — before extracting anything, compare `Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift` and `Packages/OsaurusCore/Views/Chat/NativeThinkingView.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (27 lines × 3) Packages/OsaurusCore/Subagent/SubagentSession.swift:700— Packages/OsaurusCore/Subagent/SubagentSession.swift:700-726 | Packages/OsaurusCore/Subagent/SubagentSession.swift:739-765 | Packages/OsaurusCore/Subagent/SubagentSession.swift:939-965 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/SubagentSession.swift:700` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (25–27 lines × 2) Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:458— Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:458-484 | Packages/OsaurusCore/ComputerUse/Driver/Mac/InputController.swift:185-209 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Driver/Mac/BackgroundDriver.swift:458` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26–27 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:675— Packages/OsaurusCore/Networking/HTTPHandler.swift:675-701 | Packages/OsaurusCore/Networking/HTTPHandler.swift:732-757 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:732` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (20–27 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:12815— Packages/OsaurusCore/Networking/HTTPHandler.swift:12815-12841 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13574-13593 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:12815` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15–26 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:421— Packages/OsaurusCore/Views/Agent/AgentsView.swift:421-440 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplatesView.swift:96-110 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:80-105 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:38-58 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandsView.swift:30-55 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1005-1028 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:108-128 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:421` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/SlashCommand/SlashCommandsView.swift:26` calls `Spacer`, `frame` and `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:33` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (26 lines × 4) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:900— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:900-925 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1001-1026 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1408-1433 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1500-1525 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:900` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–26 lines × 2) Packages/OsaurusCore/Views/Plugin/PluginsView.swift:137— Packages/OsaurusCore/Views/Plugin/PluginsView.swift:137-162 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:3002-3023 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (25 lines × 6) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:949— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:949-973 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1336-1360 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1788-1812 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1419-1443 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1124-1148 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1464-1488 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1788` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `timedOutWaitingForMore` to `Bool = false` in one and `Bool` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (20–25 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:416— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:416-435 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:839-863 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:527-549 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:563-587 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1042-1066 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:416` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `20` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (25 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:1757— Packages/OsaurusCore/Networking/HTTPHandler.swift:1757-1781 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1828-1852 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16015-16039 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1757` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–25 lines × 2) Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:260— Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:260-281 | Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:324-348 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/DefaultAgentSystemPromptBuilder.swift:260` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–25 lines × 2) Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:1315— Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:1315-1339 | Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:1405-1424 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/Kinds/TextSubagentKind.swift:1315` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (24–25 lines × 2) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:143— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:143-166 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:179-203 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (21–24 lines × 3) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1071— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1071-1094 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1128-1148 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1181-1201 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:1071` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18–24 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:12826— Packages/OsaurusCore/Networking/HTTPHandler.swift:12826-12849 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12864-12881 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13583-13600 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (23–24 lines × 2) Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:240— Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:240-262 | Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:377-400 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/LocalGenerationDefaults.swift:240` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–24 lines × 2) Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:137— Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:137-160 | Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:155-170 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:161` calls `frame` and `Packages/OsaurusCore/Views/Settings/ComputerUseSettingsView.swift:171` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17–23 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:2070— Packages/OsaurusCore/Networking/HTTPHandler.swift:2070-2086 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2104-2126 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:2070` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–23 lines × 2) Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:867— Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:867-878 | Packages/OsaurusCore/Views/Chat/NativeMarkdownView.swift:1540-1562 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/NativeBlockViews.swift:867` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–23 lines × 2) Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:383— Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:383-402 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:47-69 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:383` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–22 lines × 2) Packages/OsaurusCore/Subagent/SubagentSession.swift:917— Packages/OsaurusCore/Subagent/SubagentSession.swift:917-938 | Packages/OsaurusCore/Subagent/SubagentSession.swift:1052-1067 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/SubagentSession.swift:917` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–22 lines × 2) Packages/OsaurusCore/Views/Common/SimpleComponents.swift:533— Packages/OsaurusCore/Views/Common/SimpleComponents.swift:533-552 | Packages/OsaurusCore/Views/Common/SimpleComponents.swift:624-645 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SimpleComponents.swift:533` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19–22 lines × 2) Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:265— Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:265-286 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:448-466 — before extracting anything, compare `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift` and `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 126 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:265` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–22 lines × 2) Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:367— Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:367-381 | Packages/OsaurusCore/Views/Settings/ConfigurationView.swift:637-658 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:367` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (21 lines × 4) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1102— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1102-1122 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1181-1201 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1263-1283 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1517-1537 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15–21 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:9021— Packages/OsaurusCore/Networking/HTTPHandler.swift:9021-9035 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9217-9237 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9445-9464 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9021` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 3) Packages/OsaurusCore/Views/Agent/AgentsView.swift:949— Packages/OsaurusCore/Views/Agent/AgentsView.swift:949-969 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:456-476 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:286-306 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:949` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19–21 lines × 3) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:883— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:883-903 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:512-530 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1138-1158 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 306 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:883` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–21 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:714— Packages/OsaurusCore/Folder/FolderTools.swift:714-731 | Packages/OsaurusCore/Folder/FolderTools.swift:786-806 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20–21 lines × 2) Packages/OsaurusCore/Storage/AgentDatabase.swift:928— Packages/OsaurusCore/Storage/AgentDatabase.swift:928-947 | Packages/OsaurusCore/Storage/AgentDatabase.swift:1010-1030 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/AgentDatabase.swift:928` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–21 lines × 2) Packages/OsaurusCore/Tools/SandboxSecretTools.swift:182— Packages/OsaurusCore/Tools/SandboxSecretTools.swift:182-202 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:216-228 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/SandboxSecretTools.swift:182` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19–21 lines × 2) Packages/OsaurusCore/Views/Agent/AgentsView.swift:6936— Packages/OsaurusCore/Views/Agent/AgentsView.swift:6936-6956 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7042-7060 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6936` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–20 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:5250— Packages/OsaurusCore/Networking/HTTPHandler.swift:5250-5269 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6896-6915 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7024-7037 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7175-7188 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7334-7353 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7885-7904 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7972-7991 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (14–20 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:6769— Packages/OsaurusCore/Networking/HTTPHandler.swift:6769-6788 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6923-6942 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7220-7239 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7400-7419 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7482-7495 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6769` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (19–20 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:1760— Packages/OsaurusCore/Networking/HTTPHandler.swift:1760-1779 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1831-1850 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1971-1989 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16018-16037 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (17–20 lines × 4) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:67— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:67-85 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:92-111 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1404-1420 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1815-1831 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:67` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/SearchView.swift:1398` calls `cancel` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (20 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:2032— Packages/OsaurusCore/Networking/HTTPHandler.swift:2032-2051 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2067-2086 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2101-2120 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:2032` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19–20 lines × 3) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:220— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:220-238 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:267-286 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2398-2416 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:220` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–20 lines × 2) Packages/OsaurusCore/Folder/FolderTools.swift:2534— Packages/OsaurusCore/Folder/FolderTools.swift:2534-2553 | Packages/OsaurusCore/Folder/FolderTools.swift:3452-3466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:2534` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–20 lines × 2) Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2156— Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2156-2165 | Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2235-2254 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Plugin/PluginHostAPI.swift:2156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19–20 lines × 2) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1020— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1020-1039 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1659-1677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1020` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–20 lines × 2) Packages/OsaurusCore/Utils/MockChatData.swift:112— Packages/OsaurusCore/Utils/MockChatData.swift:112-131 | Packages/OsaurusCore/Utils/MockChatData.swift:237-252 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Utils/MockChatData.swift:112` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (19 lines × 5) Packages/OsaurusCore/Models/Theme/CustomTheme.swift:910— Packages/OsaurusCore/Models/Theme/CustomTheme.swift:910-928 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1011-1029 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1256-1274 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1418-1436 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1510-1528 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:910` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:1277` calls `ThemeBorders` and `Packages/OsaurusCore/Models/Theme/CustomTheme.swift:929` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–19 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:9704— Packages/OsaurusCore/Networking/HTTPHandler.swift:9704-9722 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12743-12755 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16094-16112 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16202-16220 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16530-16548 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9704` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–19 lines × 3) Packages/OsaurusCore/Models/Chat/SessionSource.swift:70— Packages/OsaurusCore/Models/Chat/SessionSource.swift:70-88 | Packages/OsaurusCore/Models/Chat/SessionSource.swift:106-115 | Packages/OsaurusCore/Models/Chat/SessionSource.swift:122-131 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/SessionSource.swift:70` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–19 lines × 2) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2268— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2268-2280 | Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2297-2315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2297` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–19 lines × 2) Packages/OsaurusCore/Managers/MCPProviderManager.swift:1289— Packages/OsaurusCore/Managers/MCPProviderManager.swift:1289-1307 | Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:409-419 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Managers/MCPProviderManager.swift:1289` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (4–19 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:14328— Packages/OsaurusCore/Networking/HTTPHandler.swift:14328-14331 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17279-17297 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18031-18049 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:17279` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:17297` calls `HTTPHeaders` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:14331` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–19 lines × 2) Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:776— Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:776-785 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:878-896 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–19 lines × 2) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:201— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:201-219 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:629-637 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerComputerUseLoop.swift:201` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13–18 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019— Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019-1033 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:112-124 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceCard.swift:113-130 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:51-68 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1179-1193 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:506-520 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:689-703 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1019` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:125` calls `help`, `L` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:1034` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16–18 lines × 5) Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:333— Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:333-348 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:362-377 | Packages/OsaurusCore/Views/Chat/ChatSessionSidebar.swift:2641-2658 | Packages/OsaurusCore/Views/Chat/ChatTabStripView.swift:981-998 | Packages/OsaurusCore/Views/Chat/ProjectDetailView.swift:194-209 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:333` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:994— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:994-1011 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1377-1394 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:1472-1489 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:1026-1043 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1505-1522 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (17–18 lines × 4) Packages/OsaurusCore/Subagent/SubagentSession.swift:655— Packages/OsaurusCore/Subagent/SubagentSession.swift:655-671 | Packages/OsaurusCore/Subagent/SubagentSession.swift:815-831 | Packages/OsaurusCore/Subagent/SubagentSession.swift:882-899 | Packages/OsaurusCore/Subagent/SubagentSession.swift:1004-1021 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Subagent/SubagentSession.swift:655` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15–18 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:199— Packages/OsaurusCore/Views/Credits/CreditsView.swift:199-213 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:228-242 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:544-561 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsView.swift:199` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Credits/CreditsView.swift:564` calls `ProgressView`, `scaleEffect` and `Packages/OsaurusCore/Views/Credits/CreditsView.swift:244` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–18 lines × 2) Packages/OsaurusCore/Networking/HTTPHandler.swift:2266— Packages/OsaurusCore/Networking/HTTPHandler.swift:2266-2283 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2586-2598 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:2266` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16–18 lines × 2) Packages/OsaurusCore/Views/Common/CircularIconButton.swift:24— Packages/OsaurusCore/Views/Common/CircularIconButton.swift:24-41 | Packages/OsaurusCore/Views/Model/ModelCacheInspectorView.swift:202-217 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/CircularIconButton.swift:24` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–18 lines × 2) Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:397— Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:397-410 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:371-388 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 753 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13–17 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3150— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3150-3165 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3457-3472 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8868-8882 | Packages/OsaurusCore/Views/Agent/Setup/AgentSetupWizardView.swift:483-495 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:142-157 | Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:390-404 | Packages/OsaurusCore/Views/Settings/ConfigurationView.swift:666-680 | Packages/OsaurusCore/Views/Voice/VoiceSetupTab.swift:617-633 — there are 8 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3150` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/ChatSettingsView.swift:388` calls `lineLimit` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3148` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16–17 lines × 5) Packages/OsaurusCore/Networking/HTTPHandler.swift:1758— Packages/OsaurusCore/Networking/HTTPHandler.swift:1758-1774 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1829-1845 | Packages/OsaurusCore/Networking/HTTPHandler.swift:1969-1984 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2163-2178 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16016-16032 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1758` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–17 lines × 3) Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8041— Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8041-8057 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8098-8112 | Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8189-8203 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/FloatingInputCard.swift:8041` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–17 lines × 3) Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:96— Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:96-108 | Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift:157-169 | Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:168-184 — before extracting anything, compare `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift` and `Packages/OsaurusCore/Views/Plugin/ToolPermissionView.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 126 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:96` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–17 lines × 3) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3131— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3131-3141 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:318-334 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:900-910 — before extracting anything, compare `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift` and `Packages/OsaurusCore/Views/Watcher/WatchersView.swift` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 764 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:335` calls `fixedSize` and `Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3142` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–17 lines × 2) Packages/OsaurusCore/Identity/MasterKey.swift:277— Packages/OsaurusCore/Identity/MasterKey.swift:277-293 | Packages/OsaurusCore/Identity/MasterMnemonicStore.swift:63-74 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (10–17 lines × 2) Packages/OsaurusCore/Models/Chat/ContentBlock.swift:919— Packages/OsaurusCore/Models/Chat/ContentBlock.swift:919-928 | Packages/OsaurusCore/Models/Chat/ContentBlock.swift:940-956 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/ContentBlock.swift:940` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–17 lines × 2) Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:456— Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:456-472 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1825-1835 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ClarifyPromptOverlay.swift:456` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–17 lines × 2) Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:875— Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:875-888 | Packages/OsaurusCore/Views/Settings/SearchView.swift:389-405 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:875` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–16 lines × 6) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:121— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:121-133 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:152-167 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2433-2448 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1460-1470 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1858-1868 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:631-646 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:121` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (16 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:6846— Packages/OsaurusCore/Networking/HTTPHandler.swift:6846-6861 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6987-7002 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7114-7129 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7293-7308 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:6846` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12–16 lines × 4) Packages/OsaurusCore/Storage/MemoryDatabase.swift:1609— Packages/OsaurusCore/Storage/MemoryDatabase.swift:1609-1620 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1637-1648 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1654-1669 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:1680-1695 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:1609` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14–16 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3106— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3106-3121 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9021-9034 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:188-203 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:811-826 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–16 lines × 2) Packages/OsaurusCore/Models/Agent/AgentStarterTemplate.swift:54— Packages/OsaurusCore/Models/Agent/AgentStarterTemplate.swift:54-63 | Packages/OsaurusCore/Models/Agent/AgentStarterTemplate.swift:68-83 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5–16 lines × 3) Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:598— Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:598-613 | Packages/OsaurusCore/Services/Documents/XLSXAdapter.swift:867-871 | Packages/OsaurusCore/Services/Documents/XLSXEmitter.swift:335-348 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Documents/WorkbookWorkflowService.swift:598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–16 lines × 2) Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:217— Packages/OsaurusCore/Subagent/Kinds/ImageSubagentKind.swift:217-232 | Packages/OsaurusCore/Subagent/Kinds/VideoSubagentKind.swift:95-105 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (12–15 lines × 9) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3109— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3109-3123 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9024-9036 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1182-1195 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2591-2602 | Packages/OsaurusCore/Views/Settings/DirectoryPickerView.swift:85-97 | Packages/OsaurusCore/Views/Settings/ExternalModelsSettingsView.swift:187-201 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:191-205 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:745-756 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:814-828 — there are 9 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3109` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3125` calls `onChange`, `debouncedSave` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:9038` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:5610— Packages/OsaurusCore/Networking/HTTPHandler.swift:5610-5624 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6360-6374 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6477-6491 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6843-6857 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6984-6998 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7111-7125 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7290-7304 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5610` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12–15 lines × 6) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54-65 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:130-141 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:886-900 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2064-2076 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:54-65 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1842-1853 — before extracting anything, compare `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift` and `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–15 lines × 5) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:243— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:243-256 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:291-304 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1316-1327 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2422-2433 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:935-949 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:243` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1315` calls `disabled` and `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:242` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:107— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:107-121 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:120-134 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:111-125 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:106-120 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:132-146 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:107` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14–15 lines × 4) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:320— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:320-333 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1808-1821 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1412-1426 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1823-1837 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:320` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:4649— Packages/OsaurusCore/Networking/HTTPHandler.swift:4649-4662 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16595-16608 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16650-16664 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4649` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–15 lines × 2) Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:955— Packages/OsaurusCore/Views/Chat/SelectableTextView.swift:955-969 | Packages/OsaurusCore/Views/Common/CodeBlockView.swift:373-379 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (4–15 lines × 3) Packages/OsaurusCore/Views/Credits/CreditsView.swift:1007— Packages/OsaurusCore/Views/Credits/CreditsView.swift:1007-1021 | Packages/OsaurusCore/Views/Router/RouterAccountUsageCenterView.swift:458-472 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolActivityView.swift:184-187 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Workspaces/WorkspacePoolActivityView.swift:184` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–15 lines × 2) Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:288— Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:288-297 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:567-581 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:288` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–14 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:956— Packages/OsaurusCore/Views/Agent/AgentsView.swift:956-969 | Packages/OsaurusCore/Views/Agent/RemoteAgentViews.swift:202-212 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateCard.swift:196-206 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:273-283 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1333-1343 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:463-476 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:293-306 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:762-772 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 8 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:956` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (2–14 lines × 40) Packages/OsaurusCore/Browser/Tool/BrowserUseTool.swift:83— Packages/OsaurusCore/Browser/Tool/BrowserUseTool.swift:83-96 | Packages/OsaurusCore/ComputerUse/Tool/ComputerUseTool.swift:127-135 | Packages/OsaurusCore/Folder/FileCopyTool.swift:81-89 | Packages/OsaurusCore/Folder/FolderTools.swift:1045-1053 | Packages/OsaurusCore/Folder/PromptWorkingFolderTool.swift:127-140 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:688-689 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:746-747 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:810-811 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:858-859 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:906-907 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:960-961 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1098-1099 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1173-1174 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1243-1244 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1313-1314 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1548-1550 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1554-1555 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:76-89 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:215-223 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:404-417 | Packages/OsaurusCore/Tools/AgentLoopTools.swift:556-569 | Packages/OsaurusCore/Tools/CalculatorTool.swift:59-62 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:327-328 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:540-541 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:705-706 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1245-1246 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1438-1439 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1578-1579 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:137-145 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:326-327 | Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:100-103 | Packages/OsaurusCore/Tools/KnowledgeCurationTools.swift:111-121 | Packages/OsaurusCore/Tools/KnowledgeTools.swift:452-455 | Packages/OsaurusCore/Tools/KnowledgeWriteTools.swift:823-827 | Packages/OsaurusCore/Tools/NativeImageTools.swift:174-177 | Packages/OsaurusCore/Tools/SandboxPluginRegisterTool.swift:53-61 | Packages/OsaurusCore/Tools/SkillUpdateTool.swift:96-99 | Packages/OsaurusCore/Tools/VideoTool.swift:89-91 | Packages/OsaurusCore/Tools/WebSearchTools.swift:249-252 | Packages/OsaurusCore/Tools/WebSearchTools.swift:253-263 — there are 40 copies across 18 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 40 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Browser/Tool/BrowserUseTool.swift:83` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Tools/WebSearchTools.swift:250` calls `value`, `requireString` and `Packages/OsaurusCore/ComputerUse/Tool/ComputerUseTool.swift:127` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–14 lines × 6) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:22— Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:22-35 | Packages/OsaurusCore/Views/Settings/ServerView.swift:147-160 | Packages/OsaurusCore/Views/Settings/ServerView.swift:733-746 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1039-1049 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1336-1346 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1434-1444 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (14 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:1998— Packages/OsaurusCore/Networking/HTTPHandler.swift:1998-2011 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2031-2044 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2066-2079 | Packages/OsaurusCore/Networking/HTTPHandler.swift:2100-2113 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:1998` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–14 lines × 4) Packages/OsaurusCore/Networking/HTTPHandler.swift:14171— Packages/OsaurusCore/Networking/HTTPHandler.swift:14171-14178 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15159-15172 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15444-15455 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17154-17167 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:14171` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–14 lines × 3) Packages/OsaurusCore/Networking/HTTPHandler.swift:9733— Packages/OsaurusCore/Networking/HTTPHandler.swift:9733-9746 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12041-12051 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12119-12128 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9733` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 3) Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:117— Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:117-128 | Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:110-123 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1074-1087 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:117` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:114` calls `fixedSize` and `Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:107` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–14 lines × 2) Packages/OsaurusCore/Models/BackgroundTaskModels.swift:62— Packages/OsaurusCore/Models/BackgroundTaskModels.swift:62-75 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:466-473 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/BackgroundTaskModels.swift:62` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–14 lines × 4) Packages/OsaurusCore/Tools/AgentLoopTools.swift:66— Packages/OsaurusCore/Tools/AgentLoopTools.swift:66-78 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2677-2690 | Packages/OsaurusCore/Tools/SandboxPluginRegisterTool.swift:50-58 | Packages/OsaurusCore/Tools/SpawnAgentTool.swift:128-130 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/AgentLoopTools.swift:66` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13 lines × 12) Packages/OsaurusCore/Networking/HTTPHandler.swift:5595— Packages/OsaurusCore/Networking/HTTPHandler.swift:5595-5607 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6147-6159 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6234-6246 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6345-6357 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6462-6474 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6828-6840 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6969-6981 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7096-7108 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7275-7287 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7737-7749 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7849-7861 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11540-11552 — all 12 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5595` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8–13 lines × 10) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:120— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:120-129 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:137-144 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:151-163 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2432-2444 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:145-152 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:904-911 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:367-374 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1459-1468 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1857-1866 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:630-642 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:120` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13 lines × 8) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62— Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62-74 | Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:169-181 | Packages/OsaurusCore/Models/Method/Method.swift:43-55 | Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift:114-126 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:104-116 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:246-258 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:381-393 | Packages/OsaurusCore/Storage/ToolDatabase.swift:58-70 — there are 8 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Method/Method.swift:42` calls `Date` and `Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:168` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–13 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:9701— Packages/OsaurusCore/Networking/HTTPHandler.swift:9701-9713 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9865-9877 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12740-12746 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13719-13725 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16091-16103 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16199-16211 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16527-16539 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:9701` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 6) Packages/OsaurusCore/Models/Chat/Attachment.swift:601— Packages/OsaurusCore/Models/Chat/Attachment.swift:601-613 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:93-105 | Packages/OsaurusCore/Models/Plugin/ProvisioningJourney.swift:105-117 | Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:188-200 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1610-1622 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2942-2954 — there are 6 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/Attachment.swift:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 6) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104-3116 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5789-5801 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:9019-9030 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:532-541 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:186-198 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:809-821 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3104` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 4) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1353— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1353-1365 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:428-437 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:318-329 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1457-1469 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1353` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–13 lines × 3) Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:127— Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:127-136 | Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:141-149 | Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:153-165 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–13 lines × 2) Packages/OsaurusCore/Views/Chat/ChatImageCache.swift:47— Packages/OsaurusCore/Views/Chat/ChatImageCache.swift:47-55 | Packages/OsaurusCore/Views/Theme/ThemePreviewImageCache.swift:90-102 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatImageCache.swift:47` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 94) Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66— Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66-77 | Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:69-80 | Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:148-159 | Packages/OsaurusCore/Models/API/OpenAIAPI.swift:52-63 | Packages/OsaurusCore/Models/Agent/Agent.swift:371-382 | Packages/OsaurusCore/Models/Agent/Agent.swift:885-896 | Packages/OsaurusCore/Models/Agent/Agent.swift:1303-1314 | Packages/OsaurusCore/Models/Agent/DefaultAgentConfiguration.swift:106-117 | Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:75-86 | Packages/OsaurusCore/Models/Agent/Skill.swift:74-85 | Packages/OsaurusCore/Models/AgentDelegation/DelegationRecord.swift:63-74 | Packages/OsaurusCore/Models/Chat/ChatConfiguration.swift:167-178 | Packages/OsaurusCore/Models/Chat/ChatSessionData.swift:82-93 | Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:113-124 | Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:63-74 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:205-216 | Packages/OsaurusCore/Models/Configuration/MCPProviderTemplate.swift:157-168 | Packages/OsaurusCore/Models/Configuration/MLXModel.swift:81-92 | Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:186-197 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:214-225 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:274-285 | Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:170-181 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:53-64 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:294-305 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:133-144 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:292-303 | Packages/OsaurusCore/Models/Method/Method.swift:44-55 | Packages/OsaurusCore/Models/Plugin/SandboxConfiguration.swift:100-111 | Packages/OsaurusCore/Models/Plugin/SandboxPlugin.swift:134-145 | Packages/OsaurusCore/Models/RunTrace.swift:102-113 | Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:72-83 | Packages/OsaurusCore/Models/Template/Template.swift:119-130 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:173-184 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:485-496 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:808-819 | Packages/OsaurusCore/Models/Toast.swift:246-257 | Packages/OsaurusCore/PrivacyFilter/Core/PrivacyRulePresets.swift:156-167 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelTransportRuntime.swift:161-172 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:75-86 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:133-144 | Packages/OsaurusCore/Services/Chat/AgentConfigSnapshot.swift:239-250 | Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:671-682 | Packages/OsaurusCore/Services/Chat/ComposeRequest.swift:71-82 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:196-207 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:464-475 | Packages/OsaurusCore/Services/Context/AppleScriptEvaluator.swift:199-210 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:105-116 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:194-205 | Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:107-118 | Packages/OsaurusCore/Services/Context/ContextAttribution.swift:111-122 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:158-169 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:290-301 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:56-67 | Packages/OsaurusCore/Services/FileHistory/FileChangeModels.swift:128-139 | Packages/OsaurusCore/Services/GitHubSkillService.swift:229-240 | Packages/OsaurusCore/Services/GitHubSkillService.swift:466-477 | Packages/OsaurusCore/Services/Inference/ModelService.swift:185-196 | Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:64-75 | Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationTypes.swift:172-183 | Packages/OsaurusCore/Services/ModelRuntime.swift:437-448 | Packages/OsaurusCore/Services/ModelRuntime/ImageEffectiveParameters.swift:57-68 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:138-149 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:193-204 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:254-265 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofMatrixReporter.swift:83-94 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:206-217 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:650-661 | Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift:115-126 | Packages/OsaurusCore/Services/Skill/ClaudePluginManifestStore.swift:156-167 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:77-88 | Packages/OsaurusCore/Services/Telegram/TelegramAPIClient.swift:156-167 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:93-104 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:105-116 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:247-258 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:382-393 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:157-168 | Packages/OsaurusCore/Utils/StorageLocationStandards.swift:165-176 | Packages/OsaurusCore/Views/Common/ThemedAlertDialog.swift:223-234 | Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:69-80 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:487-498 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:249-260 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:782-793 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:877-888 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1124-1135 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1240-1251 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1827-1838 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2521-2532 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2613-2624 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2792-2803 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3243-3254 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3588-3599 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalHistory.swift:71-82 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:199-210 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:557-568 — there are 94 copies across 68 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 94 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Toast.swift:244` calls `Date` and `Packages/OsaurusCore/Models/API/OpenAIAPI.swift:50` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 90) Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:69— Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:69-80 | Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:75-86 | Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:153-164 | Packages/OsaurusCore/Models/API/OpenAIAPI.swift:55-66 | Packages/OsaurusCore/Models/Agent/Agent.swift:400-411 | Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:77-88 | Packages/OsaurusCore/Models/Agent/Skill.swift:79-90 | Packages/OsaurusCore/Models/AgentDelegation/DelegationRecord.swift:67-78 | Packages/OsaurusCore/Models/Chat/ChatConfiguration.swift:175-186 | Packages/OsaurusCore/Models/Chat/ChatSessionData.swift:91-102 | Packages/OsaurusCore/Models/Chat/ChatTurnData.swift:132-143 | Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:65-76 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:216-227 | Packages/OsaurusCore/Models/Configuration/MCPProviderTemplate.swift:160-171 | Packages/OsaurusCore/Models/Configuration/MLXModel.swift:85-96 | Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:202-213 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:221-232 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:277-288 | Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:172-183 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:55-66 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:296-307 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:140-151 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:299-310 | Packages/OsaurusCore/Models/Method/Method.swift:48-59 | Packages/OsaurusCore/Models/Plugin/SandboxConfiguration.swift:102-113 | Packages/OsaurusCore/Models/Plugin/SandboxPlugin.swift:139-150 | Packages/OsaurusCore/Models/RunTrace.swift:104-115 | Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:76-87 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:192-203 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:488-499 | Packages/OsaurusCore/Models/Theme/CustomTheme.swift:813-824 | Packages/OsaurusCore/Models/Toast.swift:249-260 | Packages/OsaurusCore/PrivacyFilter/Core/PrivacyRulePresets.swift:158-169 | Packages/OsaurusCore/Services/AgentChannel/AgentChannelTransportRuntime.swift:168-179 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:84-95 | Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:141-152 | Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:679-690 | Packages/OsaurusCore/Services/Chat/ComposeRequest.swift:76-87 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:476-487 | Packages/OsaurusCore/Services/Context/AppleScriptEvaluator.swift:208-219 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:116-127 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:201-213 | Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:109-120 | Packages/OsaurusCore/Services/Context/ContextAttribution.swift:113-124 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:174-185 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:294-305 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:58-69 | Packages/OsaurusCore/Services/FileHistory/FileChangeModels.swift:130-141 | Packages/OsaurusCore/Services/GitHubSkillService.swift:231-242 | Packages/OsaurusCore/Services/GitHubSkillService.swift:480-491 | Packages/OsaurusCore/Services/Inference/ModelService.swift:209-220 | Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:67-78 | Packages/OsaurusCore/Services/MediaGeneration/MediaGenerationTypes.swift:175-186 | Packages/OsaurusCore/Services/ModelRuntime.swift:442-453 | Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift:186-197 | Packages/OsaurusCore/Services/ModelRuntime/ImageEffectiveParameters.swift:59-70 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:142-153 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:201-212 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:262-273 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofMatrixReporter.swift:85-96 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:214-225 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:654-665 | Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift:118-129 | Packages/OsaurusCore/Services/Skill/ClaudePluginManifestStore.swift:168-179 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:84-95 | Packages/OsaurusCore/Services/Telegram/TelegramAPIClient.swift:160-171 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:97-108 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:107-118 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:254-265 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:388-399 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:159-170 | Packages/OsaurusCore/Utils/StorageLocationStandards.swift:167-178 | Packages/OsaurusCore/Views/Common/ThemedAlertDialog.swift:227-238 | Packages/OsaurusCore/Views/Model/ModelPickerTableRepresentable.swift:72-83 | Packages/OsaurusCore/Views/Voice/VoiceInputOverlay.swift:84-95 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:489-500 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:255-266 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:795-806 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:880-891 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1146-1157 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1242-1253 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1853-1864 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2529-2540 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2616-2627 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2806-2817 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3298-3309 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3606-3617 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalHistory.swift:78-89 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift:284-295 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:225-236 — there are 90 copies across 68 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 90 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:69` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:216` calls `matches`, `trimmingCharacters` and `Packages/OsaurusCore/Services/AgentDelegation/NativeImageJobCoordinator.swift:96` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 55) Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:148— Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:148-159 | Packages/OsaurusCore/Models/API/OpenAIAPI.swift:52-63 | Packages/OsaurusCore/Models/Agent/Agent.swift:371-382 | Packages/OsaurusCore/Models/Agent/DefaultAgentConfiguration.swift:106-117 | Packages/OsaurusCore/Models/Agent/RemoteAgent.swift:75-86 | Packages/OsaurusCore/Models/Agent/Skill.swift:74-85 | Packages/OsaurusCore/Models/Chat/Attachment.swift:601-612 | Packages/OsaurusCore/Models/Chat/ChatSessionData.swift:82-93 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:93-104 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:205-216 | Packages/OsaurusCore/Models/Configuration/MCPProviderTemplate.swift:157-168 | Packages/OsaurusCore/Models/Configuration/MLXModel.swift:81-92 | Packages/OsaurusCore/Models/Configuration/ModelPickerItem.swift:186-197 | Packages/OsaurusCore/Models/Configuration/RemoteProviderConfiguration.swift:214-225 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:274-285 | Packages/OsaurusCore/Models/Knowledge/KnowledgeModels.swift:294-305 | Packages/OsaurusCore/Models/Plugin/ProvisioningJourney.swift:105-116 | Packages/OsaurusCore/Models/Plugin/SandboxPlugin.swift:134-145 | Packages/OsaurusCore/Models/Schedule/ScheduleRunHistory.swift:72-83 | Packages/OsaurusCore/Models/Toast.swift:246-257 | Packages/OsaurusCore/PrivacyFilter/Core/PrivacyRulePresets.swift:156-167 | Packages/OsaurusCore/Services/Chat/AgentToolLoop.swift:671-682 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:196-207 | Packages/OsaurusCore/Services/Context/AgentLoopEvaluator.swift:464-475 | Packages/OsaurusCore/Services/Context/AppleScriptEvaluator.swift:199-210 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:105-116 | Packages/OsaurusCore/Services/Context/CacheProofEvaluator.swift:194-205 | Packages/OsaurusCore/Services/Context/CapabilityClaimsEvaluator.swift:107-118 | Packages/OsaurusCore/Services/Context/ContextAttribution.swift:111-122 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:158-169 | Packages/OsaurusCore/Services/GitHubSkillService.swift:229-240 | Packages/OsaurusCore/Services/Inference/ModelService.swift:185-196 | Packages/OsaurusCore/Services/ModelRuntime/ImageEffectiveParameters.swift:57-68 | Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift:138-149 | Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift:650-661 | Packages/OsaurusCore/Services/Skill/ClaudePluginManifestStore.swift:156-167 | Packages/OsaurusCore/Services/Telegram/TelegramAPIClient.swift:156-167 | Packages/OsaurusCore/Storage/SchedulerDatabase.swift:157-168 | Packages/OsaurusCore/Subagent/SubagentBatchAdmissionPlanner.swift:188-199 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:249-260 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:782-793 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:877-888 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1124-1135 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1240-1251 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1610-1621 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1827-1838 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2521-2532 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2613-2624 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2792-2803 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2942-2953 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3243-3254 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3588-3599 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalHistory.swift:71-82 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:199-210 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:557-568 — there are 55 copies across 39 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 55 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Model/AgentAction.swift:148` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Toast.swift:244` calls `Date` and `Packages/OsaurusCore/Models/API/OpenAIAPI.swift:50` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–12 lines × 11) Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:274— Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:274-284 | Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:286-296 | Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:221-232 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:538-549 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:769-780 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:284-295 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:585-596 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:696-707 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:141-152 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:872-883 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1538-1549 — there are 11 copies across 9 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 11 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:274` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:298` calls `keyboardShortcut` and `Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:285` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 10) Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:65— Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:65-76 | Packages/OsaurusCore/ComputerUse/Driver/MacDriver.swift:68-79 | Packages/OsaurusCore/ComputerUse/Perception/ScreenContextSnapshot.swift:91-102 | Packages/OsaurusCore/Models/Memory/MemoryManagementConsoleModels.swift:132-143 | Packages/OsaurusCore/Services/Discord/DiscordConnectionService.swift:55-66 | Packages/OsaurusCore/Services/GitHubSkillService.swift:465-476 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofMatrixReporter.swift:82-93 | Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift:205-216 | Packages/OsaurusCore/Services/Slack/SlackConnectionService.swift:76-87 | Packages/OsaurusCore/Services/Telegram/TelegramConnectionService.swift:92-103 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 10 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 10 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/ComputerUse/Diagnostics/ComputerUseGateInspector.swift:65` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 9) Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62— Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62-73 | Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:169-180 | Packages/OsaurusCore/Models/Knowledge/KnowledgeCollection.swift:61-72 | Packages/OsaurusCore/Models/Method/Method.swift:43-54 | Packages/OsaurusCore/Services/Sandbox/SandboxWorkspaceChange.swift:114-125 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:104-115 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:246-257 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:381-392 | Packages/OsaurusCore/Storage/ToolDatabase.swift:58-69 — there are 9 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/SharedArtifact.swift:62` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Models/Knowledge/KnowledgeCollection.swift:60` calls `Date` and `Packages/OsaurusCore/Models/Documents/DocumentSecurityMetadata.swift:168` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 8) Packages/OsaurusCore/Models/Chat/Attachment.swift:600— Packages/OsaurusCore/Models/Chat/Attachment.swift:600-611 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:92-103 | Packages/OsaurusCore/Services/Context/SubagentJobEvaluator.swift:157-168 | Packages/OsaurusCore/Services/MCP/OAuth/MCPOAuthDiscovery.swift:90-101 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:1239-1250 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2520-2531 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:2612-2623 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalCase.swift:3242-3253 — there are 8 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Chat/Attachment.swift:600` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:13992— Packages/OsaurusCore/Networking/HTTPHandler.swift:13992-14003 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15002-15013 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15296-15307 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16243-16254 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16551-16562 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16916-16927 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17557-17568 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:13992` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10–12 lines × 6) Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:133— Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:133-144 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:892-903 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2070-2079 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:355-366 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1447-1458 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1845-1856 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift` and `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 129 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:133` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:145` calls `frame`, `background`, `Circle` and `Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2080` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–12 lines × 4) Packages/OsaurusCore/Views/Agent/AgentsView.swift:5787— Packages/OsaurusCore/Views/Agent/AgentsView.swift:5787-5798 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2651-2661 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:185-195 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:808-818 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:5787` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–12 lines × 3) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:181— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:181-192 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:222-233 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2263-2270 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:181` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:221` calls `VStack` and `Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2262` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–12 lines × 3) Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:34— Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:34-44 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:114-123 | Packages/OsaurusCore/Views/Settings/PermissionsView.swift:34-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:34` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–12 lines × 2) Packages/OsaurusCore/Models/Agent/Agent.swift:43— Packages/OsaurusCore/Models/Agent/Agent.swift:43-48 | Packages/OsaurusCore/Models/Agent/Agent.swift:68-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Agent.swift:68` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11 lines × 16) Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:220— Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:220-230 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:537-547 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:768-778 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:283-293 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:584-594 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:695-705 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:218-228 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:265-275 | Packages/OsaurusCore/Views/Provider/ProviderCredentialPromptSheet.swift:537-547 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:3393-3403 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:140-150 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1283-1293 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2396-2406 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1537-1547 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:407-417 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:1353-1363 — there are 16 copies across 13 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 16 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:220` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–11 lines × 14) Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:205— Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:205-215 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:518-528 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:748-758 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1160-1170 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:205-212 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1298-1308 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1406-1413 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1432-1439 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:198-205 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1756-1761 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1849-1854 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1944-1951 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2004-2009 | Packages/OsaurusCore/Views/Settings/ServerView.swift:333-343 — there are 14 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 14 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:205` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Identity/IdentityView.swift:759` calls `disabled` and `Packages/OsaurusCore/Views/Identity/IdentityView.swift:530` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 11) Packages/OsaurusCore/Networking/HTTPHandler.swift:9956— Packages/OsaurusCore/Networking/HTTPHandler.swift:9956-9966 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11703-11713 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12206-12216 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12365-12375 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13997-14007 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15007-15017 | Packages/OsaurusCore/Networking/HTTPHandler.swift:15301-15311 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16248-16258 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16556-16566 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16921-16931 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17562-17572 — all 11 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:9973` calls `injectingEmptyModelIfMissing` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:15313` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–11 lines × 10) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395-3401 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3491-3499 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3537-3543 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3558-3564 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3571-3577 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3586-3592 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1651-1657 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2076-2086 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2110-2116 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:101-107 — there are 10 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3567` calls `array` and `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3404` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–11 lines × 8) Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:806— Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:806-813 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:849-859 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1452-1461 | Packages/OsaurusCore/Views/Settings/AgentChannelSettingsComponents.swift:617-627 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1039-1049 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1575-1585 | Packages/OsaurusCore/Views/Settings/ServerView.swift:212-222 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:640-647 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 8 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:806` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 8) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:286— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:286-296 | Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:455-465 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1042-1052 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:323-333 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:355-365 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:590-600 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:597-607 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1162-1172 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:286` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `10` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:282` calls `fixedSize` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:351` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–11 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:4717— Packages/OsaurusCore/Networking/HTTPHandler.swift:4717-4726 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4814-4823 | Packages/OsaurusCore/Networking/HTTPHandler.swift:4881-4890 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17255-17265 | Packages/OsaurusCore/Networking/HTTPHandler.swift:17304-17314 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18007-18017 | Packages/OsaurusCore/Networking/HTTPHandler.swift:18056-18066 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:4717` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8–11 lines × 6) Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351— Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351-1361 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2045-2053 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1003-1010 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:1545-1552 | Packages/OsaurusCore/Views/Settings/ServerView.swift:451-461 | Packages/OsaurusCore/Views/Settings/ServerView.swift:1455-1465 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:1351` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–11 lines × 5) Packages/OsaurusCore/Views/Identity/IdentityView.swift:968— Packages/OsaurusCore/Views/Identity/IdentityView.swift:968-978 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:661-671 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2067-2072 | Packages/OsaurusCore/Views/Settings/ServerView.swift:2503-2510 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:747-757 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:968` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–11 lines × 4) Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:787— Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:787-797 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:913-920 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1092-1102 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2166-2176 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:787` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2178` calls `padding` and `Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:922` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–11 lines × 3) Packages/OsaurusCore/Views/Identity/IdentityView.swift:571— Packages/OsaurusCore/Views/Identity/IdentityView.swift:571-581 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:916-926 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:1738-1745 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:571` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–11 lines × 3) Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:172— Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:172-182 | Packages/OsaurusCore/Views/Workspaces/WorkspacePoolSheets.swift:127-133 | Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:404-414 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:184` calls `Spacer` and `Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift:415` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (4–11 lines × 3) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:103— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:103-113 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:104-114 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1510-1513 — before extracting anything, compare `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift` and `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 358 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–10 lines × 15) Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:53— Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:53-61 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:168-176 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:289-297 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:626-634 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:617-625 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:647-655 | Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:138-146 | Packages/OsaurusCore/Views/Insights/InsightsView.swift:1241-1246 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:190-198 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:115-123 | Packages/OsaurusCore/Views/Settings/CommandLineToolSection.swift:27-36 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:110-118 | Packages/OsaurusCore/Views/Settings/ServerView.swift:152-161 | Packages/OsaurusCore/Views/Settings/ServerView.swift:738-747 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:167-175 — there are 15 copies across 11 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 15 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:53` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–10 lines × 13) Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290— Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290-296 | Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:304-310 | Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:237-246 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:883-892 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:603-609 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:715-721 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:427-433 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1435-1444 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:317-325 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:70-79 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:554-563 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1648-1657 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1884-1890 — there are 13 copies across 10 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 13 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:312` calls `keyboardShortcut` and `Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:247` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–10 lines × 9) Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:77— Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:77-86 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1294-1303 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:259-268 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:78-87 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1736-1742 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1752-1758 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1845-1851 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1879-1885 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2000-2006 — there are 9 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:77` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `6` in one and `5` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9–10 lines × 6) Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:569— Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:569-577 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:602-611 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:687-695 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:805-813 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:919-927 | Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:971-979 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Configuration/Declarative/ConfigPlanner.swift:569` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–10 lines × 6) Packages/OsaurusCore/Networking/HTTPHandler.swift:8010— Packages/OsaurusCore/Networking/HTTPHandler.swift:8010-8015 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9014-9023 | Packages/OsaurusCore/Networking/HTTPHandler.swift:9697-9703 | Packages/OsaurusCore/Networking/HTTPHandler.swift:12737-12742 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13904-13909 | Packages/OsaurusCore/Networking/HTTPHandler.swift:13935-13940 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:8010` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:9696` calls `AgentListResponse` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:9014` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–10 lines × 5) Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:177— Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:177-182 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:216-221 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:298-303 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:348-353 | Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:442-451 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Manifest/ManifestValidate.swift:177` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–10 lines × 5) Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:393— Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:393-400 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:881-890 | Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:504-511 | Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:510-517 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:1136-1145 — before extracting anything, compare `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift` and `Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 206 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:393` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift:506` calls `padding` and `Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift:501` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–10 lines × 4) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3443— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3443-3452 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3533-3541 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3555-3562 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3582-3590 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3443` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 4) Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:533— Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:533-541 | Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift:886-895 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:531-540 | Packages/OsaurusCore/Views/Model/ModelPickerView.swift:733-742 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentDetailChrome.swift:533` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–10 lines × 4) Packages/OsaurusCore/Views/Insights/InsightsView.swift:1026— Packages/OsaurusCore/Views/Insights/InsightsView.swift:1026-1032 | Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:117-125 | Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:110-119 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1074-1083 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsView.swift:1026` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Management/SettingsSearchResultsView.swift:114` calls `fixedSize` and `Packages/OsaurusCore/Views/Settings/ProviderRowCard.swift:107` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–10 lines × 4) Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:176— Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:176-185 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2061-2069 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2049-2054 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2066-2071 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:176` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `2` in one and `1` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5–10 lines × 3) Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2267— Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2267-2275 | Packages/OsaurusCore/Services/Provider/ProviderReplayDiagnostics.swift:215-224 | Packages/OsaurusCore/Storage/AgentChannelMessageStore.swift:277-281 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleScript/Loop/AppleScriptLoop.swift:2267` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (2–10 lines × 4) Packages/OsaurusCore/Folder/FolderTools.swift:2404— Packages/OsaurusCore/Folder/FolderTools.swift:2404-2413 | Packages/OsaurusCore/Folder/RedactionTools.swift:273-282 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1389-1390 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:134-142 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderTools.swift:2404` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Tools/AgentChannelTools.swift:1387` calls `value`, `optionalString` and `Packages/OsaurusCore/Folder/FolderTools.swift:2404` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–10 lines × 3) Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:48— Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:48-53 | Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:170-179 | Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:198-203 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `2` in one and `3` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Settings/ServerModelsTabContent.swift:168` calls `padding` and `Packages/OsaurusCore/Views/Settings/ComputerUseDiagnosticsPanel.swift:47` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 10) Packages/OsaurusCore/Views/Agent/AgentsView.swift:4249— Packages/OsaurusCore/Views/Agent/AgentsView.swift:4249-4257 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:86-94 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:419-427 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1567-1575 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:187-195 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:444-452 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:180-188 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:606-614 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:508-516 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:841-849 — there are 10 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:4249` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 9) Packages/OsaurusCore/AppleApps/AppleAppsPluginMigration.swift:76— Packages/OsaurusCore/AppleApps/AppleAppsPluginMigration.swift:76-84 | Packages/OsaurusCore/Browser/BrowserConfigurationStore.swift:71-79 | Packages/OsaurusCore/ComputerUse/Policy/ComputerUsePolicyStore.swift:107-115 | Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:455-463 | Packages/OsaurusCore/Models/Configuration/RelayConfiguration.swift:50-58 | Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:474-482 | Packages/OsaurusCore/Models/Tool/ToolConfigurationStore.swift:107-115 | Packages/OsaurusCore/Models/Voice/SpeechConfiguration.swift:256-264 | Packages/OsaurusCore/Models/Voice/TTSConfiguration.swift:177-185 — before extracting anything, compare `Packages/OsaurusCore/ComputerUse/Policy/ComputerUsePolicyStore.swift` and `Packages/OsaurusCore/Models/Tool/ToolConfigurationStore.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/AppleAppsPluginMigration.swift:76` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Models/Configuration/MCPProviderConfiguration.swift:465` calls `configurationFileURL`, `resolvePath`, `mcpProviderConfigFile` and `Packages/OsaurusCore/ComputerUse/Policy/ComputerUsePolicyStore.swift:116` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 8) Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:123— Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:123-133 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:157-167 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2438-2448 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:357-365 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1846-1854 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1462-1470 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1860-1868 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:636-646 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift` and `Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 395 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–9 lines × 7) Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:122— Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:122-128 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:220-225 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:718-724 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1819-1825 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1983-1989 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2021-2027 | Packages/OsaurusCore/Views/Voice/VoiceView.swift:299-307 — there are 7 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/IncomingPairSheet.swift:122` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `1` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2018` calls `VStack` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1980` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 7) Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:761— Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:761-769 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2298-2306 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:151-159 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:188-196 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:129-137 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:407-415 | Packages/OsaurusCore/Views/Settings/ServerView.swift:378-386 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/SpawnConfigurationEditor.swift:761` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 6) Packages/OsaurusCore/Networking/HTTPHandler.swift:16333— Packages/OsaurusCore/Networking/HTTPHandler.swift:16333-16341 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16523-16530 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16694-16702 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16741-16749 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16840-16848 | Packages/OsaurusCore/Networking/HTTPHandler.swift:16876-16884 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:16333` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5–9 lines × 5) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:647— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:647-655 | Packages/OsaurusCore/Views/Chat/MarkdownImageView.swift:168-172 | Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:211-217 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:923-927 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1269-1273 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:647` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:656` calls `overlay`, `Capsule`, `strokeBorder` and `Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:218` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–9 lines × 5) Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:107— Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:107-115 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:128-136 | Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:181-189 | Packages/OsaurusCore/Views/Settings/FileHistoryRetentionSection.swift:24-32 | Packages/OsaurusCore/Views/Voice/VADModeSettingsTab.swift:220-225 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Model/AppleScriptModelsView.swift:107` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `24` in one and `10` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5–9 lines × 4) Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:175— Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:175-183 | Packages/OsaurusCore/Services/Provider/OpenAICodexOAuthService.swift:455-459 | Packages/OsaurusCore/Services/Provider/ProviderReplayDiagnostics.swift:205-213 | Packages/OsaurusCore/Services/Provider/XAIOAuthService.swift:318-322 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/MCP/MCPProviderProbeService.swift:175` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–9 lines × 4) Packages/OsaurusCore/Views/Insights/InsightsView.swift:57— Packages/OsaurusCore/Views/Insights/InsightsView.swift:57-63 | Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:93-101 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:62-70 | Packages/OsaurusCore/Views/Settings/SearchView.swift:63-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsView.swift:57` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Insights/InsightsView.swift:54` calls `frame`, `clipped` and `Packages/OsaurusCore/Views/Plugin/ToolsManagerView.swift:92` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–9 lines × 4) Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2730— Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:2730-2736 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1001-1009 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:310-315 | Packages/OsaurusCore/Views/SlashCommand/SlashCommandEditorSheet.swift:110-115 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
Duplicated block (6–9 lines × 3) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:724— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:724-731 | Packages/OsaurusCore/Views/Agent/AgentSkillAllowListCard.swift:50-55 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:8915-8923 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:724` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `2` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7–9 lines × 3) Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1332— Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1332-1339 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1471-1479 | Packages/OsaurusCore/Views/Settings/OrchestratorSupportSections.swift:398-404 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:1471` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (4–9 lines × 4) Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:460— Packages/OsaurusCore/Storage/KnowledgeDatabase.swift:460-463 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:872-875 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:921-926 | Packages/OsaurusCore/Storage/MemoryDatabase.swift:2202-2210 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Storage/MemoryDatabase.swift:921` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Storage/MemoryDatabase.swift:928` calls `sqlite3_bind_int`, `Int32` and `Packages/OsaurusCore/Storage/MemoryDatabase.swift:877` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5–9 lines × 2) Packages/OsaurusCore/Views/Toast/ToastStyling.swift:209— Packages/OsaurusCore/Views/Toast/ToastStyling.swift:209-217 | Packages/OsaurusCore/Views/Toast/ToastView.swift:136-140 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Toast/ToastStyling.swift:209` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5–8 lines × 18) Packages/OsaurusCore/Views/Common/SectionHeader.swift:64— Packages/OsaurusCore/Views/Common/SectionHeader.swift:64-71 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:204-211 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:517-524 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1159-1166 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:80-87 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:204-209 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1297-1304 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1405-1410 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1431-1436 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:262-268 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:81-88 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:197-202 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1738-1742 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1754-1758 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1847-1851 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1881-1885 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2002-2006 | Packages/OsaurusCore/Views/Settings/ServerView.swift:332-339 — before extracting anything, compare `Packages/OsaurusCore/Views/Common/SectionHeader.swift` and `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SectionHeader.swift:64` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5–8 lines × 14) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395-3399 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3446-3453 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3491-3496 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3537-3541 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3558-3562 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3571-3575 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3586-3590 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1651-1655 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1852-1858 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2076-2083 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2110-2114 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2627-2632 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3112-3116 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:101-105 — there are 14 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 14 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3395` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3118` calls `number` and `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3401` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 11) Packages/OsaurusCore/Views/Common/SectionHeader.swift:62— Packages/OsaurusCore/Views/Common/SectionHeader.swift:62-69 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:202-209 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:515-522 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1157-1164 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:202-209 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1403-1410 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1429-1436 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:195-202 | Packages/OsaurusCore/Views/Settings/ServerView.swift:256-263 | Packages/OsaurusCore/Views/Settings/ServerView.swift:330-337 | Packages/OsaurusCore/Views/Settings/StatusPanelView.swift:275-282 — before extracting anything, compare `Packages/OsaurusCore/Views/Common/SectionHeader.swift` and `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SectionHeader.swift:62` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Settings/ServerView.swift:264` calls `frame` and `Packages/OsaurusCore/Views/Common/SectionHeader.swift:70` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–8 lines × 8) Packages/OsaurusCore/Networking/HTTPHandler.swift:5106— Packages/OsaurusCore/Networking/HTTPHandler.swift:5106-5113 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5610-5616 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6360-6366 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6477-6483 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6843-6849 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6984-6990 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7111-7117 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7290-7296 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 7) Packages/OsaurusCore/Networking/HTTPHandler.swift:5572— Packages/OsaurusCore/Networking/HTTPHandler.swift:5572-5578 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6810-6817 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6947-6953 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7258-7264 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7451-7457 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7515-7521 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7718-7724 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Networking/HTTPHandler.swift:5572` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 4) Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1047— Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1047-1053 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1087-1094 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1156-1162 | Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1197-1203 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ChatEmptyState.swift:1047` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5–8 lines × 3) Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:496— Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:496-500 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:97-104 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:122-129 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentAbilitiesOverviewView.swift:496` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (2–8 lines × 3) Packages/OsaurusCore/AppleApps/Mail/MailService.swift:359— Packages/OsaurusCore/AppleApps/Mail/MailService.swift:359-366 | Packages/OsaurusCore/AppleApps/Music/MusicService.swift:76-77 | Packages/OsaurusCore/AppleApps/Notes/NotesService.swift:64-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/AppleApps/Mail/MailService.swift:359` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5–8 lines × 2) Packages/OsaurusCore/Views/Insights/InsightsView.swift:1028— Packages/OsaurusCore/Views/Insights/InsightsView.swift:1028-1032 | Packages/OsaurusCore/Views/Settings/Shared/SettingsKit.swift:454-461 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsView.swift:1028` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 15) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54-61 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2268-2274 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1824-1831 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1988-1995 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026-2033 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2624-2632 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:130-137 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2064-2073 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:338-345 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1827-1834 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1940-1947 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2052-2058 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2069-2075 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:54-61 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1842-1849 — there are 15 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 15 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 14) Packages/OsaurusCore/Networking/HTTPHandler.swift:5601— Packages/OsaurusCore/Networking/HTTPHandler.swift:5601-5607 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5700-5706 | Packages/OsaurusCore/Networking/HTTPHandler.swift:5794-5800 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6153-6159 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6240-6246 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6351-6357 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6468-6474 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6834-6840 | Packages/OsaurusCore/Networking/HTTPHandler.swift:6975-6981 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7102-7108 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7281-7287 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7743-7749 | Packages/OsaurusCore/Networking/HTTPHandler.swift:7855-7861 | Packages/OsaurusCore/Networking/HTTPHandler.swift:11546-11552 — all 14 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Networking/HTTPHandler.swift:6248` calls `split` and `Packages/OsaurusCore/Networking/HTTPHandler.swift:5708` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 13) Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3397— Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3397-3403 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3457-3466 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3493-3501 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3539-3545 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3560-3566 | Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3569-3575 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1648-1655 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1849-1858 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2060-2069 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2073-2082 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:2108-2114 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:3110-3116 | Packages/OsaurusCore/Tools/SandboxSecretTools.swift:103-109 — there are 13 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 13 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3397` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3567` calls `array` and `Packages/OsaurusCore/Services/Chat/SystemPromptComposer.swift:3404` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 11) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3189— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3189-3195 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3494-3500 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6961-6967 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6998-7004 | Packages/OsaurusCore/Views/Chat/SubagentFeedView.swift:207-213 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1385-1391 | Packages/OsaurusCore/Views/Settings/AgentChannelCustomConnectionSheet.swift:565-571 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1156-1162 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1191-1197 | Packages/OsaurusCore/Views/Skill/SkillsView.swift:724-730 | Packages/OsaurusCore/Views/Tool/ToolPermissionBanner.swift:75-81 — there are 11 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 11 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3186` calls `updateDefaultModel`, `showSaveIndicator` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6959` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 9) Packages/OsaurusCore/Models/Agent/Skill.swift:117— Packages/OsaurusCore/Models/Agent/Skill.swift:117-124 | Packages/OsaurusCore/Models/Agent/Skill.swift:161-168 | Packages/OsaurusCore/Models/Agent/Skill.swift:207-214 | Packages/OsaurusCore/Models/Agent/Skill.swift:245-252 | Packages/OsaurusCore/Models/Agent/Skill.swift:283-290 | Packages/OsaurusCore/Models/Agent/Skill.swift:327-334 | Packages/OsaurusCore/Models/Agent/Skill.swift:372-379 | Packages/OsaurusCore/Models/Agent/Skill.swift:416-423 | Packages/OsaurusCore/Models/Agent/Skill.swift:454-460 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Models/Agent/Skill.swift:117` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 7) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1612— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1612-1618 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1712-1718 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1735-1741 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1179-1185 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1223-1229 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1263-1269 | Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift:1307-1313 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1612` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (4–7 lines × 4) Packages/OsaurusCore/Services/Method/MethodSearchService.swift:265— Packages/OsaurusCore/Services/Method/MethodSearchService.swift:265-271 | Packages/OsaurusCore/Services/Skill/SkillSearchService.swift:361-367 | Packages/OsaurusCore/Services/Tool/ToolSearchService.swift:849-855 | Packages/OsaurusCore/Utils/TextSimilarity.swift:70-73 — before extracting anything, compare `Packages/OsaurusCore/Services/Method/MethodSearchService.swift` and `Packages/OsaurusCore/Services/Skill/SkillSearchService.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Method/MethodSearchService.swift:265` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (2–6 lines × 27) Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:123— Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:123-128 | Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:609-614 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:5681-5686 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6049-6054 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6661-6666 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7086-7091 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:7888-7893 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:141-146 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:159-164 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:762-767 | Packages/OsaurusCore/Views/Insights/InsightsDetailPane.swift:64-69 | Packages/OsaurusCore/Views/Insights/InsightsView.swift:506-511 | Packages/OsaurusCore/Views/Insights/InsightsView.swift:765-766 | Packages/OsaurusCore/Views/Plugin/ClaudeMarketplaceDetailView.swift:98-103 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:129-134 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1599-1604 | Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:274-279 | Packages/OsaurusCore/Views/Settings/MCPProviderDirectoryView.swift:337-342 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:1471-1476 | Packages/OsaurusCore/Views/Settings/ProvidersView.swift:2116-2121 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:437-442 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:678-683 | Packages/OsaurusCore/Views/Settings/SearchView.swift:978-983 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:93-98 | Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsActionBar.swift:118-123 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:873-878 | Packages/OsaurusCore/Views/Tool/ToolAdvancedDiagnosticsSection.swift:249-254 — there are 27 copies across 17 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 27 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Insights/InsightsView.swift:765` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `4` in one and `3` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/PrivacyFilter/Views/PrivacyPresetRulesSection.swift:130` calls `modifier`, `ChipChrome`, `contentShape` and `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:616` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 19) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54-59 | Packages/OsaurusCore/Views/Credits/CreditsRedeemCodeCard.swift:17-25 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2268-2273 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:239-245 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1824-1829 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1988-1993 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026-2031 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2623-2630 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:130-135 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2064-2072 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:150-155 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:105-110 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:338-343 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1827-1832 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1940-1945 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2052-2057 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2069-2074 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:54-59 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1842-1847 — there are 19 copies across 12 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 19 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1822` calls `VStack` and `Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:148` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 14) Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290— Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290-295 | Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:304-309 | Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:237-245 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:883-891 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:603-608 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:715-720 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:427-432 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1435-1443 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:317-324 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:70-78 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:554-562 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:358-363 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1648-1656 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1884-1889 — there are 14 copies across 11 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 14 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Chat/ComputerUseConfirmOverlay.swift:290` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Chat/ConfigApprovalModal.swift:312` calls `keyboardShortcut` and `Packages/OsaurusCore/Views/Common/SettingsEmptyState.swift:247` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 9) Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:194— Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:194-202 | Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift:103-108 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:198-203 | Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:105-110 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1109-1114 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1673-1678 | Packages/OsaurusCore/Views/Plugin/SandboxPluginEditorView.swift:653-658 | Packages/OsaurusCore/Views/Plugin/ToolSecretsSheet.swift:133-141 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:1114-1119 — before extracting anything, compare `Packages/OsaurusCore/Views/Plugin/ClaudePluginCard.swift` and `Packages/OsaurusCore/Views/Plugin/PluginsView.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 138 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:194` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Management/AcknowledgementsView.swift:204` calls `LazyVStack`, `ForEach`, `PackageRow` and `Packages/OsaurusCore/Views/Plugin/ClaudePluginUserConfigSheet.swift:111` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5–6 lines × 2) Packages/OsaurusCore/Folder/FolderContextService.swift:315— Packages/OsaurusCore/Folder/FolderContextService.swift:315-320 | Packages/OsaurusCore/Folder/FolderContextService.swift:357-361 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FolderContextService.swift:315` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–6 lines × 4) Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:71— Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:71-73 | Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:90-92 | Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:210-215 | Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:264-269 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:71` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:269` calls `prefix` and `Packages/OsaurusCore/Services/Search/NativeSearchBackends.swift:92` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (4–6 lines × 3) Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:173— Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:173-178 | Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:232-237 | Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:290-293 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:173` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:178` calls `createFile` and `Packages/OsaurusCore/Tools/Database/DatabaseExport.swift:293` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 53) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:831— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:831-835 | Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:841-845 | Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:53-57 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:4248-4255 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:85-92 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:59-63 | Packages/OsaurusCore/Views/Credits/CreditsRedeemCodeCard.swift:16-23 | Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:52-59 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:167-174 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:288-295 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:625-632 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:706-713 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:616-623 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:646-653 | Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:137-144 | Packages/OsaurusCore/Views/Insights/InsightsView.swift:1240-1244 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:418-425 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:541-545 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:643-647 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:752-756 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:186-193 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:227-234 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:443-450 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2267-2271 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:238-243 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:179-186 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:221-228 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1823-1827 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1987-1991 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2025-2029 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:189-196 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:129-133 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:366-373 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:114-121 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2063-2070 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:149-153 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:104-108 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:605-612 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:337-341 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1939-1943 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2051-2055 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2068-2072 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:53-57 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:222-227 | Packages/OsaurusCore/Views/Settings/SearchView.swift:532-539 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1841-1845 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:109-116 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:166-173 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:840-847 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:92-99 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:122-129 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:679-684 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1120-1125 — there are 53 copies across 35 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 53 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Credits/CreditsView.swift:297` calls `fixedSize` and `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:59` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 39) Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54— Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54-58 | Packages/OsaurusCore/Views/Credits/CreditsRedeemCodeCard.swift:17-24 | Packages/OsaurusCore/Views/Credits/CreditsTopUpSheet.swift:53-60 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:168-175 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:289-296 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:626-633 | Packages/OsaurusCore/Views/Credits/CreditsView.swift:707-714 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:617-624 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:647-654 | Packages/OsaurusCore/Views/Identity/OsaurusIDSection.swift:138-145 | Packages/OsaurusCore/Views/Insights/InsightsView.swift:1241-1245 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2268-2272 | Packages/OsaurusCore/Views/Plugin/GitHubImportSheet.swift:239-244 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1824-1828 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1988-1992 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2026-2030 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2623-2629 | Packages/OsaurusCore/Views/Sandbox/SandboxView.swift:190-197 | Packages/OsaurusCore/Views/Settings/AgentChannelAddChannelSheet.swift:130-134 | Packages/OsaurusCore/Views/Settings/AgentChannelConnectionCenterView.swift:367-374 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:115-122 | Packages/OsaurusCore/Views/Settings/AgentChannelDestinationViews.swift:2064-2071 | Packages/OsaurusCore/Views/Settings/AgentRuntimesView.swift:150-154 | Packages/OsaurusCore/Views/Settings/ClaudeCodeSetupStep.swift:105-109 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:338-342 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1827-1831 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:1940-1944 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2052-2056 | Packages/OsaurusCore/Views/Settings/RemoteProviderEditSheet.swift:2069-2073 | Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:54-58 | Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift:223-228 | Packages/OsaurusCore/Views/Settings/SearchView.swift:533-540 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1842-1846 | Packages/OsaurusCore/Views/Settings/ServerSettings/AuthenticationSection.swift:110-117 | Packages/OsaurusCore/Views/Settings/StorageSettingsView.swift:167-174 | Packages/OsaurusCore/Views/Theme/ImportThemeByIdSheet.swift:93-100 | Packages/OsaurusCore/Views/Theme/ShareThemeSheet.swift:123-130 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:680-685 | Packages/OsaurusCore/Views/Theme/ThemesView.swift:1121-1126 — there are 39 copies across 25 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 39 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Credits/CreditsView.swift:297` calls `fixedSize` and `Packages/OsaurusCore/Views/Agent/AgentReorderSheet.swift:59` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 22) Packages/OsaurusCore/Views/Common/SectionHeader.swift:64— Packages/OsaurusCore/Views/Common/SectionHeader.swift:64-71 | Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift:204-211 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:517-524 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:747-754 | Packages/OsaurusCore/Views/Identity/IdentityView.swift:1159-1166 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:307-314 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:80-87 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:204-209 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1297-1304 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1405-1410 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:1431-1436 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:2371-2378 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:262-268 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:81-88 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:197-202 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1738-1742 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1754-1758 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1847-1851 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:1881-1885 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2002-2006 | Packages/OsaurusCore/Views/Settings/AccessKeyGeneratorSheet.swift:164-171 | Packages/OsaurusCore/Views/Settings/ServerView.swift:332-339 — before extracting anything, compare `Packages/OsaurusCore/Views/Common/SectionHeader.swift` and `Packages/OsaurusCore/Views/Identity/AgentKeyManagement.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Common/SectionHeader.swift:64` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 18) Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:822— Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:822-826 | Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:832-836 | Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:842-846 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:4249-4256 | Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:86-93 | Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:60-64 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:419-426 | Packages/OsaurusCore/Views/Knowledge/KnowledgeView.swift:1567-1574 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:542-546 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:644-648 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:753-757 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:187-194 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:228-235 | Packages/OsaurusCore/Views/Model/ModelDownloadView.swift:444-451 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:180-187 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:222-229 | Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:606-613 | Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift:841-848 — there are 18 copies across 11 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 18 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentCapabilityManagerView.swift:822` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Views/Agent/Templates/AgentTemplateSheets.swift:94` calls `fixedSize` and `Packages/OsaurusCore/Views/Chat/CompactionDialogView.swift:65` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (2–5 lines × 40) Packages/OsaurusCore/Folder/FileCopyTool.swift:85— Packages/OsaurusCore/Folder/FileCopyTool.swift:85-98 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:458-462 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:512-516 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:567-571 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:631-635 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:687-688 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:690-694 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:745-746 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:748-752 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:809-810 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:812-816 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:857-858 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:859-860 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:862-866 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:905-906 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:908-912 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:959-960 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:961-962 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:964-968 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1030-1034 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1097-1098 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1100-1104 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1172-1173 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1174-1175 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1242-1243 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1244-1245 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1247-1251 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1312-1313 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1314-1315 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1551-1552 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:328-334 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:541-542 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:544-547 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1246-1252 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1439-1445 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1579-1580 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1645-1648 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1741-1744 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:327-328 | Packages/OsaurusCore/Tools/VideoTool.swift:92-99 — there are 40 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 40 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Folder/FileCopyTool.swift:85` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Tools/AgentChannelTools.swift:458` calls `requireString` and `Packages/OsaurusCore/Tools/AgentChannelTools.swift:687` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 13) Packages/OsaurusCore/Views/Identity/IdentityView.swift:882— Packages/OsaurusCore/Views/Identity/IdentityView.swift:882-888 | Packages/OsaurusCore/Views/Identity/RecoverFromMnemonicSheet.swift:264-270 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:602-606 | Packages/OsaurusCore/Views/Memory/MemoryComponents.swift:714-718 | Packages/OsaurusCore/Views/Memory/MemoryView.swift:426-430 | Packages/OsaurusCore/Views/Model/HuggingFaceTokenViews.swift:280-286 | Packages/OsaurusCore/Views/Model/ModelDetailView.swift:1434-1440 | Packages/OsaurusCore/Views/Plugin/ClaudePluginDetailView.swift:316-321 | Packages/OsaurusCore/Views/Plugin/GitHubTokenViews.swift:275-281 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:69-75 | Packages/OsaurusCore/Views/Plugin/PluginConfigView.swift:553-559 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1647-1653 | Packages/OsaurusCore/Views/Settings/SearchView.swift:1883-1887 — there are 13 copies across 10 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 13 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Identity/IdentityView.swift:882` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 7) Packages/OsaurusCore/Views/Agent/AgentsView.swift:3188— Packages/OsaurusCore/Views/Agent/AgentsView.swift:3188-3194 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:3493-3499 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6960-6966 | Packages/OsaurusCore/Views/Agent/AgentsView.swift:6997-7003 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:2062-2066 | Packages/OsaurusCore/Views/Settings/BrowserSettingsView.swift:281-287 | Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift:1155-1161 — there are 7 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `8` in one and `12` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Views/Agent/AgentsView.swift:3186` calls `updateDefaultModel`, `showSaveIndicator` and `Packages/OsaurusCore/Views/Agent/AgentsView.swift:6959` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (2–5 lines × 20) Packages/OsaurusCore/Tools/AgentChannelTools.swift:375— Packages/OsaurusCore/Tools/AgentChannelTools.swift:375-376 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:410-414 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:455-456 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:509-510 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:564-565 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:628-629 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:685-686 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:743-744 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:807-808 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:855-856 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:903-904 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:957-958 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1027-1028 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1095-1096 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1170-1171 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1177-1181 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1240-1241 | Packages/OsaurusCore/Tools/AgentChannelTools.swift:1310-1311 | Packages/OsaurusCore/Tools/CalculatorTool.swift:63-65 | Packages/OsaurusCore/Tools/CurrentTimeTool.swift:51-58 — there are 20 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 20 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/AgentChannelTools.swift:410` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Tools/AgentChannelTools.swift:410` calls `optionalString` and `Packages/OsaurusCore/Tools/AgentChannelTools.swift:375` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (4–5 lines × 3) Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:132— Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:132-135 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:47-51 | Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReport.swift:741-745 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ComputerUseScorecard.swift:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `cases` to `[AgentLoopRegressionCaseSnapshot]` in one and `[EvalCaseReport]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10 lines × 8) Packages/OsaurusCore/Views/Agent/AgentsView.swift:658— Packages/OsaurusCore/Views/Agent/AgentsView.swift:658-667 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:858-867 | Packages/OsaurusCore/Views/Plugin/PluginsView.swift:3177-3186 | Packages/OsaurusCore/Views/Schedule/SchedulesView.swift:237-246 | Packages/OsaurusCore/Views/Settings/OrchestratorSettingsView.swift:331-340 | Packages/OsaurusCore/Views/Settings/ServerSettingsTabContent.swift:553-562 | Packages/OsaurusCore/Views/Watcher/WatchersView.swift:171-180 | Packages/OsaurusCore/Views/Workspaces/WorkspacesView.swift:222-231 — there are 8 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 17) Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321— Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321-325 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:445-449 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:534-538 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:606-610 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:699-703 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:795-799 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:861-865 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:915-919 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:987-991 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1079-1083 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1239-1243 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1432-1436 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1572-1576 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1639-1643 | Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:1735-1739 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:131-135 | Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:320-324 — there are 17 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 17 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:321` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Packages/OsaurusCore/Tools/Database/DatabaseTools.swift:327` calls `requireString`, `value` and `Packages/OsaurusCore/Tools/Database/SchedulerTools.swift:137` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19–29 lines × 2) scripts/live-proof/run-local-family-chat-tool-proof.py:131— scripts/live-proof/run-local-family-chat-tool-proof.py:131-149 | scripts/live-proof/run-local-family-chat-tool-proof.py:178-206 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/live-proof/run-local-family-chat-tool-proof.py:178` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–15 lines × 3) scripts/live-proof/run-post1266-family-cache-tool-matrix.py:292— scripts/live-proof/run-post1266-family-cache-tool-matrix.py:292-306 | scripts/live-proof/run-post1266-family-cache-tool-matrix.py:326-338 | scripts/live-proof/run-post1266-family-cache-tool-matrix.py:358-370 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (23–27 lines × 2) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1034— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1034-1060 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1092-1114 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1034` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1091` calls `resetStepStatus` and `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1030` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17–24 lines × 3) Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1044— Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1044-1060 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1098-1114 | Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1121-1144 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Sandbox/SandboxManager.swift:1044` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5–7 lines × 2) Packages/OsaurusCore/Services/Sandbox/SandboxEgressPolicy.swift:113— Packages/OsaurusCore/Services/Sandbox/SandboxEgressPolicy.swift:113-117 | Packages/OsaurusCore/Services/Sandbox/SandboxEgressPolicy.swift:130-136 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Packages/OsaurusCore/Services/Sandbox/SandboxEgressPolicy.swift:130` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Off the main sequence: OsaurusNetworking — OsaurusNetworking: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
X2 · Cancellation propagation· Async function without AbortSignal · ×1
Async function without AbortSignal: configureIsolatedLocalProvider scripts/evals/pi-harness-runner.mjs:32— `configureIsolatedLocalProvider` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
Silent fallback default in catch Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Import/ImportCommand.swift:690— `renderJSON` turns every thrown error into `"{}"` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerSubagent.swift:502— `crashReportSnapshot` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusRepository/ImportQueue.swift:313— `pending` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusRepository/InstalledPluginsStore.swift:87— `installedVersions` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusRepository/InstalledPluginsStore.swift:132— `allInstalledPluginIds` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Networking/HTTPHandler.swift:9095— `redactedPairInviteRequestBody` turns every thrown error into `"<redacted>"` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Networking/HTTPHandler.swift:15563— `ollamaGenerateJSON` turns every thrown error into `#"{"done":true}"#` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Networking/HTTPHandler.swift:15604— `ollamaChatJSON` turns every thrown error into `#"{"message":{"role":"assistant","content":""},"done":true}"#` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Networking/HTTPHandler.swift:15625— `ollamaGenerateErrorJSON` turns every thrown error into `#"{"error":{"message":"internal error","type":"internal_error"},"done":true}"#` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Services/FavoriteModelsStore.swift:155— `load` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Services/ModelSSDResidency.swift:33— `localNGramBytes` turns every thrown error into `0` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Configuration/Declarative/OsaurusConfigTool.swift:939— `list` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Managers/Model/ModelManager.swift:1682— `requestHFModels` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Managers/Plugin/PluginManager.swift:1646— `quarantineEntries` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Managers/Plugin/SandboxPluginLibrary.swift:92— `availableVersions` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Managers/Plugin/SandboxPluginLibrary.swift:220— `highestVersion` turns every thrown error into `0` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Agent/AgentStore.swift:165— `recoverableBackups` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Agent/RemoteAgentStore.swift:18— `loadAll` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Agent/SkillStore.swift:366— `loadFiles` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Chat/AgentTodo.swift:75— `parseItems` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Configuration/ModelFormatDetection.swift:113— `safetensorsFormatTags` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Configuration/SearchProviderConfiguration.swift:494— `loadCustom` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Knowledge/KnowledgeCollectionStore.swift:35— `loadAll` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Plugin/SandboxPlugin.swift:245— `contentHash` turns every thrown error into `""` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Packages/OsaurusCore/Models/Project/ProjectStore.swift:17— `loadAll` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Orphaned file Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file scripts/live-proof/classify-runtime-proof-summary.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Coord/CoordCommand.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/ScreenshotCaptureService.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Models/Documents/DocumentAnchor.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Plugin/SQLiteReadOnlyRecordStreamer.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/PairingPromptService.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Documents/DocumentFileInspector.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Models/Channels/ChannelSecurityPolicy.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Models/Documents/DocumentStructure.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/AgentChannel/AgentChannelTransportHealth.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/EvalScoreboardCLI.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file scripts/live-proof/test-classify-runtime-proof-summary.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Plugin/FormatAdapterRegistry.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Doctor.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Channels/ChannelCredentialVault.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bundle/MCPBundleManager.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/MCP/MCPCaptureCapabilityPolicy.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Models/Documents/Workbook.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusEvals/Sources/OsaurusEvalsCLI/ComputerUseScorecardCLI.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Documents/CSVRowParser.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusPlugins/StatsPack/Sources/OsaurusStatsPack/JSONLAdapter.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file Packages/OsaurusCore/Services/Plugin/FormatAdapter.swift:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Duplicated predicate scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py:220— `isinstance(left.get(key, 0), int) and isinstance(right.get(key, 0), int)` appears character-identically in 2 files — scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py, scripts/live-proof/run-local-vl-media-cache-proof.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate scripts/i18n/apply-ko.py:54— `unit and isinstance(unit.get("value"), str) and unit["value"].strip()` appears character-identically in 2 files — scripts/i18n/apply-ko.py, scripts/i18n/export-untranslated.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Agent/AgentsView.swift:7936— `!current.isEmpty && !builtIn.contains(current)` appears character-identically in 2 files — Packages/OsaurusCore/Views/Agent/AgentsView.swift, Packages/OsaurusCore/Views/Voice/TTSModeSettingsTab.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:1371— `!diagnostics.failures.isEmpty || presentation.tone == .error` appears character-identically in 3 files — Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift, Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift, Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:318— `!helperVerified && helperDownloadAvailable` appears character-identically in 2 files — Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift, Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:210— `!parseIds(readableChannelIdsText).isEmpty && !parseIds(senderAllowlistText).isEmpty` appears character-identically in 2 files — Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift, Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift:231— `!parseIds(readableChatIdsText).isEmpty && !parseIds(senderAllowlistText).isEmpty` appears character-identically in 3 files — Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift, Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift, Packages/OsaurusCore/Views/Settings/WhatsAppSettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:244— `!regressions.isEmpty || !newFailures.isEmpty` appears character-identically in 2 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift:1947— `!rubric.isEmpty && verdicts.count != rubric.count` appears character-identically in 2 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunner.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalRunnerAgentLoop.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Services/Context/CapabilitySearchHealth.swift:194— `$0.enabled && !excluded.contains($0.name)` appears character-identically in 2 files — Packages/OsaurusCore/Services/Context/CapabilitySearchHealth.swift, Packages/OsaurusCore/Services/Tool/ToolSearchService.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift:510— `$0.outcome == .passed || $0.outcome == .failed` appears character-identically in 3 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/ContextOptimizer.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalMatrix.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift:141— `$0.providerType != .osaurusRouter && manager.exposesModelsForInference($0)` appears character-identically in 2 files — Packages/OsaurusCore/Views/Settings/RemoteProviderReorderSheet.swift, Packages/OsaurusCore/Views/Settings/RemoteProvidersView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift:835— `$0.role == .assistant && !$0.contentIsBlank` appears character-identically in 2 files — Packages/OsaurusCore/Services/AgentChannel/AgentChannelInboundRelay.swift, Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:572— `(baseline == .failed || baseline == .errored) && current == .passed` appears character-identically in 2 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift:212— `(inboundDispatchEnabled && (inboundTarget != nil || !inboundRoutes.isEmpty)) || writeEnabled` appears character-identically in 5 files — Packages/OsaurusCore/Views/Settings/DiscordSettingsView.swift, Packages/OsaurusCore/Views/Settings/IMessageSettingsView.swift, Packages/OsaurusCore/Views/Settings/SlackSettingsView.swift, Packages/OsaurusCore/Views/Settings/TelegramSettingsView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Services/MCP/MCPElicitationPromptService.swift:76— `RuntimeEnvironment.isUnderTests && presentationOverrideForTests == nil` appears character-identically in 2 files — Packages/OsaurusCore/Services/MCP/MCPElicitationPromptService.swift, Packages/OsaurusCore/Services/ToolPermissionPromptService.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Services/FeatureTelemetry.swift:798— `Thread.isMainThread && !RuntimeEnvironment.isUnderTests` appears character-identically in 3 files — Packages/OsaurusCore/Services/FeatureTelemetry.swift, Packages/OsaurusCore/Services/LocalGenerationDefaults.swift, Packages/OsaurusCore/Services/LocalReasoningCapability.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Managers/AgentManager.swift:877— `agent.agentAddress != nil || agent.agentIndex != nil` appears character-identically in 2 files — Packages/OsaurusCore/Managers/AgentManager.swift, Packages/OsaurusCore/Services/AgentBridge/AgentBundleService.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Networking/RelayTunnelManager.swift:1194— `agent.agentAddress == nil || agent.agentIndex == nil` appears character-identically in 2 files — Packages/OsaurusCore/Networking/RelayTunnelManager.swift, Packages/OsaurusCore/Views/Workspaces/WorkspaceSheets.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Folder/FolderTools.swift:3650— `args["old_string"] != nil || args["edits"] != nil` appears character-identically in 2 files — Packages/OsaurusCore/Folder/FolderTools.swift, Packages/OsaurusCore/Tools/BuiltinSandboxTools.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift:181— `artifact.isImage || artifact.isPDF || artifact.isVideo` appears character-identically in 2 files — Packages/OsaurusCore/Views/Chat/NativeArtifactCardView.swift, Packages/OsaurusCore/Views/Chat/NativeMessageCellView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:562— `baseline == .failed && current == .errored` appears character-identically in 3 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:561— `baseline == .passed && current != .passed` appears character-identically in 3 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalReviewReport.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift:563— `baseline == .skipped && current == .errored` appears character-identically in 2 files — Packages/OsaurusEvals/Sources/OsaurusEvalsKit/AgentLoopRegressionLab.swift, Packages/OsaurusEvals/Sources/OsaurusEvalsKit/EvalDiff.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Packages/OsaurusCore/Subagent/OwnedSubagentOperation.swift:52— `cancellationRequested() || Task.isCancelled` appears character-identically in 2 files — Packages/OsaurusCore/Subagent/OwnedSubagentOperation.swift, Packages/OsaurusCore/Subagent/SpawnPermissionGate.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 117 significant file(s) lose their only recent owner: Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsCreate.swift, Packages/OsaurusCore/Views/Settings/N8nSettingsView.swift, Packages/OsaurusCore/Tools/Database/DatabaseTools.swift, REDACTED, Packages/OsaurusCore/Services/AgentChannel/AgentChannelPublishService.swift, Packages/OsaurusCore/Services/Router/OsaurusRouterTypes.swift, Packages/OsaurusCore/Services/Router/OsaurusRouterWorkspaceTypes.swift, Packages/OsaurusCore/Services/AgentChannel/AgentChannelWebhookIngress.swift (+109 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 33 significant file(s) lose their only recent owner: Packages/OsaurusCore/Views/Chat/ChatHistoryPane.swift, Packages/OsaurusCore/Views/Chat/NativeFileDiffView.swift, Packages/OsaurusCore/Managers/Chat/ChatSessionImporter.swift, Packages/OsaurusCore/Views/Chat/NativeActivityGroupView.swift, Packages/OsaurusCore/Services/MobileConnect/MobilePairingService.swift, Packages/OsaurusCore/Services/Knowledge/KnowledgeIndexService.swift, Packages/OsaurusCore/PrivacyFilter/Core/CodeBlockMasker.swift, Packages/OsaurusCore/Views/Settings/OsaurusConnectView.swift (+25 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 29 significant file(s) lose their only recent owner: Packages/OsaurusCore/AppleScript/Tool/AppleScriptToolDispatch.swift, Packages/OsaurusCore/Services/ChunkedFileDownloader.swift, Packages/OsaurusCore/Views/Settings/ServerSettings/CacheSection.swift, Packages/OsaurusCore/Services/ModelRuntime/BatchDiagnosticsSnapshot.swift, Packages/OsaurusCore/Services/ModelRuntime/ImageGenerationTypes.swift, scripts/live-proof/run-local-family-multiturn-tool-cache-proof.py, Packages/OsaurusCore/Views/Settings/ServerSettings/MTPSection.swift, Packages/OsaurusCore/Views/Settings/ServerSettings/ServerSettingsHelpers.swift (+21 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 24 significant file(s) lose their only recent owner: Packages/OsaurusCore/Services/Documents/PPTXAdapter.swift, Packages/OsaurusRepository/BoundedArchiveExtractor.swift, Packages/OsaurusCore/Managers/SkillImportPolicy.swift, Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift, Packages/OsaurusCore/Utils/StorageLocationStandards.swift, Packages/OsaurusCore/Services/SupportDiagnosticsBundle.swift, Packages/OsaurusCore/Services/Documents/ExternalOfficeRuntimeDetector.swift, Packages/OsaurusCore/Services/ModelRuntime/RuntimeProofValidation.swift (+16 more). Pair on, review, or document these before any departure.
Hand-rolled JSON/XML parsing via regex Packages/OsaurusCore/Services/Search/SearchHTMLHelpers.swift:429— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Swift code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex Packages/OsaurusCore/Services/Provider/RemoteToolDetection.swift:48— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Swift code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex Packages/OsaurusCore/Services/Provider/RemoteToolDetection.swift:49— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Swift code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex Packages/OsaurusCore/Services/Provider/RemoteToolDetection.swift:50— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Swift code already uses a real parser in the same package; use it here too.
README/code drift README.md:356— README.md links to `CONTRIBUTING.md`, but `CONTRIBUTING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift Packages/OsaurusEvals/Suites/ComputerUse/README.md:45— Packages/OsaurusEvals/Suites/ComputerUse/README.md links to `../../../docs/COMPUTER_USE_EVIDENCE.md`, but `Packages/docs/COMPUTER_USE_EVIDENCE.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 3 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (207 single-owned of 1406 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 1406 of the 1587 production source files in this repository met that bar). They are anonymized user #5 (1 file(s)), anonymized user #6 (1 file(s)), anonymized user #7 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: scripts/i18n/lint-zh-style.py, Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bundle/MCPBundleManager.swift, Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/ServerSupervisor.swift.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 2 of 9 project(s) overshoot their size bounds, lowering Project Cohesion to 5.6/10. The most over is `Packages/OsaurusCore` (639107 LoC, 5339 module-visible types across 172 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
REDACTED
D34 · Knowledge Freshness· Further orphaned files (smaller) · ×1
Further orphaned files (smaller) — 35 smaller file(s) also have no living knowledge — folded into the freshness score and metrics rather than raised one row each — most significant first: Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift, scripts/live-proof/classify-runtime-proof-summary.py, Packages/OsaurusCore/Views/Pairing/PairingApprovalView.swift, Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Coord/CoordCommand.swift, Packages/OsaurusCore/Services/ScreenshotCaptureService.swift, Packages/OsaurusCore/Models/Documents/BusinessDocumentSummary.swift, Packages/OsaurusCore/Models/Documents/DocumentAnchor.swift, Packages/OsaurusCore/Services/Plugin/SQLiteReadOnlyRecordStreamer.swift (and 27 more) (39 orphaned of 1406 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 1406 of the 1587 production source files in this repository met that bar). Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
M2 · Architecture documentation· ADRs not easily discoverable · ×1
ADRs not easily discoverable — 1 ADR-shaped document(s) detected by content — `Packages/OsaurusEvals/Config/capability-search-sweep.md`. They are not under a conventional ADR folder (docs/adr/) and are not named NNNN-title.md, and this check found them by their decision signature rather than by where they live — so a reader who does not already know these paths has no route to them. Detected by content signature only: records kept outside the repository, or written without a Status/Decision/Consequences shape, are not visible to this check and are not counted here.
Logging is not universal — Only 3/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `App`, `Packages/OsaurusCLI`, `helpers/osaurus-wa`.
No SAST — No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 59583 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
X2 · Cancellation propagation· Not all async functions that make a request accept an AbortSignal · ×1
Not all async functions that make a request accept an AbortSignal — Only 0/1 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
Silent fallback default on parse failure scripts/evals/plan-installed-vision.py:19— `object_at` returns `{}` when `(OSError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Skipped (documented): everyMascotRenders Packages/OsaurusCore/Tests/Agent/AvatarBitmapRendererTests.swift:120— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): repeatedMascotRequestsHitTheCache Packages/OsaurusCore/Tests/Agent/AvatarBitmapRendererTests.swift:130— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): disabledKeychainFailsLoudly Packages/OsaurusCore/Tests/Identity/IdentityRestoreTests.swift:65— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): inspectInstalledBundles Packages/OsaurusCore/Tests/Model/InstalledVisionEvidenceProbeTests.swift:7— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): mapping_prefersFreshPreencodedLiveAudio Packages/OsaurusCore/Tests/Model/MultimodalContentPartTests.swift:258— Skipped with a documented reason — a deferral, not lazy debt: Requires an MLXArray fixture; local SwiftPM tests cannot load default.metallib.
Skipped (documented): mapping_ignoresStalePreencodedLiveAudio Packages/OsaurusCore/Tests/Model/MultimodalContentPartTests.swift:302— Skipped with a documented reason — a deferral, not lazy debt: Requires an MLXArray fixture; local SwiftPM tests cannot load default.metallib.
Skipped (documented): temporalSlotsAreFilled Packages/OsaurusCore/Tests/Model/MuseGlimmerImageGeometryTests.swift:40— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): geometryIsConsistent Packages/OsaurusCore/Tests/Model/MuseGlimmerImageGeometryTests.swift:72— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): specialsAreAtomic Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:29— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): templateRendersStrength Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:45— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): roundTrip Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:67— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): allFourStrengthsRenderDistinctPrefixes Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:77— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): strengthLineIsInThePrefix Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:116— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): imagePartRendersPatch Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:139— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): mediaPlaceholdersAtomic Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:157— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): imagePartRendersPatchWithNilContext Packages/OsaurusCore/Tests/Model/MuseGlimmerTokenizerProbeTests.swift:170— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): modelSeesTheBands Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:43— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): forcedChoiceHue Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:101— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): solidColourFields Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:167— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): realPhotographs Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:223— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): verticalPosition Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:275— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): perceptionDump Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:348— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): shapeBattery Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:381— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): shapeDiscrimination Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionLiveTests.swift:445— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): visionWeightsAreLoaded Packages/OsaurusCore/Tests/Model/MuseGlimmerVisionWeightLoadTests.swift:34— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Outdated: aptabase-swift — `aptabase-swift` is resolved at 0.3.11, but 0.4.0 is the newest release tagged on https://github.com/aptabase/aptabase-swift.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update aptabase-swift` reaches this one with no change to Package.swift.
Outdated: async-http-client — `async-http-client` is resolved at 1.33.1, but 1.36.2 is the newest release tagged on https://github.com/swift-server/async-http-client.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update async-http-client` reaches this one with no change to Package.swift.
Outdated: containerization — `containerization` is resolved at 0.41.0, but 0.53.0 is the newest release tagged on https://github.com/apple/containerization.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update containerization` reaches this one with no change to Package.swift.
Outdated: eventsource — `eventsource` is resolved at 1.4.1, but 1.5.1 is the newest release tagged on https://github.com/mattt/eventsource.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update eventsource` reaches this one with no change to Package.swift.
Outdated: fluidaudio — `fluidaudio` is resolved at 0.14.1, but 0.17.7 is the newest release tagged on https://github.com/FluidInference/FluidAudio.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update fluidaudio` reaches this one with no change to Package.swift.
Outdated: grpc-swift-2 — `grpc-swift-2` is resolved at 2.4.0, but 2.4.4 is the newest release tagged on https://github.com/grpc/grpc-swift-2.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update grpc-swift-2` reaches this one with no change to Package.swift.
Outdated: grpc-swift-nio-transport — `grpc-swift-nio-transport` is resolved at 2.9.2, but 2.11.0 is the newest release tagged on https://github.com/grpc/grpc-swift-nio-transport.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update grpc-swift-nio-transport` reaches this one with no change to Package.swift.
Outdated: grpc-swift-protobuf — `grpc-swift-protobuf` is resolved at 2.3.0, but 2.5.0 is the newest release tagged on https://github.com/grpc/grpc-swift-protobuf.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update grpc-swift-protobuf` reaches this one with no change to Package.swift.
Outdated: ikigajson — `ikigajson` is resolved at 2.5.0, but 2.5.4 is the newest release tagged on https://github.com/orlandos-nl/IkigaJSON within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update ikigajson` reaches this one with no change to Package.swift.
Outdated: ikigajson — `ikigajson` is resolved at 2.4.3, but 2.5.4 is the newest release tagged on https://github.com/orlandos-nl/IkigaJSON within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update ikigajson` reaches this one with no change to Package.swift.
Outdated: sentry-cocoa — `sentry-cocoa` is resolved at 9.15.0, but 9.31.0 is the newest release tagged on https://github.com/getsentry/sentry-cocoa.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update sentry-cocoa` reaches this one with no change to Package.swift.
Outdated: sparkle — `sparkle` is resolved at 2.9.1, but 2.10.1 is the newest release tagged on https://github.com/sparkle-project/Sparkle within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update sparkle` reaches this one with no change to Package.swift.
Outdated: sparkle — `sparkle` is resolved at 2.9.2, but 2.10.1 is the newest release tagged on https://github.com/sparkle-project/Sparkle within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update sparkle` reaches this one with no change to Package.swift.
Outdated: swift-argument-parser — `swift-argument-parser` is resolved at 1.7.1, but 1.8.2 is the newest release tagged on https://github.com/apple/swift-argument-parser.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-argument-parser` reaches this one with no change to Package.swift.
Outdated: swift-asn1 — `swift-asn1` is resolved at 1.7.0, but 1.7.3 is the newest release tagged on https://github.com/apple/swift-asn1.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-asn1` reaches this one with no change to Package.swift.
Outdated: swift-async-algorithms — `swift-async-algorithms` is resolved at 1.1.4, but 1.1.7 is the newest release tagged on https://github.com/apple/swift-async-algorithms.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-async-algorithms` reaches this one with no change to Package.swift.
Outdated: swift-atomics — `swift-atomics` is resolved at 1.3.0, but 1.3.1 is the newest release tagged on https://github.com/apple/swift-atomics.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-atomics` reaches this one with no change to Package.swift.
Outdated: swift-certificates — `swift-certificates` is resolved at 1.19.0, but 1.21.0 is the newest release tagged on https://github.com/apple/swift-certificates.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-certificates` reaches this one with no change to Package.swift.
Outdated: swift-collections — `swift-collections` is resolved at 1.5.1, but 1.7.4 is the newest release tagged on https://github.com/apple/swift-collections.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-collections` reaches this one with no change to Package.swift.
Outdated: swift-configuration — `swift-configuration` is resolved at 1.2.0, but 1.3.0 is the newest release tagged on https://github.com/apple/swift-configuration.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-configuration` reaches this one with no change to Package.swift.
Outdated: swift-distributed-tracing — `swift-distributed-tracing` is resolved at 1.4.1, but 1.7.2 is the newest release tagged on https://github.com/apple/swift-distributed-tracing.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-distributed-tracing` reaches this one with no change to Package.swift.
Outdated: swift-http-types — `swift-http-types` is resolved at 1.6.0, but 1.8.0 is the newest release tagged on https://github.com/apple/swift-http-types.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-http-types` reaches this one with no change to Package.swift.
Outdated: swift-log — `swift-log` is resolved at 1.12.0, but 1.16.2 is the newest release tagged on https://github.com/apple/swift-log.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-log` reaches this one with no change to Package.swift.
Outdated: swift-nio — `swift-nio` is resolved at 2.99.0, but 2.104.0 is the newest release tagged on https://github.com/apple/swift-nio.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-nio` reaches this one with no change to Package.swift.
Outdated: swift-nio-extras — `swift-nio-extras` is resolved at 1.34.0, but 1.35.1 is the newest release tagged on https://github.com/apple/swift-nio-extras.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-nio-extras` reaches this one with no change to Package.swift.
+ 7 more in this group — see findings.md.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 235 file(s) — `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Bench.swift`, `Packages/OsaurusCLI/Sources/OsaurusCLICore/Commands/Tools/ToolsDev.swift`, `Packages/OsaurusCLI/Sources/OsaurusCLICore/Services/InstallationDiagnostics.swift`, `Packages/OsaurusCore/AppDelegate.swift`, `Packages/OsaurusCore/AppleApps/Calendar/CalendarService.swift`, … (+230 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a17804-a4ee-7518-b45a-6e98b9db87ca · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 59 · Warnings: 5029 · Recommendations: 122 · Info: 66 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 26-10-2026 @ 11:42 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.