diff --git a/.github/workflows/macos-app.yml b/.github/workflows/macos-app.yml index d60c82f1..aef662ac 100644 --- a/.github/workflows/macos-app.yml +++ b/.github/workflows/macos-app.yml @@ -81,10 +81,19 @@ jobs: version: "0.13.0" python-version: "3.13" - name: Swift transport regressions and native build + env: + SUPERQODE_FACTORY_PREVIEW_DIR: ${{ runner.temp }}/factory-previews run: | echo "::add-matcher::.github/matchers/swift.json" set -o pipefail swift test --build-system native --package-path apps/macos -c release 2>&1 | tee "$RUNNER_TEMP/superqode-swift-tests.log" + - name: Upload Factory native previews + if: always() + uses: actions/upload-artifact@v4 + with: + name: factory-native-previews + path: ${{ runner.temp }}/factory-previews/*.png + if-no-files-found: ignore - name: Report native test failures in check annotations if: failure() run: | @@ -171,6 +180,7 @@ jobs: with: name: native-smoke-report path: | + ${{ runner.temp }}/factory-previews/*.png apps/macos/artifacts/smoke-report.json apps/macos/artifacts/navigation-main-thread-sample.txt apps/macos/artifacts/native-app-stderr.log diff --git a/apps/macos/BETA-NOTES.md b/apps/macos/BETA-NOTES.md index cc35b3e0..1f37b7b3 100644 --- a/apps/macos/BETA-NOTES.md +++ b/apps/macos/BETA-NOTES.md @@ -1,4 +1,13 @@ -# SuperQode for macOS public beta 0.5.2 +# SuperQode for macOS public beta 0.5.3 + +Version 0.5.3 (build 60) bundles Python engine 2.33.3. + +- Factory Describe now opens with a focused, five-step journey: Describe, Connect, Review, Run and Verify. An interactive map shows your location and evidence-based milestones; detailed setup and all workflow starters remain available under Advanced setup. +- Added **Watch a Factory work**, an interactive presentation available from Welcome and Factory Studio without a project or model connection. Play, pause, step back or restart a checkout-total repair, and approve the demo's human-review step before the illustrated verification continues. +- Presentation mode stays labelled **Scripted demo**, makes no model calls, changes no files and creates no quality record or release authority. Its final step can create the existing real sample for an actual agent trial. +- Added animated transitions, active-step feedback, keyboard demo controls and Reduce Motion support. The progress strip no longer duplicates the guided Describe map. + +## 0.5.2 (build 59) Version 0.5.2 (build 59) bundles Python engine 2.33.3. diff --git a/apps/macos/README.md b/apps/macos/README.md index 43d5d813..448fc6fa 100644 --- a/apps/macos/README.md +++ b/apps/macos/README.md @@ -33,6 +33,25 @@ ACP session after setup exits successfully. On the welcome guide, **Build your factory** opens Factory Studio for the project you already have open. With no project open, it asks you to choose a folder first. +## Guided Factory setup and presentation demo + +Factory Studio's Describe page shows one step at a time: Describe, Connect, +Review, Run and Verify. Use the map to revisit a step. Model selection, source +review, protected acceptance, worker execution and release decisions keep their +existing engine contracts. Advanced setup contains the detailed model controls, +local draft recovery and all workflow starters. + +Choose **Play demo** from Welcome, or **Demo** in Factory Studio, to present the +checkout-total Factory without opening a repository or connecting a model. +Use Play/Pause, Next, Back and Restart; Left/Right arrows step through the story +and Escape closes it. Playback stops at Human review until you choose **Approve +demo repair**. Motion respects the macOS Reduce Motion setting, and playback +pauses when the window loses focus. + +This is a scripted illustration with zero model calls and zero file changes. +Its results do not create SuperGauge evidence or authorize a release. At the end, +you can explicitly create a disposable real sample and run a normal agent trial. + ## Start coding 1. Open the DMG, drag SuperQode to Applications and launch it from Applications. diff --git a/apps/macos/Sources/SuperQode/FactoryDemoStartView.swift b/apps/macos/Sources/SuperQode/FactoryDemoStartView.swift index c2943243..c506aebb 100644 --- a/apps/macos/Sources/SuperQode/FactoryDemoStartView.swift +++ b/apps/macos/Sources/SuperQode/FactoryDemoStartView.swift @@ -3,6 +3,7 @@ import AppKit /// A new sample directory only. Creation never calls a model or starts a worker. struct FactoryDemoStartView: View { + var onCreated: (() -> Void)? = nil @EnvironmentObject private var app: Workspace @State private var creating = false @State private var createdPath = "" @@ -28,6 +29,7 @@ struct FactoryDemoStartView: View { guard !createdPath.isEmpty else { throw EngineError(message: "The sample directory was not returned.") } if app.projectID == project, app.section == section, app.showWelcome == welcome { try await app.open(createdPath, landing: .factory) + onCreated?() } } catch { failure = error.localizedDescription } } diff --git a/apps/macos/Sources/SuperQode/FactoryFlowMap.swift b/apps/macos/Sources/SuperQode/FactoryFlowMap.swift new file mode 100644 index 00000000..7cfc3a52 --- /dev/null +++ b/apps/macos/Sources/SuperQode/FactoryFlowMap.swift @@ -0,0 +1,59 @@ +import SwiftUI + +struct FactoryFlowNode: Identifiable { + let id: Int + let title: String + let symbol: String + let completed: Bool +} + +/// The selected node is a page, not a claim that its work has completed. +struct FactoryFlowMap: View { + let nodes: [FactoryFlowNode] + let selection: Int + var working = false + var enabled = true + var onSelect: ((Int) -> Void)? + @Environment(\.accessibilityReduceMotion) private var reduceMotion + + var body: some View { + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 8) { + ForEach(nodes) { node in + if node.id != nodes.first?.id { + Image(systemName: "chevron.right").font(.caption2).foregroundStyle(.tertiary) + } + Button { onSelect?(node.id) } label: { + VStack(spacing: 6) { + ZStack { + RoundedRectangle(cornerRadius: 16) + .fill(node.id == selection ? Brand.purple.opacity(0.14) : Color.primary.opacity(0.035)) + RoundedRectangle(cornerRadius: 16) + .strokeBorder(node.id == selection ? Brand.purple.opacity(0.65) : Color.primary.opacity(0.08), lineWidth: node.id == selection ? 2 : 1) + Image(systemName: node.completed ? "checkmark" : node.symbol) + .font(.system(size: 21, weight: .medium)) + .foregroundStyle(node.completed ? Color.green : node.id == selection ? Brand.purple : Color.secondary) + .symbolEffect(.pulse, options: .repeating, isActive: working && node.id == selection && !reduceMotion) + }.frame(width: 52, height: 52) + Text(node.title).font(.caption.weight(node.id == selection ? .semibold : .regular)) + .foregroundStyle(node.id == selection ? Color.primary : Color.secondary) + }.frame(minWidth: 76).padding(.vertical, 4) + .contentShape(Rectangle()) + }.buttonStyle(FactoryFlowButtonStyle()) + .disabled(onSelect == nil || !enabled) + .accessibilityLabel(node.title + (node.completed ? ", completed" : node.id == selection ? ", selected" : "")) + } + }.padding(.horizontal, 2) + } + .animation(reduceMotion ? nil : .spring(response: 0.35, dampingFraction: 0.8), value: selection) + .accessibilityIdentifier("factory.flow.map") + } +} + +private struct FactoryFlowButtonStyle: ButtonStyle { + @Environment(\.accessibilityReduceMotion) private var reduceMotion + func makeBody(configuration: Configuration) -> some View { + configuration.label.scaleEffect(configuration.isPressed && !reduceMotion ? 0.96 : 1) + .animation(reduceMotion ? nil : .spring(response: 0.22, dampingFraction: 0.7), value: configuration.isPressed) + } +} diff --git a/apps/macos/Sources/SuperQode/FactoryGuidedBuilderView.swift b/apps/macos/Sources/SuperQode/FactoryGuidedBuilderView.swift new file mode 100644 index 00000000..54eba6dc --- /dev/null +++ b/apps/macos/Sources/SuperQode/FactoryGuidedBuilderView.swift @@ -0,0 +1,267 @@ +import SwiftUI + +/// A focused front door over the existing Factory engine and source editor. +struct FactoryGuidedBuilderView: View { + @EnvironmentObject private var app: Workspace + @Environment(\.accessibilityReduceMotion) private var reduceMotion + @ObservedObject var studio: FactoryStudioLibrary + @Binding var step: FactoryJourneyStep + @Binding var trialGoal: String + let setup: FactorySetupState + let idle: Bool + let onBuild: () -> Void + let onStarter: (String) -> Void + let onValidate: () -> Void + let onSave: () -> Void + let onTrial: () -> Void + let onDemo: () -> Void + var inspectAutomatically = true + + private var execution: [[String: Any]] { studio.modelSetup.execution } + private var modelsConfigured: Bool { !execution.isEmpty && execution.allSatisfy { $0["eligible"] as? Bool == true } } + private var connected: Bool { !app.provider.isEmpty && app.provider != "acp" && !app.model.isEmpty } + private var inspectionID: String { + studio.project + "\n" + String(studio.version) + "\n" + studio.modelSetup.draftingReference + "\n" + + studio.runs.map { string($0, "id") + string($0, "status") + String($0["verification_valid"] as? Bool ?? false) }.joined(separator: "\n") + } + + var body: some View { + VStack(alignment: .leading, spacing: 16) { + HStack(alignment: .top) { + VStack(alignment: .leading, spacing: 6) { + if step == .intent { + Text("Build your Factory, one step at a time.").font(.title2.bold()) + Text("Describe the outcome. Review what runs. Keep the evidence.") + .font(.callout).foregroundStyle(.secondary) + } else { + Text("Your Factory").font(.headline) + Text(studio.description.isEmpty ? "Configure a small, verifiable workflow." : studio.description) + .font(.caption).foregroundStyle(.secondary).lineLimit(1) + } + } + Spacer(minLength: 12) + Button { onDemo() } label: { Label("Watch a demo", systemImage: "play.rectangle") } + .accessibilityIdentifier("factory.journey.demo") + } + FactoryFlowMap(nodes: FactoryJourneyStep.allCases.map { + FactoryFlowNode(id: $0.rawValue, title: $0.title, symbol: $0.symbol, completed: completed($0)) + }, selection: step.rawValue, working: studio.busy || studio.setupChecking || studio.modelSetup.checking, enabled: idle, onSelect: { index in + guard idle, let target = FactoryJourneyStep(rawValue: index) else { return } + step = target + }) + HStack(spacing: 6) { + Text("STEP \(step.rawValue + 1) OF 5").font(.caption2.weight(.bold)).tracking(1.2) + Spacer() + if studio.busy || studio.setupChecking || studio.modelSetup.checking { + ProgressView().controlSize(.small) + Text(studio.busy ? "Preparing your draft…" : "Checking setup…").font(.caption) + } + }.foregroundStyle(.secondary) + Group { + switch step { + case .intent: intent + case .models: models + case .review: review + case .trial: trial + case .evidence: evidence + } + }.id(step) + .transition(reduceMotion ? .identity : .opacity.combined(with: .move(edge: .trailing))) + HStack { + if step != .intent { + Button { step = FactoryJourneyStep(rawValue: step.rawValue - 1) ?? .intent } label: { + Label("Back", systemImage: "chevron.left") + }.disabled(!idle) + } + Spacer() + Text("Your Factory stays editable as code.").font(.caption).foregroundStyle(.secondary) + } + }.padding(20).brandSurface() + .animation(reduceMotion ? nil : .spring(response: 0.38, dampingFraction: 0.88), value: step) + .accessibilityIdentifier("factory.journey") + .onAppear { + if step == .intent { + step = .suggested(saved: setup.saved, trialPrepared: setup.trialPrepared, verified: setup.hasCompletedRun) + } + } + .task(id: inspectionID) { + guard inspectAutomatically else { return } + do { try await Task.sleep(for: .milliseconds(300)) } catch { return } + guard !Task.isCancelled, !studio.project.isEmpty else { return } + await studio.modelSetup.inspect(engine: app.engine, yaml: studio.text) + guard !Task.isCancelled else { return } + await studio.inspectGettingStarted(engine: app.engine) + } + .onChange(of: studio.project) { _, _ in + step = .intent + } + .onChange(of: setup.saved) { _, saved in + if saved, step == .review { step = .trial } + } + .onChange(of: setup.hasCompletedRun) { _, verified in + if verified, step == .trial { step = .evidence } + } + } + + private var intent: some View { + VStack(alignment: .leading, spacing: 12) { + title("What would you like to build?", "Start with an outcome. You can refine every stage later.") + TextField("For example: fix incoming bugs and verify every change", text: $studio.description, axis: .vertical) + .lineLimit(2...4).textFieldStyle(.roundedBorder).font(.title3) + .accessibilityIdentifier("factory.journey.intent") + ViewThatFits(in: .horizontal) { + HStack { intentSuggestions } + VStack(alignment: .leading) { intentSuggestions } + } + HStack(spacing: 12) { + Button("Choose how to build →") { step = .models } + .buttonStyle(BrandButtonStyle()) + .disabled(!idle || studio.description.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) + .accessibilityIdentifier("factory.journey.continue") + Button("Use Fix and verify") { onStarter("fix-and-verify") }.disabled(!idle) + } + } + } + @ViewBuilder private var intentSuggestions: some View { + ForEach(["Fix bugs and verify the repair", "Triage, specify and build features", "Deliver small improvements continuously"], id: \.self) { value in + Button(value) { studio.description = value }.controlSize(.small).disabled(!idle) + } + } + private var models: some View { + VStack(alignment: .leading, spacing: 12) { + title("Choose your starting point.", "A model can help draft the Factory. Its stages keep their own execution bindings.") + HStack(spacing: 12) { + connection("Local model", detail: "Use a model on your machine.", symbol: "desktopcomputer", source: "source:local") + connection("Frontier model", detail: "Use your own API key.", symbol: "cloud", source: "source:key") + } + if connected { + Button { + studio.modelSetup.useConnected(provider: app.provider, model: app.model, harness: app.harness) + } label: { Label("Draft with " + app.provider + "/" + app.model, systemImage: "sparkles") } + .disabled(!idle).accessibilityIdentifier("factory.journey.useConnected") + } + HStack { + Image(systemName: studio.modelSetup.draftingReference.isEmpty ? "bolt.slash" : "cpu") + Text(studio.modelSetup.draftingReference.isEmpty ? "Repository inspection · no drafting-model call" : studio.modelSetup.draftingReference) + .font(.callout).textSelection(.enabled) + Spacer() + if !studio.modelSetup.draftingReference.isEmpty { + Button("Check") { + Task { await studio.modelSetup.inspect(engine: app.engine, yaml: studio.text, checkConnections: true) } + }.disabled(!idle) + Button("Clear") { studio.modelSetup.draftingReference = "" }.disabled(!idle) + } + }.padding(10).background(Brand.purple.opacity(0.06), in: RoundedRectangle(cornerRadius: 12)) + if studio.modelSetup.draftingBlocked { + Text(string(studio.modelSetup.drafting, "message")).font(.caption).foregroundStyle(.orange) + Button("Review model permissions") { studio.navigation.select("Configuration") } + } + Button("Inspect repository & build a draft…") { onBuild() } + .buttonStyle(BrandButtonStyle()).disabled(!idle) + .accessibilityIdentifier("factory.journey.build") + Text("You review the proposal before saving. Connecting a provider alone never permits cloud use.") + .font(.caption).foregroundStyle(.secondary) + } + } + private var review: some View { + VStack(alignment: .leading, spacing: 12) { + title("Make it yours. Then save.", "Check the workflow, models and protected expectations before any agent runs.") + LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], spacing: 10) { + reviewTile("Workflow", value: studio.review.isEmpty ? "Check to preview" : "\((studio.review["stages"] as? [[String: Any]] ?? []).count) stages", symbol: "point.3.connected.trianglepath.dotted", destination: "Workflow") + reviewTile("Execution models", value: modelsConfigured ? "Bindings configured" : "Choose models", symbol: "cpu", destination: "Configuration") + reviewTile("Acceptance", value: setup.hasProtectedChecks ? "Protected checks configured" : "Add protected checks", symbol: "lock.shield", destination: "Acceptance") + reviewTile("Source & definition", value: setup.saved ? "Revision saved" : "Review your draft", symbol: "doc.text", destination: "Definition") + } + HStack(spacing: 12) { + if !setup.validated { + Button("Check my Factory") { onValidate() }.buttonStyle(BrandButtonStyle()).disabled(!idle || studio.text.isEmpty) + } else if !setup.saved { + Button("Review & save…") { onSave() }.buttonStyle(BrandButtonStyle()).disabled(!idle) + } else { + Button("Continue to a trial →") { step = .trial }.buttonStyle(BrandButtonStyle()).disabled(!idle) + } + Label(setup.validated ? "Definition checked" : "Validation makes no model calls", systemImage: setup.validated ? "checkmark.circle" : "bolt.slash") + .font(.caption).foregroundStyle(.secondary) + } + } + } + private var trial: some View { + VStack(alignment: .leading, spacing: 12) { + title("Try one small, real task.", "A trial pins the inputs. Running its worker is a separate, confirmed action.") + if !setup.saved { + setupAction("Save the reviewed Factory first.", button: "Review the draft", destination: "Definition") + } else if !setup.hasProtectedChecks { + setupAction("Define the finish line with protected acceptance checks.", button: "Set up acceptance", destination: "Acceptance") + } else if !setup.committed { + setupAction("Review and commit or isolate Factory source changes.", button: "Review source changes", destination: "Sources") + } else if setup.trialPrepared { + setupAction("Your trial is prepared. Run its ready stages and review any human gates.", button: "Open the active trial", destination: "Runs") + } else { + TextField("What should this trial accomplish?", text: $trialGoal, axis: .vertical) + .lineLimit(2...3).textFieldStyle(.roundedBorder) + if !string(studio.gettingStarted, "demo_goal").isEmpty { + Button("Use the sample repair task") { trialGoal = string(studio.gettingStarted, "demo_goal") } + } + Button("Prepare my trial…") { onTrial() }.buttonStyle(BrandButtonStyle()) + .disabled(!idle || trialGoal.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) + } + Button("See what a run looks like first") { onDemo() } + .disabled(!idle) + } + } + private var evidence: some View { + VStack(alignment: .leading, spacing: 12) { + Image(systemName: setup.hasCompletedRun ? "checkmark.shield.fill" : "checkmark.shield") + .font(.system(size: 46)).foregroundStyle(setup.hasCompletedRun ? Color.green : Brand.purple) + title(setup.hasCompletedRun ? "A verified trial. Evidence you can inspect." : "Verification is the finish line.", + setup.hasCompletedRun ? "Inspect the changed files, protected checks and reported usage. Production release still needs your approval." : "A completed coding task needs protected verification. Review its evidence and resolve any held checks.") + HStack { + Button("Inspect trial & evidence") { studio.navigation.select("Runs") }.buttonStyle(BrandButtonStyle()).disabled(!idle) + if setup.hasCompletedRun { Button("Compare an improvement") { studio.navigation.select("Improve") }.disabled(!idle) } + } + } + } + private func completed(_ item: FactoryJourneyStep) -> Bool { + switch item { + case .intent: setup.saved || (setup.hasDraft && !studio.description.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) + case .models: setup.hasCompletedRun || (modelsConfigured && execution.allSatisfy { string($0, "state") != "unchecked" }) + case .review: setup.saved && setup.hasProtectedChecks && setup.committed + case .trial: setup.trialPrepared + case .evidence: setup.hasCompletedRun + } + } + private func title(_ headline: String, _ detail: String) -> some View { + VStack(alignment: .leading, spacing: 7) { + Text(headline).font(.title2.bold()) + Text(detail).font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true) + } + } + private func connection(_ title: String, detail: String, symbol: String, source: String) -> some View { + Button { app.openConnections(source, returningTo: "Factory Studio") } label: { + VStack(alignment: .leading, spacing: 8) { + Image(systemName: symbol).font(.title2).foregroundStyle(Brand.purple) + Text(title).font(.headline) + Text(detail).font(.caption).foregroundStyle(.secondary) + }.frame(maxWidth: .infinity, minHeight: 66, alignment: .leading).padding(14) + }.buttonStyle(ConnectionChoiceStyle(selected: false)).disabled(!idle) + } + private func reviewTile(_ title: String, value: String, symbol: String, destination: String) -> some View { + Button { studio.navigation.select(destination) } label: { + HStack(alignment: .top, spacing: 10) { + Image(systemName: symbol).foregroundStyle(Brand.purple) + VStack(alignment: .leading, spacing: 5) { + Text(title).font(.subheadline.bold()) + Text(value).font(.caption).foregroundStyle(.secondary) + } + Spacer(minLength: 0) + Image(systemName: "chevron.right").font(.caption2).foregroundStyle(.secondary) + }.padding(16).frame(maxWidth: .infinity, minHeight: 65, alignment: .leading) + }.buttonStyle(ConnectionChoiceStyle(selected: false)).disabled(!idle) + } + private func setupAction(_ detail: String, button: String, destination: String) -> some View { + VStack(alignment: .leading, spacing: 14) { + Label(detail, systemImage: "arrow.turn.down.right").font(.callout) + Button(button) { studio.navigation.select(destination) }.buttonStyle(BrandButtonStyle()).disabled(!idle) + }.padding(20).frame(maxWidth: .infinity, alignment: .leading).background(Brand.purple.opacity(0.06), in: RoundedRectangle(cornerRadius: 16)) + } +} diff --git a/apps/macos/Sources/SuperQode/FactoryPresentationLaunchCard.swift b/apps/macos/Sources/SuperQode/FactoryPresentationLaunchCard.swift new file mode 100644 index 00000000..47f179d2 --- /dev/null +++ b/apps/macos/Sources/SuperQode/FactoryPresentationLaunchCard.swift @@ -0,0 +1,27 @@ +import SwiftUI + +struct FactoryPresentationLaunchCard: View { + @Environment(\.accessibilityReduceMotion) private var reduceMotion + @State private var showing = false + @State private var hovering = false + var body: some View { + HStack(spacing: 18) { + FactoryStudioEmblem(size: 48) + .rotationEffect(.degrees(hovering && !reduceMotion ? 6 : 0)) + VStack(alignment: .leading, spacing: 5) { + Text("See a Factory in action").font(.headline) + Text("Follow a repair from request to human review and verification.") + .font(.callout).foregroundStyle(.secondary) + Text("Interactive, scripted demo · No project or API key needed") + .font(.caption).foregroundStyle(.secondary) + } + Spacer(minLength: 8) + Button { showing = true } label: { Label("Play demo", systemImage: "play.fill") } + .buttonStyle(BrandButtonStyle()) + .accessibilityIdentifier("welcome.factoryPresentation") + }.padding(22).brandSurface() + .onHover { hovering = $0 } + .animation(reduceMotion ? nil : .spring(response: 0.4, dampingFraction: 0.7), value: hovering) + .sheet(isPresented: $showing) { FactoryPresentationView() } + } +} diff --git a/apps/macos/Sources/SuperQode/FactoryPresentationState.swift b/apps/macos/Sources/SuperQode/FactoryPresentationState.swift new file mode 100644 index 00000000..47a99f2d --- /dev/null +++ b/apps/macos/Sources/SuperQode/FactoryPresentationState.swift @@ -0,0 +1,107 @@ +import Foundation + +/// Presentation playback has no engine, filesystem or release authority. +struct FactoryPresentationState: Equatable { + enum Stage: Int, CaseIterable, Identifiable { + case request, investigate, repair, review, verify, complete + var id: Int { rawValue } + var title: String { + switch self { + case .request: "Request" + case .investigate: "Investigate" + case .repair: "Repair" + case .review: "Human review" + case .verify: "Verify" + case .complete: "Evidence" + } + } + var symbol: String { + switch self { + case .request: "text.bubble" + case .investigate: "magnifyingglass" + case .repair: "hammer" + case .review: "hand.raised" + case .verify: "checkmark.shield" + case .complete: "doc.text.magnifyingglass" + } + } + var headline: String { + switch self { + case .request: "A small request. A clear finish line." + case .investigate: "Find the defect before changing code." + case .repair: "A focused repair, ready for review." + case .review: "The factory waits for you." + case .verify: "Test the repair against protected expectations." + case .complete: "See the evidence behind the result." + } + } + var detail: String { + switch self { + case .request: "The checkout total shows only the last item. Add every amount, including discounts and an empty basket." + case .investigate: "Two amounts, 2 and 3, produce 3. The expected total is 5. A protected case captures that difference." + case .repair: "The loop replaces the running total. Accumulating each value fixes the behavior with one changed line." + case .review: "Inspect the proposed change. This demo pauses here until you approve the illustrated repair." + case .verify: "Multiple items, discounts and an empty basket all meet their expectations in this scripted example." + case .complete: "One changed line, three illustrated passing cases and an approved demo review. A real trial supplies actual usage and verification evidence." + } + } + } + private(set) var stage: Stage = .request + private(set) var playing = false + private(set) var reviewApproved = false + private(set) var playbackID = 0 + var waitingForReview: Bool { stage == .review && !reviewApproved } + var canAdvance: Bool { stage != .complete && !waitingForReview } + + mutating func play() { + guard stage != .complete, !waitingForReview else { return } + playing = true; playbackID += 1 + } + mutating func pause() { playing = false; playbackID += 1 } + @discardableResult mutating func advance() -> Bool { + guard canAdvance, let next = Stage(rawValue: stage.rawValue + 1) else { return false } + stage = next + if stage == .review || stage == .complete { playing = false } + return true + } + mutating func approveReview() { + guard waitingForReview else { return } + reviewApproved = true; stage = .verify; playing = false; playbackID += 1 + } + mutating func back() { + pause() + guard let previous = Stage(rawValue: stage.rawValue - 1) else { return } + stage = previous + if stage.rawValue <= Stage.review.rawValue { reviewApproved = false } + } + mutating func reset() { + let nextID = playbackID + 1 + self = FactoryPresentationState(); playbackID = nextID + } +} + +enum FactoryJourneyStep: Int, CaseIterable, Identifiable { + case intent, models, review, trial, evidence + var id: Int { rawValue } + var title: String { + switch self { + case .intent: "Describe" + case .models: "Connect" + case .review: "Review" + case .trial: "Run" + case .evidence: "Verify" + } + } + var symbol: String { + switch self { + case .intent: "text.bubble" + case .models: "cpu" + case .review: "slider.horizontal.3" + case .trial: "play" + case .evidence: "checkmark.shield" + } + } + static func suggested(saved: Bool, trialPrepared: Bool, verified: Bool) -> Self { + verified ? .evidence : trialPrepared ? .trial : saved ? .review : .intent + } +} diff --git a/apps/macos/Sources/SuperQode/FactoryPresentationView.swift b/apps/macos/Sources/SuperQode/FactoryPresentationView.swift new file mode 100644 index 00000000..5b9ba65a --- /dev/null +++ b/apps/macos/Sources/SuperQode/FactoryPresentationView.swift @@ -0,0 +1,157 @@ +import SwiftUI + +/// A presenter-controlled story. It never submits work or creates quality records. +struct FactoryPresentationView: View { + @Environment(\.dismiss) private var dismiss + @Environment(\.scenePhase) private var scenePhase + @Environment(\.accessibilityReduceMotion) private var reduceMotion + @State private var playback = FactoryPresentationState() + + var body: some View { + VStack(alignment: .leading, spacing: 20) { + HStack(spacing: 12) { + FactoryStudioEmblem(size: 36) + VStack(alignment: .leading, spacing: 3) { + Text("Watch a Factory work").font(.title2.bold()) + Text("Fix and verify · Checkout totals").font(.subheadline).foregroundStyle(.secondary) + } + Spacer() + Label("Scripted demo", systemImage: "play.rectangle") + .font(.caption.bold()).padding(.horizontal, 10).padding(.vertical, 6) + .background(Brand.purple.opacity(0.12), in: Capsule()) + Button("Close") { dismiss() }.keyboardShortcut(.cancelAction) + } + FactoryFlowMap(nodes: FactoryPresentationState.Stage.allCases.map { + FactoryFlowNode(id: $0.rawValue, title: $0.title, symbol: $0.symbol, + completed: $0.rawValue < playback.stage.rawValue) + }, selection: playback.stage.rawValue, working: playback.playing) + ScrollView { + VStack(alignment: .leading, spacing: 14) { + FactoryPresentationScene(state: playback) + .id(playback.stage) + .transition(reduceMotion ? .identity : .opacity.combined(with: .move(edge: .trailing))) + if playback.stage == .complete { + FactoryDemoStartView(onCreated: { dismiss() }) + .padding(14).brandSurface() + } + } + }.frame(maxHeight: .infinity) + Divider() + HStack(spacing: 12) { + Button { playback.back() } label: { Label("Back", systemImage: "chevron.left") } + .disabled(playback.stage == .request) + .keyboardShortcut(.leftArrow, modifiers: []) + Button { playback.reset() } label: { Label("Restart", systemImage: "arrow.counterclockwise") } + .accessibilityIdentifier("factory.presentation.restart") + Spacer() + Text("\(playback.stage.rawValue + 1) of \(FactoryPresentationState.Stage.allCases.count)") + .font(.caption.monospacedDigit()).foregroundStyle(.secondary) + if playback.waitingForReview { + Button("Approve demo repair") { playback.approveReview() } + .buttonStyle(BrandButtonStyle()) + .accessibilityIdentifier("factory.presentation.approve") + } else { + Button { + if playback.playing { playback.pause() } else { playback.play() } + } label: { + Label(playback.playing ? "Pause" : "Play demo", systemImage: playback.playing ? "pause.fill" : "play.fill") + }.disabled(playback.stage == .complete) + .accessibilityIdentifier("factory.presentation.play") + Button("Next") { playback.pause(); playback.advance() } + .buttonStyle(BrandButtonStyle()).disabled(!playback.canAdvance) + .keyboardShortcut(.rightArrow, modifiers: []) + .accessibilityIdentifier("factory.presentation.next") + } + } + Text("Illustration only · 0 model calls · 0 files changed · No SuperGauge record or release approval is created.") + .font(.caption).foregroundStyle(.secondary) + }.padding(28) + .frame(minWidth: 880, idealWidth: 1020, maxWidth: 1100, minHeight: 620, idealHeight: 730, maxHeight: 800) + .background { BrandBackdrop() } + .animation(reduceMotion ? nil : .spring(response: 0.4, dampingFraction: 0.88), value: playback.stage) + .task(id: playback.playbackID) { + while playback.playing && !Task.isCancelled { + do { try await Task.sleep(for: .seconds(2.8)) } catch { return } + guard !Task.isCancelled, playback.playing else { return } + playback.advance() + } + } + .onDisappear { playback.pause() } + .onChange(of: scenePhase) { _, phase in if phase != .active { playback.pause() } } + .accessibilityIdentifier("factory.presentation") + } +} + +/// Renderable independently of Workspace, credentials and the desktop engine. +struct FactoryPresentationScene: View { + let state: FactoryPresentationState + private var repaired: Bool { state.stage.rawValue >= FactoryPresentationState.Stage.repair.rawValue } + private var verified: Bool { state.stage.rawValue >= FactoryPresentationState.Stage.verify.rawValue } + + var body: some View { + VStack(alignment: .leading, spacing: 20) { + HStack(alignment: .top, spacing: 14) { + Image(systemName: state.stage.symbol).font(.system(size: 28, weight: .medium)) + .foregroundStyle(state.waitingForReview ? Brand.orange : Brand.purple) + .frame(width: 58, height: 58) + .background((state.waitingForReview ? Brand.orange : Brand.purple).opacity(0.1), in: RoundedRectangle(cornerRadius: 17)) + VStack(alignment: .leading, spacing: 7) { + Text(state.stage.headline).font(.title2.bold()) + Text(state.stage.detail).font(.callout).foregroundStyle(.secondary) + .fixedSize(horizontal: false, vertical: true) + } + } + HStack(alignment: .top, spacing: 18) { + VStack(alignment: .leading, spacing: 12) { + Label(repaired ? "Proposed change" : "The starting code", systemImage: "chevron.left.forwardslash.chevron.right") + .font(.subheadline.bold()) + Text("def total(values):\n result = 0\n for value in values:") + .font(.system(.callout, design: .monospaced)) + Text(repaired ? "− result = value\n+ result += value" : " result = value") + .font(.system(.callout, design: .monospaced)).foregroundStyle(repaired ? Color.green : Brand.orange) + Text(" return result").font(.system(.callout, design: .monospaced)) + Text(repaired ? "One changed line. The protected expectations stay the same." : "The running total is replaced on every iteration.") + .font(.caption).foregroundStyle(.secondary) + }.frame(maxWidth: .infinity, alignment: .leading).padding(20).brandSurface() + VStack(alignment: .leading, spacing: 12) { + Label(verified ? "Illustrated check results" : "Protected expectations", systemImage: "lock.shield") + .font(.subheadline.bold()) + example("Multiple items", input: "[2, 3]", expected: "5", passes: verified) + example("Discounts", input: "[8, −3, 1]", expected: "6", passes: verified) + example("Empty basket", input: "[]", expected: "0", passes: verified) + Text(verified ? "3 / 3 passing in this scripted example" : "Coding agents do not get to edit these expectations.") + .font(.caption).foregroundStyle(.secondary) + }.frame(maxWidth: .infinity, alignment: .leading).padding(20).brandSurface() + } + if state.waitingForReview { + Label("Autoplay is paused. You decide whether this illustrated repair continues.", systemImage: "hand.raised.fill") + .font(.callout.weight(.medium)).foregroundStyle(Brand.orange) + } else if state.stage == .complete { + HStack(spacing: 18) { + metric("Changed lines", "1") + metric("Illustrated checks", "3 / 3") + metric("Model calls", "0") + metric("Real release", "Not authorized") + } + } + }.padding(24).background(Color.primary.opacity(0.025), in: RoundedRectangle(cornerRadius: 22)) + .accessibilityIdentifier("factory.presentation.scene") + } + private func example(_ title: String, input: String, expected: String, passes: Bool) -> some View { + HStack(spacing: 8) { + Image(systemName: passes ? "checkmark.circle.fill" : "circle.dashed") + .foregroundStyle(passes ? Color.green : Color.secondary) + VStack(alignment: .leading, spacing: 2) { + Text(title).font(.caption.bold()) + Text(input + " → " + expected).font(.system(.caption, design: .monospaced)).foregroundStyle(.secondary) + } + Spacer(minLength: 0) + } + } + private func metric(_ title: String, _ value: String) -> some View { + VStack(alignment: .leading, spacing: 4) { + Text(title).font(.caption).foregroundStyle(.secondary) + Text(value).font(.subheadline.bold()) + }.frame(maxWidth: .infinity, alignment: .leading) + } +} diff --git a/apps/macos/Sources/SuperQode/FactoryRLMProposalView.swift b/apps/macos/Sources/SuperQode/FactoryRLMProposalView.swift index dcb09767..5a32c307 100644 --- a/apps/macos/Sources/SuperQode/FactoryRLMProposalView.swift +++ b/apps/macos/Sources/SuperQode/FactoryRLMProposalView.swift @@ -125,11 +125,9 @@ struct FactoryRLMProposalCard: View { var body: some View { VStack(alignment: .leading, spacing: 12) { HStack(spacing: 8) { - Label("On-Demand Software Factory ready", systemImage: "checkmark.seal.fill") + Label("Review your Factory draft", systemImage: "checkmark.seal.fill") .font(.subheadline.weight(.semibold)) .foregroundStyle(Brand.purple) - pill(snapshot.engineLabel, color: Brand.purple) - pill(snapshot.modeLabel, color: snapshot.mode == "rlm-live" ? Brand.pink : Color(red: 0.14, green: 0.62, blue: 0.42)) Spacer() if snapshot.durationMs > 0 { Text(String(format: "%.1fs", Double(snapshot.durationMs) / 1000.0)) @@ -147,11 +145,11 @@ struct FactoryRLMProposalCard: View { // Interactive 3-step visual summary of what SuperQode just did HStack(spacing: 8) { - stepBadge("1", "Scanned \(snapshot.repoFiles) files") + stepBadge("1", "Indexed \(snapshot.repoFiles) files") Image(systemName: "arrow.right").font(.caption2).foregroundStyle(.tertiary) stepBadge("2", "Detected \(snapshot.detectedStacks.joined(separator: ", "))") Image(systemName: "arrow.right").font(.caption2).foregroundStyle(.tertiary) - stepBadge("3", "Built \(snapshot.recommendedWorkflow)") + stepBadge("3", "Drafted workflow") } // Clear breakdown of what this factory sets up for the repo @@ -232,7 +230,7 @@ struct FactoryRLMProposalCard: View { } } if !assumptions.isEmpty { - VStack(alignment: .leading, spacing: 3) { + DisclosureGroup("Assumptions to review (\(assumptions.count))") { ForEach(assumptions, id: \.self) { item in Text("• \(item)") .font(.caption) @@ -241,11 +239,19 @@ struct FactoryRLMProposalCard: View { } } + if !missingCapabilities.isEmpty { + DisclosureGroup("Setup still needed (\(missingCapabilities.count))") { + ForEach(missingCapabilities, id: \.self) { item in + Label(item, systemImage: "exclamationmark.circle").font(.caption).foregroundStyle(.orange) + } + } + } DisclosureGroup( "How SuperQode analyzed this repository (\(snapshot.filesInspected.count) manifests read, \(snapshot.subcalls.count) sub-queries)", isExpanded: $showTrace ) { VStack(alignment: .leading, spacing: 6) { + Text(snapshot.engineLabel + " · " + snapshot.modeLabel).font(.caption) if !snapshot.filesInspected.isEmpty { Text("Files inspected: " + snapshot.filesInspected.joined(separator: ", ")) .font(.caption2.monospaced()) @@ -281,7 +287,7 @@ struct FactoryRLMProposalCard: View { onApply(selectedSkills) } label: { Label( - selectedSkills.isEmpty ? "Apply & Edit Factory →" : "Apply, Add \(selectedSkills.count) Skills & Edit Factory →", + selectedSkills.isEmpty ? "Use this draft" : "Use draft & add \(selectedSkills.count) skills", systemImage: "arrow.right.circle.fill" ) } @@ -289,7 +295,7 @@ struct FactoryRLMProposalCard: View { .disabled(busy) .accessibilityIdentifier("factory.rlm.applyWithSkills") - Button("Open YAML only") { + Button("Use draft only") { onApplyYamlOnly() } .disabled(busy) @@ -297,10 +303,10 @@ struct FactoryRLMProposalCard: View { } HStack(alignment: .firstTextBaseline, spacing: 6) { - Image(systemName: "sparkles") + Image(systemName: "doc.text") .font(.caption2) .foregroundStyle(Brand.purple) - Text("**Coming next — Recursive Software Factories:** dynamically spawn isolated, SuperGauge-verified sub-factories on demand for multi-service and monorepo tasks, governed by your committed `factory.yaml`.") + Text("Review and save the definition before preparing a trial. Selected skills create local files when you use this draft.") .font(.caption2) .foregroundStyle(.secondary) } diff --git a/apps/macos/Sources/SuperQode/FactoryStudioView.swift b/apps/macos/Sources/SuperQode/FactoryStudioView.swift index b60bba4a..b9d8d679 100644 --- a/apps/macos/Sources/SuperQode/FactoryStudioView.swift +++ b/apps/macos/Sources/SuperQode/FactoryStudioView.swift @@ -24,6 +24,9 @@ struct FactoryStudioView: View { @State private var syncedControls: FactoryControlDraft? @State private var runDetailTab = ProcessInfo.processInfo.arguments.contains("--factory-acceptance-inspect") ? "checks" : "pipeline" @State private var showTour = false + @State private var showPresentation = false + @State private var showAdvancedSetup = false + @State private var journeyStep: FactoryJourneyStep = .intent @State private var contentReady = false @State private var uiSkillPreset = "web" @State private var appliedRLMSnapshot: FactoryRLMLineageSnapshot? @@ -65,11 +68,13 @@ struct FactoryStudioView: View { } var body: some View { HStack(alignment: .top, spacing: 20) { - FactoryNavigationHeader(navigation: library.navigation, badges: sidebarBadges).frame(width: 178) - Divider() + if tab != "Stack" || showAdvancedSetup { + FactoryNavigationHeader(navigation: library.navigation, badges: sidebarBadges).frame(width: 178) + Divider() + } VStack(alignment: .leading, spacing: 14) { headerBar - if showNextStepGuide { + if showNextStepGuide && tab != "Stack" { FactoryNextStepStrip( setup: setup, controlsHaveChanges: controlsHaveChanges, @@ -171,7 +176,7 @@ struct FactoryStudioView: View { .onChange(of: string(library.review, "snapshot_digest")) { _, value in if !value.isEmpty, !controlsHaveChanges { syncControls() } } - .onChange(of: app.projectID) { _, _ in confirmation = ""; activeAction = ""; reason = ""; goal = ""; experimentStage = ""; experimentGoal = ""; experimentTask = "" } + .onChange(of: app.projectID) { _, _ in confirmation = ""; activeAction = ""; reason = ""; goal = ""; journeyStep = .intent; showAdvancedSetup = false; experimentStage = ""; experimentGoal = ""; experimentTask = "" } .factoryConfirmation( isPresented: Binding(get: { showingSheetConfirm }, set: { if !$0 { dismissConfirmation() } }), title: confirmationTitle, @@ -186,6 +191,7 @@ struct FactoryStudioView: View { execute(action) } ) + .sheet(isPresented: $showPresentation) { FactoryPresentationView() } .sheet(isPresented: $showTour) { FactoryTourSheet( onJumpToPage: { destination in library.navigation.select(destination) }, @@ -202,7 +208,7 @@ struct FactoryStudioView: View { FactoryGroupMark(id: library.navigation.group.id, selected: true, size: 26) Text(library.navigation.pageTitle).font(.title2.bold()) Spacer() - if FactoryNavigation.buildPages.contains(tab) { + if FactoryNavigation.buildPages.contains(tab) && tab != "Stack" { Button("Check definition") { let ticket = library.navigation.ticket() activeAction = "validate" @@ -215,16 +221,24 @@ struct FactoryStudioView: View { Button("Save changes…") { requestConfirmation("save") } .disabled(!idle || library.review.isEmpty || controlsHaveChanges || setup.saved) } + if tab == "Stack", !showAdvancedSetup { + Button("All Factory controls") { library.navigation.select("Definition") } + .accessibilityIdentifier("factory.journey.allControls") + } Button { showTour = true } label: { Label("Tour", systemImage: "book.pages") } .help("Walk through how to build a Software Factory before running anything") .accessibilityIdentifier("factory.tour.open") + if tab != "Stack" { Button { showNextStepGuide.toggle() } label: { Label(showNextStepGuide ? "Guide" : "Show guide", systemImage: showNextStepGuide ? "checklist.checked" : "checklist") } .help(showNextStepGuide ? "Hide the Next-Step progress strip" : "Show the Next-Step progress strip") .accessibilityIdentifier("factory.guide.toggle") + } + Button { showPresentation = true } label: { Label("Demo", systemImage: "play.rectangle") } + .accessibilityIdentifier("factory.presentation.open") FactorySoundToggleButton() } } @@ -256,6 +270,29 @@ struct FactoryStudioView: View { } .id("factory-proposal-top") } + if !library.canApplyProposal { + FactoryGuidedBuilderView( + studio: library, step: $journeyStep, trialGoal: $goal, setup: setup, idle: idle, + onBuild: { requestConfirmation("rlm-architect") }, + onStarter: chooseWorkflow, + onValidate: { + let identity = library.project; let source = library.version + Task { + guard library.project == identity, library.version == source else { return } + await library.validate(engine: app.engine) + if library.project == identity, !library.review.isEmpty { syncControls() } + } + }, + onSave: { + if reason.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { reason = "Configured my Factory" } + requestConfirmation("save") + }, + onTrial: { requestConfirmation("trial") }, + onDemo: { showPresentation = true } + ) + } + DisclosureGroup("Advanced setup · workflows, model details and local draft recovery", isExpanded: $showAdvancedSetup) { + VStack(alignment: .leading, spacing: 18) { HStack(spacing: 8) { FactoryStudioEmblem(size: 22) Text("What should this Factory do?").font(.headline) @@ -292,6 +329,8 @@ struct FactoryStudioView: View { Spacer() nativeButton("factory.setup.next", action: advanceSetup, title: setup.action) { Text(setup.action).font(.caption.weight(.semibold)) }.disabled(!idle || (controlsHaveChanges && setup.hasDraft)) } + }.padding(.top, 14) + }.font(.callout) }.frame(maxWidth: .infinity, alignment: .leading) } .onChange(of: library.canApplyProposal) { _, ready in @@ -1255,7 +1294,8 @@ struct FactoryStudioView: View { await library.validate(engine: app.engine) if library.project == ticket.project, !library.review.isEmpty { syncControls() } if action == "template", library.navigation.isCurrent(ticket), library.failure.isEmpty, !library.text.isEmpty { - library.navigation.select("Definition") + if showAdvancedSetup { library.navigation.select("Definition") } + else { journeyStep = .review } } case "generate": if library.text.isEmpty { await library.load(engine: app.engine, template: preset) } @@ -1263,7 +1303,8 @@ struct FactoryStudioView: View { guard await checkDraftingSelection(draftingReference) else { return } await library.start(engine: app.engine, action: action, provider: draftingProvider, model: draftingModel, workflow: preset) if library.navigation.isCurrent(ticket), library.failure.isEmpty, library.message.hasPrefix("Starter settings") { - library.navigation.select("Definition") + if showAdvancedSetup { library.navigation.select("Definition") } + else { journeyStep = .review } } case "rlm-architect": guard await checkDraftingSelection(draftingReference) else { return } @@ -1308,8 +1349,11 @@ struct FactoryStudioView: View { library.text = proposedYaml library.proposal = [:] appliedRLMSnapshot = snapshot - // Jump immediately to the editable Definition page so the user sees their new factory right away. - library.navigation.select("Definition") + if library.navigation.selection == "Stack", !showAdvancedSetup { + journeyStep = .review + } else { + library.navigation.select("Definition") + } Task { for skill in skills { await library.scaffoldSkill(engine: app.engine, skill: skill.name, preset: skill.preset.isEmpty ? "web" : skill.preset) diff --git a/apps/macos/Sources/SuperQode/WelcomeView.swift b/apps/macos/Sources/SuperQode/WelcomeView.swift index 650911da..2922fa0b 100644 --- a/apps/macos/Sources/SuperQode/WelcomeView.swift +++ b/apps/macos/Sources/SuperQode/WelcomeView.swift @@ -22,6 +22,7 @@ struct WelcomeView: View { showBetaGuide = true }.buttonStyle(.link).font(.callout) } + FactoryPresentationLaunchCard().frame(maxWidth: 860) Group { if geometry.size.width >= 980 { HStack(alignment: .top, spacing: 24) { @@ -35,7 +36,6 @@ struct WelcomeView: View { } } }.frame(maxWidth: 860) - FactoryDemoStartView().frame(maxWidth: 860, alignment: .leading) HStack(spacing: 24) { Button { app.showLearningGuide = true diff --git a/apps/macos/Tests/SuperQodeTests/FactoryPresentationTests.swift b/apps/macos/Tests/SuperQodeTests/FactoryPresentationTests.swift new file mode 100644 index 00000000..af867e83 --- /dev/null +++ b/apps/macos/Tests/SuperQodeTests/FactoryPresentationTests.swift @@ -0,0 +1,149 @@ +import XCTest +import SwiftUI +import AppKit +@testable import SuperQode + +final class FactoryPresentationTests: XCTestCase { + func testAutoplayStopsAtHumanReviewAndCannotSkipIt() { + var state = FactoryPresentationState() + state.play() + XCTAssertTrue(state.playing) + XCTAssertTrue(state.advance()) + XCTAssertTrue(state.advance()) + XCTAssertTrue(state.advance()) + XCTAssertEqual(state.stage, .review) + XCTAssertTrue(state.waitingForReview) + XCTAssertFalse(state.playing) + XCTAssertFalse(state.advance()) + state.play() + XCTAssertFalse(state.playing) + state.approveReview() + XCTAssertEqual(state.stage, .verify) + XCTAssertTrue(state.reviewApproved) + XCTAssertTrue(state.advance()) + XCTAssertEqual(state.stage, .complete) + XCTAssertFalse(state.playing) + XCTAssertFalse(state.advance()) + } + + func testBackAndRestartInvalidatePlaybackAndRequireReviewAgain() { + var state = FactoryPresentationState() + for _ in 0..<3 { state.advance() } + state.approveReview() + let beforeBack = state.playbackID + state.back() + XCTAssertGreaterThan(state.playbackID, beforeBack) + XCTAssertEqual(state.stage, .review) + XCTAssertFalse(state.reviewApproved) + XCTAssertFalse(state.canAdvance) + let beforeReset = state.playbackID + state.reset() + XCTAssertEqual(state.stage, .request) + XCTAssertFalse(state.playing) + XCTAssertFalse(state.reviewApproved) + XCTAssertGreaterThan(state.playbackID, beforeReset) + } + + func testPlayingAtTheEndDoesNotRestartOrInventNewProgress() { + var state = FactoryPresentationState() + for _ in 0..<3 { state.advance() } + state.approveReview(); state.advance() + let complete = state + state.play() + XCTAssertEqual(state, complete) + } + + func testGuidedSuggestionRequiresRealEvidenceToSuggestVerification() { + XCTAssertEqual(FactoryJourneyStep.suggested(saved: false, trialPrepared: false, verified: false), .intent) + XCTAssertEqual(FactoryJourneyStep.suggested(saved: true, trialPrepared: false, verified: false), .review) + XCTAssertEqual(FactoryJourneyStep.suggested(saved: true, trialPrepared: true, verified: false), .trial) + XCTAssertEqual(FactoryJourneyStep.suggested(saved: true, trialPrepared: true, verified: true), .evidence) + } + + @MainActor func testEveryPresentationSceneRendersWithoutAnEngine() throws { + _ = NSApplication.shared + var state = FactoryPresentationState() + for stage in FactoryPresentationState.Stage.allCases { + XCTAssertEqual(state.stage, stage) + for scheme in [ColorScheme.light, .dark] { + try render(FactoryPresentationScene(state: state).environment(\.colorScheme, scheme), + name: "presentation-\(stage.rawValue)-\(scheme == .dark ? "dark" : "light")", width: 900, height: 430) + } + if state.waitingForReview { state.approveReview() } else { state.advance() } + } + } + + @MainActor func testPresentationPlayerRendersAtCompactWindowSize() throws { + _ = NSApplication.shared + try render(FactoryPresentationView(), name: "presentation-player", width: 920, height: 680) + } + + @MainActor func testGuidedScreensRenderAtNarrowAndWideWidthsWithoutRequests() throws { + _ = NSApplication.shared + let pipe = Pipe(); let engine = Engine(input: pipe.fileHandleForWriting) + let suite = "factory-preview-" + UUID().uuidString + let preferences = try XCTUnwrap(UserDefaults(suiteName: suite)) + defer { engine.stop(); preferences.removePersistentDomain(forName: suite) } + let app = Workspace(recoveryStore: WorkspaceRecoveryStore(directory: nil), preferences: preferences, engine: engine) + let studio = FactoryStudioLibrary(); studio.enter("preview") + studio.text = "preview-definition" + studio.description = "Fix bugs and verify every repair" + studio.review = ["review": "preview", "yaml": studio.text, "digest": "saved", "snapshot_digest": "snapshot", + "stages": [["id": "investigate"], ["id": "implement"], ["id": "verify"]], + "acceptance_checks": ["regression"], "application_checks": ["regression": ["evaluator": "probes"]]] + let setup = FactorySetupState(text: studio.text, review: studio.review, savedDigest: "saved", + sources: ["snapshot_digest": "snapshot", "files": [["changed": false]]], runs: []) + for step in FactoryJourneyStep.allCases { + for width: CGFloat in [560, 820] { + let view = FactoryGuidedBuilderView(studio: studio, step: .constant(step), trialGoal: .constant("Repair checkout totals"), + setup: setup, idle: true, onBuild: {}, onStarter: { _ in }, onValidate: {}, onSave: {}, onTrial: {}, onDemo: {}, inspectAutomatically: false) + .environmentObject(app) + try render(view, name: "guided-\(step.rawValue)-\(Int(width))", width: width, height: 730) + } + } + XCTAssertEqual(engine.pendingRequestCount, 0) + } + + @MainActor func testGeneratedDraftReviewRendersAtCompactWidth() throws { + _ = NSApplication.shared + let snapshot = try XCTUnwrap(FactoryRLMLineageSnapshot.parse(proposal: [ + "rlm_lineage": ["engine": "rlm-context", "mode": "rlm-local-inspect", "repo_files": 42, + "files_inspected": ["pyproject.toml"], "detected_stacks": ["Python"], + "recommended_workflow": "fix-and-verify", "detected_test_command": "pytest -q"] + ])) + for width: CGFloat in [560, 820] { + try render(FactoryRLMProposalCard(snapshot: snapshot, + assumptions: ["Review the proposed regression command before saving."], + missingCapabilities: ["Add protected acceptance probes."], busy: false, + onApply: { _ in }, onApplyYamlOnly: {}, onDismiss: {}), + name: "proposal-\(Int(width))", width: width, height: 730) + } + } + + @MainActor private func render(_ view: V, name: String, width: CGFloat, height: CGFloat) throws { + let content = view.frame(width: width, height: height, alignment: .topLeading) + .background(Color(nsColor: .windowBackgroundColor)) + // ImageRenderer omits AppKit-backed text fields and scroll content. Capture the + // actual hosted native view so previews include the controls people use. + let bounds = NSRect(x: 0, y: 0, width: width, height: height) + let window = NSWindow(contentRect: bounds, styleMask: [.borderless], backing: .buffered, defer: false) + window.appearance = NSAppearance(named: name.hasSuffix("-dark") ? .darkAqua : .aqua) + let hosting = NSHostingView(rootView: content) + hosting.frame = bounds + window.contentView = hosting + window.orderFront(nil) + defer { window.orderOut(nil) } + RunLoop.main.run(until: Date().addingTimeInterval(0.05)) + hosting.layoutSubtreeIfNeeded() + hosting.displayIfNeeded() + let bitmap = try XCTUnwrap(hosting.bitmapImageRepForCachingDisplay(in: bounds), "Could not render " + name) + hosting.cacheDisplay(in: bounds, to: bitmap) + XCTAssertGreaterThan(bitmap.pixelsWide, 0) + if let directory = ProcessInfo.processInfo.environment["SUPERQODE_FACTORY_PREVIEW_DIR"] { + let folder = URL(fileURLWithPath: directory) + try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) + let png = try XCTUnwrap(bitmap.representation(using: .png, properties: [:])) + try png.write(to: folder.appendingPathComponent(name + ".png")) + } + } +} diff --git a/apps/macos/resources/Info.plist b/apps/macos/resources/Info.plist index 20b76f4a..0fe35a46 100644 --- a/apps/macos/resources/Info.plist +++ b/apps/macos/resources/Info.plist @@ -19,9 +19,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.5.2 + 0.5.3 CFBundleVersion - 59 + 60 SuperQodeReleaseChannel Public Beta LSApplicationCategoryType diff --git a/docs/assets/harness-hub.json b/docs/assets/harness-hub.json index bf2b9a85..ff0983db 100644 --- a/docs/assets/harness-hub.json +++ b/docs/assets/harness-hub.json @@ -1,7 +1,7 @@ { "schema_version": "1.7", - "generated_at": "2026-11-15T11:06:41.060603+00:00", - "count": 108, + "generated_at": "2026-11-27T07:52:35.728207+00:00", + "count": 110, "categories": [ "SuperQode harnesses", "Coding agents", @@ -972,6 +972,68 @@ "language_confidence": "inferred", "language_evidence": "Closed source. Ships as one self-contained agy binary with no separate runtime; Google\u2019s CLI docs and launch coverage describe it as a Go build sharing the Antigravity IDE agent harness." }, + { + "id": "antigravity-acp", + "name": "Antigravity (ACP)", + "description": "Use Google's Antigravity agent over its official ACP server (agy acp) with your Google Sign-In, live model and thinking controls", + "category": "Coding agents", + "kind": "connection", + "runtime": "antigravity", + "source": "connection:acp", + "readiness": "setup-required", + "integration_level": "managed", + "continuity": "fresh-session", + "provider": "", + "model": "", + "setup": "install or update agy from https://antigravity.google/docs/cli-install (Antigravity ACP requires agy 1.5.1+), then sign in with `agy`", + "warning": "", + "project_path": "", + "homepage": "", + "repository": "", + "interface": "", + "support_note": "", + "last_verified": "", + "aliases": [], + "docs_url": "https://docs.superqode.dev/concepts/modes/", + "install_command": "install or update agy from https://antigravity.google/docs/cli-install (Antigravity ACP requires agy 1.5.1+), then sign in with `agy`", + "tui_commands": [ + ":connect antigravity-acp", + ":harness switch antigravity-acp", + ":harness status" + ], + "cli_commands": [ + "superqode harness run antigravity-acp \"Describe your task\"" + ], + "eval_commands": [], + "optimize_commands": [], + "tools": [], + "policies": [ + "The connected coding agent owns its tool loop", + "Authentication remains with the vendor CLI or account", + "SuperQode provides discovery, launch, and session continuity", + "Evaluation and optimization apply to SuperQode HarnessSpecs, not to this agent's internal loop" + ], + "capabilities": [ + "closed harness", + "multi-model", + "via ACP", + "Managed connection from SuperQode" + ], + "based_on": "Antigravity (ACP)", + "popularity_rank": 500, + "setup_steps": [ + { + "title": "Complete the required setup", + "command": "", + "description": "install or update agy from https://antigravity.google/docs/cli-install (Antigravity ACP requires agy 1.5.1+), then sign in with `agy`" + } + ], + "openness": "closed", + "license": "", + "language": "Unknown", + "language_confidence": "inferred", + "language_evidence": "No public source or distribution signal yet." + }, { "id": "antigravity-managed", "name": "Antigravity Managed Agent", @@ -2383,6 +2445,64 @@ "language_confidence": "confirmed", "language_evidence": "The Pi coding agent and its pi-acp adapter both carry tsconfig.json." }, + { + "id": "acp:pydantic-coder", + "name": "Pydantic Coder \u2014 Experimental", + "description": "Pydantic's Coder harness over SuperQode's experimental ACP connector, with model selection, file and shell tools, approvals and persistent sessions.", + "category": "ACP agents", + "kind": "acp", + "runtime": "ACP", + "source": "acp:featured", + "readiness": "setup-required", + "integration_level": "protocol", + "continuity": "context-replay", + "provider": "", + "model": "", + "setup": "superqode pydantic-coder setup", + "warning": "", + "project_path": "", + "homepage": "https://pydantic.dev/docs/ai/harness/coder/", + "repository": "", + "interface": "", + "support_note": "", + "last_verified": "", + "aliases": [], + "docs_url": "https://pydantic.dev/docs/ai/harness/coder/", + "install_command": "superqode pydantic-coder setup", + "tui_commands": [ + ":connect acp pydantic-coder", + ":harness switch acp:pydantic-coder", + ":harness status" + ], + "cli_commands": [ + "superqode harness run acp:pydantic-coder \"Describe your task\"" + ], + "eval_commands": [], + "optimize_commands": [], + "tools": [], + "policies": [ + "External agent owns its tool loop and tool inventory", + "SuperQode provides ACP connection, session handoff, and context replay" + ], + "capabilities": [ + "Agent Client Protocol", + "Context replay" + ], + "based_on": "Pydantic Coder \u2014 Experimental agent", + "popularity_rank": 500, + "setup_steps": [ + { + "title": "Install Pydantic Coder \u2014 Experimental", + "command": "superqode pydantic-coder setup", + "description": "" + } + ], + "openness": "open", + "license": "", + "language": "Unknown", + "language_confidence": "inferred", + "language_evidence": "No public source or distribution signal yet." + }, { "id": "acp:agentpool", "name": "AgentPool",