uttrflow / uttrflow/uttrflow-swift
YAML, TOML and one-line SQL, HTML or Python are classified as text rather than code
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`CodeShapes.matches` (`Sources/UttrflowClipboard/CodeShapes.swift:10-15`) needs a shebang, an import header, a known shell command, or two signals from its list. Several common kinds of code give only one signal, or none.
## Measured (headless, `ClipKindDetector.kind(of:)`)
| Clip | Kind |
|---|---|
| `select * from orders` | text (`query` is one signal; `CodeLanguage` would call it SQL) |
| `print('hello')` | text (only `invocation`) |
| `
| `from django.db import models` | text (`importHeader` allows one word after the keyword) |
| a 5-line YAML file (`name:`, `version:`, a `dependencies:` list) | text |
| a Compose-style YAML block with nested keys and a quoted port list | text |
| a 3-line TOML table (`[server]`, `host = …`, `port = 8080`) | text |
| `[1, 2, 3]` | text |
| `{"name": "Ada", "age": 36}` | code (correct) |
In a labelled set of 131 invented clips, 34 came out differently from their label. Some of those are text by design (bare domains, `ftp://`, `mailto:`, Windows and repository-relative paths, and digests masked as secrets). The colour, path, brace and command-word cases are filed separately. Code classified as text is the largest group left.
## Why it matters
Configuration files and one-line queries are among the most-copied code. They miss the Code tab, the monospaced face, the language chip and Format, which exist for exactly these.
## Acceptance criteria
- A block of two or more `key: value` lines with at least one indented or `- ` list line is code, and so is a TOML `[table]` header followed by `key = value` lines. Prose with a colon on each line must stay text: an email header block, or "Name: … / Date: …" must not match.
- A one-line SQL statement with a verb and a `from` or `into` clause is code. So is a single HTML element with a closing tag. So is `from x.y import z`.
- Each row above gets a test in `Tests/UttrflowClipboardTests/ClipKindDetectorTests.swift`, each prose near-miss gets one in `prose`, and `ClipKindOracleTests` / `ClipClassifyScalingTests` still pass.
- `CodeLanguage.detect` names YAML and TOML only if a language case is added for them. That is optional here.
Contributor guide
Research direction
Start with CodeShapes.matches in Sources/UttrflowClipboard/CodeShapes.swift and the measured behavior through ClipKindDetector.kind(of:). Add the listed YAML, TOML, SQL, HTML, Python, and prose near-miss cases to Tests/UttrflowClipboardTests/ClipKindDetectorTests.swift. Run those tests along with ClipKindOracleTests and ClipClassifyScalingTests; done means the accepted snippets classify as code while the prose and existing text cases remain text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- desktop, testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100