#!/bin/sh

# This program is copyright Gareth Smith, and licensed under the
# GPLv3 or above. See the AI Model Component Note at the end of
# the file for further clarification.
#
# This file was lovingly hand-crafted using nothing more
# complicated than ed(1) and rlwrap(1).
#
# One thing this exercise taught me is that using tabs for
# indentation feels way more natural than spaces if your
# editor has no keybinding for "insert 4 spaces" or
# "indent according to syntax" or whatever.
#
# You can run this program unmodified on any machine which uses
# bash as its /bin/sh , or you can use ksh if you first perform
# the following edit:
#    g/read/s/rsn1/rs
# ...however, that edit will cause the AI_power slide to leak a
# small amount of magic.
#
# For full enjoyment of this program, you will also want to have
# less(1), ed(1), and lynx(1) installed.
#
# If you have lynx(1) and would prefer that web-links in this
# presentation resolved on the internet instead of to local
# copies, then you should run this program with the environment
# variable 'ONLINE_MODE' set to 'true'.

SCRIPT_DIR="$( cd "$(dirname "${0}")" ; pwd )"

SOURCE_FILE="${0}"
ONLINE_MODE="${ONLINE_MODE:-false}"

if [[ "${ONLINE_MODE}" == "false" ]]
then
	BLOG_URL="${SCRIPT_DIR}/blog.html"
	FACTORY_URL="${SCRIPT_DIR}/factory.html"
	FABRO_URL="${SCRIPT_DIR}/fabro.html"
	NOTWRONG_URL="${SCRIPT_DIR}/notwrong/index.html"
else
	BLOG_URL="https://www.kindness.city/blog/2026-05-04-ok-lets-talk.html"
	FACTORY_URL="https://factory.strongdm.ai"
	FABRO_URL="https://fabro.sh"
	NOTWRONG_URL="https://third-bit.com/notwrong/"
fi

main() {
	title_slide
	main_menu 1
}

title_slide() {
	clear
	echo
	echo
	echo
	echo
	echo
	echo "    The Next FOSS Frontier?"
	echo
	echo
	echo
	echo "                            Gareth Smith"
	echo
	echo "                                     ('they' or 'he')"
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo "Slides: https://www.kindness.city/blog/2026-06-04-ai-talk.tgz"
	anykey
}

main_menu() {
	local choice
	clear
	local default_selection="${1}"

	echo
	echo "                          *************"
	echo "                          * Main Menu *"
	echo "                          *************"
	echo
	echo "1:                                    Does AI even actually work?"
	echo
	echo "2:                                           AI Centralizes Power"
	echo "3:                                           AI Burns Electricity"
	echo "4:                                              AI Stole My Stuff"
	echo "5:                                                         AI Art"
	echo
	echo "6:                                        What do we do about it?"
	echo
	echo
	echo
	echo
	echo "b:    https://www.kindness.city/blog/2026-05-04-ok-lets-talk.html"
	echo "r:                                                      The Rules"
	echo "v:                                                    View Source"
	echo "e:                                                    Edit Source"
	echo "w:                                                     Whiteboard"
	echo
	echo "q:                                                           Quit"
	echo
	echo
	echo
	echo -n "  Choose [${default_selection}] : "

	read -rsn1 choice
	if [[ -z "${choice}" ]]
	then
		choice="${default_selection}"
	fi

	case "${choice}" in
		"1") does_AI_work_p ;;
		"2") AI_power ;;
		"3") AI_elec ;;
		"4") AI_stole ;;
		"5") AI_art ;;
		"6") whatdo ;;
		"b") blog ;;
		"r") the_rules ;;
		"v") view_source ;;
		"e") edit_source ;;
		"w") mplayer -tv device=/dev/video2 tv:// ; main_menu "${default_selection}" ;;
		"q") echo ; echo ; exit 0 ;;
		*)   main_menu "${default_selection}" ;;
	esac
}

does_AI_work_p() {
	clear
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo "                    **********************"
	echo "                    * Does AI Even Work? *"
	echo "                    **********************"
	echo
	echo
	echo
	echo
	echo
	anykey
	AI_works
}

AI_works() {
	clear
	echo
	echo "                          ************"
	echo "                          * AI Works *"
	echo "                          ************"
	echo
	echo "AI works at least as well as:"
	echo
	echo "* Formal Methods"
	echo "* Agile methods"
	echo "* Waterfall methods"
	echo "* Static Type Systems"
	echo "* Dynamic Type Systems"
	echo
	echo
	echo
	echo "Some AI Techniques:   Pairing, Research, QC, One-Shotting,"
	echo "                      Orchestrators, Bug-Finding, Chaos-"
	echo "                      -Testing, Dark Factories..."
	echo
	echo
	echo "Some References:"
	echo
	echo "1:                            https://factory.strongdm.ai"
	echo "2:                                       https://fabro.sh"
	echo "3:                        https://third-bit.com/notwrong/"
	echo "4:                         Quote from simplermachines.com"
	echo
	echo "m:                                              Main Menu"
	echo "w:                                             Whiteboard"
	echo
	echo
	echo
	echo -n "   Choose [m] : "

	read -rsn1 choice
	if [[ -z "${choice}" ]]
	then
		choice="m"
	fi

	case "${choice}" in
		"1") factory ;;
		"2") fabro ;;
		"3") notwrong ;;
		"4") simplermachines ;;
		"m") main_menu 2 ;;
		"w") mplayer -tv device=/dev/video2 tv:// ; main_menu "2" ;;
		*) AI_works
	esac
}

AI_power() {
	clear
	echo
	echo "                    ************************"
	echo "                    * AI Centralises Power *"
	echo "                    ************************"
	echo
	echo

	echo " Tell me some models?"
	echo
	read -rsn1 choice
	while [[ "${choice}" != "" ]]
	do
		case "${choice}" in
			"g") echo "                                        Google's Gemini" ;;
			"m") echo "                       Microsoft OpenAI's Codex/ChatGPT" ;;
			"c") echo "                                     Anthropic's Claude" ;;
			"a") echo "                                     Anthropic's Claude" ;;
			"f") echo "                                      Mistral's Mistral" ;;
			"d") echo "                                               Deepseek" ;;
			"q") echo "                                                 QWEN 3" ;;
			"h") echo "                          Other stuff from Hugging Face" ;;
			*)   echo "                     Something Gareth didn't anticipate" ;;
		esac
		read -rsn1 choice
	done
	echo
	echo "    Which of these are good to code with?"
	echo
	anykey
	echo
	echo "    How do you install an open-model programming tool?"
	anykey
	main_menu 3
}

AI_elec() {
	clear
	echo
	echo "                    ************************"
	echo "                    * AI Burns Electricity *"
	echo "                    ************************"
	echo
	echo "* Data centres are absolutely:"
	echo "        --> Power-Hungry"
	echo "        --> Coolant-Hungry"
	echo
	anykey
	echo
	echo
	echo "                  Gareth's Hot Take"
	echo
	echo
	echo
	echo
	echo "                                              (rant)"
	anykey
	main_menu 4
}

AI_stole() {
	clear
	echo
	echo "                     *********************"
	echo "                     * AI Stole My Stuff *"
	echo "                     *********************"
	echo
	echo
	echo "          Yeah, AI"
	echo
	echo "                      *absolutely*"
	echo
	echo "                                      stole your stuff."
	echo
	echo
	echo
	anykey
	echo
	echo
	echo "                           (if curious, ask about the DDoS problem)"
	echo
	echo
	anykey
	main_menu 5
}

AI_art() {
	clear
	echo
	echo "                          **************"
	echo "                          * AI and Art *"
	echo "                          **************"
	echo
	echo
	echo
	echo "                 It's gonna' be weird."
	echo
	echo
	anykey
	main_menu 6
}

whatdo() {
	clear
	echo
	echo "                  ***************************"
	echo "                  * What do we do about it? *"
	echo "                  ***************************"
	echo
	echo
	echo "        Make Good Stuff"
	echo
	echo "        Support other people who Make Good Stuff"
	echo
	echo "        Provide tech support for your elderly neighbours."
	echo
	echo
	echo
	echo
	echo
	echo "Some cool stuff:"
	echo "        https://github.com/ollama/ollama"
	echo "        https://github.com/ggml-org/llama.cpp"
	echo "        https://github.com/openclaw/openclaw"
	echo "        https://github.com/antirez/ds4"
	echo "        https://github.com/charmbracelet/crush"
	echo "        https://github.com/anomalyco/opencode"
	echo "        https://github.com/earendil-works/pi"
	anykey
	main_menu v
}

blog() {
	lynx "${BLOG_URL}"
	main_menu v
}

view_source() {
	less "${SOURCE_FILE}"
	main_menu v
}

edit_source() {
	echo
	echo "Calling ed(1) , the _standard_ editor ..."
	echo
	if which rlwrap > /dev/null 2>&1
	then
		rlwrap ed "${SOURCE_FILE}"
	else
		ed "${SOURCE_FILE}"
	fi
	exec "${SOURCE_FILE}"
	main_menu v
}

factory() {
	lynx "${FACTORY_URL}"
	AI_works
}

fabro() {
	lynx "${FABRO_URL}"
	AI_works
}

notwrong() {
	lynx "${NOTWRONG_URL}"
	AI_works
}

simplermachines() {
	clear
	echo
	echo
	echo
	cat ./simpler-machines-quote.txt
	echo
	echo
	echo
	anykey
	AI_works
}

the_rules() {
	clear
	echo
	echo
	echo "                               *************"
	echo "                               * The Rules *"
	echo "                               *************"
	echo
	echo
	echo "                           ***   No Doxxing   ***"
	echo
	echo "                        *** Tell your own story ***"
	echo
	echo "                      *** Listen to other stories ***"
	echo
	echo
	echo
	echo
	anykey
	main_menu 1
}

anykey() {

	read -rsn1 _
}

main "${@}"


# The following interpretative note is taken from
# https://inno3.fr/en/blog/an-ai-model-component-exception-for-open-source-licenses/
#
#     AI Model Component Note
#     =======================
#
#     Interpretive clarification for software incorporating AI model components
#
#     The following interpretive clarification applies to the software designated below (the “Program”) and is provided by the copyright holder(s) of the Program. This clarification supplements -​- and shall be read together with -​- the license under which the Program is distributed (the “Applicable License”). It does not add to or remove from the rights and obligations established by the Applicable License; rather, it makes explicit how certain existing obligations apply when the Program incorporates AI model components. To the extent that any provision of this clarification conflicts with the Applicable License, the Applicable License prevails.
#
#     0. Definitions.
#     ---------------
#
#     An “AI Model Component” means any part of the Program whose behavior is determined, in whole or in part, by a machine learning model -​- including but not limited to trained parameters (weights, biases, embeddings), model configuration files, calibration data, quantization tables, or any other artifact whose modification is necessary to adapt, correct, or improve the behavior of that part of the Program.
#
#     For the avoidance of doubt, an AI Model Component is part of the Program; the fact that its behavior results from learned parameters rather than from explicitly programmed instructions does not alter its character as software or diminish the rights granted to recipients under the Applicable License.
#
#     The “Model Corresponding Information” for an AI Model Component means the complete set of information, data, and instructions reasonably necessary for a skilled person to understand, reproduce, modify, and reintegrate that Component into the Program -​- that is, the preferred form of the AI Model Component for making modifications to it. This includes, without limitation:
#
#     (a) the complete specification of the model architecture (topology, layer configuration, activation functions, normalization schemes) in a documented, machine-readable format;
#
#     (b) the trained parameters (weights, biases) in a standard or well-documented format;
#
#     (c) the complete source code of the training, fine-tuning, and evaluation procedures used to produce the distributed parameters, including data preprocessing and augmentation pipelines;
#
#     (d) the training configuration (hyperparameters, optimization settings, random seeds where deterministic reproduction is feasible);
#
#     (e) a sufficiently detailed description of the training data -​- including its provenance, collection method, and processing steps -​- to enable a reasonably skilled person to assemble a functionally equivalent dataset, or the training data itself where it can be lawfully redistributed; and
#
#     (f) the instructions necessary to retrain, fine-tune, or replace the AI Model Component and to reintegrate the modified version into the Program, such that the Program functions with the modified Component in the same manner as it functioned with the original.
#
#     1. Model Corresponding Information as part of Corresponding Source.
#     -------------------------------------------------------------------
#
#     For the avoidance of doubt, the copyright holder(s) clarify that the Model Corresponding Information for each AI Model Component constitutes part of the Corresponding Source (or equivalent concept, as defined in the Applicable License) -​- that is, the preferred form of the work for making modifications to it. The obligation to provide such information arises from the Applicable License itself; this clarification merely makes its scope explicit in the context of software incorporating AI model components.
#
#     Accordingly, any person who distributes or otherwise makes available the Program (or any work based on it) must provide the Model Corresponding Information for each AI Model Component under the same conditions, through the same means, and at the same time as the source code (or equivalent material) required by the Applicable License.
#
#     This applies regardless of the form in which the AI Model Component is distributed -​- whether as source code, binary files, serialized parameters, compiled or optimized intermediate representations, or any other form.
#
#     2. Scope and limitations.
#     -------------------------
#
#     This clarification applies solely to AI Model Components that form an integral part of the Program -​- that is, components without which the Program would not function as intended, or whose removal would materially alter the behavior of the Program. It does not extend to:
#
#     (a) independent AI models merely aggregated with the Program on a volume of storage or distribution medium; or
#
#     (b) AI models invoked by the Program as separate and independent works through standard, publicly documented interfaces (including but not limited to APIs and network calls).
#
#     This clarification creates no obligation with respect to outputs produced by the Program, nor with respect to AI models generated through the use of the Program as a tool. It pertains exclusively to components of the Program itself.
#
#     Where the provision of any element of the Model Corresponding Information is prevented by a legal impediment independent of the distributor’s will -​- in particular, obligations arising under data protection law or the sui generis database right -​- the distributor must provide all elements not so affected, together with a documented description of the missing elements and the precise legal grounds for their omission, so as to enable the recipient to reconstitute or independently obtain such elements.
#
#     3. No further restrictions.
#     ---------------------------
#
#     The Model Corresponding Information must be provided under terms no more restrictive than the Applicable License. You may not impose any further restrictions on the exercise of the rights granted under the Applicable License with respect to the Model Corresponding Information -​- including by way of additional contractual obligations, technical protection measures, access controls, or terms of use that would prevent recipients from using, studying, modifying, or redistributing such information.
#
#     Any such restriction shall be deemed a further restriction within the meaning of the Applicable License, and shall be void and of no effect to the maximum extent permitted by applicable law.
