filebase 0.1.0

Query a directory of Slipcase containers by their metadata and look at what comes back
Documentation
# The Microsoft Store screenshots, as recipes rather than as prose.
#
# `take-shots.ps1` beside this takes a set given the recipes for it, and
# `screenshot.ps1` under that is the driver and knows nothing about Filebase.
# Both are generated by ship and the same in every repository with a window to
# photograph. This file is the part that is Filebase's - which document, which
# shot, and what has to happen in the window before the shutter. It is the
# Windows spelling of `packaging/macos/shots.sh`, which is the same split.
#
# Everything a person would change to retake the set lives at the top, and
# running it by hand on the Windows machine is the same command CI runs:
#
#     powershell -ExecutionPolicy Bypass -File packaging\windows\shots.ps1
#
# WHAT THE SET HAS TO SHOW, AND WHY
#
# Apple rejected the Mac four under guideline 2.3.3 - *the Mac screenshots do
# not show the actual app in use in the majority of the screenshots* - and the
# rejection was right. Nothing was selected in any of them, so the element pane
# read *Select an element on the page or in the structure* in all four, and no
# edit was under way. A frame of an editor with nothing selected is a frame of
# a viewer. The Windows four are that same set in its Windows spelling and the
# same criticism is true of them, so: something is selected in every shot below,
# and an edit is under way or just done in more than one.
#
# The coordinates are measured from the frame's top-left corner at the size
# declared here. Change the size and they all move; that is why the size is a
# constant beside them rather than an argument with a default.
#
# WHAT THE ASSOCIATION MEANS FOR WHAT IS PHOTOGRAPHED
#
# The executable is launched directly with the folder as an argument, so what
# appears is the build in `target\release` and not whatever the shell might
# have registered. Nothing is registered to this application at all: it opens a
# folder, and Windows has no association for that.
#
# Author: David M. Anderson
# Built with AI assistance (Claude, Anthropic)

[CmdletBinding()]
param(
    # One plain capture of the document at rest, and nothing else. This is how
    # the coordinates below get measured: take it, open it, read the pixel of
    # each control off it, and fill the constants in.
    [switch] $Reference,
    [string] $OutDir
)

$ErrorActionPreference = 'Stop'

. "$PSScriptRoot\take-shots.ps1"

$root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path

# --- the configuration ------------------------------------------------------

# 1366x768 is the Microsoft Store's minimum for a desktop screenshot, and a
# window this size looks like a window rather than like an advertisement.
$WIDTH = 1366
$HEIGHT = 768

# The folder the window opens on, built by `packaging/demo-corpus.sh`. A folder
# rather than a document, because that is what this application opens; the
# driver passes it as an argument, since Filebase declares no file type for the
# shell to route.
$CORPUS = Join-Path $root 'dist\corpus'

# The executable, launched directly with the folder as an argument rather than
# through the shell. The siblings use `-Launch shell` because their document's
# extension is registered to them; nothing is registered to this one, because it
# opens a folder and Windows has no way to declare that. `-Launch exe` is the
# driver's mode for exactly this, and odox uses it for the same reason.
$EXE = Join-Path $root 'target\release\filebase.exe'

# The process the window belongs to, which the driver stops first so the frame
# holds this run's window and not a previous one's.
$PROCESS = 'filebase'

# Where the shots land. Not committed: dist is where every built artefact goes.
if (-not $OutDir) { $OutDir = Join-Path $root 'dist\screenshots' }

# The controls, by what they do rather than by where they are, so a recipe below
# reads as the thing it is doing. Each is "X,Y" in the frame.
#
# **These are not filled in yet.** Every one is read off a reference frame, and
# a coordinate guessed from a description of a window photographs the wrong
# thing and passes while doing it. Take the frame, measure, and replace them:
#
#     powershell -ExecutionPolicy Bypass -File packaging\windows\shots.ps1 -Reference
#
$RECURSIVE = 'RECURSIVE_XY'      # the recursive tick box in the folder bar
$QUERY_BOX = 'QUERY_BOX_XY'      # the query box
$FIRST_ROW = 'FIRST_ROW_XY'      # the first row of the results table
$FOURTH_ROW = 'FOURTH_ROW_XY'    # a row whose container has no governance.owner
$NOTICES = 'NOTICES_FOLD_XY'     # the "What the scan noticed" fold, under the count

# The two queries the frames are of. The first is the listing's own example; the
# second is the one that makes both notices appear at once, because the corpus
# has a container whose `pages` is a word and a file named like a container that
# is not one.
$QUERY = 'select @path, title, status, governance.owner'
$QUERY_NOTICES = 'select @path, title, pages where pages > 10'

# --- the shots --------------------------------------------------------------

# One shot to a line: name, then the actions that put the window into the state
# being photographed, in the order they are given.
#
#   click X,Y     press a control
#   double X,Y    press it twice inside the double-click interval, which is
#                 how a block in the document pane opens for typing
#   type TEXT     type
#   key NAME      one key, optionally with modifiers: ctrl+a, return
function Get-Shots {
    # The answer to a question, with a row selected: rows filling the table, a
    # column per metadata key, and the container on the right. This is the frame
    # that has to carry the listing, so it is first.
    #
    # A frame of Filebase with no query run is a frame of an empty window, which
    # is this application's version of the trap Apple rejected segler's first
    # set for: nothing selected, so the pane reads as a prompt in every shot.
    Shot '01-a-folder-answering' @(
        "click $RECURSIVE",
        "click $QUERY_BOX", 'key ctrl+a', "type $QUERY", 'key return',
        "click $FIRST_ROW"
    )

    # A container in full: the payload card and the whole description as a tree,
    # beside the rows it came from. The empty governance.owner cell on another
    # row is in the same frame, which is the ad-hoc-metadata argument made in a
    # picture rather than in a sentence.
    Shot '02-a-container-in-full' @(
        "click $RECURSIVE",
        "click $QUERY_BOX", 'key ctrl+a', "type $QUERY", 'key return',
        "click $FOURTH_ROW"
    )

    # What the scan could not do, said out loud: a file it could not read and a
    # comparison that crossed types, both under the count.
    Shot '03-what-the-scan-noticed' @(
        "click $RECURSIVE",
        "click $QUERY_BOX", 'key ctrl+a', "type $QUERY_NOTICES", 'key return',
        "click $NOTICES"
    )
}


Take-Shots -Launch @('exe', $EXE, $CORPUS) -Process $PROCESS `
    -Width $WIDTH -Height $HEIGHT -OutDir $OutDir -Reference:$Reference