Merge spike/editor-presentation: editor substrate verdict (ADR-0010)
Three throwaway editor spikes (CodeEdit fork / TextKit2 / SwiftUI blocks) plus the pinned corpus and ADR-0010 recording the TextKit2 mode-B verdict. Spike code is historical reference — the real editor (#19) builds fresh from the ADR. [Generated by AI] # Conflicts: # AGENTS.md # docs/devlog/INDEX.md
No files matched your search
@@ -177,6 +177,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
|
||||
<!-- write-log: window-start -->
|
||||
| Date | Log |
|
||||
|------|-----|
|
||||
| 2026-10-01 | [20261001-issue55-verdict-substrate-adr-0010_log.md](docs/devlog/20261001-issue55-verdict-substrate-adr-0010_log.md) |
|
||||
| 2026-09-25 | [20260925-issue50-profile-backup-s2-6_log.md](docs/devlog/20260925-issue50-profile-backup-s2-6_log.md) |
|
||||
| 2026-09-16 | [20260916-issue14-acp-bridge-s2-2_log.md](docs/devlog/20260916-issue14-acp-bridge-s2-2_log.md) |
|
||||
| 2026-09-05 | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](docs/devlog/20260905-issue48-provisioning-failure-alert-retry-ux_log.md) |
|
||||
|
||||
@@ -10,7 +10,7 @@ Owned by the root AGENTS.md contract.
|
||||
|
||||
## Local Contracts
|
||||
|
||||
- ADRs live in `docs/adr/`, sequentially numbered `NNNNN-slug.md` (currently `0001`–`0009`: stack, license, forge/CI, content layout, learnings home, fix-card transport, state ownership, tools host, sandbox posture).
|
||||
- ADRs live in `docs/adr/`, sequentially numbered `NNNNN-slug.md` (currently `0001`–`0010`: stack, license, forge/CI, content layout, learnings home, fix-card transport, state ownership, tools host, sandbox posture, prose editor substrate).
|
||||
- ADR format follows the domain-modeling skill's `ADR-FORMAT.md`: short title + 1–3 sentences; optional Considered Options / Consequences only when they earn their place.
|
||||
- `docs/agents/` holds the engineering-skills config (issue tracker, triage labels, domain-docs consumer rules) written by `setup-matt-pocock-skills` — edit directly, no child doc needed.
|
||||
- `docs/sample-pass.md` is the worked sample Pass demonstrating the craft-canon skills firing as Fix Cards (issues #7 and #11 verification artifacts); card shape follows CONTEXT.md, anchors follow ADR-0006.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# 0010 — Native TextKit2 prose editor (mode B)
|
||||
|
||||
The editor is a native NSTextView/TextKit2 surface presenting markdown source as calm writing (mode B: styled source, dimmed syntax, reading toggle), with presentation as a flat line-kind→attribute map — no third-party editor dependency. Decided from three throwaway spikes on the pinned calibration corpus (`spike/codeedit/`, `spike/textkit2/`, `spike/blocks/` on `spike/editor-presentation`): TextKit2 delivers full typographic calm at the lowest cost, editing (undo, IME, selection) is native and free, and the Fix-Card anchor proof — exact-range quote highlight + stale-anchor alert with the web-proto wording — passes live on this substrate (2.4 ms anchor search on PERF-3k, ≤1.1 ms full-doc attribute load).
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **CodeEditSourceEditor fork `0.15.8-helm`** (the presumptive leader, proven in Classis): anchor mechanics clean, but the substrate cannot reach typographic calm — one font size for everything, no paragraph spacing (`EditorTheme`/`attributesFor` builds every run from a single base font), mid-word wraps at typographic apostrophes, and emphasis ghost-doubles colored spans (CATextLayer re-draw, unfixable from the API side). Museion takes no CodeEdit dependency; Classis keeps its fork pin, untouched.
|
||||
- **SwiftUI block editor (mode C, live preview)**: best-in-class typography, but structural interaction ceilings — no cross-block selection, per-block undo only, split/merge outside any undo stack, and lists shatter into per-bullet blocks. Each solvable, none for free; it pays in interaction-model decisions where TextKit2 pays in already-written presentation code.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Typography stance: variable heading sizes and real paragraph spacing are required, and natively expressible — not a compromise to accept.
|
||||
- Reading toggle renders block-aware: blank-line split, per-paragraph inline parse, headings fonted by level. A monolithic single-`Text` `.full` markdown dump flattens block structure — the anti-pattern.
|
||||
- Paper-grade polish is not a deferred phase; it is iterative practice, applied whenever the writing surface feels short of calm.
|
||||
@@ -0,0 +1,56 @@
|
||||
# Wayfinder map #16 closed — editor substrate verdict + ADR-0010
|
||||
|
||||
> **Date:** 2026-10-01
|
||||
> **Type:** issue
|
||||
> **Reference:** [#55 Verdict: substrate decision + ADR-0010](https://git.babylondreams.de/AlexKucera/Museion/issues/55) (map: [#16](https://git.babylondreams.de/AlexKucera/Museion/issues/16))
|
||||
|
||||
## Goal
|
||||
|
||||
Resolve the final ticket of wayfinder map #16: the live verdict session weighing the three editor spikes (A CodeEdit fork, B TextKit2, C SwiftUI blocks) and drafting ADR-0010.
|
||||
|
||||
## What Was Done
|
||||
|
||||
- Claimed #55, verified all three blockers (#52, #53, #54) closed with resolutions; verified the spike `run.sh` entry points and anchor-highlight wiring in `spike/textkit2/` exist before the session.
|
||||
- Two grilling rounds with Alexander (live side-by-side of all three spikes): substrate+mode (Q1), v2 path (Q2), then typography stance, fork-sharing, reading renderer, anchor story (Q3–Q6).
|
||||
- Drafted `docs/adr/0010-native-textkit2-prose-editor.md` (Considered Options + Consequences per format).
|
||||
- Posted the #55 resolution comment (issuecomment-22384), closed #55.
|
||||
- Updated map #16: verdict appended to Decisions so far, Not-yet-specified emptied, re-scope of #19–#21 moved to Out of scope (downstream hand-off), map closed — frontier empty, way clear.
|
||||
- DOX pass: `docs/AGENTS.md` ADR range bumped 0001–0009 → 0001–0010.
|
||||
|
||||
## Decisions & Rationale
|
||||
|
||||
| Decision | Rationale |
|
||||
|----------|-----------|
|
||||
| **Substrate: native NSTextView/TextKit2, mode B** (styled source, dimmed syntax, reading toggle; zero editor dependencies) | Tie-breaker `calm > effort > everything else`. A cannot express variable heading sizes or paragraph spacing (substrate limit) plus integration tax; C confirmed hands-on — bullet lists shatter into per-bullet blocks, no cross-block selection, per-block undo. B: editing native/free, presentation is an already-written attribute map. |
|
||||
| Typography: variable heading sizes + paragraph spacing required | "A must for a proper writing tool" — and natively expressible in B, so no compromise to record. |
|
||||
| Fork-sharing: dissolved | Museion takes no CodeEdit dependency; Classis keeps `0.15.8-helm` untouched. |
|
||||
| Reading toggle: block-aware rendering | Blank-line split + per-paragraph inline parse + headings fonted by level; single-`Text` `.full` dump is the anti-pattern (flattens blocks). |
|
||||
| Anchor story: re-proof satisfied | Spike B proves exact-range quote highlight + `scrollRangeToVisible` + stale-alert with web-proto wording, live; 2.4 ms on PERF-3k. |
|
||||
| Paper-grade polish: iterative practice, not a phase | Alexander: tackled step by step whenever something needs more polish. Premise for un-deferring never materialized. |
|
||||
|
||||
## Gotchas & Fixes
|
||||
|
||||
| Problem | Root Cause | Fix |
|
||||
|---------|------------|-----|
|
||||
| Gitea issue-asset upload (`POST /issues/55/assets`) returns 500 HTML | Server-side breakage on this instance (spike tickets show `"assets":[]` too — precedent) | Dropped the attachment; ADR gist in the resolution comment, file in the working tree, referenced by path |
|
||||
| `patch` hit the wrong path (`scratch/docs/AGENTS.md`) | Terminal cwd had moved to scratch; patch used a relative path | Re-ran patch with absolute path |
|
||||
| `tea`-skill traps confirmed | - | Asset upload with `-F file=` also 500s; map body PATCH via `-F body=@file` works cleanly |
|
||||
|
||||
## Files Changed
|
||||
|
||||
| File | Change Summary |
|
||||
|------|---------------|
|
||||
| `docs/adr/0010-native-textkit2-prose-editor.md` | NEW — the substrate ADR (uncommitted, on `spike/editor-presentation` working tree) |
|
||||
| `docs/AGENTS.md` | ADR range 0001–0009 → 0001–0010, added "prose editor substrate" |
|
||||
| Gitea #55 | Resolution comment + closed |
|
||||
| Gitea #16 | Decisions so far + Out of scope updated, map closed |
|
||||
|
||||
## Open Items & Next Steps
|
||||
|
||||
- [ ] Alexander: commit ADR-0010 to main / merge the spike branch — his call, outside the map
|
||||
- [ ] Re-scope #19–#21 against ADR-0010 (downstream hand-off; #19 is now a TextKit2 integration)
|
||||
- [ ] Spike B styling flaws (left-anchored measure, tight first line) → production work in #20/#21
|
||||
|
||||
---
|
||||
|
||||
*Log written by write-log skill*
|
||||
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
|
||||
<!-- write-log: full-index -->
|
||||
| Date | Type | File | Summary |
|
||||
|------|------|------|---------|
|
||||
| 2026-10-01 | issue | [20261001-issue55-verdict-substrate-adr-0010_log.md](20261001-issue55-verdict-substrate-adr-0010_log.md) | #55 + map #16 closed: TextKit2 mode B wins, ADR-0010 drafted, typography/rendering stances locked |
|
||||
| 2026-09-25 | issue | [20260925-issue50-profile-backup-s2-6_log.md](20260925-issue50-profile-backup-s2-6_log.md) | #50 S2.6 daily profile backup: liveness gate, curated copy, retention 7, RESTORE.md — 8 tests green |
|
||||
| 2026-09-16 | issue | [20260916-issue14-acp-bridge-s2-2_log.md](20260916-issue14-acp-bridge-s2-2_log.md) | #14 M0 ACP bridge: NDJSON JSON-RPC client, mentor pane, fix-card round-trip, crash restart — 37 tests green |
|
||||
| 2026-09-05 | issue | [20260905-issue48-provisioning-failure-alert-retry-ux_log.md](20260905-issue48-provisioning-failure-alert-retry-ux_log.md) | #48 shipped: failure card with retry/Not-Now, traversal guard, temp sweep — 30 tests green |
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// swift-tools-version:6.2
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "BlocksSpike",
|
||||
platforms: [.macOS(.v26)],
|
||||
targets: [.executableTarget(name: "BlocksSpike")]
|
||||
)
|
||||
@@ -0,0 +1,84 @@
|
||||
// Spike C (#54): SwiftUI block editor (live preview, mode C) — THROWAWAY, answers a question, not product code.
|
||||
// Question: can a block editor reach live-preview mode C without becoming the project?
|
||||
// Run: spike/blocks/run.sh (from repo root, branch spike/editor-presentation)
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Block: Identifiable, Equatable {
|
||||
var id = UUID()
|
||||
var raw: String // markdown source incl. marker; kind is derived, never stored
|
||||
}
|
||||
|
||||
nonisolated enum BlockModel {
|
||||
enum Kind { case heading1, heading2, paragraph, quote, hr }
|
||||
|
||||
/// Blank-line split — identical strategy to Spike B's readingBlocks, so the
|
||||
/// spikes differ by substrate, not by parse. ponytail: no AST, no lists/setext (corpus has none, #51).
|
||||
static func parse(_ md: String) -> [Block] {
|
||||
md.components(separatedBy: "\n\n")
|
||||
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.filter { !$0.isEmpty }
|
||||
.map { Block(raw: $0) }
|
||||
}
|
||||
|
||||
static func kind(of raw: String) -> Kind {
|
||||
if raw.hasPrefix("## ") { return .heading2 }
|
||||
if raw.hasPrefix("# ") { return .heading1 }
|
||||
if raw.hasPrefix("> ") { return .quote }
|
||||
if raw.count <= 6, !raw.isEmpty, raw.allSatisfy({ $0 == "*" || $0 == "-" || $0 == "_" || $0.isWhitespace }) { return .hr }
|
||||
return .paragraph
|
||||
}
|
||||
|
||||
/// Rendered text: marker stripped, inline markdown parsed (inline-only — block
|
||||
/// structure is ours, exactly like Spike B's reading mode).
|
||||
static func rendered(_ raw: String) -> AttributedString {
|
||||
var p = raw
|
||||
let k = kind(of: raw)
|
||||
switch k {
|
||||
case .heading1: p = String(p.dropFirst(2))
|
||||
case .heading2: p = String(p.dropFirst(3))
|
||||
case .quote: p = String(p.dropFirst(2))
|
||||
case .hr: return AttributedString("⁂")
|
||||
case .paragraph: break
|
||||
}
|
||||
var opts = AttributedString.MarkdownParsingOptions()
|
||||
opts.interpretedSyntax = .inlineOnlyPreservingWhitespace
|
||||
return (try? AttributedString(markdown: p, options: opts)) ?? AttributedString(p)
|
||||
}
|
||||
|
||||
/// Marker-stripped plain text (anchor search runs over this).
|
||||
static func plainText(_ raw: String) -> String {
|
||||
switch kind(of: raw) {
|
||||
case .heading1: return String(raw.dropFirst(2))
|
||||
case .heading2: return String(raw.dropFirst(3))
|
||||
case .quote: return String(raw.dropFirst(2))
|
||||
case .hr: return ""
|
||||
case .paragraph: return raw
|
||||
}
|
||||
}
|
||||
|
||||
/// Within-block UTF-16 range of `quote` (word-tokenized, whitespace-tolerant — same
|
||||
/// strategy as Spike B's anchorRange, scoped to one block). nil = stale.
|
||||
static func anchorRange(of quote: String, in raw: String) -> NSRange? {
|
||||
let text = plainText(raw)
|
||||
let textWords = words(text), quoteWords = words(quote)
|
||||
guard !quoteWords.isEmpty, textWords.count >= quoteWords.count else { return nil }
|
||||
for start in 0 ... textWords.count - quoteWords.count {
|
||||
if (start ..< start + quoteWords.count).allSatisfy({ textWords[$0].norm == quoteWords[$0 - start].norm }) {
|
||||
let from = textWords[start].range.lowerBound
|
||||
let to = textWords[start + quoteWords.count - 1].range.upperBound
|
||||
return NSRange(location: text.utf16.distance(from: text.startIndex, to: from),
|
||||
length: text.utf16.distance(from: from, to: to))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private struct Word { let norm: String; let range: Range<String.Index> }
|
||||
private static func words(_ s: String) -> [Word] {
|
||||
s.split(whereSeparator: \.isWhitespace).map { sub in
|
||||
Word(norm: sub.lowercased().trimmingCharacters(in: .punctuationCharacters),
|
||||
range: sub.startIndex ..< sub.endIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
// Spike C (#54) — THROWAWAY. Block editor shell: ScrollView of blocks, focused block = raw source,
|
||||
// unfocused = rendered live. Anchor demo at block granularity. Also: --check self-check.
|
||||
// Run: spike/blocks/run.sh (from repo root, branch spike/editor-presentation)
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SpikeApp: App {
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
||||
var body: some Scene {
|
||||
Window("Spike C — Blocks", id: "main") {
|
||||
ContentView()
|
||||
.frame(minWidth: 900, minHeight: 640)
|
||||
.onAppear { NSApp.activate(ignoringOtherApps: true) }
|
||||
}
|
||||
.windowStyle(.hiddenTitleBar)
|
||||
}
|
||||
|
||||
// ponytail: one runnable check — `swift run --package-path spike/blocks --check`
|
||||
init() {
|
||||
if CommandLine.arguments.contains("--check") { Self.selfCheck(); exit(0) }
|
||||
}
|
||||
|
||||
static func selfCheck() {
|
||||
let text = try! String(contentsOfFile: "spike/prose/the-expected-value-of-showing.md", encoding: .utf8)
|
||||
let blocks = BlockModel.parse(text)
|
||||
assert(blocks.count > 10, "FAIL: parse produced \(blocks.count) blocks")
|
||||
assert(BlockModel.kind(of: blocks[0].raw) == .heading2, "FAIL: first block not a heading (## in corpus)")
|
||||
let kinds = blocks.map { BlockModel.kind(of: $0.raw) }
|
||||
assert(kinds.contains(.heading2), "FAIL: no ## blocks")
|
||||
assert(kinds.contains(.hr), "FAIL: corpus hr (* * *) not detected")
|
||||
// rendered text must hide block markup
|
||||
let rendered = blocks.map { String(BlockModel.rendered($0.raw).characters) }
|
||||
assert(rendered.allSatisfy { !$0.hasPrefix("# ") && !$0.hasPrefix("## ") && !$0.hasPrefix("> ") },
|
||||
"FAIL: markup leaked into rendered view")
|
||||
assert(rendered.contains { $0.contains("expected value") }, "FAIL: body text missing")
|
||||
// anchor feasibility: block containing the DM quote
|
||||
let anchor = ContentView.findAnchorBlock(quote: "“I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.”", in: blocks)
|
||||
assert(anchor != nil, "FAIL: anchor block not found")
|
||||
// within-block range feasibility: same word search as Spike B, scoped to one block
|
||||
if let a = anchor {
|
||||
let r = BlockModel.anchorRange(of: "the expected value of joining", in: a.raw)
|
||||
assert(r != nil, "FAIL: within-block anchor range")
|
||||
}
|
||||
// paste-split: multi-paragraph raw splits into blocks
|
||||
assert(BlockModel.parse("one\n\ntwo\n\nthree").count == 3, "FAIL: paste-split")
|
||||
// perf: block-ify PERF-3k
|
||||
let perf = (try? String(contentsOfFile: "spike/prose/PERF-3k.md", encoding: .utf8)) ?? text
|
||||
var ms = 0.0
|
||||
for _ in 0..<3 {
|
||||
let t0 = DispatchTime.now()
|
||||
_ = BlockModel.parse(perf)
|
||||
ms = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1e6
|
||||
}
|
||||
print("PASS: \(blocks.count) blocks; anchor block found; PERF-3k block-ify \(String(format: "%.1f", ms)) ms")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Content
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var blocks: [Block]
|
||||
@State private var focusedID: UUID?
|
||||
@State private var anchorID: UUID?
|
||||
@State private var staleShown = false
|
||||
@State private var loadMs: Double = 0
|
||||
@State private var hint = "Click a block to edit its source. Enter splits, ⌫ at start merges. IME probe: type ⌥U a in a block."
|
||||
|
||||
init() {
|
||||
let args = CommandLine.arguments
|
||||
let arg = args.count > 1 && args[1] != "--check" ? args[1] : nil
|
||||
let t = Self.loadCorpus(arg)
|
||||
let t0 = DispatchTime.now()
|
||||
_blocks = State(initialValue: BlockModel.parse(t))
|
||||
_loadMs = State(initialValue: Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1e6)
|
||||
}
|
||||
|
||||
/// Arg as given, then the default piece (run.sh passes absolute paths).
|
||||
static func loadCorpus(_ arg: String?) -> String {
|
||||
for c in [arg, "spike/prose/the-expected-value-of-showing.md"].compactMap({ $0 }) {
|
||||
if let s = try? String(contentsOfFile: c, encoding: .utf8) { return s }
|
||||
}
|
||||
return "# Spike C\n\n(No corpus file found — run from repo root.)"
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
bar
|
||||
Divider()
|
||||
ScrollViewReader { proxy in
|
||||
ScrollView([.vertical]) {
|
||||
LazyVStack(alignment: .leading, spacing: 18) {
|
||||
ForEach(blocks) { block in
|
||||
BlockRow(
|
||||
block: block,
|
||||
isFocused: focusedID == block.id,
|
||||
isAnchored: anchorID == block.id,
|
||||
onEdit: { raw in edit(block.id, raw: raw) },
|
||||
onSplit: { at in split(block.id, at: at) },
|
||||
onMerge: { merge(block.id) },
|
||||
onFocus: {
|
||||
focusedID = block.id
|
||||
hint = "Focused block \(block.id.uuidString.prefix(4)) — type to edit."
|
||||
}
|
||||
)
|
||||
.id(block.id)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: 720, alignment: .leading)
|
||||
.padding(.horizontal, 40)
|
||||
.padding(.vertical, 24)
|
||||
.onChange(of: anchorID) { id in
|
||||
if let id { proxy.scrollTo(id, anchor: .center) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
Text(hint).font(.caption).foregroundStyle(.secondary).frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 16).padding(.vertical, 6)
|
||||
}
|
||||
.alert("Anchor not found", isPresented: $staleShown) {
|
||||
Button("OK", role: .cancel) {}
|
||||
} message: {
|
||||
Text("The Post changed after this Fix Card was issued; no text was selected or changed.")
|
||||
}
|
||||
}
|
||||
|
||||
private var bar: some View {
|
||||
HStack(spacing: 12) {
|
||||
Button("Anchor: DM quote") { applyAnchor("“I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.”") }
|
||||
Button("Stale anchor") { applyAnchor("this quote was deleted from the text") }
|
||||
if anchorID != nil { Text("anchored").foregroundStyle(.secondary).font(.caption) }
|
||||
Spacer()
|
||||
Text("load \(String(format: "%.1f", loadMs)) ms · \(blocks.count) blocks").foregroundStyle(.secondary).font(.caption)
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
// MARK: block ops
|
||||
|
||||
private func edit(_ id: UUID, raw: String) {
|
||||
guard let i = blocks.firstIndex(where: { $0.id == id }) else { return }
|
||||
// paste-split: multi-paragraph raw explodes into blocks at the same position
|
||||
if raw.contains("\n\n") {
|
||||
let parts = BlockModel.parse(raw)
|
||||
guard !parts.isEmpty else { return }
|
||||
blocks.replaceSubrange(i ... i, with: parts)
|
||||
focusedID = parts[parts.count - 1].id
|
||||
} else {
|
||||
blocks[i].raw = raw
|
||||
}
|
||||
}
|
||||
|
||||
private func split(_ id: UUID, at location: Int) {
|
||||
guard let i = blocks.firstIndex(where: { $0.id == id }) else { return }
|
||||
let ns = blocks[i].raw as NSString
|
||||
let loc = max(0, min(location, ns.length))
|
||||
let before = ns.substring(to: loc).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let after = ns.substring(from: loc).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
blocks[i].raw = before
|
||||
blocks.insert(Block(raw: after), at: i + 1)
|
||||
focusedID = blocks[i + 1].id
|
||||
}
|
||||
|
||||
private func merge(_ id: UUID) {
|
||||
guard let i = blocks.firstIndex(where: { $0.id == id }), i > 0 else { return }
|
||||
blocks[i - 1].raw += " " + blocks[i].raw
|
||||
blocks.remove(at: i)
|
||||
focusedID = blocks[i - 1].id
|
||||
}
|
||||
|
||||
// MARK: anchor (block-granular Fix-Card feasibility)
|
||||
|
||||
static func findAnchorBlock(quote: String, in blocks: [Block]) -> Block? {
|
||||
let qw = normWords(quote)
|
||||
guard !qw.isEmpty else { return nil }
|
||||
for b in blocks {
|
||||
let bw = normWords(BlockModel.plainText(b.raw))
|
||||
guard bw.count >= qw.count else { continue }
|
||||
if (0 ... bw.count - qw.count).contains(where: { s in
|
||||
(s ..< s + qw.count).allSatisfy { bw[$0] == qw[$0 - s] }
|
||||
}) { return b }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
static func normWords(_ s: String) -> [String] {
|
||||
s.split(whereSeparator: \.isWhitespace).map { $0.lowercased().trimmingCharacters(in: .punctuationCharacters) }
|
||||
}
|
||||
|
||||
private func applyAnchor(_ quote: String) {
|
||||
let t0 = DispatchTime.now()
|
||||
let hit = ContentView.findAnchorBlock(quote: quote, in: blocks)
|
||||
loadMs = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1e6
|
||||
if let hit {
|
||||
anchorID = hit.id
|
||||
} else {
|
||||
anchorID = nil
|
||||
staleShown = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - One block: rendered, or raw source when focused
|
||||
|
||||
private struct BlockRow: View {
|
||||
let block: Block
|
||||
let isFocused: Bool
|
||||
let isAnchored: Bool
|
||||
let onEdit: (String) -> Void
|
||||
let onSplit: (Int) -> Void
|
||||
let onMerge: () -> Void
|
||||
let onFocus: () -> Void
|
||||
@State private var raw: String
|
||||
|
||||
init(block: Block, isFocused: Bool, isAnchored: Bool,
|
||||
onEdit: @escaping (String) -> Void, onSplit: @escaping (Int) -> Void,
|
||||
onMerge: @escaping () -> Void, onFocus: @escaping () -> Void) {
|
||||
self.block = block
|
||||
self.isFocused = isFocused
|
||||
self.isAnchored = isAnchored
|
||||
self.onEdit = onEdit
|
||||
self.onSplit = onSplit
|
||||
self.onMerge = onMerge
|
||||
self.onFocus = onFocus
|
||||
_raw = State(initialValue: block.raw)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if isFocused {
|
||||
SingleBlockEditor(text: $raw, onEdit: onEdit, onSplit: onSplit, onMerge: onMerge)
|
||||
.frame(height: max(28, SingleBlockEditor.height(for: raw)))
|
||||
} else {
|
||||
rendered.padding(.vertical, 1)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(isAnchored ? Color(nsColor: NSColor(calibratedRed: 0.79, green: 0.39, blue: 0.26, alpha: 0.18)) : Color.clear)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { onFocus() }
|
||||
.onChange(of: block.raw) { raw = $0 } // external change (undo of split/merge)
|
||||
}
|
||||
|
||||
@ViewBuilder private var rendered: some View {
|
||||
let k = BlockModel.kind(of: block.raw)
|
||||
switch k {
|
||||
case .heading1:
|
||||
Text(BlockModel.rendered(block.raw)).font(.custom("Iowan Old Style", size: 26).bold())
|
||||
case .heading2:
|
||||
Text(BlockModel.rendered(block.raw)).font(.custom("Iowan Old Style", size: 20).bold())
|
||||
case .quote:
|
||||
Text(BlockModel.rendered(block.raw)).font(.custom("Iowan Old Style", size: 17))
|
||||
.padding(.leading, 14).overlay(alignment: .leading) { Rectangle().fill(.quaternary).frame(width: 3) }
|
||||
case .hr:
|
||||
Text("⁂").font(.system(size: 17)).frame(maxWidth: .infinity, alignment: .center).foregroundStyle(.secondary)
|
||||
case .paragraph:
|
||||
Text(BlockModel.rendered(block.raw)).font(.custom("Iowan Old Style", size: 17))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Focused block = one non-scrolling NSTextView (native IME/undo/select/cut-paste)
|
||||
|
||||
struct SingleBlockEditor: NSViewRepresentable {
|
||||
@Binding var text: String
|
||||
var onEdit: (String) -> Void
|
||||
var onSplit: (Int) -> Void
|
||||
var onMerge: () -> Void
|
||||
|
||||
static func height(for raw: String) -> CGFloat {
|
||||
let s = NSAttributedString(string: raw, attributes: [.font: NSFontManager.shared
|
||||
.font(withFamily: "Iowan Old Style", traits: [], weight: 5, size: 17) ?? .systemFont(ofSize: 17)])
|
||||
return ceil(s.boundingRect(with: CGSize(width: 640, height: CGFloat.greatestFiniteMagnitude),
|
||||
options: [.usesLineFragmentOrigin]).height) + 8
|
||||
}
|
||||
|
||||
func makeNSView(context: Context) -> NSTextView {
|
||||
let tv = NSTextView()
|
||||
tv.isRichText = false
|
||||
tv.allowsUndo = true // per-block native undo — across-block undo is an honest spike finding
|
||||
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||
tv.isAutomaticDashSubstitutionEnabled = false
|
||||
tv.isAutomaticTextReplacementEnabled = false
|
||||
tv.isAutomaticSpellingCorrectionEnabled = false
|
||||
tv.drawsBackground = true
|
||||
tv.backgroundColor = NSColor(calibratedRed: 0.99, green: 0.965, blue: 0.88, alpha: 1) // "source mode" tint
|
||||
tv.typingAttributes = Self.typing
|
||||
tv.string = text
|
||||
tv.delegate = context.coordinator
|
||||
tv.isEditable = true
|
||||
tv.isSelectable = true
|
||||
tv.textContainer?.containerSize = NSSize(width: 640, height: CGFloat.greatestFiniteMagnitude)
|
||||
tv.textContainer?.widthTracksTextView = false
|
||||
tv.textContainer?.lineFragmentPadding = 4
|
||||
tv.isVerticallyResizable = false
|
||||
tv.isHorizontallyResizable = false
|
||||
context.coordinator.textView = tv
|
||||
DispatchQueue.main.async { tv.window?.makeFirstResponder(tv) }
|
||||
return tv
|
||||
}
|
||||
|
||||
func updateNSView(_ tv: NSTextView, context: Context) {
|
||||
if tv.string != text { tv.string = text }
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator { Coordinator(self) }
|
||||
|
||||
static var typing: [NSAttributedString.Key: Any] { [
|
||||
.font: NSFontManager.shared.font(withFamily: "Iowan Old Style", traits: [], weight: 5, size: 17) ?? .systemFont(ofSize: 17),
|
||||
] }
|
||||
|
||||
final class Coordinator: NSObject, NSTextViewDelegate {
|
||||
let parent: SingleBlockEditor
|
||||
weak var textView: NSTextView?
|
||||
init(_ parent: SingleBlockEditor) { self.parent = parent }
|
||||
|
||||
func textDidChange(_ notification: Notification) {
|
||||
guard let tv = notification.object as? NSTextView else { return }
|
||||
parent.text = tv.string
|
||||
parent.onEdit(tv.string)
|
||||
}
|
||||
|
||||
// Enter = split at cursor, ⌫ at position 0 = merge up — the block-model lift meter.
|
||||
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||
parent.onSplit(textView.selectedRange().location)
|
||||
return true
|
||||
}
|
||||
if commandSelector == #selector(NSResponder.deleteBackward(_:)) {
|
||||
if textView.selectedRange().location == 0, textView.selectedRange().length == 0 {
|
||||
parent.onMerge()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ponytail: bare SPM executable gets .accessory activation — no window. Set policy BEFORE scenes build.
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
}
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.5 MiB |
@@ -0,0 +1,28 @@
|
||||
#!/bin/zsh
|
||||
# ponytail: wrap the SPM binary in a minimal .app — SwiftUI needs a bundle to make windows.
|
||||
set -e
|
||||
ROOT="$PWD"
|
||||
cd "$(dirname "$0")"
|
||||
swift build 2>&1 | tail -1
|
||||
APP=.build/BlocksSpike.app
|
||||
rm -rf "$APP" && mkdir -p "$APP/Contents/MacOS"
|
||||
cp .build/debug/BlocksSpike "$APP/Contents/MacOS/"
|
||||
cat > "$APP/Contents/Info.plist" <<'PLIST'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key><string>BlocksSpike</string>
|
||||
<key>CFBundleIdentifier</key><string>de.babylondreams.museion.spike-c</string>
|
||||
<key>CFBundleName</key><string>Spike C — Blocks</string>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>LSMinimumSystemVersion</key><string>26.0</string>
|
||||
<key>NSHighResolutionCapable</key><true/>
|
||||
<key>NSSupportsAutomaticWindowRestoration</key><false/>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
# ponytail: always hand the binary an ABSOLUTE corpus path — its cwd here is spike/blocks
|
||||
ARG="${1:-$ROOT/spike/prose/the-expected-value-of-showing.md}"
|
||||
case "$ARG" in /*) ;; *) ARG="$ROOT/$ARG" ;; esac
|
||||
exec "$APP/Contents/MacOS/BlocksSpike" "$ARG"
|
||||
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"originHash" : "453562669f1231fef7eb30ffcd1db6224d44e963de82930718a931775a8d93bd",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "codeeditlanguages",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/CodeEditApp/CodeEditLanguages.git",
|
||||
"state" : {
|
||||
"revision" : "331d5dbc5fc8513be5848fce8a2a312908f36a11",
|
||||
"version" : "0.1.20"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "codeeditsourceeditor",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/AlexKucera/CodeEditSourceEditor.git",
|
||||
"state" : {
|
||||
"revision" : "3ce600768d4cb9a4f65f5a106ffa193f9fd861d9",
|
||||
"version" : "0.15.8-helm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "codeeditsymbols",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/CodeEditApp/CodeEditSymbols.git",
|
||||
"state" : {
|
||||
"revision" : "ae69712b08571c4469c2ed5cd38ad9f19439793e",
|
||||
"version" : "0.2.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "codeedittextview",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/AlexKucera/CodeEditTextView.git",
|
||||
"state" : {
|
||||
"revision" : "fe1e34d90f10660c8e91688b0b2be383300b815e",
|
||||
"version" : "0.12.3-helm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "rearrange",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/ChimeHQ/Rearrange",
|
||||
"state" : {
|
||||
"revision" : "4de8be41dba304192e87dc0a11e0aa39e72aa2e8",
|
||||
"version" : "2.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections.git",
|
||||
"state" : {
|
||||
"revision" : "98ef3c98609a1e31b7e157b5b619579001a789d6",
|
||||
"version" : "1.7.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swifttreesitter",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter.git",
|
||||
"state" : {
|
||||
"revision" : "08ef81eb8620617b55b08868126707ad72bf754f",
|
||||
"version" : "0.25.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "textformation",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/ChimeHQ/TextFormation",
|
||||
"state" : {
|
||||
"revision" : "b1ce9a14bd86042bba4de62236028dc4ce9db6a1",
|
||||
"version" : "0.9.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "textstory",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/ChimeHQ/TextStory",
|
||||
"state" : {
|
||||
"revision" : "a52db1a2eca74d37c8c19bf3165416941632ed45",
|
||||
"version" : "0.9.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "tree-sitter",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/tree-sitter/tree-sitter",
|
||||
"state" : {
|
||||
"revision" : "da6fe9beb4f7f67beb75914ca8e0d48ae48d6406",
|
||||
"version" : "0.25.10"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// swift-tools-version:6.2
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "CodeEditSpike",
|
||||
platforms: [.macOS(.v26)],
|
||||
dependencies: [
|
||||
// Fork fact from map #16: same fork + revision as Classis (0.15.8-helm = 3ce6007).
|
||||
.package(url: "https://github.com/AlexKucera/CodeEditSourceEditor.git", exact: "0.15.8-helm"),
|
||||
],
|
||||
targets: [.executableTarget(name: "CodeEditSpike", dependencies: ["CodeEditSourceEditor"])]
|
||||
)
|
||||
@@ -0,0 +1,391 @@
|
||||
// Spike A (#52) — THROWAWAY. CodeEditSourceEditor fork as prose editor (mode B), anchor proof.
|
||||
// Question: can the presumptive-leader code substrate present prose source as calm writing?
|
||||
// Run: spike/codeedit/run.sh (from repo root, branch spike/editor-presentation)
|
||||
import AppKit
|
||||
@preconcurrency import CodeEditLanguages
|
||||
@preconcurrency import CodeEditSourceEditor
|
||||
@preconcurrency import CodeEditTextView
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - Prose theme (uniform-font compromise documented in the resolution)
|
||||
|
||||
enum ProseTheme {
|
||||
// Iowan Old Style like Spike B / the web proto; falls back to system serif.
|
||||
static var bodyFont: NSFont {
|
||||
NSFontManager.shared.font(withFamily: "Iowan Old Style", traits: [], weight: 5, size: 17)
|
||||
?? NSFont.systemFont(ofSize: 17, weight: .regular, width: .standard)
|
||||
}
|
||||
|
||||
static let ink = NSColor(srgbRed: 0.10, green: 0.10, blue: 0.09, alpha: 1)
|
||||
static let dim = NSColor(srgbRed: 0.55, green: 0.55, blue: 0.55, alpha: 1)
|
||||
static let paper = NSColor(srgbRed: 0.98, green: 0.98, blue: 0.98, alpha: 1)
|
||||
static let accent = NSColor(srgbRed: 0.79, green: 0.39, blue: 0.26, alpha: 1)
|
||||
|
||||
static var theme: EditorTheme {
|
||||
EditorTheme(
|
||||
text: .init(color: ink),
|
||||
insertionPoint: ink,
|
||||
invisibles: .init(color: dim),
|
||||
background: paper,
|
||||
lineHighlight: NSColor(srgbRed: 0.955, green: 0.955, blue: 0.955, alpha: 1),
|
||||
selection: NSColor(srgbRed: 0.79, green: 0.39, blue: 0.26, alpha: 0.18),
|
||||
keywords: .init(color: dim), // markdown markers route here via prosePass below
|
||||
commands: .init(color: ink),
|
||||
types: .init(color: ink, bold: true), // headings: bold, same size (substrate limit)
|
||||
attributes: .init(color: ink),
|
||||
variables: .init(color: ink),
|
||||
values: .init(color: ink),
|
||||
numbers: .init(color: ink),
|
||||
strings: .init(color: NSColor(srgbRed: 0.25, green: 0.42, blue: 0.31, alpha: 1)), // blockquote tint
|
||||
characters: .init(color: ink),
|
||||
comments: .init(color: dim)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Prose highlight pass (helm's MonokaiHighlighter pattern: wrap tree-sitter, add regex passes)
|
||||
|
||||
/// Wraps the stock TreeSitterClient; after its captures, adds prose passes over markdown:
|
||||
/// heading lines → bold capture, marker+inline-syntax runs → dim capture. Emphasis/anchor is NOT
|
||||
/// done here — layer-backed Emphasis handles it.
|
||||
final class ProseHighlighter: HighlightProviding {
|
||||
private let wrapped = TreeSitterClient()
|
||||
|
||||
func setUp(textView: TextView, codeLanguage: CodeLanguage) {
|
||||
wrapped.setUp(textView: textView, codeLanguage: codeLanguage)
|
||||
}
|
||||
|
||||
func applyEdit(
|
||||
textView: TextView,
|
||||
range: NSRange,
|
||||
delta: Int,
|
||||
completion: @escaping @MainActor (Result<IndexSet, Error>) -> Void
|
||||
) {
|
||||
wrapped.applyEdit(textView: textView, range: range, delta: delta, completion: completion)
|
||||
}
|
||||
|
||||
func queryHighlightsFor(
|
||||
textView: TextView,
|
||||
range: NSRange,
|
||||
completion: @escaping @MainActor (Result<[HighlightRange], Error>) -> Void
|
||||
) {
|
||||
wrapped.queryHighlightsFor(textView: textView, range: range) { result in
|
||||
switch result {
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
case .success(let tsRanges):
|
||||
var out = tsRanges
|
||||
let ns = textView.string as NSString
|
||||
let safe = range.intersection(NSRange(location: 0, length: ns.length)) ?? range
|
||||
out += Self.proseRanges(in: ns, range: safe)
|
||||
completion(.success(out))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pure: heading text → .type (bold via theme), heading marker + inline marks → .keyword (dim).
|
||||
/// ponytail: line-scan regex, not an AST — corpus is plain prose markdown; enough for the spike.
|
||||
static func proseRanges(in ns: NSString, range: NSRange) -> [HighlightRange] {
|
||||
var out: [HighlightRange] = []
|
||||
ns.enumerateSubstrings(in: range, options: [.byLines]) { line, lineRange, _, _ in
|
||||
guard let line, !line.isEmpty else { return }
|
||||
if let markerLen = Self.headingMarkerLen(line) {
|
||||
// heading text (after marker, same line) → bold capture
|
||||
let textLen = lineRange.length - markerLen
|
||||
if textLen > 0 {
|
||||
out.append(HighlightRange(
|
||||
range: NSRange(location: lineRange.location + markerLen, length: textLen),
|
||||
capture: .type
|
||||
))
|
||||
}
|
||||
// marker → dim
|
||||
out.append(HighlightRange(
|
||||
range: NSRange(location: lineRange.location, length: markerLen),
|
||||
capture: .keyword
|
||||
))
|
||||
} else if line.hasPrefix(">") {
|
||||
// quote line: text → tinted .string, markers dimmed
|
||||
let textLen = lineRange.length - 1
|
||||
if textLen > 0 {
|
||||
out.append(HighlightRange(range: NSRange(location: lineRange.location + 1, length: textLen), capture: .string))
|
||||
}
|
||||
out.append(HighlightRange(range: NSRange(location: lineRange.location, length: 1), capture: .keyword))
|
||||
} else {
|
||||
// inline syntax chars → dim, one run per char (runs merge at render)
|
||||
let marks: Set<UInt16> = [0x2A, 0x5F, 0x60, 0x5B, 0x5D, 0x28, 0x29, 0x21, 0x3C, 0x3E] // * _ ` [ ] ( ) ! < >
|
||||
for (off, ch) in line.utf16.enumerated() where marks.contains(ch) {
|
||||
out.append(HighlightRange(
|
||||
range: NSRange(location: lineRange.location + off, length: 1),
|
||||
capture: .keyword
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
private static func headingMarkerLen(_ line: String) -> Int? {
|
||||
guard line.hasPrefix("#") else { return nil }
|
||||
let hashes = line.prefix { $0 == "#" }.count
|
||||
guard hashes <= 6, line.dropFirst(hashes).hasPrefix(" ") else { return nil }
|
||||
return hashes + 1
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Quote anchor (identical algorithm to Spike B — same feasibility question)
|
||||
|
||||
nonisolated enum AnchorSearch {
|
||||
private struct Word { let norm: String; let range: Range<String.Index> }
|
||||
private static func words(_ s: String) -> [Word] {
|
||||
s.split(whereSeparator: \.isWhitespace).map { sub in
|
||||
Word(norm: sub.lowercased().trimmingCharacters(in: .punctuationCharacters), range: sub.startIndex ..< sub.endIndex)
|
||||
}
|
||||
}
|
||||
|
||||
/// Word-tokenized whitespace/punctuation-tolerant search. nil = stale anchor.
|
||||
static func range(of quote: String, in text: String) -> NSRange? {
|
||||
let textWords = words(text)
|
||||
let quoteWords = words(quote)
|
||||
guard !quoteWords.isEmpty, textWords.count >= quoteWords.count else { return nil }
|
||||
for start in 0...(textWords.count - quoteWords.count) {
|
||||
if (start..<start + quoteWords.count).allSatisfy({
|
||||
textWords[$0].norm == quoteWords[$0 - start].norm
|
||||
}) {
|
||||
let from = textWords[start].range.lowerBound
|
||||
let to = textWords[start + quoteWords.count - 1].range.upperBound
|
||||
return NSRange(
|
||||
location: text.utf16.distance(from: text.startIndex, to: from),
|
||||
length: text.utf16.distance(from: from, to: to)
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - App shell
|
||||
|
||||
@main
|
||||
struct SpikeApp: App {
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
||||
var body: some Scene {
|
||||
Window("Spike A — CodeEdit fork", id: "main") {
|
||||
ContentView()
|
||||
.frame(minWidth: 900, minHeight: 640)
|
||||
.onAppear { NSApp.activate(ignoringOtherApps: true) }
|
||||
}
|
||||
.windowStyle(.hiddenTitleBar)
|
||||
}
|
||||
|
||||
// ponytail: one runnable check for the prose pass + anchor logic — `run.sh --check`
|
||||
init() {
|
||||
if CommandLine.arguments.contains("--check") { Self.selfCheck(); exit(0) }
|
||||
}
|
||||
|
||||
static func selfCheck() {
|
||||
// Repo root from compile-time path (self-check must not depend on cwd).
|
||||
let root = URL(fileURLWithPath: #filePath)
|
||||
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
|
||||
let text = (try? String(contentsOf: root.appendingPathComponent("spike/prose/the-expected-value-of-showing.md"), encoding: .utf8)) ?? ""
|
||||
assert(!text.isEmpty, "FAIL: corpus missing — run from repo root")
|
||||
let ns = text as NSString
|
||||
let full = NSRange(location: 0, length: ns.length)
|
||||
let ranges = ProseHighlighter.proseRanges(in: ns, range: full)
|
||||
// headings detected (calibration piece has H1 + H2s)
|
||||
let headingTexts = ranges.filter { $0.capture == .type }
|
||||
assert(headingTexts.count >= 3, "FAIL: expected headings, got \(headingTexts.count)")
|
||||
assert(headingTexts.allSatisfy { (ns.substring(with: $0.range) as NSString).range(of: "#").location == NSNotFound },
|
||||
"FAIL: marker leaked into heading text")
|
||||
// markers dimmed
|
||||
assert(ranges.contains { $0.capture == .keyword && ns.substring(with: $0.range).hasPrefix("#") },
|
||||
"FAIL: heading marker not dimmed")
|
||||
// anchor: live quote found; stale → nil; whitespace-tolerant
|
||||
let quote = "\"I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.\""
|
||||
guard let r = AnchorSearch.range(of: quote, in: text) else { assert(false, "FAIL: live quote not found"); return }
|
||||
assert((ns.substring(with: r) as NSString).length > 50)
|
||||
let squished = quote.components(separatedBy: .newlines).joined(separator: " ")
|
||||
assert(AnchorSearch.range(of: squished, in: text) != nil, "FAIL: whitespace tolerance")
|
||||
assert(AnchorSearch.range(of: "this quote was deleted years ago", in: text) == nil, "FAIL: stale should be nil")
|
||||
// perf smoke: PERF-3k anchor timing
|
||||
let perfURL = root.appendingPathComponent("spike/prose/PERF-3k.md")
|
||||
if let perf = try? String(contentsOf: perfURL, encoding: .utf8) {
|
||||
let t0 = DispatchTime.now()
|
||||
_ = AnchorSearch.range(of: "The odds are better than they look", in: perf)
|
||||
let ms = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1e6
|
||||
print("PASS: \(headingTexts.count) headings, anchor @ \(r.location) len \(r.length); PERF-3k anchor search \(String(format: "%.1f", ms)) ms")
|
||||
} else {
|
||||
print("PASS: \(headingTexts.count) headings, anchor @ \(r.location) len \(r.length); PERF-3k not found")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var text: String
|
||||
@State private var editorState = SourceEditorState()
|
||||
@State private var reading = false
|
||||
@State private var staleShown = false
|
||||
@State private var loadMs: Double = 0
|
||||
@State private var anchorNote: String?
|
||||
/// Captured controller — the path to Emphasis/setCursorPositions (helm #160 pattern).
|
||||
/// Reference box, not @State: writes during makeNSViewController are dropped (see ControllerBox).
|
||||
private let box = ControllerBox()
|
||||
|
||||
init() {
|
||||
// Repo root from compile-time path — launchd cwd is "/", so relative paths never hit.
|
||||
let repoRoot = URL(fileURLWithPath: #filePath) // <root>/spike/codeedit/Sources/CodeEditSpike/SpikeApp.swift
|
||||
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
|
||||
let corpus = repoRoot.appendingPathComponent("spike/prose/the-expected-value-of-showing.md")
|
||||
let arg = CommandLine.arguments.first(where: { $0.hasSuffix(".md") })
|
||||
let url = arg.map { URL(fileURLWithPath: $0, relativeTo: repoRoot) } ?? corpus
|
||||
let t = (try? String(contentsOf: url, encoding: .utf8))
|
||||
?? (try? String(contentsOf: corpus, encoding: .utf8))
|
||||
?? "# Spike A\n\n(No corpus file found at \(corpus.path).)"
|
||||
_text = State(initialValue: t)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
bar
|
||||
Divider()
|
||||
if reading {
|
||||
// Reading toggle: same per-block renderer stance as Spike B (its resolution is the map's reference)
|
||||
ScrollView(.vertical) {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
ForEach(Array(SpikeApp.readingBlocks(text).enumerated()), id: \.offset) { _, block in
|
||||
Text(block.text)
|
||||
.font(block.level > 0
|
||||
? .system(size: CGFloat(32 - block.level * 3), weight: .bold, design: .serif)
|
||||
: .system(size: 17))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: 720, alignment: .leading)
|
||||
.padding(.horizontal, 40)
|
||||
.padding(.vertical, 24)
|
||||
}
|
||||
} else {
|
||||
editor
|
||||
}
|
||||
}
|
||||
.alert("Anchor not found", isPresented: $staleShown) {
|
||||
Button("OK", role: .cancel) {}
|
||||
} message: {
|
||||
Text("The Post changed after this Fix Card was issued; no text was selected or changed.")
|
||||
}
|
||||
}
|
||||
|
||||
private var editor: some View {
|
||||
// Centered measure via maxWidth (iA-Writer approach; no GeometryReader — it proposes
|
||||
// 0×0 to the AppKit leaf on first pass and the window never places in this shell).
|
||||
SourceEditor(
|
||||
$text,
|
||||
language: .markdown,
|
||||
configuration: config,
|
||||
state: $editorState,
|
||||
highlightProviders: [ProseHighlighter()],
|
||||
coordinators: [ControllerCapture(onCapture: { box.controller = $0 })]
|
||||
)
|
||||
.frame(maxWidth: 720)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 24)
|
||||
}
|
||||
|
||||
private var config: SourceEditorConfiguration {
|
||||
SourceEditorConfiguration(
|
||||
appearance: .init(
|
||||
theme: ProseTheme.theme,
|
||||
font: ProseTheme.bodyFont,
|
||||
lineHeightMultiple: 1.45, // paragraph rhythm via line-height (no per-paragraph spacing on substrate)
|
||||
wrapLines: true
|
||||
),
|
||||
behavior: .init(reformatAtColumn: 10_000), // never hard-wrap prose
|
||||
peripherals: .init(
|
||||
showGutter: false, // no line numbers in a writing app
|
||||
showMinimap: false,
|
||||
showReformattingGuide: false,
|
||||
showFoldingRibbon: false,
|
||||
invisibleCharactersConfiguration: .init(showSpaces: false, showTabs: false, showLineEndings: false),
|
||||
warningCharacters: []
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private var bar: some View {
|
||||
HStack(spacing: 12) {
|
||||
Toggle("Reading", isOn: $reading)
|
||||
Divider().frame(height: 14)
|
||||
Button("Anchor: DM quote") { applyAnchor("\"I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.\"") }
|
||||
Button("Stale anchor") { applyAnchor("this quote was deleted from the text") }
|
||||
if let note = anchorNote { Text(note).foregroundStyle(.secondary).font(.caption) }
|
||||
Spacer()
|
||||
Text("load \(String(format: "%.1f", loadMs)) ms").foregroundStyle(.secondary).font(.caption)
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
private func applyAnchor(_ quote: String) {
|
||||
let controller = box.controller
|
||||
let t0 = DispatchTime.now()
|
||||
let r = AnchorSearch.range(of: quote, in: text)
|
||||
loadMs = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1_000_000
|
||||
guard let r else {
|
||||
anchorNote = nil
|
||||
staleShown = true
|
||||
return
|
||||
}
|
||||
anchorNote = "anchored @ \(r.location)–\(r.location + r.length)\(controller == nil ? " (no ctrl!)" : "")"
|
||||
guard let controller else { return }
|
||||
// Layer-backed emphasis highlight (survives re-highlighting) + scroll-to + selection.
|
||||
controller.textView.emphasisManager?.replaceEmphases(
|
||||
[Emphasis(range: r, style: .outline(color: ProseTheme.accent, fill: false))],
|
||||
for: "fix-card-anchor"
|
||||
)
|
||||
controller.setCursorPositions([CursorPosition(range: r)], scrollToVisible: true)
|
||||
}
|
||||
}
|
||||
|
||||
/// Captures the live TextViewController at prepareCoordinator (helm #160's captured-controller pattern).
|
||||
/// Reference box, NOT @State: prepareCoordinator fires inside makeNSViewController — during SwiftUI's
|
||||
/// view update — and @State writes there are silently dropped (root cause of the "(no ctrl!)" case).
|
||||
final class ControllerBox: @unchecked Sendable {
|
||||
var controller: TextViewController?
|
||||
}
|
||||
final class ControllerCapture: TextViewCoordinator {
|
||||
let onCapture: (TextViewController) -> Void
|
||||
init(onCapture: @escaping (TextViewController) -> Void) { self.onCapture = onCapture }
|
||||
func prepareCoordinator(controller: TextViewController) {
|
||||
onCapture(controller)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Reading blocks (Spike B's proven per-block renderer; .full syntax)
|
||||
|
||||
extension SpikeApp {
|
||||
// ponytail: blank-line split + inline parse per block; no AST. Setext/list blocks not handled — corpus has none.
|
||||
static func readingBlocks(_ md: String) -> [(level: Int, text: AttributedString)] {
|
||||
md.components(separatedBy: "\n\n").map { para in
|
||||
var level = 0
|
||||
var p = para.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if p.hasPrefix("#") {
|
||||
let hashes = p.prefix { $0 == "#" }.count
|
||||
p = String(p.dropFirst(hashes)).trimmingCharacters(in: .whitespaces)
|
||||
level = hashes
|
||||
}
|
||||
let attr = (try? AttributedString(
|
||||
markdown: p,
|
||||
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
|
||||
)) ?? AttributedString(p)
|
||||
return (level, attr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ponytail: bare SPM executable gets .accessory activation — no window. Set policy BEFORE scenes build.
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
}
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 140 KiB |
@@ -0,0 +1,28 @@
|
||||
#!/bin/zsh
|
||||
# ponytail: wrap the SPM binary in a minimal .app — SwiftUI needs a bundle to make windows,
|
||||
# and CodeEditLanguages/Symbols resource bundles must ship inside it (NSBundle.module crash otherwise).
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
swift build 2>&1 | tail -1
|
||||
APP=.build/CodeEditSpike.app
|
||||
rm -rf "$APP" && mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
cp .build/debug/CodeEditSpike "$APP/Contents/MacOS/"
|
||||
for b in .build/debug/CodeEditLanguages_CodeEditLanguages.bundle .build/debug/CodeEditSymbols_CodeEditSymbols.bundle; do
|
||||
cp -R "$b" "$APP/Contents/Resources/" 2>/dev/null || echo "warn: $b missing"
|
||||
done
|
||||
cat > "$APP/Contents/Info.plist" <<'PLIST'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key><string>CodeEditSpike</string>
|
||||
<key>CFBundleIdentifier</key><string>de.babylondreams.museion.spike-a</string>
|
||||
<key>CFBundleName</key><string>Spike A — CodeEdit fork</string>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>LSMinimumSystemVersion</key><string>26.0</string>
|
||||
<key>NSHighResolutionCapable</key><true/>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
echo "built: $APP"
|
||||
exec "$APP/Contents/MacOS/CodeEditSpike" "${@:-}"
|
||||
@@ -0,0 +1,259 @@
|
||||
# The expected value of showing up
|
||||
|
||||
August 17, 2026 Alexander Kucera
|
||||
|
||||
"I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high."
|
||||
|
||||
That's the DM that got me into this. Not "you're good enough." Just: most people won't bother, so the odds are better than they look. I'd already turned the invitation down once. Then Roman did the math at me, and I couldn't argue with it.
|
||||
|
||||
The invitation was a coding challenge he runs: build a video game with a single prompt. One message, sent to an AI coding agent in an empty directory. After you hit enter, you don't touch anything. No follow-up questions, no course corrections, no "actually, make it blue." Whatever the agent builds from that one message is your entry. Judges score the game, then break the winning prompt down line by line.
|
||||
|
||||
If you've used an AI assistant recently, you know how wild that constraint is. Half my interactions are "no, that's not what I meant" by message three. Getting a whole game out of one message means everything has to be in the prompt before you start: the goal, the architecture, the definition of done, and the answers to questions the agent hasn't asked yet. The prompt has to steer without a steering wheel.
|
||||
|
||||
## Three brains
|
||||
|
||||
I didn't sit down and think of a game. I asked three different agents to do it for me.
|
||||
|
||||
Same brief to each: a strong game concept for this challenge. Three different harnesses, two different models. And three completely different afternoons.
|
||||
|
||||
Both sessions running GLM-5.2 skipped any deliberation and pitched games on the spot. Both, without comparing notes, pitched roguelikes. Hermes Agent came back with Body Snatcher, a possession game where you're a ghost with one hit point and no attack, and you survive by literally wearing your enemies: twelve of them, each with its own hunting AI and a different move set once it's your body.
|
||||
|
||||
Pi running the same model pitched Underdepths, a classic dungeon crawler in Python: procedurally generated floors, enemies that hunt you through the dark, gear, levels, a dragon at the bottom.
|
||||
|
||||
The third session, running GPT-5.6 Sol, behaved like a different species. It opened a full brainstorm first: forced relationships, morphological analysis, SCAMPER, constraint mapping. Twenty-three ideas, developed and narrowed over four structured phases. What survived was Adaptive Loop, a deterministic strategy puzzle about rotating glass rings to route nutrients through a microbial ecosystem that adapts against you. It's the most original of the three, and I'll admit I don't fully understand it while playing it.
|
||||
|
||||
Three briefs in, I had three concepts and no way to pick. So I didn't.
|
||||
|
||||
## Sixteen runs
|
||||
|
||||
From there, everything standardized. Every build ran the same way: Pi, my coding agent, with all my saved skills switched off, running GPT-5.6 Sol. The only variable left was the prompt itself.
|
||||
|
||||
August 12 to 16. Sixteen complete runs: five passes on Body Snatcher, four on Adaptive Loop, seven on Underdepths. Each pass was a fresh empty directory, one message, hands off. Between passes I rewrote the prompt and let the corpse of the last run decide what to change.
|
||||
|
||||
That cadence, prompt → run → autopsy → prompt, taught me more about directing agents than months of normal back-and-forth work. Because there's no conversation, every failure traces back to something the prompt failed to say. What the corpses taught me:
|
||||
|
||||
**Make the agent build its own verifier first.** The Underdepths prompt never says "make a game." Its opening move: "write a test suite that defines done, then write a build pipeline that dispatches each phase of work to a headless copy of yourself, gates every phase behind those tests, and feeds failures back in." The agent built itself a small factory, and the factory wouldn't let it ship broken floors.
|
||||
|
||||
**Specify what must be true, never how.** The prompts that worked state pass conditions and boundaries: what counts as done, who may touch what. They never prescribe data structures or algorithms. The moment I told an agent how, it stopped thinking and started transcribing.
|
||||
|
||||
**Keep the scars.** One dead run shipped stairs that existed in the map data but were never drawn—you couldn't see the way down. The next prompt carried the line "a prior build shipped stairs only in map data, never drawn. Do not repeat that." Every dead pass left a sentence like that behind. Those scar sentences are the actual prompt engineering.
|
||||
|
||||
**Pin what the model will otherwise optimize away.** Body Snatcher's spec says, in bold, that enemies must never damage each other. Sounds obvious. But the first builds had bombers and turrets clearing whole floors on their own, and suddenly there was no game—just an arena watching itself. Rules that feel trivial to a human are load-bearing, and the only way to know which ones is to watch a run collapse without them.
|
||||
|
||||
## The result
|
||||
|
||||
Three finished games. A possession roguelike in a single HTML file with zero dependencies. A Python dungeon crawler built by an agent-driven factory that passed every one of its own gates. And a deterministic glass-ring ecosystem I can't quite master, generated by the one model that brainstormed before it spoke.
|
||||
|
||||
The challenge rules say one prompt, one entry. I submitted all three games, one uncut video showing all three being played, and told the judges to pick. The whole thing was one experiment anyway: same brief, same process, three prompts. The code is public in the repo; the prompts went to the judges privately, as the rules require.
|
||||
|
||||
I don't know yet how the challenge shakes out. But the meta-lesson already paid for itself. Roman's expected-value argument isn't really about contests. Nearly everything worth entering has a showing-up problem: the field is small because most people talk themselves out of it. I was most people, briefly. Then a two-sentence DM did the math at me.
|
||||
|
||||
The odds are better than they look. Enter the thing.
|
||||
|
||||
* * *
|
||||
|
||||
**Play them:** repo at [git.babylondreams.de/AlexKucer…](https://git.babylondreams.de/AlexKucera/agentic-labs-challenge-submission)
|
||||
|
||||
# My Current Setup
|
||||
|
||||
October 10, 2024 Alexander Kucera
|
||||
|
||||
I thought I’d write down my current workflow setup since it has changed drastically since I last wrote about it. Not only am I exclusively working from home these days—due to health reasons—but I am also working in a very reduced capacity. This means I am mostly using my iPhone, iPad, and iMac for leisure.
|
||||
|
||||
With that being said, here is what I use on a daily basis.
|
||||
|
||||
## Keeping up with the Joneses
|
||||
|
||||
### Micro.blog
|
||||
|
||||
I said goodbye to social media a while ago. While I was quite active on Twitter and even more so on App.net and Slack, I have since dropped all of these. There really isn't much point in spinning my wheels there.
|
||||
|
||||
These days, I post to my own blog, which is syndicated to the Micro.blog timeline and also cross-posted to Mastodon. I'm not active on Mastodon, but thanks to the Fediverse, any replies I receive on Mastodon should appear on my Micro.blog timeline.
|
||||
|
||||
Posting to my blog is done via the Micro.blog app or website, which is very frictionless for the most part.
|
||||
|
||||
* My [Micro.blog Account](https://micro.blog/AlexKucera)
|
||||
* My [website](https://alexanderkucera.com)
|
||||
* My Fediverse ID: [@alex@alexanderkucera.com](@alex@alexanderkucera.com)
|
||||
|
||||
|
||||
|
||||
### Fiery Feeds and FeedBin
|
||||
|
||||
For my daily news, I tend to watch the local news show [Tagesthemen](https://youtube.com/@tagesschau?si=DNoE4UhebBbcOiOz) while eating breakfast. This keeps me up to date on both local and global news and politics.
|
||||
|
||||
For my tech news and other updates, I use [Feedbin](https://feedbin.com/home) to curate my feeds and [Fiery Feeds](https://voidstern.net/fiery-feeds) for reading them. Fiery Feeds has a few nice intelligent curation options, like Hot Links or Long and Short articles, that make it easy to catch up on too many RSS feeds every day. Yes, maybe I should subscribe to fewer feeds, but with Fiery Feeds, I really don’t have to.
|
||||
|
||||
### Overcast
|
||||
|
||||
Every couple of years, I switch podcast apps. I used to be an avid user of [Pocket Casts](https://apps.apple.com/de/app/pocket-casts-podcast-player/id414834813), and [Castro](https://apps.apple.com/de/app/castro-podcast-player/id1080840241) was my favorite player for years. These days, I am back with [Overcast](https://apps.apple.com/de/app/overcast/id888422857). I don’t have any special feelings for it; it works well.
|
||||
|
||||
### YouTube
|
||||
|
||||
Sadly, I am a sucker for YouTube videos. I do not browse the auto-suggestions much, but I have way too many subscriptions. At the moment, my „Watch Later“ queue contains 24 items, most of which are in the 20-30 minute range. However, there are a few videos that are 1.5-3 hours long that I haven’t gotten around to watching.
|
||||
|
||||
### Discord
|
||||
|
||||
While I don’t engage much on Discord, I follow a few servers to get news announcements and participate in one or two in-person chats. The days when I was active daily for several hours on Slack and Discord are long gone.
|
||||
|
||||
## Health related
|
||||
|
||||
### MacroFactor
|
||||
|
||||
I recently started using [MacroFactor](https://macrofactorapp.com/) to track my food and water intake. I have been on and off the food-tracking wagon in the past; usually, I track for a week or two before stopping again. The apps I have used in the past, like Lifesum and MyFitnessPal, are all nice and work reasonably well with tracking EU foods. However, they all miss a crucial element: they don’t adapt to one’s personal habits; they simply track food.
|
||||
|
||||
MacroFactor, on the other hand, adapts to your eating habits, providing you with tailored goals and occasionally coaching you on what you can improve or change. It simply clicks with me much more than all the other apps I have tried.
|
||||
|
||||
### RP Hypertrophy
|
||||
|
||||
About a year ago, I finally accepted that I needed to build some strength to get my life back. Due to severe health-related issues, I pretty much stopped moving around 2016. I didn’t blow up, but I lost nearly all my muscle. Moving around the house became a chore at times. Combined with some serious joint inflammation, this kept me sedentary.
|
||||
|
||||
No more. I started slowly to build muscle again. At first, I went too quickly, which resulted in weeks of not being able to work out due to inflamed joints. However, in combination with MacroFactor, I have been able to manage my food intake in a way that reduces inflammation while providing enough protein and energy to rebuild my strength.
|
||||
|
||||
The [RP Hypertrophy](https://rpstrength.com/pages/hypertrophy-app) app has been my steadfast companion. There are other exercise apps out there—some cheaper, some more expensive, and some even free—but none of them resonate with me like the RP Hypertrophy app does. The way it allows me to quickly set up a training plan is unparalleled. It also helps me with my progression by analyzing my workout volume. Great! One less thing to think about.
|
||||
|
||||
RP Strength also has a [Diet Coach](https://rpstrength.com/pages/diet-coach-app) app, but for me, MacroFactor works better.
|
||||
|
||||
## Writing
|
||||
|
||||
### Paper
|
||||
|
||||
I recently stumbled across [Paper](https://papereditor.app) as a writing tool, and I really, really like it. I haven’t quite found the justification to pay for it yet. It comes with a hefty price tag in my region (the developer consciously charges more in richer regions of the world). However, I might consider it in the future, depending on whether I start writing professionally again in the coming months. For now, I’m going the cheapskate route and clicking away the nag screens that pop up now and again. Sorry, [Mihhail](https://twitter.com/_mihhail)!
|
||||
|
||||
### Textastic
|
||||
|
||||
I don’t use [Textastic](https://apps.apple.com/de/app/textastic-code-editor/id1049254261) for actual writing, but it is a great general text editor if I need to edit something from my iCloud, modify a file on my server, or whip up a quick Python script or other scripts.
|
||||
|
||||
### AirMail
|
||||
|
||||
My email client of choice is [AirMail](https://airmailapp.com). There’s not much to say about it, really. It works for me.
|
||||
|
||||
## Apps by Readdle
|
||||
|
||||
I use several apps from the Ukrainian developer [Readdle](https://readdle.com/). They tend to deliver a polished experience, and their support is excellent.
|
||||
|
||||
### Calendars
|
||||
|
||||
Their [calendar solution](https://readdle.com/calendars) is top-notch. It supports natural language event creation, the UI is nice, and it works better for me than the native Calendar app on iOS.
|
||||
|
||||
### Scanner
|
||||
|
||||
Their [document scanner](https://readdle.com/scannerpro) works in a very no-nonsense way. It offers great support for de-skewing and straightening out your wonky document photos. It provides automatic OCR and document naming, and you can create workflows—something I haven’t taken advantage of yet, as my needs aren’t that complex.
|
||||
|
||||
### PDF Expert
|
||||
|
||||
Their [PDF reader](https://pdfexpert.com) works great. You can edit and annotate PDFs. Sadly, there is no OCR on iOS or iPadOS yet, but I am told it’s coming.
|
||||
|
||||
## Strongbox
|
||||
|
||||
I used to be a strong [1Password](https://1password.com/) supporter. I bought it way back when I got my first iPhone—an iPhone 4. Since then, I have bought several updates, and when they switched to a subscription model, I purchased the family plan for—I think—two years.
|
||||
|
||||
Then I read a thread on Micro.blog where someone talked about [Strongbox](https://strongboxsafe.com/). I checked it out, installed it, and took advantage of their very generous three-month trial. After a week or so of use, they had won me over, and I happily paid for their lifetime license after the trial period was over.
|
||||
|
||||
Granted, using Strongbox is a little bit more complicated and less streamlined than using 1Password, but their lifetime license costs what I used to pay for 1Password in a year. There is simply no comparison when it comes to value per euro.
|
||||
|
||||
## AI
|
||||
|
||||
### Perplexity
|
||||
|
||||
I use [Perplexity](https://www.perplexity.ai) for searching most of the time instead of doing a Google or DuckDuckGo search. I enjoy getting nicely written summarized results, and if I want to dig deeper, I can simply open the sources Perplexity found for a given topic. I haven’t found any instances where the AI hallucinated an answer, but there have been a few occasions where the suggested follow-up questions were just nonsense.
|
||||
|
||||
### TypingMind
|
||||
|
||||
[TypingMind](https://www.typingmind.com) is a great ChatGPT interface that allows me to use most ChatGPT features without shelling out over $20 a month. It connects via the ChatGPT API, which results in much more reasonable costs. I got myself a premium license and haven’t looked back since.
|
||||
|
||||
### MidJourney
|
||||
|
||||
Generative Imaging. Some people loathe it; I personally love it. [MidJourney](https://www.midjourney.com) is great for quickly generating dozens of variations on an idea, especially since they enabled generation via the website instead of in a Discord chat. We have used it to rapidly create initial drafts and, yes, even final designs for projects, both professional and private.
|
||||
|
||||
## Graphics
|
||||
|
||||
### Affinity Designer 2
|
||||
|
||||
Since I have mostly stepped back from work, we primarily focus on occasional graphic design for local projects, such as flyers, postcards, roll-up flags, and the like.
|
||||
|
||||
[Affinity Designer](https://affinity.serif.com/designer/) is unbeatable in terms of price and the value it offers for this purpose. Additionally, we can use it on the iPad for initial mockups and then continue working on the same file on the Mac. Brilliant!
|
||||
|
||||
### Affinity Photo 2
|
||||
|
||||
It’s pixel-related brother, [Affinity Photo](https://affinity.serif.com/photo/), while not as intuitive and powerful as Photoshop, is still nevertheless our main go-to when it comes to editing images. Plus, it works well together with Designer and also offers the same iPad-to-Mac and back workflow.
|
||||
|
||||
### QR Factory
|
||||
|
||||
Since we switched to a more graphic design-based workflow, we regularly need to create QR codes. While there are many online and free generators available, [QR Factory](https://www.tunabellysoftware.com/qrfactory/) offers a comprehensive suite of QR options in one package. I wouldn’t consider using any other option anymore.
|
||||
|
||||
### Nuke
|
||||
|
||||
Foundry’s [Nuke](https://www.foundry.com/products/nuke-family) is my main workhorse for paid work. Although I don’t do as much as I once did, I am still very happy to pay for an Indie license when the occasional project comes in. Nuke remains the gold standard for compositing.
|
||||
|
||||
### Modo
|
||||
|
||||
Similarly, when I need to do some 3D work, I use my trusty copy of Foundry’s [modo](https://www.foundry.com/products/modo). It still gets me everywhere I need to go—though these days, that isn’t very far.
|
||||
|
||||
## Outbank
|
||||
|
||||
For banking in Germany, this is the way to go. [Outbank](https://outbankapp.com) has the best banking support of any app I’ve tried in the past. The developers had some negative press a couple of years ago related to pricing, subscriptions, and a completely revamped UI design, but I think they have recovered well from that.
|
||||
|
||||
For my money, this is the best way to keep track of your money, at least for European/German users.
|
||||
|
||||
## Etsy and Printful
|
||||
|
||||
I recently discovered [Printful](www.printful.com/de/give-5-get-5/FO7BEA), and it got me interested enough to open our own little [Etsy store](https://bdscribblewear.etsy.com) with designs from the cutting room floor. I mean, why let perfectly good doodles and scribbles go to waste?“
|
||||
|
||||
## IT
|
||||
|
||||
### FE File Explorer
|
||||
|
||||
[FE File Explorer](https://www.skyjos.com/fileexplorer/) is my go-to app when the Files app on iOS won’t suffice. It is also a great FTP client and integrates nicely with our online workflow.
|
||||
|
||||
### ShellFish
|
||||
|
||||
[ShellFish](https://secureshellfish.app) is my preferred SSH client. I have tried a few others in the past, but ShellFish has really stuck with me. It also integrates nicely with Files.app.
|
||||
|
||||
# For the Sake of Building?
|
||||
|
||||
August 22, 2026 Alexander Kucera
|
||||
|
||||
I noticed this three days ago. I was mid-feature on my Agentic Development Environment [Classis](https://classis.app) when I realized it had crossed a threshold. It could be used to develop itself. Not perfectly, but _it could_. I’d spent almost four weeks poring over every feature and edge case, and somewhere in that stretch the tool had become capable enough.
|
||||
|
||||
And instead of triumph, I felt something closer to dread.
|
||||
|
||||
Not because Classis isn’t good. It’s _good_. I’m having a ball building it. The kind of deep-focus month where you’re still thinking about architecture in the shower, where every solved problem feels like cracking a safe. This is the real thing, and I know it, which makes the next sentence harder to write:
|
||||
|
||||
**I have no idea what I’ll build with it once it’s done.**
|
||||
|
||||
Another month of polishing, maybe six weeks, and Classis ships. Then I’ll hold a powerful developer tool, and think: _okay, now what?_
|
||||
|
||||
_Build a SaaS startup._ With what idea? I didn’t build this to solve a specific problem. I built it because building it was interesting.
|
||||
|
||||
_Contribute to open source._ Maybe. But that’s finding excuses to use a hammer you forged yourself, not the same as having a project that needs it.
|
||||
|
||||
_Just keep improving the tool._ This one’s dangerous. I could spend another year on Classis. There’s always one more feature to add, one more layer of polish. And every week spent improving the tool is a week not using it for anything except improving the tool.
|
||||
|
||||
* * *
|
||||
|
||||
You fall in love with the process of making. Not the thing you’re making. The making itself. The 2am debugging sessions where a problem finally cracks open. The architectural decisions that click into place and make you mutter “yeah, that’s right” at an empty room.
|
||||
|
||||
I’ve been here before. Most developers have. You finish a project, the high drains out, and you’re staring at a repository thinking _that was fun, what now?_ The difference this time is scale. A month of focused work. Real opportunity cost.
|
||||
|
||||
So the question keeping me up isn’t _is this tool any good?_
|
||||
|
||||
It’s: **Am I just developing for the sake of developing?**
|
||||
|
||||
What if I’m not someone who builds tools to make things? What if I just love the act of building so much that I’ve convinced myself I need a _reason_ for it?
|
||||
|
||||
Part of me says: that’s fine. Building for the joy of building is honest in a way that building for metrics never is. One month crafting something, learning a lot along the way, and I’m the only user. I am ok with that.
|
||||
|
||||
Another part says: cop-out. That’s the story you tell when you’re afraid to ship, afraid to put work in front of people who might not care. “I build for the love of building” sounds noble until you notice it also protects you from judgment.
|
||||
|
||||
Both parts are right, I think.
|
||||
|
||||
In four or five weeks [Classis](https://classis.app) will be polished enough to hand to another developer and say “here, try this” without cringing. I don’t know what happens after that sentence.
|
||||
|
||||
Maybe the right problem appears and the tool turns out to be exactly what the problem needed. Maybe this whole spiral is just pre-launch nerves, the feeling before any release when you’ve invested enough that _of course_ you’re questioning whether it matters.
|
||||
|
||||
Or maybe I finish, sit in front of it for a week, and realize the best part is already over. Building done. Fun done. And I have to decide: find something new to build, or figure out what “done” feels like when you’ve been running toward it for two months.
|
||||
|
||||
I’ll let you know which one.
|
||||
|
||||
Assuming I figure it out myself.
|
||||
@@ -0,0 +1,7 @@
|
||||
## Are AI products stale the day they ship?
|
||||
|
||||
September 4, 2026 Alexander Kucera
|
||||
|
||||
At the pace AI moves, is selling an AI product just selling yesterday's tech? I dropped that question into a community thread this week, and it's still rattling around my head. Those of us in the field sprint just to keep up, and the ground shifts under anything sitting on top of it. By the time a product is built, tested, polished, and shipped, the layer beneath it has moved twice. Traditional software had years of shelf life. This stuff has a sell-by date measured in weeks.
|
||||
|
||||
None of this makes selling AI unethical—it just makes it weird. The intelligence itself is rented from a provider and improves on someone else's schedule. What you actually sell is a snapshot: the workflow you designed and the glue you maintain. Maybe that's why it's all subscriptions. Nobody in their right mind would buy an AI product outright. The monthly bill is a freshness guarantee. You're paying someone else to keep sprinting, so the product never quite goes stale.
|
||||
@@ -0,0 +1,47 @@
|
||||
## For the Sake of Building?
|
||||
|
||||
August 22, 2026 Alexander Kucera
|
||||
|
||||
I noticed this three days ago. I was mid-feature on my Agentic Development Environment [Classis](https://classis.app) when I realized it had crossed a threshold. It could be used to develop itself. Not perfectly, but _it could_. I’d spent almost four weeks poring over every feature and edge case, and somewhere in that stretch the tool had become capable enough.
|
||||
|
||||
And instead of triumph, I felt something closer to dread.
|
||||
|
||||
Not because Classis isn’t good. It’s _good_. I’m having a ball building it. The kind of deep-focus month where you’re still thinking about architecture in the shower, where every solved problem feels like cracking a safe. This is the real thing, and I know it, which makes the next sentence harder to write:
|
||||
|
||||
**I have no idea what I’ll build with it once it’s done.**
|
||||
|
||||
Another month of polishing, maybe six weeks, and Classis ships. Then I’ll hold a powerful developer tool, and think: _okay, now what?_
|
||||
|
||||
_Build a SaaS startup._ With what idea? I didn’t build this to solve a specific problem. I built it because building it was interesting.
|
||||
|
||||
_Contribute to open source._ Maybe. But that’s finding excuses to use a hammer you forged yourself, not the same as having a project that needs it.
|
||||
|
||||
_Just keep improving the tool._ This one’s dangerous. I could spend another year on Classis. There’s always one more feature to add, one more layer of polish. And every week spent improving the tool is a week not using it for anything except improving the tool.
|
||||
|
||||
* * *
|
||||
|
||||
You fall in love with the process of making. Not the thing you’re making. The making itself. The 2am debugging sessions where a problem finally cracks open. The architectural decisions that click into place and make you mutter “yeah, that’s right” at an empty room.
|
||||
|
||||
I’ve been here before. Most developers have. You finish a project, the high drains out, and you’re staring at a repository thinking _that was fun, what now?_ The difference this time is scale. A month of focused work. Real opportunity cost.
|
||||
|
||||
So the question keeping me up isn’t _is this tool any good?_
|
||||
|
||||
It’s: **Am I just developing for the sake of developing?**
|
||||
|
||||
What if I’m not someone who builds tools to make things? What if I just love the act of building so much that I’ve convinced myself I need a _reason_ for it?
|
||||
|
||||
Part of me says: that’s fine. Building for the joy of building is honest in a way that building for metrics never is. One month crafting something, learning a lot along the way, and I’m the only user. I am ok with that.
|
||||
|
||||
Another part says: cop-out. That’s the story you tell when you’re afraid to ship, afraid to put work in front of people who might not care. “I build for the love of building” sounds noble until you notice it also protects you from judgment.
|
||||
|
||||
Both parts are right, I think.
|
||||
|
||||
In four or five weeks [Classis](https://classis.app) will be polished enough to hand to another developer and say “here, try this” without cringing. I don’t know what happens after that sentence.
|
||||
|
||||
Maybe the right problem appears and the tool turns out to be exactly what the problem needed. Maybe this whole spiral is just pre-launch nerves, the feeling before any release when you’ve invested enough that _of course_ you’re questioning whether it matters.
|
||||
|
||||
Or maybe I finish, sit in front of it for a week, and realize the best part is already over. Building done. Fun done. And I have to decide: find something new to build, or figure out what “done” feels like when you’ve been running toward it for two months.
|
||||
|
||||
I’ll let you know which one.
|
||||
|
||||
Assuming I figure it out myself.
|
||||
@@ -0,0 +1,29 @@
|
||||
## My current posting workflow while on the go
|
||||
|
||||
February 6, 2017 Alexander Kucera
|
||||
|
||||
[Nick Parfene](http://parfene.com/) over in the Indie Microblogging Slack asked me to write about my posting workflow and since I haven’t written about how I blog for [over three years](http://blog.alexanderkucera.com/articles/blogging_workflow_again) it could do with an update.
|
||||
|
||||
## Why change?
|
||||
|
||||
First, why change the previous workflow? I got confused. Simple as that. My blogging schedule is erratic at best. And the old run and gun style workflow, while working, always left me scratching my head when I hadn’t touched it for a few months. I know, months is a sad amount of idle time between posts. But it is what it is.
|
||||
|
||||
So to keep myself in the loop what happened to my blog I decided to adopt Git for keeping a publishing history. Not only does it allow me to tinker with the blog’s templates and CSS without messing up, it also serves as a nice automatic history what I did when and for what reason. I just need to read the commit log to job my memory.
|
||||
|
||||
## The in-between workflow
|
||||
|
||||
The last workflow I wrote about three years ago relied on a desktop machine running. While I have a server machine running 24/7 I did experience too many hiccups with that approach to feel reliable. So I switched it to a two pronged process that worked pretty well. On the go I was posting with Workflow and Transmit and on the desktop I was using Hazel with a [custom Python script](https://alexanderkucera.com/uploads/2024/blog-post-transform.zip).
|
||||
|
||||
This tended to work pretty well. Especially the on the go version. Write stuff in whatever text editor suits you best (I use [Ulysses](https://geo.itunes.apple.com/de/app/ulysses/id950335311?mt=8&ign-mpt=uo%253D4)), send over to [Workflow](https://geo.itunes.apple.com/app/workflow-powerful-automation/id915249334?) for [processing](https://workflow.is/workflows/b0364be085534bb8b94003de824f8d4d) and upload to blog with [Transmit](https://geo.itunes.apple.com/us/app/transmit-ios/id917432930?mt=8&ign-mpt=uo%253D4). For images the procedure is similar only I use [ImageOptim](https://workflow.is/workflows/42d6d670bbd940148a8e3c945682bc15) or [Kraken](https://workflow.is/workflows/a70ddd60f996477385a2d5d2d934fa60) for image optimization before uploading. I use both at the moment and have not decided which one I like better.
|
||||
|
||||
## Micro.blog and Git
|
||||
|
||||
Now, beginning of this year [Manton Reece](http://www.manton.org) created a [Kickstarter project](https://www.kickstarter.com/projects/manton/indie-microblogging-owning-your-short-form-writing) about Microblogging (Kickstarter is over, but you can enter your details on a [mailing list](http://riverfold.us9.list-manage.com/subscribe?u=241a0ce5d267c19de7fcf819f&id=98f8896de4) if you are interested in it). I found the idea enticing and so I joined the project. This basically got me fired up to tinker with my blog again, which led to the adoption of Git since I couldn’t make heads or tails of whatever my latest changes to it had been.
|
||||
|
||||
The idea is really quite simple. Git has the ability to run scripts, so called [Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), when certain events happen. In my case I use the [post-receive hook](https://www.kernel.org/pub/software/scm/git/docs/githooks.html) to check out the newest version of my site whenever I push something to my server’s repository. There are a [number](http://bobbelderbos.com/2012/03/push-code-remote-web-server-git/) of [guides](http://toroid.org/git-website-howto) available, but the one I found most helpful was [Nicolas Gallagher’s](http://nicolasgallagher.com/simple-git-deployment-strategy-for-static-sites/).
|
||||
|
||||
Once that is set up the writing pipeline is really pretty similar to what I had above.
|
||||
|
||||
Write stuff in whatever text editor suits you best (I still use [Ulysses](https://geo.itunes.apple.com/de/app/ulysses/id950335311?mt=8&ign-mpt=uo%253D4)), send over to [Workflow](https://geo.itunes.apple.com/app/workflow-powerful-automation/id915249334?) for [processing](https://workflow.is/workflows/1eb4469c83b145c8867311bdcb9cd986), which then sends the article to [Working Copy](https://geo.itunes.apple.com/us/app/working-copy-enterprise/id965019520?mt=8), an iOS Git client. In Working Copy I can check and if necessary correct the post or snippet and then commit and push the changes to my Git repository on the server. There is gets immediately checked out to the live site. For images I still use [ImageOptim](https://workflow.is/workflows/42d6d670bbd940148a8e3c945682bc15) or [Kraken](https://workflow.is/workflows/a70ddd60f996477385a2d5d2d934fa60).
|
||||
|
||||
The desktop version is almost the same really. I also use [Ulysses](https://geo.itunes.apple.com/de/app/ulysses/id623795237?mt=12&ign-mpt=uo%253D4) for my desktop writing. From there I go via a custom [Alfred workflow](https://alexanderkucera.com/uploads/2024/ulysses-blog-post.zip) that preps the article and then I push the changes up to my Git repository with [Tower](https://www.git-tower.com/mac/), but I could just as easily fire off a simple `git push` from Terminal.
|
||||
@@ -0,0 +1,155 @@
|
||||
## My Current Setup
|
||||
|
||||
October 10, 2024 Alexander Kucera
|
||||
|
||||
I thought I’d write down my current workflow setup since it has changed drastically since I last wrote about it. Not only am I exclusively working from home these days—due to health reasons—but I am also working in a very reduced capacity. This means I am mostly using my iPhone, iPad, and iMac for leisure.
|
||||
|
||||
With that being said, here is what I use on a daily basis.
|
||||
|
||||
## Keeping up with the Joneses
|
||||
|
||||
### Micro.blog
|
||||
|
||||
I said goodbye to social media a while ago. While I was quite active on Twitter and even more so on App.net and Slack, I have since dropped all of these. There really isn't much point in spinning my wheels there.
|
||||
|
||||
These days, I post to my own blog, which is syndicated to the Micro.blog timeline and also cross-posted to Mastodon. I'm not active on Mastodon, but thanks to the Fediverse, any replies I receive on Mastodon should appear on my Micro.blog timeline.
|
||||
|
||||
Posting to my blog is done via the Micro.blog app or website, which is very frictionless for the most part.
|
||||
|
||||
* My [Micro.blog Account](https://micro.blog/AlexKucera)
|
||||
* My [website](https://alexanderkucera.com)
|
||||
* My Fediverse ID: [@alex@alexanderkucera.com](@alex@alexanderkucera.com)
|
||||
|
||||
|
||||
|
||||
### Fiery Feeds and FeedBin
|
||||
|
||||
For my daily news, I tend to watch the local news show [Tagesthemen](https://youtube.com/@tagesschau?si=DNoE4UhebBbcOiOz) while eating breakfast. This keeps me up to date on both local and global news and politics.
|
||||
|
||||
For my tech news and other updates, I use [Feedbin](https://feedbin.com/home) to curate my feeds and [Fiery Feeds](https://voidstern.net/fiery-feeds) for reading them. Fiery Feeds has a few nice intelligent curation options, like Hot Links or Long and Short articles, that make it easy to catch up on too many RSS feeds every day. Yes, maybe I should subscribe to fewer feeds, but with Fiery Feeds, I really don’t have to.
|
||||
|
||||
### Overcast
|
||||
|
||||
Every couple of years, I switch podcast apps. I used to be an avid user of [Pocket Casts](https://apps.apple.com/de/app/pocket-casts-podcast-player/id414834813), and [Castro](https://apps.apple.com/de/app/castro-podcast-player/id1080840241) was my favorite player for years. These days, I am back with [Overcast](https://apps.apple.com/de/app/overcast/id888422857). I don’t have any special feelings for it; it works well.
|
||||
|
||||
### YouTube
|
||||
|
||||
Sadly, I am a sucker for YouTube videos. I do not browse the auto-suggestions much, but I have way too many subscriptions. At the moment, my „Watch Later“ queue contains 24 items, most of which are in the 20-30 minute range. However, there are a few videos that are 1.5-3 hours long that I haven’t gotten around to watching.
|
||||
|
||||
### Discord
|
||||
|
||||
While I don’t engage much on Discord, I follow a few servers to get news announcements and participate in one or two in-person chats. The days when I was active daily for several hours on Slack and Discord are long gone.
|
||||
|
||||
## Health related
|
||||
|
||||
### MacroFactor
|
||||
|
||||
I recently started using [MacroFactor](https://macrofactorapp.com/) to track my food and water intake. I have been on and off the food-tracking wagon in the past; usually, I track for a week or two before stopping again. The apps I have used in the past, like Lifesum and MyFitnessPal, are all nice and work reasonably well with tracking EU foods. However, they all miss a crucial element: they don’t adapt to one’s personal habits; they simply track food.
|
||||
|
||||
MacroFactor, on the other hand, adapts to your eating habits, providing you with tailored goals and occasionally coaching you on what you can improve or change. It simply clicks with me much more than all the other apps I have tried.
|
||||
|
||||
### RP Hypertrophy
|
||||
|
||||
About a year ago, I finally accepted that I needed to build some strength to get my life back. Due to severe health-related issues, I pretty much stopped moving around 2016. I didn’t blow up, but I lost nearly all my muscle. Moving around the house became a chore at times. Combined with some serious joint inflammation, this kept me sedentary.
|
||||
|
||||
No more. I started slowly to build muscle again. At first, I went too quickly, which resulted in weeks of not being able to work out due to inflamed joints. However, in combination with MacroFactor, I have been able to manage my food intake in a way that reduces inflammation while providing enough protein and energy to rebuild my strength.
|
||||
|
||||
The [RP Hypertrophy](https://rpstrength.com/pages/hypertrophy-app) app has been my steadfast companion. There are other exercise apps out there—some cheaper, some more expensive, and some even free—but none of them resonate with me like the RP Hypertrophy app does. The way it allows me to quickly set up a training plan is unparalleled. It also helps me with my progression by analyzing my workout volume. Great! One less thing to think about.
|
||||
|
||||
RP Strength also has a [Diet Coach](https://rpstrength.com/pages/diet-coach-app) app, but for me, MacroFactor works better.
|
||||
|
||||
## Writing
|
||||
|
||||
### Paper
|
||||
|
||||
I recently stumbled across [Paper](https://papereditor.app) as a writing tool, and I really, really like it. I haven’t quite found the justification to pay for it yet. It comes with a hefty price tag in my region (the developer consciously charges more in richer regions of the world). However, I might consider it in the future, depending on whether I start writing professionally again in the coming months. For now, I’m going the cheapskate route and clicking away the nag screens that pop up now and again. Sorry, [Mihhail](https://twitter.com/_mihhail)!
|
||||
|
||||
### Textastic
|
||||
|
||||
I don’t use [Textastic](https://apps.apple.com/de/app/textastic-code-editor/id1049254261) for actual writing, but it is a great general text editor if I need to edit something from my iCloud, modify a file on my server, or whip up a quick Python script or other scripts.
|
||||
|
||||
### AirMail
|
||||
|
||||
My email client of choice is [AirMail](https://airmailapp.com). There’s not much to say about it, really. It works for me.
|
||||
|
||||
## Apps by Readdle
|
||||
|
||||
I use several apps from the Ukrainian developer [Readdle](https://readdle.com/). They tend to deliver a polished experience, and their support is excellent.
|
||||
|
||||
### Calendars
|
||||
|
||||
Their [calendar solution](https://readdle.com/calendars) is top-notch. It supports natural language event creation, the UI is nice, and it works better for me than the native Calendar app on iOS.
|
||||
|
||||
### Scanner
|
||||
|
||||
Their [document scanner](https://readdle.com/scannerpro) works in a very no-nonsense way. It offers great support for de-skewing and straightening out your wonky document photos. It provides automatic OCR and document naming, and you can create workflows—something I haven’t taken advantage of yet, as my needs aren’t that complex.
|
||||
|
||||
### PDF Expert
|
||||
|
||||
Their [PDF reader](https://pdfexpert.com) works great. You can edit and annotate PDFs. Sadly, there is no OCR on iOS or iPadOS yet, but I am told it’s coming.
|
||||
|
||||
## Strongbox
|
||||
|
||||
I used to be a strong [1Password](https://1password.com/) supporter. I bought it way back when I got my first iPhone—an iPhone 4. Since then, I have bought several updates, and when they switched to a subscription model, I purchased the family plan for—I think—two years.
|
||||
|
||||
Then I read a thread on Micro.blog where someone talked about [Strongbox](https://strongboxsafe.com/). I checked it out, installed it, and took advantage of their very generous three-month trial. After a week or so of use, they had won me over, and I happily paid for their lifetime license after the trial period was over.
|
||||
|
||||
Granted, using Strongbox is a little bit more complicated and less streamlined than using 1Password, but their lifetime license costs what I used to pay for 1Password in a year. There is simply no comparison when it comes to value per euro.
|
||||
|
||||
## AI
|
||||
|
||||
### Perplexity
|
||||
|
||||
I use [Perplexity](https://www.perplexity.ai) for searching most of the time instead of doing a Google or DuckDuckGo search. I enjoy getting nicely written summarized results, and if I want to dig deeper, I can simply open the sources Perplexity found for a given topic. I haven’t found any instances where the AI hallucinated an answer, but there have been a few occasions where the suggested follow-up questions were just nonsense.
|
||||
|
||||
### TypingMind
|
||||
|
||||
[TypingMind](https://www.typingmind.com) is a great ChatGPT interface that allows me to use most ChatGPT features without shelling out over $20 a month. It connects via the ChatGPT API, which results in much more reasonable costs. I got myself a premium license and haven’t looked back since.
|
||||
|
||||
### MidJourney
|
||||
|
||||
Generative Imaging. Some people loathe it; I personally love it. [MidJourney](https://www.midjourney.com) is great for quickly generating dozens of variations on an idea, especially since they enabled generation via the website instead of in a Discord chat. We have used it to rapidly create initial drafts and, yes, even final designs for projects, both professional and private.
|
||||
|
||||
## Graphics
|
||||
|
||||
### Affinity Designer 2
|
||||
|
||||
Since I have mostly stepped back from work, we primarily focus on occasional graphic design for local projects, such as flyers, postcards, roll-up flags, and the like.
|
||||
|
||||
[Affinity Designer](https://affinity.serif.com/designer/) is unbeatable in terms of price and the value it offers for this purpose. Additionally, we can use it on the iPad for initial mockups and then continue working on the same file on the Mac. Brilliant!
|
||||
|
||||
### Affinity Photo 2
|
||||
|
||||
It’s pixel-related brother, [Affinity Photo](https://affinity.serif.com/photo/), while not as intuitive and powerful as Photoshop, is still nevertheless our main go-to when it comes to editing images. Plus, it works well together with Designer and also offers the same iPad-to-Mac and back workflow.
|
||||
|
||||
### QR Factory
|
||||
|
||||
Since we switched to a more graphic design-based workflow, we regularly need to create QR codes. While there are many online and free generators available, [QR Factory](https://www.tunabellysoftware.com/qrfactory/) offers a comprehensive suite of QR options in one package. I wouldn’t consider using any other option anymore.
|
||||
|
||||
### Nuke
|
||||
|
||||
Foundry’s [Nuke](https://www.foundry.com/products/nuke-family) is my main workhorse for paid work. Although I don’t do as much as I once did, I am still very happy to pay for an Indie license when the occasional project comes in. Nuke remains the gold standard for compositing.
|
||||
|
||||
### Modo
|
||||
|
||||
Similarly, when I need to do some 3D work, I use my trusty copy of Foundry’s [modo](https://www.foundry.com/products/modo). It still gets me everywhere I need to go—though these days, that isn’t very far.
|
||||
|
||||
## Outbank
|
||||
|
||||
For banking in Germany, this is the way to go. [Outbank](https://outbankapp.com) has the best banking support of any app I’ve tried in the past. The developers had some negative press a couple of years ago related to pricing, subscriptions, and a completely revamped UI design, but I think they have recovered well from that.
|
||||
|
||||
For my money, this is the best way to keep track of your money, at least for European/German users.
|
||||
|
||||
## Etsy and Printful
|
||||
|
||||
I recently discovered [Printful](www.printful.com/de/give-5-get-5/FO7BEA), and it got me interested enough to open our own little [Etsy store](https://bdscribblewear.etsy.com) with designs from the cutting room floor. I mean, why let perfectly good doodles and scribbles go to waste?“
|
||||
|
||||
## IT
|
||||
|
||||
### FE File Explorer
|
||||
|
||||
[FE File Explorer](https://www.skyjos.com/fileexplorer/) is my go-to app when the Files app on iOS won’t suffice. It is also a great FTP client and integrates nicely with our online workflow.
|
||||
|
||||
### ShellFish
|
||||
|
||||
[ShellFish](https://secureshellfish.app) is my preferred SSH client. I have tried a few others in the past, but ShellFish has really stuck with me. It also integrates nicely with Files.app.
|
||||
@@ -0,0 +1,9 @@
|
||||
## School Reunion
|
||||
|
||||
October 15, 2024 Alexander Kucera
|
||||
|
||||
I am leaving for our gymnasium reunion in two days. I haven't seen any of my old school friends in at least ten years. I've never been much of a social person; while I enjoy the company of friends, I'm not particularly good at keeping in touch.
|
||||
|
||||
So, I am essentially meeting a bunch of strangers in four days. I'm not very good at social gatherings where I don't know anyone, so I'm unsure how I feel about the reunion. On one hand, I'm looking forward to it; on the other, I'm really dreading it.
|
||||
|
||||
My health situation doesn't help to make me feel less awkward. Having a stiff neck that is locked at an angle, making my most comfortable stance one that looks at people's crotches, is, well, suboptimal.
|
||||
@@ -0,0 +1,19 @@
|
||||
## Standing Desk
|
||||
|
||||
April 14, 2015 Alexander Kucera
|
||||
|
||||
My workday consists, like pretty much everyone else’s these days, of about 99% sitting in front of a computer followed by more sitting on the couch after work. I recently jumped on the [bandwagon](http://ddg.gg/?q=standing+desk) and decided to stand more often.
|
||||
|
||||
Overall I am trying to stand in the morning and sit in the afternoon, which works out fine most days. Occasionally I’ll switch it around, but standing in the morning has the effect of keeping morning drowsiness at bay.
|
||||
|
||||
I can confirm that concentrating while standing is a bit harder at first, but on the flip side I find that I am much more focused once I managed to find my focus.
|
||||
|
||||
I’m lucky as my desk is already height adjustable. Only by about 10 centimeters or so, but in combination with my height adjustable monitor on a little pedestal it is enough to accommodate a sitting and a standing configuration.
|
||||
|
||||
I also built myself a little table for my keyboard, mouse and a glass of water out of a very nice bamboo slab. I’m kind of proud of it. It feels very smooth and doing the little bit of carpentry was refreshing.
|
||||
|
||||
Having something I built myself also seems to help with daily motivation to actually stand. I had a crude setup before the bamboo table was finished and I noticed that I skipped standing much more often.
|
||||
|
||||
Cost for this little endeavor was about €50, but only because I splurged a bit for a nice wooden slab and some high quality varnish.
|
||||
|
||||
After a few weeks I feel good about this setup and am already thinking about upgrading it from a standing to a walking desk. The costs for a good treadmill that will fit under a desk are considerable though. From my research I gathered that one will come in at around €1000 no matter which brand. This will need some more pondering, but in the end it is probably worth it to get more active.
|
||||
@@ -0,0 +1,55 @@
|
||||
## The expected value of showing up
|
||||
|
||||
August 17, 2026 Alexander Kucera
|
||||
|
||||
"I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high."
|
||||
|
||||
That's the DM that got me into this. Not "you're good enough." Just: most people won't bother, so the odds are better than they look. I'd already turned the invitation down once. Then Roman did the math at me, and I couldn't argue with it.
|
||||
|
||||
The invitation was a coding challenge he runs: build a video game with a single prompt. One message, sent to an AI coding agent in an empty directory. After you hit enter, you don't touch anything. No follow-up questions, no course corrections, no "actually, make it blue." Whatever the agent builds from that one message is your entry. Judges score the game, then break the winning prompt down line by line.
|
||||
|
||||
If you've used an AI assistant recently, you know how wild that constraint is. Half my interactions are "no, that's not what I meant" by message three. Getting a whole game out of one message means everything has to be in the prompt before you start: the goal, the architecture, the definition of done, and the answers to questions the agent hasn't asked yet. The prompt has to steer without a steering wheel.
|
||||
|
||||
## Three brains
|
||||
|
||||
I didn't sit down and think of a game. I asked three different agents to do it for me.
|
||||
|
||||
Same brief to each: a strong game concept for this challenge. Three different harnesses, two different models. And three completely different afternoons.
|
||||
|
||||
Both sessions running GLM-5.2 skipped any deliberation and pitched games on the spot. Both, without comparing notes, pitched roguelikes. Hermes Agent came back with Body Snatcher, a possession game where you're a ghost with one hit point and no attack, and you survive by literally wearing your enemies: twelve of them, each with its own hunting AI and a different move set once it's your body.
|
||||
|
||||
Pi running the same model pitched Underdepths, a classic dungeon crawler in Python: procedurally generated floors, enemies that hunt you through the dark, gear, levels, a dragon at the bottom.
|
||||
|
||||
The third session, running GPT-5.6 Sol, behaved like a different species. It opened a full brainstorm first: forced relationships, morphological analysis, SCAMPER, constraint mapping. Twenty-three ideas, developed and narrowed over four structured phases. What survived was Adaptive Loop, a deterministic strategy puzzle about rotating glass rings to route nutrients through a microbial ecosystem that adapts against you. It's the most original of the three, and I'll admit I don't fully understand it while playing it.
|
||||
|
||||
Three briefs in, I had three concepts and no way to pick. So I didn't.
|
||||
|
||||
## Sixteen runs
|
||||
|
||||
From there, everything standardized. Every build ran the same way: Pi, my coding agent, with all my saved skills switched off, running GPT-5.6 Sol. The only variable left was the prompt itself.
|
||||
|
||||
August 12 to 16. Sixteen complete runs: five passes on Body Snatcher, four on Adaptive Loop, seven on Underdepths. Each pass was a fresh empty directory, one message, hands off. Between passes I rewrote the prompt and let the corpse of the last run decide what to change.
|
||||
|
||||
That cadence, prompt → run → autopsy → prompt, taught me more about directing agents than months of normal back-and-forth work. Because there's no conversation, every failure traces back to something the prompt failed to say. What the corpses taught me:
|
||||
|
||||
**Make the agent build its own verifier first.** The Underdepths prompt never says "make a game." Its opening move: "write a test suite that defines done, then write a build pipeline that dispatches each phase of work to a headless copy of yourself, gates every phase behind those tests, and feeds failures back in." The agent built itself a small factory, and the factory wouldn't let it ship broken floors.
|
||||
|
||||
**Specify what must be true, never how.** The prompts that worked state pass conditions and boundaries: what counts as done, who may touch what. They never prescribe data structures or algorithms. The moment I told an agent how, it stopped thinking and started transcribing.
|
||||
|
||||
**Keep the scars.** One dead run shipped stairs that existed in the map data but were never drawn—you couldn't see the way down. The next prompt carried the line "a prior build shipped stairs only in map data, never drawn. Do not repeat that." Every dead pass left a sentence like that behind. Those scar sentences are the actual prompt engineering.
|
||||
|
||||
**Pin what the model will otherwise optimize away.** Body Snatcher's spec says, in bold, that enemies must never damage each other. Sounds obvious. But the first builds had bombers and turrets clearing whole floors on their own, and suddenly there was no game—just an arena watching itself. Rules that feel trivial to a human are load-bearing, and the only way to know which ones is to watch a run collapse without them.
|
||||
|
||||
## The result
|
||||
|
||||
Three finished games. A possession roguelike in a single HTML file with zero dependencies. A Python dungeon crawler built by an agent-driven factory that passed every one of its own gates. And a deterministic glass-ring ecosystem I can't quite master, generated by the one model that brainstormed before it spoke.
|
||||
|
||||
The challenge rules say one prompt, one entry. I submitted all three games, one uncut video showing all three being played, and told the judges to pick. The whole thing was one experiment anyway: same brief, same process, three prompts. The code is public in the repo; the prompts went to the judges privately, as the rules require.
|
||||
|
||||
I don't know yet how the challenge shakes out. But the meta-lesson already paid for itself. Roman's expected-value argument isn't really about contests. Nearly everything worth entering has a showing-up problem: the field is small because most people talk themselves out of it. I was most people, briefly. Then a two-sentence DM did the math at me.
|
||||
|
||||
The odds are better than they look. Enter the thing.
|
||||
|
||||
* * *
|
||||
|
||||
**Play them:** repo at [git.babylondreams.de/AlexKucer…](https://git.babylondreams.de/AlexKucera/agentic-labs-challenge-submission)
|
||||
@@ -0,0 +1,17 @@
|
||||
## The new Reeder is not for me
|
||||
|
||||
September 8, 2024 Alexander Kucera
|
||||
|
||||
I tried the new Reeder app yesterday for about 20 minutes before deleting it again. It just didn’t fit my needs at all. Or maybe I simply didn’t get it.
|
||||
|
||||
The idea of an endless scrolling timeline stresses me out. No unread count. You mean there is no indication of it ever ending? That sounds stress inducing to no end.
|
||||
|
||||
With my RSS reader (the now called Reeder Classic), I have a ton of feeds that are very high frequency that I only scan to see if something pops out. I have a folder called favorites that I scan more closely. At the end I mark both the „firehose“ and the favorites as read. The posts disappear and I am at ease that I got the most important bits.
|
||||
|
||||
Then I open YouTube take a quick glance at what the homepage suggests. Usually junk. If there is something interesting it goes into my watch later queue. Then I scan my subscriptions. Same deal. Done.
|
||||
|
||||
I do this once a days in the morning. Once.
|
||||
|
||||
During the day I catch up on my Micro.blog feed, which is easy, becausee I only follow a couple of people compared to several hundreds I followed on Twitter.
|
||||
|
||||
I don’t need much morere then this. My past self probably would be all over Tapestry and the new Reeder. In fact, I did use a timeline aggregation app about ten years ago from Realmac Software that is no longer available and whose name I have forgotten. They were way ahead of their time back then. Maybe they should dust it off as well.
|
||||
@@ -0,0 +1,8 @@
|
||||
// swift-tools-version:6.2
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "TextKit2Spike",
|
||||
platforms: [.macOS(.v26)],
|
||||
targets: [.executableTarget(name: "TextKit2Spike")]
|
||||
)
|
||||
@@ -0,0 +1,85 @@
|
||||
// Spike B (#53) — THROWAWAY. AppKit text editor with TextKit2 custom attributes.
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - TextKit2-backed editor (NSTextView with custom attribute re-apply on edit)
|
||||
|
||||
/// NSViewRepresentable wrapper around a scrollable NSTextView, restyling the edited
|
||||
/// paragraph after each edit burst (textDidChange), preserving undo/IME natively.
|
||||
struct EditorPane: NSViewRepresentable {
|
||||
let attributed: NSAttributedString
|
||||
var onEdit: ((String) -> Void)?
|
||||
/// When set, highlight this range (Fix-Card anchor).
|
||||
var anchorHighlight: NSRange?
|
||||
|
||||
func makeNSView(context: Context) -> NSScrollView {
|
||||
let tv = NSTextView()
|
||||
tv.isRichText = false // plain source of truth; attributes are presentation-only
|
||||
tv.allowsUndo = true
|
||||
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||
tv.isAutomaticDashSubstitutionEnabled = false
|
||||
tv.isAutomaticTextReplacementEnabled = false
|
||||
tv.isAutomaticSpellingCorrectionEnabled = false
|
||||
tv.usesFindBar = true
|
||||
tv.backgroundColor = NSColor(white: 0.98, alpha: 1)
|
||||
tv.typingAttributes = ProsePresenter.bodyAttributes
|
||||
tv.delegate = context.coordinator
|
||||
tv.layoutManager?.allowsNonContiguousLayout = true
|
||||
let scroll = NSScrollView()
|
||||
scroll.documentView = tv
|
||||
scroll.hasVerticalScroller = true
|
||||
scroll.autohidesScrollers = true
|
||||
scroll.drawsBackground = true
|
||||
scroll.backgroundColor = NSColor(white: 0.98, alpha: 1)
|
||||
// centered measure: text container inset
|
||||
let containerWidth: CGFloat = 640
|
||||
tv.minSize = NSSize(width: 0, height: 0)
|
||||
tv.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
|
||||
tv.isVerticallyResizable = true
|
||||
tv.isHorizontallyResizable = false
|
||||
tv.autoresizingMask = [.width]
|
||||
tv.textContainer?.containerSize = NSSize(width: containerWidth, height: .greatestFiniteMagnitude)
|
||||
tv.textContainer?.widthTracksTextView = false
|
||||
tv.textContainer?.lineFragmentPadding = 12
|
||||
context.coordinator.textView = tv
|
||||
return scroll
|
||||
}
|
||||
|
||||
func updateNSView(_ scroll: NSScrollView, context: Context) {
|
||||
guard let tv = scroll.documentView as? NSTextView else { return }
|
||||
if context.coordinator.loadedHash != attributed.hash {
|
||||
context.coordinator.loadedHash = attributed.hash
|
||||
tv.textStorage?.setAttributedString(attributed)
|
||||
}
|
||||
applyAnchor(to: tv)
|
||||
}
|
||||
|
||||
private func applyAnchor(to tv: NSTextView) {
|
||||
let storage = tv.textStorage!
|
||||
storage.removeAttribute(.backgroundColor, range: NSRange(location: 0, length: storage.length))
|
||||
guard let anchorHighlight else { return }
|
||||
storage.addAttribute(.backgroundColor, value: NSColor(calibratedRed: 0.79, green: 0.39, blue: 0.26, alpha: 0.18), range: anchorHighlight)
|
||||
tv.scrollRangeToVisible(anchorHighlight)
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator { Coordinator(onEdit: onEdit) }
|
||||
|
||||
final class Coordinator: NSObject, NSTextViewDelegate {
|
||||
let onEdit: ((String) -> Void)?
|
||||
weak var textView: NSTextView?
|
||||
var loadedHash: Int = 0
|
||||
|
||||
init(onEdit: ((String) -> Void)?) { self.onEdit = onEdit }
|
||||
|
||||
func textDidChange(_ notification: Notification) {
|
||||
guard let tv = notification.object as? NSTextView, let storage = tv.textStorage else { return }
|
||||
let sel = tv.selectedRange()
|
||||
// Re-attribute the paragraph(s) touching the selection — one paragraph, one pass.
|
||||
let paragraphRange = (storage.string as NSString).paragraphRange(for: sel)
|
||||
ProsePresenter.reattribute(storage as NSMutableAttributedString, paragraphRange: paragraphRange)
|
||||
// re-dim inline syntax across the edited line (already done in reattribute)
|
||||
tv.typingAttributes = ProsePresenter.bodyAttributes
|
||||
onEdit?(storage.string)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// Spike B (#53): NSTextView/TextKit2 with custom attributes — THROWAWAY, answers a question, not product code.
|
||||
// Question: what does TextKit2 + custom attributes cost and buy for calm prose editing (mode B)?
|
||||
// Run: swift run --package-path spike/textkit2 (from repo root, branch spike/editor-presentation)
|
||||
|
||||
import AppKit
|
||||
|
||||
// MARK: - Markdown presentation (the lift-if-it-wins module)
|
||||
|
||||
/// Line-based markdown presenter for prose: dimmed syntax, heading scale, paragraph spacing.
|
||||
/// Pure functions over text; no AppKit state. Applied post-load and re-applied per edited paragraph.
|
||||
nonisolated enum ProsePresenter {
|
||||
enum LineKind { case heading1, heading2, quote, syntaxOnly, body }
|
||||
|
||||
static func lineKind(_ line: String) -> LineKind {
|
||||
let t = line.drop(while: { $0 == " " })
|
||||
if t.hasPrefix("## ") { return .heading2 }
|
||||
if t.hasPrefix("# ") { return .heading1 }
|
||||
if t.hasPrefix("> ") { return .quote }
|
||||
if !t.isEmpty && t.allSatisfy({ $0 == "*" || $0 == " " || $0 == "-" || $0 == "_" }) { return .syntaxOnly }
|
||||
return .body
|
||||
}
|
||||
|
||||
static let inlineSyntax: Set<Character> = ["*", "_", "`", "[", "]", "(", ")", "!", "<", ">"]
|
||||
|
||||
/// Paragraph spacing + font for a line kind, applied via NSParagraphStyle.
|
||||
static func paragraph(_ kind: LineKind) -> NSParagraphStyle {
|
||||
let p = NSMutableParagraphStyle()
|
||||
switch kind {
|
||||
case .heading1: p.paragraphSpacing = 18; p.paragraphSpacingBefore = 26
|
||||
case .heading2: p.paragraphSpacing = 12; p.paragraphSpacingBefore = 20
|
||||
case .quote: p.paragraphSpacing = 10; p.paragraphSpacingBefore = 10
|
||||
case .syntaxOnly, .body: p.paragraphSpacing = 10
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
/// Attribute a whole text (initial load). Headings/body/quote styling + dimmed inline syntax.
|
||||
static func attribute(_ text: String) -> NSAttributedString {
|
||||
let out = NSMutableAttributedString(string: text, attributes: bodyAttributes)
|
||||
let ns = text as NSString
|
||||
ns.enumerateSubstrings(in: NSRange(location: 0, length: ns.length), options: [.byLines]) { line, range, _, _ in
|
||||
guard let line else { return }
|
||||
let kind = lineKind(line)
|
||||
out.setAttributes(Self.attributes(for: kind), range: range)
|
||||
dimSyntax(in: out, range: range)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/// Attribute one paragraph (editing-time re-apply). Cheap: one line, one pass.
|
||||
static func reattribute(_ out: NSMutableAttributedString, paragraphRange: NSRange) {
|
||||
let line = (out.string as NSString).substring(with: paragraphRange)
|
||||
let kind = lineKind(line)
|
||||
out.setAttributes(Self.attributes(for: kind), range: paragraphRange)
|
||||
dimSyntax(in: out, range: paragraphRange)
|
||||
}
|
||||
|
||||
// Typography: system serif for prose (New York), 17pt body, scaled headings — the web proto's Iowan/Charter stance.
|
||||
static var serif: NSFont { NSFont.systemFont(ofSize: 17, weight: .regular, width: .compressed) }
|
||||
static var bodyFont: NSFont { NSFontManager.shared.font(withFamily: "Iowan Old Style", traits: [], weight: 5, size: 17)
|
||||
?? NSFont.systemFont(ofSize: 17) }
|
||||
|
||||
static var bodyAttributes: [NSAttributedString.Key: Any] { [
|
||||
.font: bodyFont, .paragraphStyle: paragraph(.body), .foregroundColor: NSColor(red: 0.10, green: 0.10, blue: 0.09, alpha: 1),
|
||||
] }
|
||||
|
||||
static func attributes(for kind: LineKind) -> [NSAttributedString.Key: Any] {
|
||||
switch kind {
|
||||
case .heading1: [.font: NSFontManager.shared.font(withFamily: "Iowan Old Style", traits: [.boldFontMask], weight: 9, size: 26) ?? .boldSystemFont(ofSize: 26), .paragraphStyle: paragraph(.heading1)]
|
||||
case .heading2: [.font: NSFontManager.shared.font(withFamily: "Iowan Old Style", traits: [.boldFontMask], weight: 8, size: 20) ?? .boldSystemFont(ofSize: 20), .paragraphStyle: paragraph(.heading2)]
|
||||
case .quote: bodyAttributes
|
||||
case .syntaxOnly, .body: bodyAttributes
|
||||
}
|
||||
}
|
||||
|
||||
/// Dim markdown syntax characters within a line range (marker prefixes + inline marks).
|
||||
static func dimSyntax(in out: NSMutableAttributedString, range: NSRange) {
|
||||
let ns = out.string as NSString
|
||||
guard range.length > 0 else { return }
|
||||
let line = ns.substring(with: range)
|
||||
let kind = lineKind(line)
|
||||
// prefix markers
|
||||
let markerLen: Int
|
||||
switch kind {
|
||||
case .heading1: markerLen = 2
|
||||
case .heading2: markerLen = 3
|
||||
case .quote: markerLen = 2
|
||||
default: markerLen = 0
|
||||
}
|
||||
let dim: [NSAttributedString.Key: Any] = [.foregroundColor: NSColor(white: 0.55, alpha: 1), .font: NSFont.monospacedSystemFont(ofSize: 13, weight: .regular)]
|
||||
if markerLen > 0 { out.addAttributes(dim, range: NSRange(location: range.location, length: min(markerLen, range.length))) }
|
||||
// inline marks in body/quote
|
||||
if kind == .body || kind == .quote {
|
||||
for (offset, ch) in line.utf16.enumerated() {
|
||||
if let c = Unicode.Scalar(ch).map({ Character($0) }), inlineSyntax.contains(c) {
|
||||
out.addAttributes(dim, range: NSRange(location: range.location + offset, length: 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Quote anchor (Fix-Card feasibility note for the ADR)
|
||||
|
||||
/// Word-tokenized, whitespace/punctuation-tolerant search for `quote` in `text`.
|
||||
/// Returns nil when not found — the stale-anchor case. O(n·m) worst case, fine at 3k words.
|
||||
static func anchorRange(of quote: String, in text: String) -> NSRange? {
|
||||
let textWords = words(text)
|
||||
let quoteWords = words(quote)
|
||||
guard !quoteWords.isEmpty, textWords.count >= quoteWords.count else { return nil }
|
||||
for start in 0...(textWords.count - quoteWords.count) {
|
||||
if (start..<start + quoteWords.count).allSatisfy({ textWords[$0].norm == quoteWords[$0 - start].norm }) {
|
||||
let from = textWords[start].range.lowerBound
|
||||
let to = textWords[start + quoteWords.count - 1].range.upperBound
|
||||
let loc = text.utf16.distance(from: text.startIndex, to: from)
|
||||
let len = text.utf16.distance(from: from, to: to)
|
||||
return NSRange(location: loc, length: len)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private struct Word { let norm: String; let range: Range<String.Index> }
|
||||
private static func words(_ s: String) -> [Word] {
|
||||
s.split(whereSeparator: \.isWhitespace).map { sub in
|
||||
Word(norm: sub.lowercased().trimmingCharacters(in: .punctuationCharacters), range: sub.startIndex ..< sub.endIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Spike B (#53) — THROWAWAY. Window shell: editor + reading toggle + Fix-Card anchor demo.
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SpikeApp: App {
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
|
||||
var body: some Scene {
|
||||
Window("Spike B — TextKit2", id: "main") {
|
||||
ContentView()
|
||||
.frame(minWidth: 900, minHeight: 640)
|
||||
.onAppear { NSApp.activate(ignoringOtherApps: true) }
|
||||
}
|
||||
.windowStyle(.hiddenTitleBar)
|
||||
}
|
||||
|
||||
// ponytail: one runnable check for the anchor logic — `swift run TextKit2Spike --check`
|
||||
init() {
|
||||
if CommandLine.arguments.contains("--check") { Self.selfCheck(); exit(0) }
|
||||
}
|
||||
|
||||
static func selfCheck() {
|
||||
let text = try! String(contentsOfFile: "spike/prose/the-expected-value-of-showing.md", encoding: .utf8)
|
||||
let quote = "“I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.”"
|
||||
guard let r = ProsePresenter.anchorRange(of: quote, in: text) else {
|
||||
print("FAIL: live quote not found"); return
|
||||
}
|
||||
let found = (text as NSString).substring(with: r)
|
||||
assert(found.count > 50 && text.contains(found.trimmingCharacters(in: .whitespacesAndNewlines)))
|
||||
// whitespace-tolerant: join with single spaces, must still match
|
||||
let squished = quote.components(separatedBy: .newlines).joined(separator: " ")
|
||||
assert(ProsePresenter.anchorRange(of: squished, in: text) != nil, "FAIL: whitespace-tolerant match")
|
||||
// stale anchor: deleted text
|
||||
assert(ProsePresenter.anchorRange(of: "this quote was deleted years ago", in: text) == nil, "FAIL: stale should be nil")
|
||||
// reading blocks: heading detected, markup hidden
|
||||
let blocks = SpikeApp.readingBlocks(text)
|
||||
assert(String(blocks[0].text.characters).hasPrefix("The expected value"), "FAIL: H1 block")
|
||||
assert(blocks.allSatisfy { !String($0.text.characters).contains("#") }, "FAIL: markup leaked into reading view")
|
||||
// perf smoke: PERF-3k anchor timing
|
||||
let perf = (try? String(contentsOfFile: "spike/prose/PERF-3k.md", encoding: .utf8)) ?? text
|
||||
let t0 = DispatchTime.now()
|
||||
_ = ProsePresenter.anchorRange(of: "The odds are better than they look", in: perf)
|
||||
let ms = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1e6
|
||||
print("PASS: anchor found @ \(r.location), len \(r.length); PERF-3k anchor search \(String(format: "%.1f", ms)) ms")
|
||||
}
|
||||
|
||||
// ponytail: blank-line split + inline parse per block; no AST. Setext/list blocks not handled — corpus has none.
|
||||
static func readingBlocks(_ md: String) -> [(level: Int, text: AttributedString)] {
|
||||
md.components(separatedBy: "\n\n").map { para in
|
||||
var level = 0, p = para.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if p.hasPrefix("#") {
|
||||
let hashes = p.prefix { $0 == "#" }.count
|
||||
p = String(p.dropFirst(hashes)).trimmingCharacters(in: .whitespaces)
|
||||
level = hashes
|
||||
}
|
||||
let attr = (try? AttributedString(markdown: p)) ?? AttributedString(p)
|
||||
return (level, attr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var text: String
|
||||
@State private var reading = false
|
||||
@State private var anchor: NSRange?
|
||||
@State private var staleShown = false
|
||||
@State private var loadMs: Double = 0
|
||||
@State private var doc: NSAttributedString
|
||||
|
||||
// calibration piece default; PERF-3k via arg
|
||||
init() {
|
||||
let args = CommandLine.arguments
|
||||
let path = args.count > 1 ? args[1] : "spike/prose/the-expected-value-of-showing.md"
|
||||
let t = (try? String(contentsOfFile: path, encoding: .utf8))
|
||||
?? (try? String(contentsOfFile: "spike/prose/the-expected-value-of-showing.md", encoding: .utf8))
|
||||
?? "# Spike B\n\n(No corpus file found — run from repo root.)"
|
||||
_text = State(initialValue: t)
|
||||
_doc = State(initialValue: ProsePresenter.attribute(t))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
bar
|
||||
Divider()
|
||||
if reading {
|
||||
ScrollView([.vertical]) {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
ForEach(Array(SpikeApp.readingBlocks(text).enumerated()), id: \.offset) { _, block in
|
||||
Text(block.text)
|
||||
.font(block.level > 0
|
||||
? .system(size: CGFloat(32 - block.level * 3), weight: .bold, design: .serif)
|
||||
: .system(size: 17))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: 720, alignment: .leading)
|
||||
.padding(.horizontal, 40)
|
||||
.padding(.vertical, 24)
|
||||
}
|
||||
} else {
|
||||
EditorPane(attributed: doc, onEdit: { newText in
|
||||
text = newText
|
||||
}, anchorHighlight: anchor)
|
||||
}
|
||||
}
|
||||
.alert("Anchor not found", isPresented: $staleShown) {
|
||||
Button("OK", role: .cancel) {}
|
||||
} message: {
|
||||
Text("The Post changed after this Fix Card was issued; no text was selected or changed.")
|
||||
}
|
||||
}
|
||||
|
||||
private var bar: some View {
|
||||
HStack(spacing: 12) {
|
||||
Toggle("Reading", isOn: $reading)
|
||||
Divider().frame(height: 14)
|
||||
Button("Anchor: DM quote") { applyAnchor(#"“I'm not too sure that many people will compete. So, the expected value of joining is actually pretty high.”"#) }
|
||||
Button("Stale anchor") { applyAnchor("this quote was deleted from the text") }
|
||||
if let a = anchor { Text("anchored @ \(a.location)–\(a.location + a.length)").foregroundStyle(.secondary).font(.caption) }
|
||||
Spacer()
|
||||
Text("load \(String(format: "%.1f", loadMs)) ms").foregroundStyle(.secondary).font(.caption)
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
|
||||
private func applyAnchor(_ quote: String) {
|
||||
let t0 = DispatchTime.now()
|
||||
let r = ProsePresenter.anchorRange(of: quote, in: text)
|
||||
let ms = Double(DispatchTime.now().uptimeNanoseconds - t0.uptimeNanoseconds) / 1_000_000
|
||||
loadMs = ms
|
||||
if let r {
|
||||
anchor = r
|
||||
} else {
|
||||
anchor = nil
|
||||
staleShown = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ponytail: bare SPM executable gets .accessory activation — no window. Set policy BEFORE scenes build.
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
}
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
@@ -0,0 +1,24 @@
|
||||
#!/bin/zsh
|
||||
# ponytail: wrap the SPM binary in a minimal .app — SwiftUI needs a bundle to make windows.
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
swift build 2>&1 | tail -1
|
||||
APP=.build/TextKit2Spike.app
|
||||
rm -rf "$APP" && mkdir -p "$APP/Contents/MacOS"
|
||||
cp .build/out/Products/Debug/TextKit2Spike "$APP/Contents/MacOS/"
|
||||
cat > "$APP/Contents/Info.plist" <<'PLIST'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key><string>TextKit2Spike</string>
|
||||
<key>CFBundleIdentifier</key><string>de.babylondreams.museion.spike-b</string>
|
||||
<key>CFBundleName</key><string>Spike B — TextKit2</string>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>LSMinimumSystemVersion</key><string>26.0</string>
|
||||
<key>NSHighResolutionCapable</key><true/>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
echo "built: $APP"
|
||||
exec "$APP/Contents/MacOS/TextKit2Spike" "${@:-../../prose/the-expected-value-of-showing.md}"
|
||||