fix(#783): init JSON envelope now includes hint and already_initialized fields for orchestrator parity

This commit is contained in:
YeonGyu-Kim
2026-05-27 08:04:15 +09:00
parent 32c9276fdb
commit 81fe0ccbb7
3 changed files with 85 additions and 0 deletions

View File

@@ -8179,15 +8179,26 @@ fn init_json_value(report: &crate::init::InitReport, message: &str) -> serde_jso
// Derive top-level status: "ok" when all artifacts succeeded (created or
// skipped = idempotent); no failure path exists today so always "ok".
let status = "ok";
// #783: already_initialized lets orchestrators detect the idempotent case
// without checking created.len() == 0; hint gives a stable next-action pointer.
let already_initialized = report.artifacts_with_status(InitStatus::Created).is_empty()
&& report.artifacts_with_status(InitStatus::Updated).is_empty();
let hint = if already_initialized {
"Workspace already initialised. Run `claw doctor` to verify health, or edit CLAUDE.md to customise guidance."
} else {
"Review and tailor CLAUDE.md to your project, then run `claw doctor` to verify the workspace."
};
json!({
"kind": "init",
"action": "init",
"status": status,
"already_initialized": already_initialized,
"project_path": report.project_root.display().to_string(),
"created": report.artifacts_with_status(InitStatus::Created),
"updated": report.artifacts_with_status(InitStatus::Updated),
"skipped": report.artifacts_with_status(InitStatus::Skipped),
"artifacts": report.artifact_json_entries(),
"hint": hint,
"next_step": crate::init::InitReport::NEXT_STEP,
"message": message,
})