mos-tui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/mos.sh CHANGED
@@ -1,14 +1,9 @@
1
1
  #!/usr/bin/env bash
2
- # ─────────────────────────────────────────────────────────────
3
- # MOS Terminal UI Launcher
4
- # Usage: ./mos.sh
5
- # Run from the same directory as OS_CP.c
6
- # ─────────────────────────────────────────────────────────────
7
-
8
2
  set -e
9
3
 
10
4
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
5
  TUI="$SCRIPT_DIR/mos_tui.py"
6
+ DEFAULT_OS="$SCRIPT_DIR/OS_CP.c"
12
7
 
13
8
  # Check Python 3
14
9
  if ! command -v python3 &>/dev/null; then
@@ -22,23 +17,28 @@ if ! command -v gcc &>/dev/null; then
22
17
  exit 1
23
18
  fi
24
19
 
25
- # Check OS_CP.c exists in current dir
26
- if [ ! -f "OS_CP.c" ]; then
27
- echo " OS_CP.c not found in current directory."
28
- echo " Place OS_CP.c here or cd into the right folder, then re-run."
29
- echo " Launching TUI anyway — you can still use it without the source."
20
+ # Decide which OS_CP.c to use
21
+ if [ -f "OS_CP.c" ]; then
22
+ OS_FILE="$(pwd)/OS_CP.c"
23
+ echo "📄 Using OS_CP.c from current directory"
24
+ else
25
+ OS_FILE="$DEFAULT_OS"
26
+ echo "📦 Using bundled OS_CP.c"
30
27
  fi
31
28
 
32
- # Ensure the TUI script is alongside
29
+ # Export so Python can use it
30
+ export MOS_OS_FILE="$OS_FILE"
31
+
32
+ # Ensure the TUI script exists
33
33
  if [ ! -f "$TUI" ]; then
34
- echo " mos_tui.py not found at: $TUI"
34
+ echo "mos_tui.py not found at: $TUI"
35
35
  exit 1
36
36
  fi
37
37
 
38
- # Set up terminal properly
38
+ # Terminal setup
39
39
  export TERM="${TERM:-xterm-256color}"
40
40
 
41
- echo " Starting MOS Terminal UI..."
41
+ echo "🚀 Starting MOS Terminal UI..."
42
42
  sleep 0.3
43
43
 
44
44
  python3 "$TUI"
package/core/mos_tui.py CHANGED
@@ -28,8 +28,18 @@ C_INPUT = 9 # green on black (input text)
28
28
  C_ORANGE = 10 # yellow bright (used for EXEC tags)
29
29
  C_STAT_VAL = 11 # cyan bold for stat values
30
30
 
31
- BINARY = "./mos_bin"
32
- SOURCE = "OS_CP.c"
31
+ # Correct base directory (where this script is installed)
32
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
33
+
34
+ # Get source file (user provided OR bundled)
35
+ SOURCE = os.environ.get(
36
+ "MOS_OS_FILE",
37
+ os.path.join(BASE_DIR, "OS_CP.c")
38
+ )
39
+
40
+ # Binary will be created in same directory as source
41
+ BINARY = os.path.join(os.path.dirname(SOURCE), "mos_bin")
42
+
33
43
 
34
44
  # ── STATE ─────────────────────────────────────────────────────────────────────
35
45
  class State:
@@ -70,7 +80,9 @@ def compile_source():
70
80
  state.add_debug("INFO", f"Compiling {SOURCE}...")
71
81
  result = subprocess.run(
72
82
  ["gcc", "-o", BINARY, SOURCE, "-lm"],
73
- capture_output=True, text=True
83
+ cwd=os.path.dirname(SOURCE),
84
+ capture_output=True,
85
+ text=True
74
86
  )
75
87
  if result.returncode != 0:
76
88
  state.compile_error = result.stderr.strip()
@@ -573,7 +585,7 @@ def main(stdscr):
573
585
  stdscr.keypad(True)
574
586
 
575
587
  state.add_debug("INFO", "MOS Terminal UI started")
576
- state.add_debug("INFO", f"Looking for {SOURCE} in: {os.getcwd()}")
588
+ state.add_debug("INFO", f"Using source: {SOURCE}")
577
589
  if os.path.exists(SOURCE):
578
590
  state.add_debug("OK", f"Found {SOURCE} — press F6 to compile")
579
591
  else:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mos-tui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MOS Terminal UI Launcher",
5
5
  "bin": {
6
6
  "mos": "./bin/mos.js"
@@ -8,4 +8,4 @@
8
8
  "type": "commonjs",
9
9
  "author": "Ayush",
10
10
  "license": "MIT"
11
- }
11
+ }