@icarusmx/creta 1.4.17 → 1.4.18
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/lib/cli/index.js +7 -0
- package/lib/customizers/TerminalCustomizer.js +104 -0
- package/package.json +1 -1
- package/wea-fome-qlia.sh +92 -0
package/lib/cli/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { showHelp } from '../commands/help.js'
|
|
|
8
8
|
import { CretaCodeSession } from '../session.js'
|
|
9
9
|
import { greetUser } from '../utils/greeting.js'
|
|
10
10
|
import { SandboxManager } from '../sandbox/SandboxManager.js'
|
|
11
|
+
import TerminalCustomizer from '../customizers/TerminalCustomizer.js'
|
|
11
12
|
|
|
12
13
|
async function executeMainMenu() {
|
|
13
14
|
const menu = new MenuBuilder(getMainMenuConfig())
|
|
@@ -40,6 +41,11 @@ async function resetUserState() {
|
|
|
40
41
|
console.log('✅ Estado de usuario reiniciado. La próxima vez que ejecutes creta, se te pedirá tu nombre de nuevo.')
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
async function customizeTerminal() {
|
|
45
|
+
const customizer = new TerminalCustomizer()
|
|
46
|
+
await customizer.customize()
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
const COMMANDS = new Map([
|
|
44
50
|
['enunciados', () => executeEnunciados()],
|
|
45
51
|
['sintaxis', () => executeSintaxis()],
|
|
@@ -47,6 +53,7 @@ const COMMANDS = new Map([
|
|
|
47
53
|
['portafolio', () => executePortfolio(0)],
|
|
48
54
|
['code', () => runCodeSession()],
|
|
49
55
|
['reset', () => resetUserState()],
|
|
56
|
+
['icarus-terminal', () => customizeTerminal()],
|
|
50
57
|
['help', () => showHelp()],
|
|
51
58
|
['ayuda', () => showHelp()]
|
|
52
59
|
])
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
|
|
6
|
+
class TerminalCustomizer {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.homeDir = os.homedir();
|
|
9
|
+
this.zshrcPath = path.join(this.homeDir, '.zshrc');
|
|
10
|
+
this.icarusZshPath = path.join(this.homeDir, '.icarus-zsh');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async customize() {
|
|
14
|
+
console.log('\n🏛️ Configurando tu terminal Icarus...\n');
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// Backup existing .zshrc if it exists
|
|
18
|
+
if (fs.existsSync(this.zshrcPath)) {
|
|
19
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
20
|
+
const backupPath = `${this.zshrcPath}.backup.${timestamp}`;
|
|
21
|
+
fs.copyFileSync(this.zshrcPath, backupPath);
|
|
22
|
+
console.log(`✅ Backup creado: ${backupPath}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Create ~/.icarus-zsh with custom configuration
|
|
26
|
+
this.createIcarusZsh();
|
|
27
|
+
console.log(`✅ Configuración creada: ${this.icarusZshPath}`);
|
|
28
|
+
|
|
29
|
+
// Add source line to .zshrc if not already present
|
|
30
|
+
this.updateZshrc();
|
|
31
|
+
console.log(`✅ Terminal configurado`);
|
|
32
|
+
|
|
33
|
+
// Apply changes instantly
|
|
34
|
+
this.applyChanges();
|
|
35
|
+
|
|
36
|
+
console.log('\n🎉 ¡Terminal Icarus configurado exitosamente!');
|
|
37
|
+
console.log('💡 Reinicia tu terminal o ejecuta: source ~/.zshrc\n');
|
|
38
|
+
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('❌ Error al configurar el terminal:', error.message);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
createIcarusZsh() {
|
|
46
|
+
// Use template literal with escaped $ to prevent Node.js interpolation
|
|
47
|
+
const config = `# ========================================
|
|
48
|
+
# 🏛️ Icarus Terminal Configuration
|
|
49
|
+
# ========================================
|
|
50
|
+
|
|
51
|
+
# Custom Icarus prompt with color #007acc
|
|
52
|
+
autoload -U colors && colors
|
|
53
|
+
|
|
54
|
+
# Prompt color codes
|
|
55
|
+
ICARUS_BLUE='%F{39}'
|
|
56
|
+
RESET='%f'
|
|
57
|
+
|
|
58
|
+
# Custom prompt: [🏛️ icarus] ~/path $
|
|
59
|
+
PROMPT="\${ICARUS_BLUE}[🏛️ icarus]\${RESET} %~ $ "
|
|
60
|
+
|
|
61
|
+
# Welcome message using print -P (interprets prompt escapes)
|
|
62
|
+
print ""
|
|
63
|
+
print -P "\${ICARUS_BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\${RESET}"
|
|
64
|
+
print -P "\${ICARUS_BLUE} 🏛️ Bienvenido a Icarus Terminal\${RESET}"
|
|
65
|
+
print -P "\${ICARUS_BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\${RESET}"
|
|
66
|
+
print ""
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
fs.writeFileSync(this.icarusZshPath, config, 'utf8');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
updateZshrc() {
|
|
73
|
+
const sourceLine = '\n# Source Icarus terminal configuration\n[ -f ~/.icarus-zsh ] && source ~/.icarus-zsh\n';
|
|
74
|
+
|
|
75
|
+
// Create .zshrc if it doesn't exist
|
|
76
|
+
if (!fs.existsSync(this.zshrcPath)) {
|
|
77
|
+
fs.writeFileSync(this.zshrcPath, sourceLine, 'utf8');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Check if already sourced
|
|
82
|
+
const currentContent = fs.readFileSync(this.zshrcPath, 'utf8');
|
|
83
|
+
if (currentContent.includes('source ~/.icarus-zsh') || currentContent.includes('. ~/.icarus-zsh')) {
|
|
84
|
+
console.log('⚠️ Icarus ya estaba configurado en .zshrc (actualizando)');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Append source line
|
|
89
|
+
fs.appendFileSync(this.zshrcPath, sourceLine, 'utf8');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
applyChanges() {
|
|
93
|
+
try {
|
|
94
|
+
// Note: This won't change the current terminal session's prompt,
|
|
95
|
+
// but it will be applied in new sessions
|
|
96
|
+
execSync('source ~/.zshrc', { shell: '/bin/zsh', stdio: 'inherit' });
|
|
97
|
+
} catch (error) {
|
|
98
|
+
// Source command may fail in some contexts, but config is still written
|
|
99
|
+
// User can manually source or restart terminal
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default TerminalCustomizer;
|
package/package.json
CHANGED
package/wea-fome-qlia.sh
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Summarize a repository's architecture via codex using lightweight bash reconnaissance.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
show_help() {
|
|
6
|
+
cat <<'USAGE'
|
|
7
|
+
Usage: wea-fome-qlia.sh [path-to-repo]
|
|
8
|
+
|
|
9
|
+
Collects structural signals from the repository using basic shell commands
|
|
10
|
+
and streams them into `codex -p` to obtain a five-sentence architecture summary.
|
|
11
|
+
Set the SUMMARIZER_PROMPT environment variable to override the default prompt.
|
|
12
|
+
USAGE
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then
|
|
16
|
+
show_help
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if (( $# > 1 )); then
|
|
21
|
+
echo "Only zero or one path argument is supported." >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
REPO_DIR=${1:-.}
|
|
26
|
+
if [[ ! -d "$REPO_DIR" ]]; then
|
|
27
|
+
echo "The path '$REPO_DIR' is not a directory." >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if [[ -z ${BASH_VERSION:-} ]]; then
|
|
32
|
+
echo "This script requires bash. Run it as './wea-fome-qlia.sh' or 'bash wea-fome-qlia.sh'." >&2
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
if ! command -v codex >/dev/null 2>&1; then
|
|
37
|
+
echo "The 'codex' CLI is required but was not found in PATH." >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
REPO_DIR=$(cd "$REPO_DIR" && pwd)
|
|
42
|
+
TEMP_INPUT=$(mktemp)
|
|
43
|
+
trap 'rm -f "$TEMP_INPUT"' EXIT
|
|
44
|
+
|
|
45
|
+
MAX_DIRS=8
|
|
46
|
+
MAX_ITEMS=12
|
|
47
|
+
PROMPT=${SUMMARIZER_PROMPT:-"You are a senior software architect. Using the repository signals provided, write exactly five sentences that explain the current architecture, main modules, dominant technologies, notable build or tooling traits, and any potential work-in-progress areas."}
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
echo "Repository: $REPO_DIR"
|
|
51
|
+
echo
|
|
52
|
+
echo "Top-level entries (ls):"
|
|
53
|
+
ls -1A "$REPO_DIR" | sed 's/^/ - /'
|
|
54
|
+
|
|
55
|
+
echo
|
|
56
|
+
echo "Directory snapshots:"
|
|
57
|
+
dir_count=0
|
|
58
|
+
while IFS= read -r entry; do
|
|
59
|
+
[[ -z "$entry" ]] && continue
|
|
60
|
+
path="$REPO_DIR/$entry"
|
|
61
|
+
if [[ -d "$path" ]]; then
|
|
62
|
+
((dir_count++))
|
|
63
|
+
echo "* $entry"
|
|
64
|
+
ls -1A "$path" | head -n "$MAX_ITEMS" | sed 's/^/ /'
|
|
65
|
+
if command -v git >/dev/null 2>&1; then
|
|
66
|
+
echo " (files: $(ls -1A "$path" | wc -l | tr -d ' '))"
|
|
67
|
+
fi
|
|
68
|
+
echo
|
|
69
|
+
fi
|
|
70
|
+
if (( dir_count >= MAX_DIRS )); then
|
|
71
|
+
break
|
|
72
|
+
fi
|
|
73
|
+
done <<EOF
|
|
74
|
+
$(ls -1A "$REPO_DIR")
|
|
75
|
+
EOF
|
|
76
|
+
|
|
77
|
+
if command -v git >/dev/null 2>&1 && git -C "$REPO_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
78
|
+
echo "Git status:"
|
|
79
|
+
git -C "$REPO_DIR" status -sb
|
|
80
|
+
|
|
81
|
+
echo
|
|
82
|
+
echo "Recent commits:"
|
|
83
|
+
git -C "$REPO_DIR" log -5 --oneline
|
|
84
|
+
fi
|
|
85
|
+
} > "$TEMP_INPUT"
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
printf '%s\n\n' "$PROMPT"
|
|
89
|
+
echo '--- Repository signals start ---'
|
|
90
|
+
cat "$TEMP_INPUT"
|
|
91
|
+
echo '--- Repository signals end ---'
|
|
92
|
+
} | codex exec -
|