add skill and some adjustments

This commit is contained in:
2026-02-20 19:42:19 -05:00
parent bac294714b
commit bc30206e65
7 changed files with 108 additions and 75 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@
references/processed_visuals
build
bootslop.proj
clay_ui_temp

View File

@@ -27,17 +27,15 @@ This document outlines the strict C style and architectural conventions expected
* **Case:** Strictly use `lower_snake_case` for all functions and variables.
* **Types:** Use `PascalCase` for type names (`FArena`, `SWord_Tag`).
* **WinAPI Symbols:** When declaring foreign Win32 symbols, prefix the C function name with `ms_` (using `lower_snake_case`) and use the `asm("SymbolName")` attribute to link it to the actual DLL export.
* *Correct:* `WinAPI U2 ms_register_class(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
* *Correct:* `WinAPI U2 ms_register_class_a(const MS_WNDCLASSA* lpWndClass) asm("RegisterClassA");`
* *Incorrect:* `WinAPI U2 RegisterClassA(...);`
## 4. Memory Management
## 4. Formatting & Layout
* **Vertical Alignment:** Align related variable declarations, struct fields, and function prototypes into columns to create a "sheet-like" layout. This improves visual parsing.
* **Brace Style:** Use Allman style (braces on a new line) for function bodies control block (`if`, `for`, `switch`, etc.) that spans more than 50 lines or contains nested logic.
* **Conditionals:** Always place `else if` and `else` statements on a new line, un-nested from the previous closing brace.
## 5. Memory Management
* **No Standard Library:** The environment is built with `-nostdlib` and `-ffreestanding`. Never include `<stdlib.h>`, `<string.h>`, etc.
* **Arenas over Malloc:** Use `FArena` and its associated macros (`farena_push`, `farena_push_type`, `farena_reset`) for all dynamic memory allocations. Do not use raw pointers with manual arithmetic when an arena can handle it.
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic. (A minimal `memset`/`memcpy` shim is only provided to satisfy compiler intrinsic struct zeroing under `-nostdlib`).
## 5. Modifiers
* `internal`: Static functions.
* `global`: Global state variables.
* `IA_`: Internal Always Inline.
* `I_`: Internal Inline.
* Pointers use `*r` (restrict) or `*v` (volatile) macros where applicable.
* **Memory Ops:** Use `mem_fill` and `mem_copy` instead of standard `memset`/`memcpy` within the application logic.

View File

@@ -182,6 +182,24 @@ IA_ U8 align_pow2(U8 x, U8 b) {
return ((x + b - 1) & (~(b - 1)));
}
#if 0
#pragma clang optimize off
// TODO(Ed): Replace these later (only matters if CRT is not used)
void* memset(void* dest, int c, U8 count) {
U1* bytes = (U1*)dest;
while (count--) *bytes++ = (U1)c;
return dest;
}
void* memcpy(void* dest, const void* src, U8 count) {
U1* d = (U1*)dest;
const U1* s = (const U1*)src;
while (count--) *d++ = *s++;
return dest;
}
#pragma clang optimize on
#endif
IA_ U8 mem_copy (U8 dest, U8 src, U8 len) { return (U8)(__builtin_memcpy ((void*)dest, (void const*)src, len)); }
IA_ U8 mem_copy_overlapping(U8 dest, U8 src, U8 len) { return (U8)(__builtin_memmove((void*)dest, (void const*)src, len)); }
IA_ U8 mem_fill (U8 dest, U8 value, U8 len) { return (U8)(__builtin_memset ((void*)dest, (int) value, len)); }

View File

@@ -93,21 +93,6 @@ typedef struct {
global DictEntry dict[256];
global U8 dict_count = 0;
#pragma clang optimize off
void* memset(void* dest, int c, U8 count) {
U1* bytes = (U1*)dest;
while (count--) *bytes++ = (U1)c;
return dest;
}
void* memcpy(void* dest, const void* src, U8 count) {
U1* d = (U1*)dest;
const U1* s = (const U1*)src;
while (count--) *d++ = *s++;
return dest;
}
#pragma clang optimize on
IA_ void scatter(U4 token, const char* anno_str) {
if (tape_arena.used + sizeof(U4) <= tape_arena.capacity && anno_arena.used + sizeof(U8) <= anno_arena.capacity) {
U4*r ptr = C_(U4*r, tape_arena.start + tape_arena.used);

BIN
colorforth-nudge.skill Normal file

Binary file not shown.

31
colorforth-nudge/SKILL.md Normal file
View File

@@ -0,0 +1,31 @@
---
name: colorforth-nudge
description: "Interactive mentor for building a sourceless, zero-overhead ColorForth derivative. Use when the user wants to work on the 'bootslop' project, providing guided nudges and architectural validation based on the Lottes/Onat paradigm."
---
# ColorForth Nudge & Review Skill
This skill transforms Gemini CLI into a highly contextualized mentor for building a specific type of zero-overhead, sourceless ColorForth derivative.
## Workflow Trigger
This skill should be activated when the user expresses intent to work on the "bootslop" or "ColorForth" project.
## Your Role: The Mentor
Your primary goal is to *guide*, not *do*. The user is learning how to build this system from scratch. Your task is to provide architectural validation, specific tactical assistance when requested, and "guided nudges" to help them get to the next step.
## Session Start Procedure
On activation, immediately perform the following steps:
1. **Refresh Context:** Read the following two files from the project root to load the complete architectural blueprint into your context:
* `C:/projects/forth/bootslop/CONVENTIONS.md`
* `C:/projects/forth/bootslop/references/Architectural_Consolidation.md`
2. **Analyze Current State:**
* List the contents of the `attempt_1/` directory.
* Read the `attempt_1/main.c` file.
3. **Prompt for Nudge:** Conclude your first response with a summary of the project's current state and ask the user for the next step.
* **Example:** *"The context is loaded. The current prototype has a working JIT compiler, a modal editor, and a 2-character dictionary resolver. The editor supports keyboard input and visualizes the sourceless token array. What is the next implementation step you'd like me to guide you through?"*

View File

@@ -51,8 +51,8 @@ $compiler_args += $flag_no_optimization
$compiler_args += $flag_diagnostics_absolute_paths
$compiler_args += $flag_exceptions_disabled
$compiler_args += ($flag_include + (join-path $path_root "attempt_1"))
$compiler_args += "-nostdlib"
$compiler_args += "-ffreestanding"
# $compiler_args += "-nostdlib"
# $compiler_args += "-ffreestanding"
$compiler_args += $flag_compile
$compiler_args += $flag_path_output, $object
$compiler_args += $unit_source
@@ -73,7 +73,7 @@ $linker_args += $flag_link_win_debug
$linker_args += $flag_link_win_pdb + $pdb
$linker_args += $flag_link_mapfile + $map
$linker_args += $flag_link_win_subsystem_console
$linker_args += "/nodefaultlib"
# $linker_args += "/nodefaultlib"
$linker_args += "kernel32.lib"
$linker_args += "user32.lib"
$linker_args += "gdi32.lib"