MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / manual_init

Method manual_init

crates/chat-cli/src/cli/chat/checkpoint.rs:103–146  ·  view source on GitHub ↗

Initialize checkpoint manager manually

(
        os: &Os,
        path: impl AsRef<Path>,
        current_history: &VecDeque<HistoryEntry>,
    )

Source from the content-addressed store, hash-verified

101
102 /// Initialize checkpoint manager manually
103 pub async fn manual_init(
104 os: &Os,
105 path: impl AsRef<Path>,
106 current_history: &VecDeque<HistoryEntry>,
107 ) -> Result<Self> {
108 let path = path.as_ref();
109 os.fs.create_dir_all(path).await?;
110
111 let work_tree_path =
112 std::env::current_dir().map_err(|e| eyre!("Failed to get current working directory: {}", e))?;
113
114 // Initialize bare repository
115 run_git(path, None, &["init", "--bare", &path.to_string_lossy()])?;
116
117 // Configure git
118 configure_git(&path.to_string_lossy())?;
119
120 // Create initial checkpoint
121 stage_commit_tag(&path.to_string_lossy(), &work_tree_path, "Initial state", "0")?;
122
123 let initial_checkpoint = Checkpoint {
124 tag: "0".to_string(),
125 timestamp: Local::now(),
126 description: "Initial state".to_string(),
127 history_snapshot: current_history.clone(),
128 is_turn: true,
129 tool_name: None,
130 };
131
132 let mut tag_index = HashMap::new();
133 tag_index.insert("0".to_string(), 0);
134
135 Ok(Self {
136 shadow_repo_path: path.to_path_buf(),
137 work_tree_path,
138 checkpoints: vec![initial_checkpoint],
139 tag_index,
140 current_turn: 0,
141 tools_in_turn: 0,
142 pending_user_message: None,
143 message_locked: false,
144 file_stats_cache: HashMap::new(),
145 })
146 }
147
148 /// Create a new checkpoint point
149 pub fn create_checkpoint(

Callers

nothing calls this directly

Calls 8

run_gitFunction · 0.85
configure_gitFunction · 0.85
stage_commit_tagFunction · 0.85
create_dir_allMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
as_refMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected