mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
Our history is just-every's with author emails rewritten, so the graphs are
disjoint and git finds no merge base. Supplied one by hand: d1f1f51a41, the
just-every commit matching our Oct-2025 fork point (22 files apart). 9618
upstream commits, 7004 files, +1.81M/-159k, 37 conflicts.
Resolution:
- Upstream code where our side was the Oct-2025 prototype of a feature they
have since reimplemented 3-5x larger (agent_runs, browser_sessions,
history_cell/{agent,browser}, the vt100 harness and its snapshots).
- Upstream's config.rs module split (builder/defaults/sources/validation)
kept; zen5-coder and the provider-follows-model rule re-applied on top.
- Ours where the file IS the identity: README, package.json, postinstall,
release notes pipeline, integration-zed.
- Hybrid where upstream improved a file we had branded: updates.rs (their
release-repo migration, our hanzoai/dev), release.yml (their fail-fast npm
auth check, our package name), chatwidget.rs (their turn handling, our
HANZO_USER_KEY hint), exec human output (their 237 lines, our banner).
Superseded and dropped deliberately: our resume_command_name() coder-alias
hack — upstream's derive_resume_command_name() reads the invocation basename
generically, which yields "dev" for us.
LLM.md now records the real topology and the sync point; AGENTS.md and
CLAUDE.md are symlinks to it again. Single parent on purpose: adopting
jecode/main as a second parent would re-import 13,742 commits carrying the
upstream author emails a prior rewrite deliberately removed.
Version 0.2.188 -> 0.2.189.
Co-authored-by: Hanzo Dev <[email protected]>
96 lines
2.6 KiB
Rust
96 lines
2.6 KiB
Rust
use crate::arg_type::ArgType;
|
|
use crate::error::Result;
|
|
use serde::Serialize;
|
|
|
|
/// exec() invocation that has been accepted by a `Policy`.
|
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)]
|
|
pub struct ValidExec {
|
|
pub program: String,
|
|
pub flags: Vec<MatchedFlag>,
|
|
pub opts: Vec<MatchedOpt>,
|
|
pub args: Vec<MatchedArg>,
|
|
|
|
/// If non-empty, a prioritized list of paths to try instead of `program`.
|
|
/// For example, `/bin/ls` is harder to compromise than whatever `ls`
|
|
/// happens to be in the user's `$PATH`, so `/bin/ls` would be included for
|
|
/// `ls`. The caller is free to disregard this list and use `program`.
|
|
pub system_path: Vec<String>,
|
|
}
|
|
|
|
impl ValidExec {
|
|
pub fn new(program: &str, args: Vec<MatchedArg>, system_path: &[&str]) -> Self {
|
|
Self {
|
|
program: program.to_string(),
|
|
flags: vec![],
|
|
opts: vec![],
|
|
args,
|
|
system_path: system_path.iter().map(|&s| s.to_string()).collect(),
|
|
}
|
|
}
|
|
|
|
/// Whether a possible side effect of running this command includes writing
|
|
/// a file.
|
|
pub fn might_write_files(&self) -> bool {
|
|
self.opts.iter().any(|opt| opt.r#type.might_write_file())
|
|
|| self.args.iter().any(|opt| opt.r#type.might_write_file())
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
|
pub struct MatchedArg {
|
|
pub index: usize,
|
|
pub r#type: ArgType,
|
|
pub value: String,
|
|
}
|
|
|
|
impl MatchedArg {
|
|
pub fn new(index: usize, r#type: ArgType, value: &str) -> Result<Self> {
|
|
r#type.validate(value)?;
|
|
Ok(Self {
|
|
index,
|
|
r#type,
|
|
value: value.to_string(),
|
|
})
|
|
}
|
|
}
|
|
|
|
/// A match for an option declared with opt() in a .policy file.
|
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
|
pub struct MatchedOpt {
|
|
/// Name of the option that was matched.
|
|
pub name: String,
|
|
/// Value supplied for the option.
|
|
pub value: String,
|
|
/// Type of the value supplied for the option.
|
|
pub r#type: ArgType,
|
|
}
|
|
|
|
impl MatchedOpt {
|
|
pub fn new(name: &str, value: &str, r#type: ArgType) -> Result<Self> {
|
|
r#type.validate(value)?;
|
|
Ok(Self {
|
|
name: name.to_string(),
|
|
value: value.to_string(),
|
|
r#type,
|
|
})
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
&self.name
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
|
pub struct MatchedFlag {
|
|
/// Name of the flag that was matched.
|
|
pub name: String,
|
|
}
|
|
|
|
impl MatchedFlag {
|
|
pub fn new(name: &str) -> Self {
|
|
Self {
|
|
name: name.to_string(),
|
|
}
|
|
}
|
|
}
|