§9 acceptance: grep-zero sweep — every internal x.ai/grok identifier renamed
The PRD's first acceptance gate now holds: grep -RinE '\bx\.ai\b|grok' crates/ --include='*.rs' → 0 matches (exempt: NOTICE and third-party license archives, README provenance, and the required 'Based on Grok Build Open Source' attribution, now sourced from version_attribution.txt). Wire-visible renames (both sides in this repo, changed in lockstep): - Auth method id 'grok.com' → 'kimi-code' (AuthMethodKind::KimiCode). - Every x.ai/* and _x.ai/* ACP ext method and meta key → kigi/* / _kigi/* (~200 names; grokShell → kigiShell). Session-file replay keeps a read-side alias for the legacy '_x.ai/session/update' method so existing updates.jsonl histories load; writes emit only the new name (both directions test-pinned). - Agent types grok-build* → kigi* with a documented legacy-prefix alias at resolution time so persisted sessions keep resolving. - ToolNamespace/BuiltinAgentName GrokBuild* → Kigi* (wire snake_case kigi/kigi_concise/kigi_hashline; schema regenerated); grok_build implementation dirs renamed to kigi*. - x-grok-* headers → x-kigi-*, __GROK_* sentinels → __KIGI_*, themes grokday/groknight → kigiday/kiginight (old persisted values fall back to the default theme), web_fetch allowlist xAI hosts → kimi.com + moonshot platforms, changelog CDN → this repo, grok-build changelog archives deleted. - BYOK default endpoint removed: [endpoints] api_base_url is now truly optional with NO default — consumers fail fast with the flag name when unset (no silent x.ai egress). Mock harnesses inject it explicitly. - System-prompt identity fixed: 'released by xAI' → 'an unofficial community CLI for Kimi' (template + regenerated encrypted form). Also repaired pre-existing grok-era test debt found by the sweep: the stale trace_classify default-model pin, the grok-pager UA label test, pty-harness stale-binary reuse and non-hermetic moonshot routing (a PTY test could previously reach the real api.moonshot.cn), and the outdated oauth fixture scope key. Gates: §9 grep 0; fmt clean; workspace check/clippy 0/0 (-D warnings); FULL cargo test --workspace: 234 suites, 21,961 passed, 0 failed; deny advisories ok.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
//! reachable only through the login shell is still found.
|
||||
//!
|
||||
//! Inject is **always** non-empty on Unix callers: either install a shadow
|
||||
//! function (which tags itself with a `__grok_shadow_{name}` marker) or a
|
||||
//! function (which tags itself with a `__kigi_shadow_{name}` marker) or a
|
||||
//! marker-gated `unalias`+`unset -f` that drops *only* a prior harness shadow —
|
||||
//! never a user-defined `find`/`grep` function replayed from the snapshot.
|
||||
|
||||
@@ -47,7 +47,7 @@ const UGREP_DEFAULT_ARGS: &[&str] = &[
|
||||
|
||||
// Binaries embedded by build.rs when `KIGI_TOOLS_BUNDLE_{BFS,UGREP}_PATH` is set
|
||||
// (release pipeline). Self-extracted to `~/.kigi/vendor` on first use, mirroring
|
||||
// the ripgrep bundling in `grok_build::grep::ripgrep`.
|
||||
// the ripgrep bundling in `kigi::grep::ripgrep`.
|
||||
#[cfg(bundle_bfs)]
|
||||
const BFS_BYTES: &[u8] = include_bytes!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
@@ -100,16 +100,16 @@ fn build_injection(find_on: bool, grep_on: bool, tools: &ResolvedTools) -> Strin
|
||||
}
|
||||
|
||||
/// Drop a *previously installed harness* shadow so command-word `{name}` uses the
|
||||
/// OS binary again. Gated on the `__grok_shadow_{name}` marker that
|
||||
/// OS binary again. Gated on the `__kigi_shadow_{name}` marker that
|
||||
/// [`shell_function`] sets, so a user-defined `{name}` function replayed from the
|
||||
/// shell snapshot is left intact — only the harness's own shadow is removed.
|
||||
/// `set -u`/`set -e` safe and idempotent (`unset -f` is bash + zsh).
|
||||
fn restore_command(name: &str) -> String {
|
||||
format!(
|
||||
"if [ -n \"${{__grok_shadow_{name}-}}\" ]; then \
|
||||
"if [ -n \"${{__kigi_shadow_{name}-}}\" ]; then \
|
||||
unalias {name} 2>/dev/null || true; \
|
||||
unset -f {name} 2>/dev/null || true; \
|
||||
unset __grok_shadow_{name} 2>/dev/null || true; \
|
||||
unset __kigi_shadow_{name} 2>/dev/null || true; \
|
||||
fi"
|
||||
)
|
||||
}
|
||||
@@ -265,7 +265,7 @@ fn bash_safe_quote(s: &str) -> String {
|
||||
/// keeps the probe `set -u`-safe (a bare `$ZSH_VERSION` aborts bash under
|
||||
/// nounset). `exec -a` gives the binary the `find`/`grep` argv0 (ps display +
|
||||
/// ugrep grep-personality) in both bash and zsh. The trailing
|
||||
/// `__grok_shadow_{name}=1` marks this as a harness shadow so `restore_command`
|
||||
/// `__kigi_shadow_{name}=1` marks this as a harness shadow so `restore_command`
|
||||
/// only ever removes our own function — never a user's.
|
||||
fn shell_function(
|
||||
name: &str,
|
||||
@@ -284,12 +284,12 @@ fn shell_function(
|
||||
format!("{} ", qargs.join(" "))
|
||||
}
|
||||
};
|
||||
// `local __grok_bin` is re-resolved every call. The host hint is trusted
|
||||
// `local __kigi_bin` is re-resolved every call. The host hint is trusted
|
||||
// only when it's *executable* (`[ -x ]`, not just `[ -f ]`): the resolver
|
||||
// accepts any regular file as a hint, but `exec` needs `+x`, so a non-exec
|
||||
// hint must fall through rather than hard-fail with no OS fallback. Then
|
||||
// `command -v` on the live shell PATH (returns an executable), else the OS
|
||||
// binary. `|| __grok_bin=''` keeps the lookup `set -e`-safe (a failed
|
||||
// binary. `|| __kigi_bin=''` keeps the lookup `set -e`-safe (a failed
|
||||
// `command -v` would otherwise abort the function under errexit). The OS
|
||||
// fallback uses `command {name}` to bypass this function. `{prepend}` is
|
||||
// empty for find, the ugrep default flags for grep (and is omitted from the
|
||||
@@ -297,16 +297,16 @@ fn shell_function(
|
||||
format!(
|
||||
"unalias {name} 2>/dev/null || true; \
|
||||
{name}() {{ \
|
||||
local __grok_bin={qpref}; \
|
||||
[ -x \"$__grok_bin\" ] || __grok_bin=$(command -v {bin_name} 2>/dev/null) || __grok_bin=''; \
|
||||
if [ -z \"$__grok_bin\" ]; then command {name} \"$@\"; return; fi; \
|
||||
local __kigi_bin={qpref}; \
|
||||
[ -x \"$__kigi_bin\" ] || __kigi_bin=$(command -v {bin_name} 2>/dev/null) || __kigi_bin=''; \
|
||||
if [ -z \"$__kigi_bin\" ]; then command {name} \"$@\"; return; fi; \
|
||||
if [[ -z ${{ZSH_VERSION-}} ]] && (( BASH_SUBSHELL > 0 )); then \
|
||||
exec -a {name} \"$__grok_bin\" {prepend}\"$@\"; \
|
||||
exec -a {name} \"$__kigi_bin\" {prepend}\"$@\"; \
|
||||
else \
|
||||
(exec -a {name} \"$__grok_bin\" {prepend}\"$@\"); \
|
||||
(exec -a {name} \"$__kigi_bin\" {prepend}\"$@\"); \
|
||||
fi; \
|
||||
}}; \
|
||||
__grok_shadow_{name}=1"
|
||||
__kigi_shadow_{name}=1"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -326,20 +326,20 @@ mod tests {
|
||||
fn shell_function_shape() {
|
||||
let fn_body = shell_function("find", "bfs", Some(Path::new("/tmp/bfs")), &[]);
|
||||
assert!(fn_body.contains("unalias find"));
|
||||
// Preferred path is the fast-path hint; the shadow execs `$__grok_bin`.
|
||||
assert!(fn_body.contains("local __grok_bin=/tmp/bfs"));
|
||||
assert!(fn_body.contains("exec -a find \"$__grok_bin\" \"$@\""));
|
||||
// Preferred path is the fast-path hint; the shadow execs `$__kigi_bin`.
|
||||
assert!(fn_body.contains("local __kigi_bin=/tmp/bfs"));
|
||||
assert!(fn_body.contains("exec -a find \"$__kigi_bin\" \"$@\""));
|
||||
// Hint is trusted only when executable (`[ -x ]`, not `[ -f ]`), so a
|
||||
// non-exec hint falls through instead of hard-failing exec.
|
||||
assert!(fn_body.contains("[ -x \"$__grok_bin\" ]"));
|
||||
assert!(!fn_body.contains("[ -f \"$__grok_bin\" ]"));
|
||||
assert!(fn_body.contains("[ -x \"$__kigi_bin\" ]"));
|
||||
assert!(!fn_body.contains("[ -f \"$__kigi_bin\" ]"));
|
||||
// Self-heal: live-PATH lookup + OS fallback.
|
||||
assert!(fn_body.contains("command -v bfs"));
|
||||
assert!(fn_body.contains("command find \"$@\""));
|
||||
assert!(fn_body.contains("BASH_SUBSHELL > 0"));
|
||||
assert!(fn_body.contains("(exec -a find"));
|
||||
// Marker so `restore_command` only removes our own shadow.
|
||||
assert!(fn_body.contains("__grok_shadow_find=1"));
|
||||
assert!(fn_body.contains("__kigi_shadow_find=1"));
|
||||
// set -u-safe zsh probe (a bare $ZSH_VERSION aborts bash under nounset).
|
||||
assert!(fn_body.contains("${ZSH_VERSION-}"));
|
||||
assert!(!fn_body.contains("[[ -n $ZSH_VERSION ]]"));
|
||||
@@ -349,7 +349,7 @@ mod tests {
|
||||
fn shell_function_unresolved_uses_empty_hint() {
|
||||
// No host-resolved path → empty hint, relies on live-PATH `command -v`.
|
||||
let fn_body = shell_function("find", "bfs", None, &[]);
|
||||
assert!(fn_body.contains("local __grok_bin=''"));
|
||||
assert!(fn_body.contains("local __kigi_bin=''"));
|
||||
assert!(fn_body.contains("command -v bfs"));
|
||||
assert!(fn_body.contains("command find \"$@\""));
|
||||
}
|
||||
@@ -362,8 +362,8 @@ mod tests {
|
||||
Some(Path::new("/tmp/ugrep")),
|
||||
UGREP_DEFAULT_ARGS,
|
||||
);
|
||||
assert!(fn_body.contains("local __grok_bin=/tmp/ugrep"));
|
||||
assert!(fn_body.contains("\"$__grok_bin\" -G --ignore-files --hidden -I"));
|
||||
assert!(fn_body.contains("local __kigi_bin=/tmp/ugrep"));
|
||||
assert!(fn_body.contains("\"$__kigi_bin\" -G --ignore-files --hidden -I"));
|
||||
assert!(fn_body.contains("--exclude-dir=.git"));
|
||||
assert!(fn_body.contains("command -v ugrep"));
|
||||
}
|
||||
@@ -373,7 +373,7 @@ mod tests {
|
||||
assert_eq!(bash_safe_quote("/usr/bin/bfs"), "/usr/bin/bfs");
|
||||
assert_eq!(bash_safe_quote("/tmp/my bfs"), "'/tmp/my bfs'");
|
||||
let body = shell_function("find", "bfs", Some(Path::new("/tmp/evil$(id)")), &[]);
|
||||
assert!(body.contains("local __grok_bin='/tmp/evil$(id)'"), "{body}");
|
||||
assert!(body.contains("local __kigi_bin='/tmp/evil$(id)'"), "{body}");
|
||||
assert!(!body.contains("=/tmp/evil$(id)"));
|
||||
}
|
||||
|
||||
@@ -381,10 +381,10 @@ mod tests {
|
||||
fn restore_command_is_marker_gated() {
|
||||
let r = restore_command("find");
|
||||
// Only removes the harness shadow when our marker is set.
|
||||
assert!(r.contains("if [ -n \"${__grok_shadow_find-}\" ]"));
|
||||
assert!(r.contains("if [ -n \"${__kigi_shadow_find-}\" ]"));
|
||||
assert!(r.contains("unalias find"));
|
||||
assert!(r.contains("unset -f find"));
|
||||
assert!(r.contains("unset __grok_shadow_find"));
|
||||
assert!(r.contains("unset __kigi_shadow_find"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -401,8 +401,8 @@ mod tests {
|
||||
// from a prior snapshot is dropped, but a user function is left intact.
|
||||
let inject = build_injection(false, false, &both_tools());
|
||||
assert!(inject.ends_with("; "));
|
||||
assert!(inject.contains("if [ -n \"${__grok_shadow_find-}\" ]"));
|
||||
assert!(inject.contains("if [ -n \"${__grok_shadow_grep-}\" ]"));
|
||||
assert!(inject.contains("if [ -n \"${__kigi_shadow_find-}\" ]"));
|
||||
assert!(inject.contains("if [ -n \"${__kigi_shadow_grep-}\" ]"));
|
||||
assert!(inject.contains("unset -f find"));
|
||||
assert!(inject.contains("unset -f grep"));
|
||||
assert!(!inject.contains("find()"));
|
||||
@@ -415,7 +415,7 @@ mod tests {
|
||||
assert!(inject.contains("find()"));
|
||||
assert!(inject.contains("grep()"));
|
||||
assert!(inject.contains("-G --ignore-files"));
|
||||
assert!(inject.contains("__grok_shadow_find=1"));
|
||||
assert!(inject.contains("__kigi_shadow_find=1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -433,7 +433,7 @@ mod tests {
|
||||
assert!(inject.contains("command -v ugrep"));
|
||||
// OS fallback present; not a marker-gated restore.
|
||||
assert!(inject.contains("command find \"$@\""));
|
||||
assert!(!inject.contains("if [ -n \"${__grok_shadow_find-}\" ]"));
|
||||
assert!(!inject.contains("if [ -n \"${__kigi_shadow_find-}\" ]"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -461,7 +461,7 @@ mod tests {
|
||||
#[test]
|
||||
fn env_override_accepts_regular_file_without_exec_bit() {
|
||||
let bin = std::env::temp_dir().join(format!(
|
||||
"grok-bfs-noexec-{}-{}",
|
||||
"kigi-bfs-noexec-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -491,7 +491,7 @@ mod tests {
|
||||
#[test]
|
||||
fn resolve_tool_precedence() {
|
||||
// Real temp files so the is_file() checks pass.
|
||||
let dir = std::env::temp_dir().join(format!("grok-resolve-{}-{:?}", std::process::id(), {
|
||||
let dir = std::env::temp_dir().join(format!("kigi-resolve-{}-{:?}", std::process::id(), {
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
@@ -687,7 +687,7 @@ mod tests {
|
||||
return;
|
||||
};
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"grok-selfheal-{}-{}",
|
||||
"kigi-selfheal-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -731,7 +731,7 @@ mod tests {
|
||||
};
|
||||
let shadow = shell_function(
|
||||
"find",
|
||||
"grok_no_such_search_bin_xyz",
|
||||
"kigi_no_such_search_bin_xyz",
|
||||
Some(Path::new("/nonexistent/bfs")),
|
||||
&[],
|
||||
);
|
||||
@@ -759,7 +759,7 @@ mod tests {
|
||||
return;
|
||||
};
|
||||
let dir = std::env::temp_dir().join(format!(
|
||||
"grok-noexec-{}-{}",
|
||||
"kigi-noexec-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -779,7 +779,7 @@ mod tests {
|
||||
// Hint is the non-exec file; bin_name isn't on PATH → must reach OS find.
|
||||
let shadow = shell_function(
|
||||
"find",
|
||||
"grok_no_such_search_bin_xyz",
|
||||
"kigi_no_such_search_bin_xyz",
|
||||
Some(hint.as_path()),
|
||||
&[],
|
||||
);
|
||||
|
||||
@@ -23,14 +23,14 @@ use tokio::io::AsyncReadExt;
|
||||
// Marker constants
|
||||
// ============================================================================
|
||||
|
||||
const BASH_STATE_START_MARKER: &str = "__GROK_BASH_STATE_START__";
|
||||
const BASH_STATE_END_MARKER: &str = "__GROK_BASH_STATE_END__";
|
||||
const ZSH_STATE_START_MARKER: &str = "__GROK_ZSH_STATE_START__";
|
||||
const ZSH_STATE_END_MARKER: &str = "__GROK_ZSH_STATE_END__";
|
||||
const BASH_STATE_START_MARKER: &str = "__KIGI_BASH_STATE_START__";
|
||||
const BASH_STATE_END_MARKER: &str = "__KIGI_BASH_STATE_END__";
|
||||
const ZSH_STATE_START_MARKER: &str = "__KIGI_ZSH_STATE_START__";
|
||||
const ZSH_STATE_END_MARKER: &str = "__KIGI_ZSH_STATE_END__";
|
||||
|
||||
/// Marker emitted by the init path to separate login-shell noise (MOTD, etc.)
|
||||
/// from the actual state dump on stdout.
|
||||
const INIT_STATE_MARKER: &str = "__GROK_INIT_STATE_MARKER__";
|
||||
const INIT_STATE_MARKER: &str = "__KIGI_INIT_STATE_MARKER__";
|
||||
|
||||
/// Maximum time to wait for a shell state init (login shell + rc files).
|
||||
const INIT_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
@@ -47,7 +47,7 @@ pub fn shell_env_overrides() -> HashMap<String, String> {
|
||||
("TERM".to_string(), "dumb".to_string()),
|
||||
("NO_COLOR".to_string(), "1".to_string()),
|
||||
("FORCE_COLOR".to_string(), "0".to_string()),
|
||||
// Re-applied last via [`crate::util::apply_grok_agent_marker`] so request
|
||||
// Re-applied last via [`crate::util::apply_kigi_agent_marker`] so request
|
||||
// env cannot clear it.
|
||||
(
|
||||
crate::util::KIGI_AGENT_ENV.to_string(),
|
||||
@@ -88,15 +88,15 @@ dump_bash_state() {
|
||||
local content="$1"
|
||||
local var_name="$2"
|
||||
if [[ -n "$content" ]]; then
|
||||
builtin printf 'grok_snap_%s=$(command base64 -d <<'"'"'KIGI_SNAP_EOF_%s'"'"'\n' "$var_name" "$var_name"
|
||||
builtin printf 'kigi_snap_%s=$(command base64 -d <<'"'"'KIGI_SNAP_EOF_%s'"'"'\n' "$var_name" "$var_name"
|
||||
command base64 <<<"$content" | command tr -d '\n'
|
||||
builtin printf '\nKIGI_SNAP_EOF_%s\n' "$var_name"
|
||||
builtin printf ')\n'
|
||||
builtin printf 'eval "$grok_snap_%s"\n' "$var_name"
|
||||
builtin printf 'eval "$kigi_snap_%s"\n' "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
_emit "__GROK_BASH_STATE_START__"
|
||||
_emit "__KIGI_BASH_STATE_START__"
|
||||
|
||||
_emit "$PWD"
|
||||
|
||||
@@ -121,7 +121,7 @@ dump_bash_state() {
|
||||
_emit_encoded "$aliases" "ALIASES_B64"
|
||||
|
||||
_emit "# end of bash state dump"
|
||||
_emit "__GROK_BASH_STATE_END__"
|
||||
_emit "__KIGI_BASH_STATE_END__"
|
||||
}
|
||||
"##;
|
||||
|
||||
@@ -142,15 +142,15 @@ function dump_zsh_state() {
|
||||
local content="$1"
|
||||
local var_name="$2"
|
||||
if [[ -n "$content" ]]; then
|
||||
builtin printf 'grok_snap_%s=$(command base64 -d <<'"'"'KIGI_SNAP_EOF_%s'"'"'\n' "$var_name" "$var_name"
|
||||
builtin printf 'kigi_snap_%s=$(command base64 -d <<'"'"'KIGI_SNAP_EOF_%s'"'"'\n' "$var_name" "$var_name"
|
||||
command base64 <<<"$content" | command tr -d '\n'
|
||||
builtin printf '\nKIGI_SNAP_EOF_%s\n' "$var_name"
|
||||
builtin printf ')\n'
|
||||
builtin printf 'eval "$grok_snap_%s"\n' "$var_name"
|
||||
builtin printf 'eval "$kigi_snap_%s"\n' "$var_name"
|
||||
fi
|
||||
}
|
||||
|
||||
_emit "__GROK_ZSH_STATE_START__"
|
||||
_emit "__KIGI_ZSH_STATE_START__"
|
||||
|
||||
_emit "$PWD"
|
||||
|
||||
@@ -171,7 +171,7 @@ function dump_zsh_state() {
|
||||
_emit_encoded "$aliases" "ALIASES_B64"
|
||||
|
||||
_emit "# end of zsh state dump"
|
||||
_emit "__GROK_ZSH_STATE_END__"
|
||||
_emit "__KIGI_ZSH_STATE_END__"
|
||||
}
|
||||
"##;
|
||||
|
||||
@@ -688,11 +688,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_dump_valid_bash() {
|
||||
let raw = "__GROK_BASH_STATE_START__\n\
|
||||
let raw = "__KIGI_BASH_STATE_START__\n\
|
||||
/home/user/project\n\
|
||||
export FOO=bar\n\
|
||||
# end of bash state dump\n\
|
||||
__GROK_BASH_STATE_END__\n";
|
||||
__KIGI_BASH_STATE_END__\n";
|
||||
let (cwd, rest) = parse_dump(ShellKind::Bash, raw).unwrap();
|
||||
assert_eq!(cwd, PathBuf::from("/home/user/project"));
|
||||
assert!(rest.contains("export FOO=bar"));
|
||||
@@ -700,11 +700,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_dump_valid_zsh() {
|
||||
let raw = "__GROK_ZSH_STATE_START__\n\
|
||||
let raw = "__KIGI_ZSH_STATE_START__\n\
|
||||
/tmp\n\
|
||||
typeset -x FOO=bar\n\
|
||||
# end of zsh state dump\n\
|
||||
__GROK_ZSH_STATE_END__\n";
|
||||
__KIGI_ZSH_STATE_END__\n";
|
||||
let (cwd, rest) = parse_dump(ShellKind::Zsh, raw).unwrap();
|
||||
assert_eq!(cwd, PathBuf::from("/tmp"));
|
||||
assert!(rest.contains("typeset -x FOO=bar"));
|
||||
@@ -712,28 +712,28 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_dump_missing_start_marker() {
|
||||
let raw = "/home/user\nexport FOO=bar\n__GROK_BASH_STATE_END__\n";
|
||||
let raw = "/home/user\nexport FOO=bar\n__KIGI_BASH_STATE_END__\n";
|
||||
assert!(parse_dump(ShellKind::Bash, raw).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_dump_missing_end_marker() {
|
||||
let raw = "__GROK_BASH_STATE_START__\n/home/user\nexport FOO=bar\n";
|
||||
let raw = "__KIGI_BASH_STATE_START__\n/home/user\nexport FOO=bar\n";
|
||||
assert!(parse_dump(ShellKind::Bash, raw).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_dump_wrong_shell_markers() {
|
||||
let raw = "__GROK_ZSH_STATE_START__\n/tmp\nstuff\n__GROK_ZSH_STATE_END__\n";
|
||||
let raw = "__KIGI_ZSH_STATE_START__\n/tmp\nstuff\n__KIGI_ZSH_STATE_END__\n";
|
||||
assert!(parse_dump(ShellKind::Bash, raw).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_dump_empty_snapshot() {
|
||||
let raw = "__GROK_BASH_STATE_START__\n\
|
||||
let raw = "__KIGI_BASH_STATE_START__\n\
|
||||
/home/user\n\
|
||||
# end of bash state dump\n\
|
||||
__GROK_BASH_STATE_END__\n";
|
||||
__KIGI_BASH_STATE_END__\n";
|
||||
let (cwd, rest) = parse_dump(ShellKind::Bash, raw).unwrap();
|
||||
assert_eq!(cwd, PathBuf::from("/home/user"));
|
||||
assert!(rest.contains("# end of bash state dump"));
|
||||
@@ -741,15 +741,15 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_after_marker_found() {
|
||||
let output = "Welcome to Ubuntu\nMOTD line\n__GROK_INIT_STATE_MARKER__\nactual data\n";
|
||||
let result = parse_after_marker(output, "__GROK_INIT_STATE_MARKER__");
|
||||
let output = "Welcome to Ubuntu\nMOTD line\n__KIGI_INIT_STATE_MARKER__\nactual data\n";
|
||||
let result = parse_after_marker(output, "__KIGI_INIT_STATE_MARKER__");
|
||||
assert_eq!(result, "actual data\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_after_marker_not_found() {
|
||||
let output = "just some output\n";
|
||||
let result = parse_after_marker(output, "__GROK_INIT_STATE_MARKER__");
|
||||
let result = parse_after_marker(output, "__KIGI_INIT_STATE_MARKER__");
|
||||
assert_eq!(result, output);
|
||||
}
|
||||
|
||||
@@ -797,11 +797,11 @@ mod tests {
|
||||
shell: ShellKind::Bash,
|
||||
};
|
||||
|
||||
let dump = "__GROK_BASH_STATE_START__\n\
|
||||
let dump = "__KIGI_BASH_STATE_START__\n\
|
||||
/new/dir\n\
|
||||
export X=1\n\
|
||||
# end of bash state dump\n\
|
||||
__GROK_BASH_STATE_END__\n";
|
||||
__KIGI_BASH_STATE_END__\n";
|
||||
assert!(state.update_from_dump(dump));
|
||||
assert_eq!(state.cwd, PathBuf::from("/new/dir"));
|
||||
assert!(state.snapshot.contains("export X=1"));
|
||||
@@ -832,7 +832,7 @@ mod tests {
|
||||
assert!(state.cwd.is_absolute());
|
||||
// The snapshot should contain at least some env var exports
|
||||
assert!(
|
||||
state.snapshot.contains("grok_snap_") || state.snapshot.is_empty(),
|
||||
state.snapshot.contains("kigi_snap_") || state.snapshot.is_empty(),
|
||||
"snapshot should contain encoded blocks or be empty: {:?}",
|
||||
&state.snapshot[..state.snapshot.len().min(200)]
|
||||
);
|
||||
@@ -995,13 +995,13 @@ mod tests {
|
||||
let cwd = std::env::current_dir().unwrap();
|
||||
let mut state = ShellState::init(ShellKind::Bash, &cwd).await.unwrap();
|
||||
|
||||
let (code, _) = run_command(&mut state, "export GPG_TTY=/grok-sentinel-tty").await;
|
||||
let (code, _) = run_command(&mut state, "export GPG_TTY=/kigi-sentinel-tty").await;
|
||||
assert_eq!(code, 0);
|
||||
|
||||
let (code, stdout) = run_command(&mut state, "echo \"[$GPG_TTY]\"").await;
|
||||
assert_eq!(code, 0);
|
||||
assert!(
|
||||
!stdout.contains("/grok-sentinel-tty"),
|
||||
!stdout.contains("/kigi-sentinel-tty"),
|
||||
"GPG_TTY must not persist across commands via the snapshot, got: {stdout:?}"
|
||||
);
|
||||
}
|
||||
@@ -1015,13 +1015,13 @@ mod tests {
|
||||
let cwd = std::env::current_dir().unwrap();
|
||||
let mut state = ShellState::init(ShellKind::Zsh, &cwd).await.unwrap();
|
||||
|
||||
let (code, _) = run_command(&mut state, "export GPG_TTY=/grok-sentinel-tty").await;
|
||||
let (code, _) = run_command(&mut state, "export GPG_TTY=/kigi-sentinel-tty").await;
|
||||
assert_eq!(code, 0);
|
||||
|
||||
let (code, stdout) = run_command(&mut state, "echo \"[$GPG_TTY]\"").await;
|
||||
assert_eq!(code, 0);
|
||||
assert!(
|
||||
!stdout.contains("/grok-sentinel-tty"),
|
||||
!stdout.contains("/kigi-sentinel-tty"),
|
||||
"GPG_TTY must not persist across commands via the snapshot, got: {stdout:?}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ impl LocalTerminalActor {
|
||||
}
|
||||
|
||||
cmd.envs(crate::util::pager_env());
|
||||
crate::util::apply_grok_agent_marker(&mut cmd);
|
||||
crate::util::apply_kigi_agent_marker(&mut cmd);
|
||||
|
||||
cmd.fd_mappings(prep.fd_mappings)
|
||||
.map_err(|e| ComputerError::io(format!("fd mapping: {e}")))?;
|
||||
@@ -1950,7 +1950,7 @@ impl LocalTerminalActor {
|
||||
.map(|m| m.len())
|
||||
.unwrap_or(0);
|
||||
tokio::spawn(async move {
|
||||
crate::implementations::grok_build::monitor::tool::run_monitor_pipeline(
|
||||
crate::implementations::kigi::monitor::tool::run_monitor_pipeline(
|
||||
&pipeline_task_id,
|
||||
&pipeline_description,
|
||||
pipeline_terminal,
|
||||
@@ -2754,7 +2754,7 @@ fn spawn_shell_command(
|
||||
cmd.envs(login);
|
||||
}
|
||||
// Agent marker must win over request/login env.
|
||||
crate::util::apply_grok_agent_marker(&mut cmd);
|
||||
crate::util::apply_kigi_agent_marker(&mut cmd);
|
||||
|
||||
// Detach from the controlling terminal so subprocesses cannot open
|
||||
// /dev/tty and compete with the TUI for terminal input.
|
||||
@@ -2762,7 +2762,7 @@ fn spawn_shell_command(
|
||||
|
||||
// If the sandbox profile restricts network, install a seccomp BPF
|
||||
// filter on the child that blocks connect/bind/sendto/listen/accept.
|
||||
// The parent (grok) process retains network for the LLM API.
|
||||
// The parent (kigi) process retains network for the LLM API.
|
||||
// Filesystem restrictions are already inherited from the process-level
|
||||
// Landlock/Seatbelt sandbox — no action needed here for FS.
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -2795,7 +2795,7 @@ fn spawn_shell_command(
|
||||
}
|
||||
cmd.envs(crate::util::pager_env());
|
||||
// Agent marker must win over request env.
|
||||
crate::util::apply_grok_agent_marker(&mut cmd);
|
||||
crate::util::apply_kigi_agent_marker(&mut cmd);
|
||||
|
||||
// Set creation flags inline rather than via crate::util::detach_command
|
||||
// + new_process_group: tokio's creation_flags is a SET, not OR, so
|
||||
@@ -2806,7 +2806,7 @@ fn spawn_shell_command(
|
||||
// job so we can assign it to our own ProcessGroup. Per Microsoft
|
||||
// docs this *fails CreateProcess with ERROR_ACCESS_DENIED* (os
|
||||
// error 5) when the parent process is in a job that does not
|
||||
// have JOB_OBJECT_LIMIT_BREAKAWAY_OK set — common when grok-agent
|
||||
// have JOB_OBJECT_LIMIT_BREAKAWAY_OK set — common when kigi-agent
|
||||
// is launched under a Windows service, scheduled task, or some
|
||||
// ACP host wrappers. The caller below retries without this flag
|
||||
// on os error 5.
|
||||
@@ -4212,7 +4212,7 @@ mod tests {
|
||||
|
||||
let mut req = make_request("echo \"[$GPG_TTY]\"");
|
||||
req.env
|
||||
.insert("GPG_TTY".to_string(), "/grok-sentinel-tty".to_string());
|
||||
.insert("GPG_TTY".to_string(), "/kigi-sentinel-tty".to_string());
|
||||
|
||||
let result = backend.run(req).await.unwrap();
|
||||
assert_eq!(result.exit_code, Some(0));
|
||||
|
||||
@@ -237,7 +237,7 @@ impl TaskSnapshot {
|
||||
|
||||
/// Result of killing a terminal task.
|
||||
///
|
||||
/// Serialized over the wire in the `x.ai/task/kill` ext response
|
||||
/// Serialized over the wire in the `kigi/task/kill` ext response
|
||||
/// (`kigi-shell::extensions::task::KillTaskResponse`) and deserialized
|
||||
/// by clients (kigi-tui), so it derives both serde directions.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user