Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/).

## [0.1.9] - 2026-09-01

### Fixed

- Render task responses containing currency fields with the task table and its billable column instead of misclassifying them as clients.
- Show the actual human-readable duration format in `time stop`, `time log`, and `time running` help examples.
- Validate agent lifecycle metadata against the 4KB API limit after adding required skill and duration fields.

## [0.1.8] - 2026-09-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "keito-cli"
version = "0.1.8"
version = "0.1.9"
edition = "2021"
description = "AI agent time tracking CLI for Keito: capture billable human and agent work for client billing, agency projects, and AI-native services"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions src/cli/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ EXAMPLE:
\"project\": \"Acme Website\",
\"task\": \"Development\",
\"duration_hours\": 1.5,
\"duration\": \"1:30\",
\"duration\": \"1h 30m\",
\"spent_date\": \"2026-03-04\",
\"billable\": true,
\"source\": \"cli\"
Expand Down Expand Up @@ -146,7 +146,7 @@ EXAMPLE:
\"project\": \"Acme Website\",
\"task\": \"Development\",
\"duration_hours\": 1.5,
\"duration\": \"1:30\",
\"duration\": \"1h 30m\",
\"spent_date\": \"2025-01-15\",
\"date\": \"2025-01-15\",
\"billable\": true,
Expand Down Expand Up @@ -367,7 +367,7 @@ EXAMPLE:
\"source\": \"cli\",
\"started_at\": \"2026-03-04T09:00:00Z\",
\"elapsed_hours\": 1.5,
\"elapsed\": \"1:30\"
\"elapsed\": \"1h 30m\"
}

EXIT CODES:
Expand Down
41 changes: 40 additions & 1 deletion src/commands/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,16 @@ fn prepare_agent_log_metadata(
"duration_seconds".into(),
Value::Number(duration_seconds.into()),
);
Ok(Some(Value::Object(map)))
let value = Value::Object(map);
let size = serde_json::to_string(&value)
.map_err(|err| AppError::InvalidInput(format!("failed to serialize metadata: {err}")))?
.len();
if size > 4096 {
return Err(AppError::InvalidInput(
"--metadata payload must be 4KB or smaller".into(),
));
}
Ok(Some(value))
}

fn insert_string_metadata(map: &mut Map<String, Value>, key: &str, value: Option<String>) {
Expand Down Expand Up @@ -972,4 +981,34 @@ mod tests {
assert_eq!(metadata["skill"], "keito-time-track");
assert_eq!(metadata["duration_seconds"], 900);
}

#[test]
fn agent_log_lifecycle_metadata_checks_final_size() {
let raw = serde_json::json!({
"session_id": "session-123",
"padding": "x".repeat(4020),
})
.to_string();
assert!(raw.len() <= 4096);

let error = prepare_agent_log_metadata(
build_metadata(MetadataInput {
metadata: Some(raw),
session_id: None,
agent_id: None,
agent_type: None,
skill: None,
})
.unwrap(),
"agent",
900,
)
.unwrap_err();

assert!(matches!(
error,
AppError::InvalidInput(message)
if message == "--metadata payload must be 4KB or smaller"
));
}
}
29 changes: 29 additions & 0 deletions src/output/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ fn try_as_clients(arr: &[serde_json::Value]) -> Option<Vec<Client>> {
let first = arr.first()?.as_object()?;
if first.contains_key("name")
&& first.contains_key("currency")
&& !first.contains_key("billable_by_default")
&& !first.contains_key("project_id")
&& !first.contains_key("task_id")
&& !first.contains_key("is_billable")
Expand Down Expand Up @@ -349,3 +350,31 @@ fn format_me_table(me_list: &[MeResponse]) -> String {
"No data.".into()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn task_with_currency_uses_task_table() {
let task = Task {
id: "task-1".into(),
name: "Development".into(),
is_active: true,
billable_by_default: true,
default_hourly_rate: Some(100.0),
effective_billable_rate: Some(120.0),
currency: Some("GBP".into()),
budget: None,
is_default: false,
parent_task_id: None,
created_at: None,
updated_at: None,
};

let output = to_table(&[task]);

assert!(output.contains("Billable"));
assert!(!output.contains("Currency"));
}
}