Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(skill-burger): retain Git metadata mutations in saved runs
Afloata6077aca788a
diff --git a/shared/run-command.ts b/shared/run-command.tsindex 2827ab6cc3..75b635ce4a 100644--- a/shared/run-command.ts+++ b/shared/run-command.ts@@ -76,8 +76,9 @@ const READ_PROGRAM = new Set(["md5", "shasum", "sha256sum", "jq", "yq", "column","export", "unset", "alias", "true", "false", ":", "sleep", "exit",]);-const GIT_READ = new Set(["status", "log", "diff", "show", "blame", "branch", "tag", "ls-files", "rev-parse", "remote", "describe", "shortlog", "reflog"]);+const GIT_READ = new Set(["status", "log", "diff", "show", "blame", "ls-files", "rev-parse", "describe", "shortlog"]);const GIT_VALUE_FLAG = new Set(["-C", "-c"]);+const GIT_REF_VALUE_FLAG = new Set(["--sort", "--format"]);const GH_READ = new Set(["pr view", "pr list", "pr checks", "pr diff", "issue view", "issue list", "run view", "run list"]);const GH_VALUE_FLAG = new Set(["-R", "--repo"]);const NO_VALUE_FLAG = new Set<string>();@@ -99,6 +100,40 @@ function words(rest: string[], valueFlags: ReadonlySet<string>): string[] {return found;}+function isGitRead(rest: string[]): boolean {+ let i = 0;+ while (i < rest.length && unquote(rest[i]).startsWith("-")) {+ i += GIT_VALUE_FLAG.has(unquote(rest[i])) ? 2 : 1;+ }+ const subcommand = rest[i] && unquote(rest[i]);+ const args = rest.slice(i + 1).map(unquote);+ const flags: string[] = [];+ for (let j = 0; j < args.length; j += 1) {+ if (GIT_REF_VALUE_FLAG.has(args[j])) j += 1;+ else if (args[j].startsWith("-")) flags.push(args[j]);+ }+ switch (subcommand) {+ case "branch":+ if (flags.some((arg) => /^-[^-]*[dDmMcCfu]/.test(arg) || /^--(?:delete|delete-merged|move|copy|force|set-upstream-to|unset-upstream|edit-description)(?:=|$)/.test(arg))) return false;+ if (flags.some((arg) => /^-[^-]*[lar]/.test(arg) || /^--(?:list|all|remotes|show-current|contains|no-contains|merged|no-merged|points-at|forked)(?:=|$)/.test(arg))) return true;+ return words(args, GIT_REF_VALUE_FLAG).length === 0;+ case "tag":+ if (flags.some((arg) => /^-[^-]*[adfFsmue]/.test(arg) || /^--(?:delete|annotate|sign|force|message|file|local-user|edit|trailer|cleanup)(?:=|$)/.test(arg))) return false;+ if (flags.some((arg) => /^-[^-]*[lnv]/.test(arg) || /^--(?:list|verify|contains|no-contains|merged|no-merged|points-at)(?:=|$)/.test(arg))) return true;+ return words(args, GIT_REF_VALUE_FLAG).length === 0;+ case "remote": {+ const [verb] = words(args, NO_VALUE_FLAG);+ return verb === undefined || verb === "show" || verb === "get-url";+ }+ case "reflog": {+ const [verb] = words(args, NO_VALUE_FLAG);+ return !/^(?:expire|delete|drop|write)$/.test(verb ?? "");+ }+ default:+ return subcommand === undefined || GIT_READ.has(subcommand);+ }+}+function mutatesOverHttp(rest: string[]): boolean {for (let i = 0; i < rest.length; i += 1) {const token = unquote(rest[i]);@@ -123,10 +158,7 @@ function isRead(argv: string[]): boolean {switch (program) {case "sed":return !rest.some((token) => SED_IN_PLACE.test(unquote(token)));- case "git": {- const [subcommand] = words(rest, GIT_VALUE_FLAG);- return subcommand === undefined || GIT_READ.has(subcommand);- }+ case "git": return isGitRead(rest);case "gh": {const [group, verb] = words(rest, GH_VALUE_FLAG);if (group === "api") return !mutatesOverHttp(rest) && !rest.some((token) => GH_FIELD_FLAG.test(unquote(token)));diff --git a/shared/skill-burger/draft.test.ts b/shared/skill-burger/draft.test.tsindex 91702a7e13..2fe89d41eb 100644--- a/shared/skill-burger/draft.test.ts+++ b/shared/skill-burger/draft.test.ts@@ -107,6 +107,20 @@ describe("burger layers", () => {});describe("draftWorkflow", () => {+ it.each(["Bash", "mcp__agents__vm_exec", "mcp__computer__exec", "mcp__localComputer__exec"])("keeps Git mutations when saving a %s release workflow", (name) => {+ const draft = draftWorkflow([+ ask("Publish the release"),+ tool(name, { command: "git tag --list" }),+ tool(name, { command: "git tag v1.2.3" }),+ tool(name, { command: "git push origin v1.2.3" }),+ ]);+ expect(draft).not.toBeNull();+ expect(draft!.workflow.steps.map((step) => step.kind === "shell" && step.run)).toEqual([+ "git tag v1.2.3", "git push origin v1.2.3",+ ]);+ expect(workflowSchema.safeParse(draft!.workflow).success).toBe(true);+ });+it("returns nothing for a run of fewer than two steps", () => {expect(draftWorkflow([ask("hi"), tool("Bash", { command: "git push" }, { summary: "git push" })])).toBeNull();});diff --git a/src/lib/verify-steps.test.ts b/src/lib/verify-steps.test.tsindex 388d5e0fcd..833e08cb0b 100644--- a/src/lib/verify-steps.test.ts+++ b/src/lib/verify-steps.test.ts@@ -85,6 +85,26 @@ describe("parseRunCommand", () => {"cat scripts/x.ts","git log --oneline","git -C repo status --short",+ "git branch",+ "git branch -avv",+ "git branch --list 'release/*'",+ "git branch --contains HEAD",+ "git branch --format '%(refname:short)'",+ "git branch --sort -committerdate",+ "git -c color.ui=always branch --show-current",+ "git tag",+ "git tag -ln2 'v*'",+ "git tag --verify v1.2.3",+ "git tag -v v1.2.3",+ "git tag --sort version:refname",+ "git tag --format '%(refname:short)'",+ "git tag --points-at HEAD",+ "git remote -v",+ "git remote show origin",+ "git remote get-url --push origin",+ "git reflog HEAD",+ "git reflog show main",+ "git reflog show delete","gh pr view 12","gh api repos/o/r/pulls/1","grep -rn foo src",@@ -104,6 +124,24 @@ describe("parseRunCommand", () => {it.each([[PUSH, "git push"],["git -C repo commit -m x", "git commit"],+ ["git branch release", "git branch"],+ ["git branch -D obsolete", "git branch"],+ ["git branch -rd origin/obsolete", "git branch"],+ ["git branch -m renamed", "git branch"],+ ["git branch --unset-upstream", "git branch"],+ ["git branch --set-upstream-to=origin/main", "git branch"],+ ["git -c color.ui=always -C repo branch --copy main release", "git branch"],+ ["git branch --format '%(refname:short)' release", "git branch"],+ ["git tag v1.2.3", "git tag"],+ ["git tag -am release v1.2.3", "git tag"],+ ["git tag --delete v1.2.3", "git tag"],+ ["git tag --sort version:refname v1.2.3", "git tag"],+ ["git remote add upstream https://example.com/upstream.git", "git remote"],+ ["git remote set-url origin https://example.com/fork.git", "git remote"],+ ["git remote remove upstream", "git remote"],+ ["git remote update --prune", "git remote"],+ ["git reflog expire --expire=now --all", "git reflog"],+ ["git reflog delete HEAD@{1}", "git reflog"],["gh release create v1 --notes x", "gh release"],["gh api -X POST repos/o/r/issues -f title=x", "gh api"],["gh api --method DELETE repos/o/r/issues/1", "gh api"],@@ -168,6 +206,18 @@ describe("nameIsCommand", () => {});describe("runSteps", () => {+ it("keeps the tag creation needed before publishing a release", () => {+ const steps = runSteps([+ ask("Publish the release"),+ claude("git tag --list", true),+ claude("git tag v1.2.3", true),+ claude("git push origin v1.2.3", true),+ ]);+ expect(steps.map((step) => step.command)).toEqual(["git tag v1.2.3", "git push origin v1.2.3"]);+ expect(showRun(steps)).toBe(true);+ expect(skillPrompt(steps)).toContain("git tag v1.2.3");+ });+it("lists every command from every driver shape, in order, reads left out, control-CLI steps verified", () => {const steps = runSteps([ask("verify the fixture"),