repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | /** |
| #2 | * State Versioning |
| #3 | * |
| #4 | * Version control the automaton's own state files (~/.automaton/). |
| #5 | * Every self-modification triggers a git commit with a descriptive message. |
| #6 | * The automaton's entire identity history is version-controlled and replayable. |
| #7 | */ |
| #8 | import { gitInit, gitCommit, gitStatus, gitLog } from "./tools.js"; |
| #9 | const AUTOMATON_DIR = "~/.automaton"; |
| #10 | function resolveHome(p) { |
| #11 | const home = process.env.HOME || "/root"; |
| #12 | if (p.startsWith("~")) { |
| #13 | return `${home}${p.slice(1)}`; |
| #14 | } |
| #15 | return p; |
| #16 | } |
| #17 | /** |
| #18 | * Initialize git repo for the automaton's state directory. |
| #19 | * Creates .gitignore to exclude sensitive files. |
| #20 | */ |
| #21 | export async function initStateRepo(runtime) { |
| #22 | const dir = resolveHome(AUTOMATON_DIR); |
| #23 | // Check if already initialized |
| #24 | const checkResult = await runtime.exec(`test -d ${dir}/.git && echo "exists" || echo "nope"`, 5000); |
| #25 | if (checkResult.stdout.trim() === "exists") { |
| #26 | return; |
| #27 | } |
| #28 | // Initialize |
| #29 | await gitInit(runtime, dir); |
| #30 | // Create .gitignore for sensitive files |
| #31 | const gitignore = `# Sensitive files - never commit |
| #32 | wallet.json |
| #33 | config.json |
| #34 | state.db |
| #35 | state.db-wal |
| #36 | state.db-shm |
| #37 | logs/ |
| #38 | *.log |
| #39 | *.err |
| #40 | `; |
| #41 | await runtime.writeFile(`${dir}/.gitignore`, gitignore); |
| #42 | // Configure git user |
| #43 | await runtime.exec(`cd ${dir} && git config user.name "Automaton" && git config user.email "automaton@x402.wtf"`, 5000); |
| #44 | // Initial commit |
| #45 | await gitCommit(runtime, dir, "genesis: automaton state repository initialized"); |
| #46 | } |
| #47 | /** |
| #48 | * Commit a state change with a descriptive message. |
| #49 | * Called after any self-modification. |
| #50 | */ |
| #51 | export async function commitStateChange(runtime, description, category = "state") { |
| #52 | const dir = resolveHome(AUTOMATON_DIR); |
| #53 | // Check if there are changes |
| #54 | const status = await gitStatus(runtime, dir); |
| #55 | if (status.clean) { |
| #56 | return "No changes to commit"; |
| #57 | } |
| #58 | const message = `${category}: ${description}`; |
| #59 | const result = await gitCommit(runtime, dir, message); |
| #60 | return result; |
| #61 | } |
| #62 | /** |
| #63 | * Commit after a SOUL.md update. |
| #64 | */ |
| #65 | export async function commitSoulUpdate(runtime, description) { |
| #66 | return commitStateChange(runtime, description, "soul"); |
| #67 | } |
| #68 | /** |
| #69 | * Commit after a skill installation or removal. |
| #70 | */ |
| #71 | export async function commitSkillChange(runtime, skillName, action) { |
| #72 | return commitStateChange(runtime, `${action} skill: ${skillName}`, "skill"); |
| #73 | } |
| #74 | /** |
| #75 | * Commit after heartbeat config change. |
| #76 | */ |
| #77 | export async function commitHeartbeatChange(runtime, description) { |
| #78 | return commitStateChange(runtime, description, "heartbeat"); |
| #79 | } |
| #80 | /** |
| #81 | * Commit after config change. |
| #82 | */ |
| #83 | export async function commitConfigChange(runtime, description) { |
| #84 | return commitStateChange(runtime, description, "config"); |
| #85 | } |
| #86 | /** |
| #87 | * Get the state repo history. |
| #88 | */ |
| #89 | export async function getStateHistory(runtime, limit = 20) { |
| #90 | const dir = resolveHome(AUTOMATON_DIR); |
| #91 | return gitLog(runtime, dir, limit); |
| #92 | } |
| #93 | //# sourceMappingURL=state-versioning.js.map |