Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ System/config/hippocampus.db
System/config/stylistic_fingerprint.json
System/config/long_term_engram.json
System/config/*.tmp
System/config/features.json
System/tools/engrams

Meta/
Expand Down
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Pre-Alpha](https://img.shields.io/badge/Status-PreAlpha-orange.svg) ![Architecture](https://img.shields.io/badge/Architecture-Biomimetic--Multiagent-purple.svg) ![Security](https://img.shields.io/badge/Sandbox-Deno_+_WASM_or_Docker-red.svg) ![Python 3.12+](https://img.shields.io/badge/Python-3.12%2B-blue.svg) ![Coverage](https://img.shields.io/badge/Coverage-80%25-green.svg) ![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)

> **Note to Systems Engineers:** I took the biomimicry domain-driven design quite far (e.g., the master daemon is the `Medulla`, short-term memory is the `Hippocampus`). It might look eccentric, but underneath is (arguably) a highly optimized, concurrent, lock-safe, and zero-debt execution engine that runs purely on flat files.
> **Note to Systems Engineers:** I took the biomimicry domain-driven design quite far (e.g., the master daemon is the `Medulla`, short-term memory is the `Hippocampus`). It might look eccentric, but underneath is (arguably) a highly optimized, concurrent, lock-safe, and zero-debt-oriented execution engine that runs purely on flat files.

**CoreTex** is a fully local, headless AI operating system inspired by human neuroanatomy and the Unix Philosophy. It operates directly in a sandbox, supercharges your Obsidian vault, orchestrates multi-agent swarms, and executes code within strict Deno / WebAssembly sandboxes. Docker and Firecracker support soon.

Expand All @@ -14,6 +14,14 @@
1. **0-Token Ingestion:** Absorb and index your local workspace using local embeddings (`uv` + local python scripts) with **0 external API calls**. You can read, index, and organize your private vault without spending money or leaking data.
2. **Safe-by-Default Execution:** The default "Cognitive Mode" is strictly read/write advisory. Active shell or script execution requires explicit user consent, and is hard-isolated inside an offline Deno-hosted V8 WebAssembly jail with strict CPU/memory caps and filesystem masking. Or just run it in Docker.

### Threat model, briefly

- **Read scope:** CoreTex reads files you explicitly point it at through commands like `ctx absorb`, sensory tools, or configured workspace paths.
- **Write scope:** File writes are routed through safe-file helpers and constrained to project/vault paths rather than arbitrary host mutation.
- **Execution scope:** Advisory/cognitive flows do not execute generated code by default. Agentic execution requires an explicit mode/tool path and routes untrusted code through the Deno/WASM sandbox or Docker runtime.
- **If Deno is missing:** setup prompts to install it for local sandboxing; Docker remains the isolated fallback path.


---

## ⚡ The "Aha!" Moment (Quickstart)
Expand All @@ -36,19 +44,22 @@ cat error.log | grep "Timeout" | ctx task "Explain this failure cascade"

### Show HN demo loop

For a deterministic first-value demo that does not require an LLM key, run:
The README GIF uses only CoreTex commands:

```bash
python3 scripts/show_hn_demo.py
cat Professional/show-hn-demo-checklist.md
ctx status
ctx absorb examples/show-hn-mini-project --domain Professional --tags show-hn,demo
ctx daydream "Review the absorbed demo context and identify the next useful action" --domain Professional
ctx print-daydream --lines 40
```

For the full CoreTex loop with your provider configured, see
[`docs/ShowHN-Demo.md`](docs/ShowHN-Demo.md).
`ctx print-daydream` writes the DMN ledger to stdout, so it composes naturally with Unix tools and pipes.

For a deterministic non-LLM fallback demo, see [`docs/ShowHN-Demo.md`](docs/ShowHN-Demo.md).

---

## 🚀 Installation (Zero-Debt & Frictionless)
## 🚀 Installation (Low-Friction Setup)

CoreTex features a unified, self-healing installation pipeline that automates all prerequisite matching, virtual environments, and secure container structures out of the box. Clone the repository and run the setup utility matching your host environment:

Expand All @@ -61,7 +72,7 @@ chmod +x setup.sh

For a non-interactive runtime choice, use `./setup.sh --local` or `./setup.sh --docker`.

*Note: The script automatically evaluates your localized package manager (`apt`, `dnf`, `yum`, `pacman`, `apk`, or `brew`) to resolve missing system dependencies like `curl`, `unzip`, and `file`.*
*Note: The script automatically evaluates your localized package manager (`apt`, `dnf`, `yum`, `pacman`, `apk`, or `brew`) to resolve missing system dependencies like `curl`, `unzip`, `file`, and Python prerequisites when possible.*

### 🔷 Windows (PowerShell)
To bypass native Windows script execution restrictions safely without modifying your global system security profile, execute the script via this process-isolated command:
Expand Down Expand Up @@ -153,7 +164,7 @@ ctx destroy
---

## 🤝 Contributing
CoreTex values Shift-Left engineering. We enforce strict 100% test coverage on all security, file locking, and execution bypass logic. To verify your PR against our automated gates:
CoreTex values Shift-Left engineering. We enforce focused regression coverage around security, file locking, and execution bypass logic. To verify your PR against our automated gates:
```bash
uv run pytest System/tests Sense/tests -v
uv run ruff check .
Expand Down
3 changes: 3 additions & 0 deletions System/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
list_reflexes,
map_topology,
observe,
print_daydream,
reflex,
sleep,
status,
Expand Down Expand Up @@ -367,6 +368,8 @@ def run_absorb(
somatic_app.command(name="map-topology")(map_topology)
somatic_app.command(name="status")(status)
somatic_app.command(name="list-reflexes")(list_reflexes)
somatic_app.command(name="print-daydream")(print_daydream)
app.command(name="print-daydream")(print_daydream)
somatic_app.command(name="reflex")(reflex)
somatic_app.command(name="sleep")(sleep)
somatic_app.command(name="assimilate")(assimilate)
Expand Down
22 changes: 22 additions & 0 deletions System/cli_somatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ def status():
console.print("\n")


def print_daydream(
path: Path = typer.Option(
ROOT_DIR / "Meta" / "DMN" / "daydreams.md",
"--path",
"-p",
help="Daydream ledger path to print.",
),
lines: Optional[int] = typer.Option(
None, "--lines", "-n", help="Only print the last N lines."
),
):
"""Prints the DMN daydream ledger to stdout for Unix pipes."""
if not path.exists():
console.print(f"[bold yellow]No daydream ledger found at {path}[/bold yellow]")
raise typer.Exit(code=1)

text = path.read_text(encoding="utf-8", errors="replace")
if lines is not None:
text = "\n".join(text.splitlines()[-lines:])
console.print(text)


def list_reflexes():
"""Reflex Arc: Lists all consolidated muscle memories (Engrams) in the Cerebellum."""
from System.tools import list_engrams
Expand Down
20 changes: 20 additions & 0 deletions System/tests/test_cli_regressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typer.testing import CliRunner

from System.cli import app


def test_map_topology_cli_smoke(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)

result = CliRunner().invoke(app, ["map-topology"])

assert result.exit_code == 0
assert "ImportError" not in result.stdout
assert "cannot import name" not in result.stdout


def test_list_reflexes_cli_smoke():
result = CliRunner().invoke(app, ["list-reflexes"])

assert result.exit_code == 0
assert "Reflex Arc Triggered" in result.stdout
1 change: 1 addition & 0 deletions System/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
)

execute_engram = execute_engram_tool
list_engrams = list_engrams_tool

# PROJECT FORGE LAYER
from .forge import bootstrap_project as bootstrap_project
Binary file removed docs/assets/coretex-ctx-demo.gif
Binary file not shown.
67 changes: 63 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,61 @@ sys.exit(0 if sys.version_info[:2] >= need else 1)
PY
}

python_install_hint() {
if command_exists apt-get; then
echo "sudo apt-get update && sudo apt-get install -y python3 python3-venv"
elif command_exists dnf; then
echo "sudo dnf install -y python3"
elif command_exists yum; then
echo "sudo yum install -y python3"
elif command_exists pacman; then
echo "sudo pacman -Sy --noconfirm python"
elif command_exists apk; then
echo "sudo apk add python3 py3-pip"
elif command_exists brew; then
echo "brew install python@${CORETEX_MIN_PYTHON}"
else
echo "Install Python ${CORETEX_MIN_PYTHON}+ from https://www.python.org/downloads/"
fi
}

install_python_runtime() {
if python_version_available; then
return 0
fi
local hint
hint="$(python_install_hint)"
echo -e "\033[1;33m[!] Python ${CORETEX_MIN_PYTHON}+ is required for local setup.\033[0m"
echo "Suggested install command: $hint"
if ! confirm_default_yes "Install Python prerequisites now?"; then
echo -e "\033[1;31mAborting. Install Python ${CORETEX_MIN_PYTHON}+ manually, or run ./setup.sh --docker.\033[0m" >&2
return 1
fi
SUDO=""
if [ "$(id -u)" -ne 0 ] && command_exists sudo; then SUDO="sudo"; fi
if command_exists apt-get; then
$SUDO apt-get update -y
$SUDO apt-get install -y python3 python3-venv
elif command_exists dnf; then
$SUDO dnf install -y python3
elif command_exists yum; then
$SUDO yum install -y python3
elif command_exists pacman; then
$SUDO pacman -Sy --noconfirm python
elif command_exists apk; then
$SUDO apk add python3 py3-pip
elif command_exists brew; then
brew install "python@${CORETEX_MIN_PYTHON}"
else
echo -e "\033[1;31mERROR: unsupported package manager. $hint\033[0m" >&2
return 1
fi
if ! python_version_available; then
echo -e "\033[1;31mERROR: Python ${CORETEX_MIN_PYTHON}+ still unavailable after install. Try opening a new terminal or run ./setup.sh --docker.\033[0m" >&2
return 1
fi
}

print_next_steps() {
cat <<'EOF'

Expand Down Expand Up @@ -193,6 +248,13 @@ if [ ${#MISSING_UTILS[@]} -ne 0 ]; then
fi

if [ "$AUTO_INSTALL" = true ]; then
if [ "$PKG_MANAGER" != "homebrew" ] && [ "$(id -u)" -ne 0 ] && [ -z "$SUDO" ]; then
echo -e "\033[1;31mCannot install system dependencies: non-root user and sudo is unavailable.\033[0m" >&2
echo "Run manually as an admin/root user:" >&2
if [ -n "$UPDATE_CMD" ]; then echo " $UPDATE_CMD" >&2; fi
echo " $INSTALL_CMD" >&2
exit 1
fi
echo "[*] Installing system dependencies natively..."
if [ -n "$UPDATE_CMD" ]; then
$SUDO $UPDATE_CMD
Expand Down Expand Up @@ -320,10 +382,7 @@ fi

echo -e "\n[*] \033[1;36mInitializing Pure Local Environment...\033[0m"

if ! python_version_available; then
echo -e "\033[1;31mERROR: Python ${CORETEX_MIN_PYTHON}+ is required for local setup. Install Python ${CORETEX_MIN_PYTHON}+ or run ./setup.sh --docker.\033[0m" >&2
exit 1
fi
install_python_runtime

install_uv_runtime
install_deno_runtime
Expand Down
Loading