YujunZhou/tellonce / codex
tellonce
VerifiedUse to view, explain, correct, delete or reorganize the user's saved preferences, or to record one by hand when automatic recording is off; learning and rule injection otherwise run automatically through Codex hooks.
tellonce_codex/install.py
View on GitHubfrom __future__ import annotations
import os
import sys
from dataclasses import dataclass
from pathlib import Path
from .ledger import secure_write_text
from .paths import Registration, register_project
@dataclass(frozen=True)
class InstallRecord:
state_root: Path
registration: Registration
hooks_registered: bool = False
def _try_register_global_hooks() -> tuple[bool, str]:
"""Auto-register PT hooks in ~/.codex/hooks.json if the global
runtime layout exists. Idempotent — re-running is safe (skipped =
"already registered").
Returns (registered, message). registered=True iff the call ran without
error AND the hooks dir exists. message is for the caller to surface.
"""
skill_dir = Path.home() / ".codex" / "skills" / "tellonce"
# Mirror codex/install.sh's clone detection: when the user's git clone
# occupies the default path, the generated runtime (with the CODEX hook
# scripts) lives in the sibling -runtime dir. The clone's root hooks/
# holds the Claude Code variant's hooks — registering that dir here would
# create phantom entries pointing at scripts that don't exist there.
# `.git` covers clones; the codex/install.sh marker covers repos COPIED
# there without git metadata (the generated runtime layout has no codex/).
if (skill_dir / ".git").exists() or (skill_dir / "codex" / "install.sh").exists():
skill_dir = Path.home() / ".codex" / "skills" / "tellonce-runtime"
hooks_dir = skill_dir / "hooks"
hooks_json = Path.home() / ".codex" / "hooks.json"
if not hooks_dir.is_dir():
return False, (
f"⚠ ~/.codex/skills/tellonce/hooks/ not present — global "
f"runtime not installed yet. Run `bash codex/install.sh` once to "
f"deploy the runtime + hooks. Current call only initialized "
f"per-project state."
)
try:
from .install_codex_hooks import cmd_add
cmd_add(str(hooks_json), str(hooks_dir))
return True, f"✓ hooks registered in {hooks_json}"
except Exception as e:
return False, f"⚠ hook registration failed: {type(e).__name__}: {e}"
def install(project_root: Path, register_hooks: bool = True) -> InstallRecord:
disabled_marker = project_root.resolve() / ".codex" / "tellonce.disabled"
try:
disabled_marker.unlink()
except OSError:
pass
registration = register_project(project_root)
state = registration.state_root
secure_write_text(state / "install_record.json", '{"status":"installed"}\n')
secure_write_text(state / "managed_runtime.txt", "tellonce_codex runtime\n")
hooks_registered = False
if register_hooks:
hooks_registered, msg = _try_register_global_hooks()
# Surface the message so users running `tellonce_codex install`
# bare (without bash install.sh wrapping it) see what happened.
try:
sys.stderr.write(msg + "\n")
except Exception:
pass
return InstallRecord(
state_root=state,
registration=registration,
hooks_registered=hooks_registered,
)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |