diff --git a/README.md b/README.md index 723cadf..095b9fd 100644 --- a/README.md +++ b/README.md @@ -157,8 +157,11 @@ as well, see [On your phone, too](#on-your-phone-too). If you run your local services with [LaunchX](https://github.com/AutoPhd-org/launchx), register this repository with `lx add` and the workspace becomes one of them: `rmd web` then hands over to -`lx open rmd`, and scripts and agents can read and change it over HTTP. See -[LaunchX](https://autophd-org.github.io/schedule-everything/docs/advanced/launchx). +`lx open rmd`, and scripts and agents can read and change it over HTTP. Allow +it to use LaunchX's shared memory (`lx memory access rmd write`) and it keeps +your routine and upcoming deadlines on the memory's `schedule` page for your +other apps and agents, and Suggest reads your profile and preferences from it. +See [LaunchX](https://autophd-org.github.io/schedule-everything/docs/advanced/launchx). ## The browser workspace @@ -194,8 +197,9 @@ run `rmd mode j|p`. OpenAI-compatible service (OpenAI, OpenRouter, a local Ollama), in **Settings → AI suggestions**. **Suggest** on the board then asks that model for a few tasks you are likely to need, from your open tasks, deadlines, - today's schedule, habits, recent work, and profile. Its ideas wait on the - board as suggestions, like an agent's. + today's schedule, habits, recent work, and profile, and, under LaunchX with + your permission, the profile and preferences in its shared memory. Its ideas + wait on the board as suggestions, like an agent's. - **Timers.** Dials above the board count down to timed tasks due by tonight (overdue ones count up) and to deadlines in their last 24 hours. One bar shows the progress of today's timed work, optionally weighted by importance. @@ -271,7 +275,8 @@ your fitness history and metrics stand on their own. ### Settings Plugins; board, workload, and progress preferences; reminder preferences; task and -deadline types; and an editor for your configuration files that checks every +deadline types; the model Suggest asks; under LaunchX, what the workspace may do +with your shared memory; and an editor for your configuration files that checks every save with the same rules as `rmd check` and refuses to overwrite newer edits. ### On your phone, too diff --git a/crates/rmd/src/config.rs b/crates/rmd/src/config.rs index 8e3dedf..f30331d 100644 --- a/crates/rmd/src/config.rs +++ b/crates/rmd/src/config.rs @@ -167,7 +167,11 @@ impl ScheduleConfig { /// Whether `date` falls on one of the configured `skip_days`. pub fn should_skip_date(&self, date: chrono::NaiveDate) -> bool { - let weekday = py::weekday_name(date); + self.skips_weekday(py::weekday_name(date)) + } + + /// Whether `weekday` (`"monday"`, ...) is one of the configured `skip_days`. + pub fn skips_weekday(&self, weekday: &str) -> bool { match self.settings.get("skip_days") { Some(Value::Array(days)) => days.iter().any(|d| d.as_str() == Some(weekday)), Some(Value::String(days)) => !days.is_empty() && days.contains(weekday), diff --git a/crates/rmd/src/lib.rs b/crates/rmd/src/lib.rs index 87a8010..e0c4924 100644 --- a/crates/rmd/src/lib.rs +++ b/crates/rmd/src/lib.rs @@ -31,6 +31,7 @@ pub mod commands; pub mod conferences; pub mod install_config_wizard; pub mod launchx; +pub mod memory; pub mod opener; pub mod plugins; pub mod popups; diff --git a/crates/rmd/src/memory.rs b/crates/rmd/src/memory.rs new file mode 100644 index 0000000..e5b9298 --- /dev/null +++ b/crates/rmd/src/memory.rs @@ -0,0 +1,1404 @@ +//! LaunchX shared memory: the small wiki of pages about the user that their +//! apps and agents keep together (contract §12 of LaunchX's `SPEC.md`). +//! +//! Under LaunchX, `rmd serve` gets the memory API's address and a token of +//! its own (`LAUNCHX_MEMORY_URL`, `LAUNCHX_MEMORY_TOKEN`). The user decides +//! in LaunchX whether rmd may read memory, read and write it, or neither +//! (`lx memory access rmd write`). The launcher checks that switch on every +//! request, so rmd asks (`GET /me`) instead of assuming. +//! +//! - With read access, Suggest gives the model the memory's index and the +//! `profile` and `preferences` pages ([`suggest_context`]). +//! - With write access, rmd keeps its section of the well-known `schedule` +//! page current: the shape of the weekly routine and the upcoming deadlines +//! ([`schedule_section`]). The section sits between two marker lines +//! ([`merge_section`]); the rest of the page belongs to other writers and is +//! never changed. Live data such as the task list stays out of memory: other +//! apps read it from `/api/state`. +//! +//! Every write names the revision it read; when another writer got there +//! first (`409`), rmd puts its section into the page as it is now and tries +//! once more ([`sync_section`]). Writes follow changes to the routine and +//! deadlines, a few seconds after the last one ([`schedule_changed`]), and a +//! check every two minutes catches edits made with the CLI or by hand. +//! +//! Memory is optional. When it is off, unreachable or refuses a request, rmd +//! works as before and says so in its settings ([`status`]). The token is +//! never logged or shown. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender}; +use std::sync::{Mutex, MutexGuard, OnceLock}; +use std::time::{Duration, Instant}; + +use chrono::{Datelike, NaiveDate, NaiveTime}; +use serde_json::{Value, json}; + +use crate::config::{ScheduleConfig, WeeklySchedule}; +use crate::py::{self, Dict}; +use crate::recurrence::{anchor_day, repeat_rule}; +use crate::synced_schedule::{format_event_label, get_event_block_name}; + +pub const URL_ENV: &str = "LAUNCHX_MEMORY_URL"; +pub const TOKEN_ENV: &str = "LAUNCHX_MEMORY_TOKEN"; +/// The access `launchx.toml` asks for. +pub const WANTS: Access = Access::Write; +/// The well-known page that holds the shape of the user's time. +pub const SCHEDULE_PAGE: &str = "schedule"; +/// The summary rmd gives the `schedule` page when it creates it, or finds it without one. +const SCHEDULE_SUMMARY: &str = + "The shape of the user's time: weekly routine, fixed commitments, deadlines that matter beyond one app"; +/// The log note of rmd's writes. +const NOTE: &str = "Schedule Everything: routine or deadlines changed"; +/// What begins the first line of rmd's section; the rest of the line may change. +const BEGIN: &str = ""; +const END_LINE: &str = ""; + +const REQUEST_TIMEOUT: Duration = Duration::from_secs(3); +/// The first check, shortly after the server starts. +const FIRST_SYNC: Duration = Duration::from_secs(2); +/// Quiet time after a change before writing, so a burst of edits makes one write. +const DEBOUNCE: Duration = Duration::from_secs(5); +/// The longest a write waits while changes keep coming. +const MAX_WAIT: Duration = Duration::from_secs(30); +/// How often the page is checked without a change in the workspace. +const POLL: Duration = Duration::from_secs(120); +/// How old the known access may be before the settings page asks again. +const STALE: Duration = Duration::from_secs(5); + +/// How much of the index and of each page Suggest passes on. +const INDEX_LIMIT: usize = 4_000; +const PAGE_LIMIT: usize = 3_000; +/// One-off deadlines further ahead than this stay out of the page. +const DEADLINE_DAYS: i64 = 183; +const MAX_DEADLINES: usize = 20; +const LABEL_LIMIT: usize = 60; + +const WEEKDAYS: [&str; 7] = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]; +const DAY_NAMES: [&str; 7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; + +// ============================================================================= +// The API +// ============================================================================= + +/// What the user lets rmd do with memory. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum Access { + None, + Read, + Write, +} + +impl Access { + pub fn parse(text: &str) -> Option { + match text { + "none" => Some(Self::None), + "read" => Some(Self::Read), + "write" => Some(Self::Write), + _ => None, + } + } + + pub fn as_str(self) -> &'static str { + match self { + Self::None => "none", + Self::Read => "read", + Self::Write => "write", + } + } +} + +/// One page as the API returns it. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Page { + pub rev: String, + pub title: String, + pub summary: String, + pub body: String, + pub updated_by: Option, +} + +impl Page { + fn from_json(value: &Value) -> Option { + let text = |key: &str| value.get(key).and_then(Value::as_str).unwrap_or_default().to_string(); + value.get("rev").and_then(Value::as_str)?; + Some(Self { + rev: text("rev"), + title: text("title"), + summary: text("summary"), + body: text("body"), + updated_by: value.get("updated_by").and_then(Value::as_str).map(str::to_string), + }) + } +} + +/// Why a request to memory did not succeed. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Failure { + /// `403`: the user has not allowed this (`access` is what they allow). + Denied { + access: Access, + message: String, + }, + /// `409`: the page changed since the revision the write named; `current` + /// is the page now, `None` when it was deleted. + Conflict { + current: Option, + }, + NotFound, + /// No answer: the launcher is not running, or the request timed out. + Unreachable(String), + Status { + status: u16, + message: String, + }, +} + +impl Failure { + /// One line for the log and the settings page. + pub fn message(&self) -> String { + match self { + Self::Denied { message, .. } => message.clone(), + Self::Conflict { .. } => "Another writer changed the page at the same time.".into(), + Self::NotFound => "Not found.".into(), + Self::Unreachable(error) => format!("LaunchX did not answer: {error}"), + Self::Status { status: 401, .. } => "LaunchX did not accept this server's memory token.".into(), + Self::Status { status, message } => format!("LaunchX answered {status}: {message}"), + } + } +} + +/// The memory API at `LAUNCHX_MEMORY_URL`, with this service's token. +#[derive(Clone)] +pub struct Client { + url: String, + token: String, + agent: ureq::Agent, +} + +/// Never the token. +impl std::fmt::Debug for Client { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Client").field("url", &self.url).finish_non_exhaustive() + } +} + +impl Client { + pub fn new(url: &str, token: &str) -> Self { + let agent = ureq::Agent::config_builder() + .proxy(None) + .timeout_global(Some(REQUEST_TIMEOUT)) + .http_status_as_error(false) + .user_agent("schedule-everything") + .build() + .into(); + Self { url: url.trim().trim_end_matches('/').to_string(), token: token.trim().to_string(), agent } + } + + /// The memory LaunchX gives a service it manages; `None` outside LaunchX, + /// or from a launcher without memory. + pub fn from_env() -> Option { + std::env::var_os("LAUNCHX")?; + let var = |name: &str| std::env::var(name).ok().map(|v| v.trim().to_string()).filter(|v| !v.is_empty()); + Some(Self::new(&var(URL_ENV)?, &var(TOKEN_ENV)?)) + } + + pub fn url(&self) -> &str { + &self.url + } + + fn call(&self, method: &str, path: &str, body: Option<&Value>) -> Result { + let url = format!("{}{path}", self.url); + let authorization = format!("Bearer {}", self.token); + let response = match body { + None => self.agent.get(&url).header("Authorization", &authorization).call(), + Some(body) => { + let request = match method { + "PUT" => self.agent.put(&url), + _ => self.agent.post(&url), + }; + request + .header("Authorization", &authorization) + .header("Content-Type", "application/json") + .send(body.to_string()) + } + } + .map_err(|e| Failure::Unreachable(e.to_string()))?; + let status = response.status().as_u16(); + let text = response.into_body().read_to_string().map_err(|e| Failure::Unreachable(e.to_string()))?; + let value: Value = serde_json::from_str(&text).unwrap_or(Value::Null); + let message = || value.get("error").and_then(Value::as_str).unwrap_or("no detail").to_string(); + match status { + 200..=299 => Ok(value), + 403 => Err(Failure::Denied { + access: value.get("access").and_then(Value::as_str).and_then(Access::parse).unwrap_or(Access::None), + message: message(), + }), + 404 => Err(Failure::NotFound), + 409 => Err(Failure::Conflict { current: value.get("current").and_then(Page::from_json) }), + _ => Err(Failure::Status { status, message: message() }), + } + } + + /// `GET /me`: what the user lets this service do, now. + pub fn me(&self) -> Result { + let me = self.call("GET", "/me", None)?; + me.get("access") + .and_then(Value::as_str) + .and_then(Access::parse) + .ok_or_else(|| Failure::Status { status: 200, message: "no access level in /me".into() }) + } + + /// `GET /index`: one line per page, and how many pages there are. + pub fn index(&self) -> Result<(String, u64), Failure> { + let index = self.call("GET", "/index", None)?; + let markdown = index.get("markdown").and_then(Value::as_str).unwrap_or_default().to_string(); + Ok((markdown, index.get("pages").and_then(Value::as_u64).unwrap_or(0))) + } + + /// `GET /pages/`; `None` when there is no such page. + pub fn page(&self, page: &str) -> Result, Failure> { + match self.call("GET", &format!("/pages/{page}"), None) { + Ok(value) => Ok(Page::from_json(&value)), + Err(Failure::NotFound) => Ok(None), + Err(failure) => Err(failure), + } + } + + /// `PUT /pages/`: create it (`base` `None`) or update the revision + /// `base`. Title and summary stay as they are unless `summary` is given. + pub fn put(&self, page: &str, body: &str, base: Option<&str>, summary: Option<&str>) -> Result { + let mut request = json!({"body": body, "base": base, "note": NOTE}); + if let Some(summary) = summary { + request["summary"] = json!(summary); + } + let written = self.call("PUT", &format!("/pages/{page}"), Some(&request))?; + Page::from_json(&written) + .ok_or_else(|| Failure::Status { status: 200, message: "no page in the answer".into() }) + } +} + +// ============================================================================= +// rmd's section of a page +// ============================================================================= + +/// `content` between rmd's marker lines. +pub fn section(content: &str) -> String { + format!("{BEGIN_LINE}\n{}\n{END_LINE}", content.trim_matches('\n')) +} + +fn is_begin(line: &str) -> bool { + line.trim_start().starts_with(BEGIN) +} + +fn is_end(line: &str) -> bool { + line.trim() == END_LINE +} + +/// `body` with `section` in place of rmd's section, or added at the end when +/// it has none. Every line outside rmd's markers is kept as it is; a copy of +/// the section is removed, and a begin marker without its end loses only the +/// marker line. +pub fn merge_section(body: &str, section: &str) -> String { + let lines: Vec<&str> = body.lines().collect(); + let mut out: Vec<&str> = Vec::with_capacity(lines.len()); + let mut placed = false; + let mut i = 0; + while i < lines.len() { + if !is_begin(lines[i]) { + out.push(lines[i]); + i += 1; + continue; + } + match lines[i + 1..].iter().position(|line| is_end(line)) { + Some(offset) => { + if !placed { + out.push(section); + placed = true; + } + i += offset + 2; + } + None => i += 1, + } + } + let mut text = out.join("\n").trim_end().to_string(); + if !placed { + if !text.trim().is_empty() { + text.push_str("\n\n"); + } + text.push_str(section); + } + text.push('\n'); + text +} + +/// What [`sync_section`] did. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum Synced { + /// The page already held the section. + Unchanged(Page), + Written(Page), +} + +/// Put `section` into `page`: read it, merge, and write with the revision +/// read as `base`. When another writer changed it in between (`409`), merge +/// into the page as it is now and write once more. +pub fn sync_section(client: &Client, page: &str, section: &str) -> Result { + let current = client.page(page)?; + match write_section(client, page, section, current.as_ref()) { + Err(Failure::Conflict { current }) => write_section(client, page, section, current.as_ref()), + other => other, + } +} + +fn write_section(client: &Client, page: &str, section: &str, current: Option<&Page>) -> Result { + let body = merge_section(current.map_or("", |page| page.body.as_str()), section); + if let Some(current) = current + && current.body.trim() == body.trim() + { + return Ok(Synced::Unchanged(current.clone())); + } + let summary = match current { + Some(current) if !current.summary.trim().is_empty() => None, + _ => Some(SCHEDULE_SUMMARY), + }; + client.put(page, &body, current.map(|page| page.rev.as_str()), summary).map(Synced::Written) +} + +// ============================================================================= +// What rmd writes: the routine's shape and the upcoming deadlines +// ============================================================================= + +/// Text for the page: one line, no marker, at most `limit` characters. +fn clean(text: &str, limit: usize) -> String { + let text = text.replace("", ""); + let text = text.split_whitespace().collect::>().join(" "); + if text.chars().count() <= limit { + return text; + } + let cut: String = text.chars().take(limit.saturating_sub(1)).collect(); + format!("{}…", cut.trim_end()) +} + +/// An event as the page names it: a block or time point by its name with +/// spaces (`long_break` → `long break`), anything else as the workspace shows it. +fn event_label(event: &Value, config: &ScheduleConfig) -> String { + match event { + Value::String(name) + if config.time_blocks.contains_key(name.trim()) || config.time_points.contains_key(name.trim()) => + { + name.trim().replace('_', " ") + } + _ => format_event_label(event), + } +} + +/// One day of the routine on one line: the span of the day, then its events +/// in order, with a run of the same block counted (`14:00–15:55 pomodoro ×4`). +fn day_shape(schedule: &Dict, config: &ScheduleConfig) -> String { + struct Run { + label: String, + first: NaiveTime, + last: NaiveTime, + count: usize, + minutes: Option, + } + let mut events: Vec<(NaiveTime, &Value)> = + schedule.iter().filter_map(|(time, event)| Some((py::parse_hhmm(time)?, event))).collect(); + events.sort_by_key(|(time, _)| *time); + let mut runs: Vec = Vec::new(); + for (at, event) in events { + let label = clean(&event_label(event, config), LABEL_LIMIT); + if label.is_empty() { + continue; + } + match runs.last_mut() { + Some(run) if run.label == label => { + run.last = at; + run.count += 1; + } + _ => { + let minutes = get_event_block_name(event).and_then(|block| { + config.block_minutes(&block).or_else(|| config.block_minutes(&block.replace(' ', "_"))) + }); + runs.push(Run { label, first: at, last: at, count: 1, minutes }) + } + } + } + let (Some(first), Some(last)) = (runs.first(), runs.last()) else { + return "nothing scheduled".into(); + }; + if runs.len() == 1 && first.count == 1 { + return format!("{} {}", py::hhmm(first.first), first.label); + } + let end = |run: &Run| run.minutes.map_or(run.last, |m| run.last + chrono::Duration::minutes(m)); + let parts: Vec = runs + .iter() + .map(|run| match run.count { + 1 => format!("{} {}", py::hhmm(run.first), run.label), + n => format!("{}–{} {} ×{n}", py::hhmm(run.first), py::hhmm(end(run)), run.label), + }) + .collect(); + format!("{}–{} · {}", py::hhmm(first.first), py::hhmm(end(last)), parts.join(", ")) +} + +/// `Monday–Friday, Sunday`: weekdays by index, three or more in a row as a range. +fn days_label(days: &[usize]) -> String { + if days.len() == 7 { + return "Every day".into(); + } + let mut parts = Vec::new(); + let mut i = 0; + while i < days.len() { + let mut j = i; + while j + 1 < days.len() && days[j + 1] == days[j] + 1 { + j += 1; + } + if j - i >= 2 { + parts.push(format!("{}–{}", DAY_NAMES[days[i]], DAY_NAMES[days[j]])); + } else { + parts.extend(days[i..=j].iter().map(|&day| DAY_NAMES[day].to_string())); + } + i = j + 1; + } + parts.join(", ") +} + +/// A week of the routine: days with the same shape share a line. +fn week_lines(weekly: &WeeklySchedule, parity: &str, config: &ScheduleConfig) -> Vec { + let mut groups: Vec<(String, Vec)> = Vec::new(); + for (index, day) in WEEKDAYS.iter().enumerate() { + let shape = if config.skips_weekday(day) { + "no reminders (a skip day)".to_string() + } else { + day_shape(&weekly.schedule_for_day(parity, day), config) + }; + match groups.iter_mut().find(|(known, _)| *known == shape) { + Some((_, days)) => days.push(index), + None => groups.push((shape, vec![index])), + } + } + groups.into_iter().map(|(shape, days)| format!("- {}: {shape}", days_label(&days))).collect() +} + +/// Upcoming deadlines, soonest first: one-offs in the next six months, and +/// recurring ones by their rule. +fn deadline_lines(deadlines: &[Value], task_types: &Dict, today: NaiveDate) -> Vec { + let horizon = today + chrono::Duration::days(DEADLINE_DAYS); + let mut rows: Vec<(NaiveDate, String)> = Vec::new(); + for item in deadlines.iter().filter_map(Value::as_object) { + let event = clean(&py::get_str_or_empty(item, "event"), LABEL_LIMIT); + let date = py::strptime_date(py::get_str_or_empty(item, "deadline").trim(), "%Y-%m-%d"); + let (false, Some(date)) = (event.is_empty(), date) else { continue }; + let rule = repeat_rule(item); + if date < today || (rule.is_none() && date > horizon) { + continue; + } + let weekday = DAY_NAMES[date.weekday().num_days_from_monday() as usize]; + let when = match rule { + Some("weekly") => format!("Every {weekday}"), + Some("biweekly") => format!("Every other {weekday}, next {date}"), + Some("monthly") => format!("Monthly on day {}", anchor_day(item, date)), + _ => format!("{date} ({})", &weekday[..3]), + }; + let kind = item + .get("type") + .map(py::py_str) + .map(|id| id.trim().to_string()) + .filter(|id| !id.is_empty()) + .map(|id| task_types.get(&id).map(py::py_str).unwrap_or(id)) + .map(|name| format!(" · {}", clean(&name, LABEL_LIMIT))) + .unwrap_or_default(); + rows.push((date, format!("- {when}: {event}{kind}"))); + } + rows.sort(); + rows.into_iter().take(MAX_DEADLINES).map(|(_, line)| line).collect() +} + +/// rmd's part of the `schedule` page (without markers): the routine week by +/// week, and the upcoming deadlines. Absolute dates only, so it changes when +/// the routine or deadlines do, not every day. +pub fn render_schedule( + config: &ScheduleConfig, + weekly: &WeeklySchedule, + deadlines: &[Value], + task_types: &Dict, + today: NaiveDate, +) -> String { + let mut text = String::from("## From Schedule Everything\n\n"); + let odd = week_lines(weekly, "odd", config); + let even = week_lines(weekly, "even", config); + if odd == even { + text.push_str("Weekly routine (reminder blocks, local time):\n"); + text.push_str(&odd.join("\n")); + } else { + text.push_str("Weekly routine in odd ISO weeks (reminder blocks, local time):\n"); + text.push_str(&odd.join("\n")); + text.push_str("\n\nIn even ISO weeks:\n"); + text.push_str(&even.join("\n")); + } + text.push_str("\n\nUpcoming deadlines:\n"); + let deadlines = deadline_lines(deadlines, task_types, today); + if deadlines.is_empty() { + text.push_str("- None."); + } else { + text.push_str(&deadlines.join("\n")); + } + text +} + +/// rmd's section of the `schedule` page from the active configuration, with +/// its markers; `None` while the schedule configuration does not load. +pub fn schedule_section() -> Option { + let paths = crate::web::services::snapshot_runtime_paths(); + let config = ScheduleConfig::load(&paths.settings_path).ok()?; + let weekly = WeeklySchedule::load(&paths.odd_path, &paths.even_path).ok()?; + let today = crate::clock::today(); + // Read without saving: recurring deadlines roll forward in memory only. + let deadlines = std::fs::read_to_string(&paths.ddl_path) + .ok() + .and_then(|text| serde_json::from_str::(&text).ok()) + .and_then(|value| value.as_array().cloned()) + .unwrap_or_default(); + let deadlines = crate::commands::deadlines::refresh_deadlines(&deadlines, Some(today)).kept; + let task_types = crate::web::services::load_task_types(); + Some(section(&render_schedule(&config, &weekly, &deadlines, &task_types, today))) +} + +// ============================================================================= +// What Suggest reads +// ============================================================================= + +fn clip(text: &str, limit: usize) -> String { + if text.chars().count() <= limit { + return text.to_string(); + } + let cut: String = text.chars().take(limit).collect(); + format!("{}\n…", cut.trim_end()) +} + +/// The memory's index and the `profile` and `preferences` pages, short +/// enough for a prompt; `None` when memory holds nothing yet. +pub fn read_context(client: &Client) -> Result, Failure> { + let (index, pages) = client.index()?; + if pages == 0 { + return Ok(None); + } + let mut text = format!("\n{}\n", clip(index.trim(), INDEX_LIMIT)); + for name in ["profile", "preferences"] { + if let Some(page) = client.page(name)?.filter(|page| !page.body.trim().is_empty()) { + text.push_str(&format!("\n\n{}\n", clip(page.body.trim(), PAGE_LIMIT))); + } + } + Ok(Some(text)) +} + +// ============================================================================= +// The server's memory +// ============================================================================= + +/// What the settings page shows. +#[derive(Clone, Debug, Default)] +struct Status { + access: Option, + reachable: Option, + checked: Option, + error: Option, + synced_at: Option, + rev: Option, + sync_error: Option, +} + +enum Wake { + /// Ask LaunchX for the access now. + Check, + /// The routine or deadlines changed. + Changed, +} + +struct Memory { + id: String, + client: Client, + status: Mutex, + wake: Mutex>, + check_pending: AtomicBool, +} + +static MEMORY: OnceLock = OnceLock::new(); + +/// Use `client` as service `id` for the rest of the process: Suggest reads +/// from it, and a background thread keeps the `schedule` page current. +pub fn start(id: &str, client: Client) { + let (sender, receiver) = mpsc::channel(); + let memory = Memory { + id: id.to_string(), + client, + status: Mutex::new(Status::default()), + wake: Mutex::new(sender), + check_pending: AtomicBool::new(false), + }; + if MEMORY.set(memory).is_ok() + && let Err(e) = std::thread::Builder::new().name("rmd-memory".into()).spawn(move || run(receiver)) + { + eprintln!("LaunchX memory: could not start its thread: {e}"); + } +} + +/// The routine or deadlines may have changed: update the `schedule` page +/// once things are quiet. Does nothing outside LaunchX. +pub fn schedule_changed() { + if let Some(memory) = MEMORY.get() { + memory.send(Wake::Changed); + } +} + +/// What Suggest gives the model from memory, when rmd may read it. +pub fn suggest_context() -> Option { + let memory = MEMORY.get()?; + match read_context(&memory.client) { + Ok(context) => { + memory.answered(None); + context + } + Err(failure) => { + memory.failed(&failure); + None + } + } +} + +/// Memory as the state document and the settings page show it. +pub fn status() -> Value { + status_of(MEMORY.get()) +} + +/// [`status`] of `memory`; asks LaunchX again in the background when what +/// is known is more than a few seconds old. +fn status_of(memory: Option<&Memory>) -> Value { + let command = |id: &str| format!("lx memory access {id} {}", WANTS.as_str()); + let Some(memory) = memory else { + return json!({ + "available": false, + "access": null, + "wants": WANTS.as_str(), + "reachable": null, + "error": null, + "change": command(crate::launchx::SERVICE_ID), + "schedule": null, + }); + }; + let status = memory.status().clone(); + if status.checked.is_none_or(|checked| checked.elapsed() > STALE) + && !memory.check_pending.swap(true, Ordering::SeqCst) + { + memory.send(Wake::Check); + } + json!({ + "available": true, + "access": status.access.map(Access::as_str), + "wants": WANTS.as_str(), + "reachable": status.reachable, + "error": status.error, + "change": command(&memory.id), + "schedule": { + "page": SCHEDULE_PAGE, + "rev": status.rev, + "syncedAt": status.synced_at, + "error": status.sync_error, + }, + }) +} + +impl Memory { + fn status(&self) -> MutexGuard<'_, Status> { + self.status.lock().unwrap_or_else(|poisoned| poisoned.into_inner()) + } + + fn send(&self, wake: Wake) { + let _ = self.wake.lock().unwrap_or_else(|poisoned| poisoned.into_inner()).send(wake); + } + + /// LaunchX answered; `access` when the answer said what it is. + fn answered(&self, access: Option) { + let mut status = self.status(); + if status.reachable != Some(true) { + println!("LaunchX memory: connected at {}", self.client.url()); + } + if let Some(access) = access + && status.access != Some(access) + { + println!("LaunchX memory: Schedule Everything may {}", access_words(access)); + status.access = Some(access); + } + status.reachable = Some(true); + status.error = None; + } + + /// A request failed. A refusal tells the access; anything else is logged + /// once, until it changes. + fn failed(&self, failure: &Failure) { + let mut status = self.status(); + if let Failure::Denied { access, .. } = failure { + if status.access != Some(*access) { + println!("LaunchX memory: Schedule Everything may {}", access_words(*access)); + } + status.access = Some(*access); + status.reachable = Some(true); + status.error = None; + return; + } + let message = failure.message(); + if status.error.as_deref() != Some(message.as_str()) { + eprintln!("LaunchX memory: {message}"); + } + let reachable = !matches!(failure, Failure::Unreachable(_)); + if !reachable { + status.access = None; + } + status.reachable = Some(reachable); + status.error = Some(message); + } + + /// Ask LaunchX what rmd may do; the access, or `None` without an answer. + fn check(&self) -> Option { + self.check_pending.store(false, Ordering::SeqCst); + let result = self.client.me(); + self.status().checked = Some(Instant::now()); + match result { + Ok(access) => { + self.answered(Some(access)); + Some(access) + } + Err(failure) => { + self.failed(&failure); + None + } + } + } + + /// Bring rmd's section of the `schedule` page up to date, if rmd may write. + fn sync(&self) { + if self.check() != Some(Access::Write) { + return; + } + let Some(section) = schedule_section() else { return }; + let result = sync_section(&self.client, SCHEDULE_PAGE, §ion); + let mut status = self.status(); + match result { + Ok(synced) => { + let page = match synced { + Synced::Written(page) => { + println!("LaunchX memory: updated the {SCHEDULE_PAGE} page (rev {})", page.rev); + page + } + Synced::Unchanged(page) => page, + }; + status.rev = Some(page.rev); + status.synced_at = Some(crate::clock::now().format("%Y-%m-%dT%H:%M:%S").to_string()); + status.sync_error = None; + } + // Refused or unanswered: what the connection shows. + Err(failure @ (Failure::Denied { .. } | Failure::Unreachable(_))) => { + drop(status); + self.failed(&failure); + } + // The write itself failed (a page too large, say): logged once, + // shown in Settings, and tried again at the next change or check. + Err(failure) => { + let message = failure.message(); + if status.sync_error.as_deref() != Some(message.as_str()) { + eprintln!("LaunchX memory: could not update the {SCHEDULE_PAGE} page: {message}"); + } + status.sync_error = Some(message); + } + } + } +} + +fn access_words(access: Access) -> &'static str { + match access { + Access::None => "not use the shared memory", + Access::Read => "read the shared memory", + Access::Write => "read and write the shared memory", + } +} + +/// The background thread: sync shortly after start, a few seconds after the +/// last change, when rmd is first allowed to write, and every two minutes. +fn run(wake: Receiver) { + let Some(memory) = MEMORY.get() else { return }; + let mut due = Some(Instant::now() + FIRST_SYNC); + let mut first_change: Option = None; + loop { + let timeout = due.map_or(POLL, |due| due.saturating_duration_since(Instant::now())); + match wake.recv_timeout(timeout) { + Ok(Wake::Check) => { + let before = memory.status().access; + if memory.check() == Some(Access::Write) && before != Some(Access::Write) { + due = Some(Instant::now()); + } + } + Ok(Wake::Changed) => { + let now = Instant::now(); + let first = *first_change.get_or_insert(now); + due = Some((now + DEBOUNCE).min(first + MAX_WAIT)); + } + Err(RecvTimeoutError::Timeout) => { + due = None; + first_change = None; + memory.sync(); + } + Err(RecvTimeoutError::Disconnected) => return, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::BTreeMap; + use std::io::{BufRead, BufReader, Read, Write}; + use std::net::TcpListener; + use std::sync::Arc; + + // ------------------------------------------------------------------------- + // A memory API to talk to: the parts of LaunchX's that rmd uses. + // ------------------------------------------------------------------------- + + #[derive(Default)] + struct Fake { + access: Option<&'static str>, + pages: BTreeMap, + revisions: u32, + /// Text another writer adds to a page between rmd's read and its write. + sneak_in: Option<(String, String)>, + /// An answer to every write instead of writing. + refuse_writes: Option<(u16, &'static str)>, + requests: Vec, + } + + impl Fake { + fn page_json(&self, name: &str) -> Value { + let (rev, body) = &self.pages[name]; + json!({"page": name, "rev": rev, "title": "Schedule", "summary": "", "body": body, "updated_by": "someone"}) + } + + fn set(&mut self, name: &str, body: &str) { + self.revisions += 1; + self.pages.insert(name.into(), (format!("rev{}", self.revisions), body.into())); + } + + fn answer(&mut self, method: &str, path: &str, authorization: &str, body: &str) -> (u16, Value) { + self.requests.push(format!("{method} {path}")); + if authorization != "Bearer memory-token" { + return (401, json!({"error": "Unauthorized"})); + } + let access = self.access.unwrap_or("none"); + let level = Access::parse(access).unwrap(); + let refuse = || (403, json!({"error": "rmd may not use the user's memory", "access": access})); + match (method, path) { + ("GET", "/me") => (200, json!({"role": "app", "id": "rmd", "access": access})), + ("GET", "/index") if level >= Access::Read => { + let lines: Vec = self.pages.keys().map(|name| format!("- `{name}`")).collect(); + (200, json!({"markdown": format!("# Memory\n{}", lines.join("\n")), "pages": self.pages.len()})) + } + ("GET", page) if page.starts_with("/pages/") => { + if level < Access::Read { + return refuse(); + } + let name = &page["/pages/".len()..]; + if !self.pages.contains_key(name) { + return (404, json!({"error": "No page"})); + } + let page = self.page_json(name); + if let Some((target, extra)) = self.sneak_in.take().filter(|(target, _)| target == name) { + let body = format!("{}\n{extra}\n", self.pages[&target].1.trim_end()); + self.set(&target, &body); + } + (200, page) + } + ("PUT", page) if page.starts_with("/pages/") => { + if level < Access::Write { + return refuse(); + } + if let Some((status, error)) = self.refuse_writes { + return (status, json!({"error": error})); + } + let name = &page["/pages/".len()..]; + let request: Value = serde_json::from_str(body).unwrap(); + let base = request["base"].as_str(); + match (base, self.pages.get(name)) { + (None, Some(_)) => return (409, json!({"error": "exists", "current": self.page_json(name)})), + (Some(_), None) => return (409, json!({"error": "gone", "current": null})), + (Some(base), Some((rev, _))) if base != rev => { + return (409, json!({"error": "changed", "current": self.page_json(name)})); + } + _ => {} + } + assert!(request["note"].as_str().is_some_and(|note| !note.is_empty())); + self.set(name, request["body"].as_str().unwrap()); + (200, self.page_json(name)) + } + ("GET", _) => refuse(), + _ => (404, json!({"error": "Not found"})), + } + } + } + + /// Serve `fake` on a local port until the test ends; the client for it. + fn serve(fake: Fake) -> (Client, Arc>) { + let fake = Arc::new(Mutex::new(fake)); + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let url = format!("http://127.0.0.1:{}/api/memory", listener.local_addr().unwrap().port()); + let shared = fake.clone(); + std::thread::spawn(move || { + for stream in listener.incoming() { + let Ok(stream) = stream else { return }; + let mut reader = BufReader::new(stream); + let mut head = String::new(); + let (mut length, mut authorization) = (0, String::new()); + loop { + let mut line = String::new(); + if reader.read_line(&mut line).unwrap_or(0) == 0 || line == "\r\n" { + break; + } + if let Some((name, value)) = line.split_once(':') { + if name.eq_ignore_ascii_case("content-length") { + length = value.trim().parse().unwrap(); + } else if name.eq_ignore_ascii_case("authorization") { + authorization = value.trim().to_string(); + } + } + if head.is_empty() { + head = line; + } + } + let mut body = vec![0; length]; + reader.read_exact(&mut body).unwrap(); + let mut parts = head.split_whitespace(); + let (method, path) = (parts.next().unwrap_or(""), parts.next().unwrap_or("")); + let path = path.strip_prefix("/api/memory").unwrap_or(path).to_string(); + let (status, answer) = + shared.lock().unwrap().answer(method, &path, &authorization, &String::from_utf8_lossy(&body)); + let answer = answer.to_string(); + let mut stream = reader.into_inner(); + let _ = write!( + stream, + "HTTP/1.1 {status} X\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{answer}", + answer.len() + ); + } + }); + (Client::new(&url, "memory-token"), fake) + } + + fn with_access(access: &'static str) -> Fake { + Fake { access: Some(access), ..Fake::default() } + } + + // ------------------------------------------------------------------------- + // The client + // ------------------------------------------------------------------------- + + #[test] + fn the_client_reads_its_access_and_never_shows_its_token() { + let (client, _) = serve(with_access("read")); + assert_eq!(client.me(), Ok(Access::Read)); + assert!(!format!("{client:?}").contains("memory-token")); + let (wrong, _) = serve(with_access("read")); + let wrong = Client::new(wrong.url(), "other"); + let failure = wrong.me().unwrap_err(); + assert_eq!(failure.message(), "LaunchX did not accept this server's memory token."); + assert!(!failure.message().contains("other")); + } + + #[test] + fn a_refusal_says_what_the_user_allows() { + let (client, _) = serve(with_access("none")); + assert_eq!(client.me(), Ok(Access::None)); + assert!(matches!(client.index(), Err(Failure::Denied { access: Access::None, .. }))); + assert!(matches!(client.page("profile"), Err(Failure::Denied { access: Access::None, .. }))); + let (client, _) = serve(with_access("read")); + assert_eq!(client.page("profile"), Ok(None)); + assert!(matches!(client.put("schedule", "x", None, None), Err(Failure::Denied { access: Access::Read, .. }))); + } + + #[test] + fn an_absent_launcher_is_unreachable_not_an_error() { + let port = TcpListener::bind("127.0.0.1:0").unwrap().local_addr().unwrap().port(); + let client = Client::new(&format!("http://127.0.0.1:{port}/api/memory"), "memory-token"); + assert!(matches!(client.me(), Err(Failure::Unreachable(_)))); + assert!(matches!(read_context(&client), Err(Failure::Unreachable(_)))); + } + + #[test] + fn managed_mode_alone_brings_a_memory() { + let mut env = crate::test_support::TestEnv::new(); + for name in ["LAUNCHX", URL_ENV, TOKEN_ENV] { + env.remove_var(name); + } + env.set_var(URL_ENV, "http://127.0.0.1:7600/api/memory/"); + env.set_var(TOKEN_ENV, "secret"); + assert!(Client::from_env().is_none()); + env.set_var("LAUNCHX", "0.1"); + let client = Client::from_env().unwrap(); + assert_eq!(client.url(), "http://127.0.0.1:7600/api/memory"); + env.set_var(TOKEN_ENV, " "); + assert!(Client::from_env().is_none()); + } + + // ------------------------------------------------------------------------- + // Merging rmd's section into a page + // ------------------------------------------------------------------------- + + #[test] + fn the_section_goes_at_the_end_of_a_page_without_one() { + let ours = section("## From Schedule Everything\n\n- Monday: 09:00 lecture"); + assert_eq!(merge_section("", &ours), format!("{ours}\n")); + assert_eq!( + merge_section("- 1:1 with [[people/ann]] on Tuesdays\n\n", &ours), + format!("- 1:1 with [[people/ann]] on Tuesdays\n\n{ours}\n") + ); + } + + #[test] + fn only_the_lines_between_the_markers_change() { + let old = section("- Monday: old"); + let new = section("- Monday: new"); + let body = format!("Intro by someone else.\n\n{old}\n\n- Added below by an agent.\n"); + let merged = merge_section(&body, &new); + assert_eq!(merged, format!("Intro by someone else.\n\n{new}\n\n- Added below by an agent.\n")); + // Merging again changes nothing. + assert_eq!(merge_section(&merged, &new), merged); + // A begin line whose wording changed still counts as rmd's. + let reworded = format!("Intro.\n\n- Monday: old\n{END_LINE}\nAfter."); + assert_eq!(merge_section(&reworded, &new), format!("Intro.\n{new}\nAfter.\n")); + } + + #[test] + fn copies_go_and_a_lone_marker_keeps_its_text() { + let new = section("- new"); + let doubled = format!("{}\nmiddle\n{}\n", section("- a"), section("- b")); + assert_eq!(merge_section(&doubled, &new), format!("{new}\nmiddle\n")); + // A begin marker without its end (an editor cut it off): only the marker line goes. + let broken = format!("Notes.\n{BEGIN_LINE}\n- the user's own line\n"); + assert_eq!(merge_section(&broken, &new), format!("Notes.\n- the user's own line\n\n{new}\n")); + // An end marker on its own is someone else's text. + let stray = format!("{END_LINE}\nNotes."); + assert_eq!(merge_section(&stray, &new), format!("{END_LINE}\nNotes.\n\n{new}\n")); + } + + // ------------------------------------------------------------------------- + // Writing without losing writes + // ------------------------------------------------------------------------- + + #[test] + fn rmd_creates_the_page_with_a_summary_and_then_leaves_it_alone() { + let (client, fake) = serve(with_access("write")); + let ours = section("- Monday: 09:00 lecture"); + let Ok(Synced::Written(page)) = sync_section(&client, "schedule", &ours) else { panic!() }; + assert_eq!(page.body, format!("{ours}\n")); + assert_eq!(sync_section(&client, "schedule", &ours), Ok(Synced::Unchanged(page))); + let requests = fake.lock().unwrap().requests.clone(); + assert_eq!(requests, ["GET /pages/schedule", "PUT /pages/schedule", "GET /pages/schedule"]); + } + + #[test] + fn a_conflict_is_merged_into_the_current_page_and_retried_once() { + let mut fake = with_access("write"); + fake.set("schedule", &format!("Mornings: writing.\n\n{}\n", section("- Monday: old"))); + // Between rmd's read and its write, another app adds a line. + fake.sneak_in = Some(("schedule".into(), "- Tuesday 11:00: 1:1 with Ann".into())); + let (client, fake) = serve(fake); + let new = section("- Monday: new"); + let Ok(Synced::Written(page)) = sync_section(&client, "schedule", &new) else { panic!() }; + assert_eq!(page.body, format!("Mornings: writing.\n\n{new}\n- Tuesday 11:00: 1:1 with Ann\n")); + let fake = fake.lock().unwrap(); + assert_eq!(fake.requests, ["GET /pages/schedule", "PUT /pages/schedule", "PUT /pages/schedule"]); + } + + #[test] + fn a_page_deleted_meanwhile_is_created_again() { + let mut fake = with_access("write"); + fake.set("schedule", "old"); + let (client, fake) = serve(fake); + let current = client.page("schedule").unwrap(); + fake.lock().unwrap().pages.clear(); + let ours = section("- new"); + let Err(Failure::Conflict { current: None }) = write_section(&client, "schedule", &ours, current.as_ref()) + else { + panic!() + }; + assert!(matches!(write_section(&client, "schedule", &ours, None), Ok(Synced::Written(_)))); + } + + #[test] + fn reading_is_not_writing() { + let (client, fake) = serve(with_access("read")); + let failure = sync_section(&client, "schedule", §ion("- x")).unwrap_err(); + assert!(matches!(failure, Failure::Denied { access: Access::Read, .. })); + assert!(fake.lock().unwrap().pages.is_empty()); + } + + // ------------------------------------------------------------------------- + // What Suggest reads + // ------------------------------------------------------------------------- + + #[test] + fn suggest_reads_the_index_profile_and_preferences_kept_short() { + let mut fake = with_access("read"); + fake.set("profile", "PhD student in robotics. Time zone: America/Los_Angeles."); + fake.set("preferences", &"Mornings are for writing. ".repeat(400)); + fake.set("resume", "Not for Suggest."); + let (client, fake) = serve(fake); + let context = read_context(&client).unwrap().unwrap(); + assert!(context.starts_with("\n# Memory\n- `preferences`\n- `profile`\n- `resume`\n")); + assert!(context.contains("\nPhD student in robotics.")); + assert!(!context.contains("Not for Suggest.")); + let preferences = context.split("\n").nth(1).unwrap(); + assert!(preferences.chars().count() < PAGE_LIMIT + 20, "{}", preferences.len()); + assert!(preferences.ends_with("\n…\n")); + assert_eq!(fake.lock().unwrap().requests, ["GET /index", "GET /pages/profile", "GET /pages/preferences"]); + // Nothing in memory yet, or no access: nothing to add. + let (empty, _) = serve(with_access("write")); + assert_eq!(read_context(&empty), Ok(None)); + let (off, _) = serve(with_access("none")); + assert!(matches!(read_context(&off), Err(Failure::Denied { .. }))); + } + + // ------------------------------------------------------------------------- + // What rmd writes + // ------------------------------------------------------------------------- + + /// Days of the week by name, for tests that build a schedule. + fn week(days: &[(&str, &[(&str, &str)])]) -> Dict { + let mut out = Dict::new(); + for (day, events) in days { + let mut table = Dict::new(); + for (time, event) in *events { + table.insert(time.to_string(), json!(event)); + } + out.insert(day.to_string(), Value::Object(table)); + } + out + } + + fn config(text: &str) -> ScheduleConfig { + ScheduleConfig::from_dict(&crate::config::parse_toml_str(text).unwrap()) + } + + #[test] + fn days_are_named_with_ranges() { + assert_eq!(days_label(&[0, 1, 2, 3, 4]), "Monday–Friday"); + assert_eq!(days_label(&[0, 1, 3, 5, 6]), "Monday, Tuesday, Thursday, Saturday, Sunday"); + assert_eq!(days_label(&[0, 2, 3, 4, 6]), "Monday, Wednesday–Friday, Sunday"); + assert_eq!(days_label(&[0, 1, 2, 3, 4, 5, 6]), "Every day"); + } + + #[test] + fn the_routine_is_drawn_by_its_shape() { + let config = config( + "[settings]\nskip_days = [\"sunday\"]\n[time_blocks]\npomodoro = 25\nlong_break = 40\nnapping = 30\n", + ); + let day: &[(&str, &str)] = &[ + ("08:30", "pomodoro"), + ("09:00", "pomodoro"), + ("09:26", "long_break"), + ("13:20", "napping"), + ("14:00", "pomodoro"), + ("14:30", "pomodoro"), + ]; + let saturday: &[(&str, &str)] = &[("10:00", "Long run ")]; + let odd = week(&[ + ("monday", day), + ("tuesday", day), + ("wednesday", day), + ("thursday", day), + ("friday", day), + ("saturday", saturday), + ]); + let weekly = WeeklySchedule { odd_data: odd.clone(), even_data: odd }; + let mut task_types = Dict::new(); + task_types.insert("1".into(), json!("thesis")); + let today = NaiveDate::from_ymd_opt(2026, 11, 17).unwrap(); + let deadlines = vec![ + json!({"event": "Thesis draft to advisor", "deadline": "2026-12-01", "type": "1"}), + json!({"event": "Passed already", "deadline": "2026-11-16"}), + json!({"event": "Far away", "deadline": "2027-08-01"}), + json!({"event": "Group meeting notes", "deadline": "2026-11-20", "repeat": "weekly"}), + json!({"event": "Rent", "deadline": "2026-12-05", "repeat": "monthly", "repeat_day": 5}), + json!({"event": "Seminar", "deadline": "2026-11-26", "repeat": "biweekly"}), + json!({"event": "", "deadline": "2026-11-30"}), + ]; + assert_eq!( + render_schedule(&config, &weekly, &deadlines, &task_types, today), + "## From Schedule Everything + +Weekly routine (reminder blocks, local time): +- Monday–Friday: 08:30–14:55 · 08:30–09:25 pomodoro ×2, 09:26 long break, 13:20 napping, 14:00–14:55 pomodoro ×2 +- Saturday: 10:00 Long run not a marker +- Sunday: no reminders (a skip day) + +Upcoming deadlines: +- Every Friday: Group meeting notes +- Every other Thursday, next 2026-11-26: Seminar +- 2026-12-01 (Tue): Thesis draft to advisor · thesis +- Monthly on day 5: Rent" + ); + } + + #[test] + fn odd_and_even_weeks_are_told_apart_when_they_differ() { + let config = config("[time_blocks]\nmeeting = 50\n"); + let weekly = WeeklySchedule { + odd_data: week(&[("tuesday", &[("11:00", "meeting")])]), + even_data: week(&[("tuesday", &[("15:00", "meeting")])]), + }; + let text = render_schedule(&config, &weekly, &[], &Dict::new(), NaiveDate::from_ymd_opt(2026, 11, 17).unwrap()); + assert_eq!( + text, + "## From Schedule Everything + +Weekly routine in odd ISO weeks (reminder blocks, local time): +- Monday, Wednesday–Sunday: nothing scheduled +- Tuesday: 11:00 meeting + +In even ISO weeks: +- Monday, Wednesday–Sunday: nothing scheduled +- Tuesday: 15:00 meeting + +Upcoming deadlines: +- None." + ); + } + + #[test] + fn the_section_comes_from_the_active_configuration() { + let mut env = crate::test_support::TestEnv::with_fixture(); + env.set_now("2026-11-17T10:00:00"); + env.write( + "user_config_0/ddl.json", + r#"[{"event": "Paper submission", "deadline": "2026-12-01", "type": "3"}]"#, + ); + let ours = schedule_section().unwrap(); + assert!(ours.starts_with(BEGIN_LINE), "{ours}"); + assert!(ours.ends_with(END_LINE)); + assert!(ours.contains("- Sunday: no reminders (a skip day)"), "{ours}"); + assert!(ours.contains(", 21:00 summary time, 22:45 go to bed\n"), "{ours}"); + assert!(ours.contains("- 2026-12-01 (Tue): Paper submission · coding"), "{ours}"); + // Reading rolls nothing forward on disk. + env.write( + "user_config_0/ddl.json", + r#"[{"event": "Weekly report", "deadline": "2026-11-06", "repeat": "weekly"}]"#, + ); + assert!(schedule_section().unwrap().contains("- Every Friday: Weekly report")); + assert!(env.read("user_config_0/ddl.json").contains("2026-11-06")); + // A configuration that does not load writes nothing. + env.write("user_config_0/settings.toml", "[settings\nbroken"); + assert_eq!(schedule_section(), None); + } + + fn memory(client: Client) -> Memory { + Memory { + id: "rmd-dev".into(), + client, + status: Mutex::new(Status::default()), + wake: Mutex::new(mpsc::channel().0), + check_pending: AtomicBool::new(false), + } + } + + #[test] + fn the_server_keeps_its_section_current_while_it_may_write() { + let mut env = crate::test_support::TestEnv::with_fixture(); + env.set_now("2026-11-17T10:00:00"); + env.write("user_config_0/ddl.json", r#"[{"event": "Paper submission", "deadline": "2026-12-01"}]"#); + let mut fake = with_access("read"); + fake.set("schedule", "- Tuesdays 11:00: 1:1 with [[people/ann]]\n"); + let (client, fake) = serve(fake); + let memory = memory(client); + + // Read access: nothing is written, and the status says what to run. + memory.sync(); + let status = status_of(Some(&memory)); + assert_eq!((&status["available"], &status["access"]), (&json!(true), &json!("read"))); + assert_eq!(status["change"], json!("lx memory access rmd-dev write")); + assert_eq!(status["schedule"]["syncedAt"], Value::Null); + assert_eq!(fake.lock().unwrap().requests, ["GET /me"]); + + // Write access: rmd's section joins the page, below the other writer's line. + fake.lock().unwrap().access = Some("write"); + memory.sync(); + let body = fake.lock().unwrap().pages["schedule"].1.clone(); + assert!(body.starts_with("- Tuesdays 11:00: 1:1 with [[people/ann]]\n\n +## From Schedule Everything + +Weekly routine (reminder blocks, local time): +- Monday–Friday: 08:30–17:55 · 08:30–09:25 pomodoro ×2, 09:26 long break, 13:20 napping, 14:00–17:55 pomodoro ×8 +- Saturday: 10:00 Long run +- Sunday: no reminders (a skip day) + +Upcoming deadlines: +- Every Friday: Group meeting notes +- 2026-12-01 (Tue): Paper submission · Writing + +``` + +- **Its own section.** Everything between the two marker lines is the + workspace's; everything else on the page belongs to whoever wrote it, you, + another app or an agent, and is never changed. The section lives on the + `schedule` page itself rather than on a sub-page, because `schedule` is the + page other apps and agents look for, and an app that reads it gets the whole + picture in one request. Write your own notes above or below the markers. +- **What goes in.** The routine day by day, with days of the same shape on one + line and odd and even weeks apart when they differ; one-off deadlines in the + next six months and recurring ones by their rule, at most 20. Dates are + absolute, so the section changes when the routine or a deadline does, not + every day. Live data stays out: open tasks, today's progress and habits are + in the [state document](#state-document), where other apps read them. +- **When.** A few seconds after you change the routine, a deadline or a type + in the workspace (several changes make one write), as soon as you allow + writing, and every two minutes, which picks up changes made with the CLI or + in a text editor. A write happens only when the section differs from the + page. +- **No lost writes.** Every write names the revision it read. When another + writer changed the page in between, LaunchX refuses the write (`409`) and + sends the page as it is now; the workspace puts its section into that page + and writes once more. +- **Turning it off.** With read access or none, the workspace stops writing; + its section stays on the page until you or an agent remove it. With write + access, a section you delete comes back, since keeping it is what writing is + for. + +When memory is off, LaunchX is not running, or a request is refused, the +workspace works as it does without LaunchX, logs one line, and shows the +reason in Settings. It never logs the memory token. + ## HTTP interface Programs reach the service directly, not through the gateway. LaunchX records @@ -146,6 +226,7 @@ contains no tokens. It carries an `ETag`; send it back as `If-None-Match` to get | `suggestions` | Tasks suggested by agents, waiting for review. | | `plugins` | Plugins with their settings, state and log. | | `ai` | Whether the Suggest button is connected to a model (`ready`) and who it asks (`agent`). Never the API key. | +| `memory` | The [shared memory](#shared-memory): `available` (LaunchX gave the server one), `access` (`none`, `read`, `write`, or `null` until LaunchX answers), `wants`, `reachable`, `error`, `change` (the command that grants what the workspace asks for), and `schedule` with the page's `rev`, when the workspace last found it current (`syncedAt`), and the `error` of the last write. Never the token. | | `views` | The commands of `POST /api` behind the views the document leaves out, because they take a parameter or are large: `daily_overview`, `weekly_overview`, `task_history`, `conference_calendar`, `config_read`. | Within a major version, fields are only added. diff --git a/documentation/docs/browser.md b/documentation/docs/browser.md index fdcf103..9d345eb 100644 --- a/documentation/docs/browser.md +++ b/documentation/docs/browser.md @@ -335,7 +335,10 @@ address, so switching between them loses nothing. Each press sends the model your open tasks with their progress and steps, your deadlines, today's schedule and habits, your recent finished work, your profile, the suggestions waiting for review or turned down lately, so it -does not repeat them, and what you asked for more and fewer of. Nothing else is sent, and nothing is sent until you +does not repeat them, and what you asked for more and fewer of. When the +workspace runs under LaunchX and you let it read LaunchX's +[shared memory](advanced/launchx.md#shared-memory), it also sends the memory's +index and your `profile` and `preferences` pages from it, shortened. Nothing else is sent, and nothing is sent until you press **Suggest** (or **More like this**). With Codex sign-in, it goes to OpenAI through the Codex CLI. The settings, key and token included, are saved in `.ai.json` in your config root, readable only by you. diff --git a/launchx.toml b/launchx.toml index 5be1b9b..1e3d905 100644 --- a/launchx.toml +++ b/launchx.toml @@ -31,3 +31,10 @@ state = "/api/state" # Everything is switched on for agents (lx agents on rmd). [service.rmd.agents] skills = "plugins/schedule-everything/skills" + +# What Schedule Everything asks to do with your shared memory in LaunchX. It +# only asks: you decide, on its card in LaunchX or with +# `lx memory access rmd write` (or `read`, or `none`). +[service.rmd.memory] +wants = "write" +reason = "Keeps the routine and deadlines on your schedule page current, and lets Suggest read your profile and preferences" diff --git a/tests/golden/expected/api_status_snapshot_monday.json b/tests/golden/expected/api_status_snapshot_monday.json index c0a8599..a3fc838 100644 --- a/tests/golden/expected/api_status_snapshot_monday.json +++ b/tests/golden/expected/api_status_snapshot_monday.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 10:00\", \"next\": \"pomodoro: Review pull requests at 11:00\", \"timeToNext\": \"30m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 10:00\", \"next\": \"pomodoro: Review pull requests at 11:00\", \"timeToNext\": \"30m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Yesterday thing\",\n \"deadline\": \"2026-11-08\",\n \"added\": \"2026-10-20T17:06:00+00:00\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-10\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/tests/golden/expected/api_status_snapshot_odd_week.json b/tests/golden/expected/api_status_snapshot_odd_week.json index 30dbc54..5868ad2 100644 --- a/tests/golden/expected/api_status_snapshot_odd_week.json +++ b/tests/golden/expected/api_status_snapshot_odd_week.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-17\", \"weekday\": \"tuesday\", \"parity\": \"odd\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 08:30\", \"next\": \"pomodoro at 09:30\", \"timeToNext\": \"50m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"long_break\", \"block\": \"long_break\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 16, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 0, \"status\": \"today\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 3, \"status\": \"urgent\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 13, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 44, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-17\", \"weekday\": \"tuesday\", \"parity\": \"odd\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 08:30\", \"next\": \"pomodoro at 09:30\", \"timeToNext\": \"50m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"long_break\", \"block\": \"long_break\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 16, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 0, \"status\": \"today\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 3, \"status\": \"urgent\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 13, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 44, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-17\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/tests/golden/expected/api_status_snapshot_skip_day.json b/tests/golden/expected/api_status_snapshot_skip_day.json index aa5fe0a..933b288 100644 --- a/tests/golden/expected/api_status_snapshot_skip_day.json +++ b/tests/golden/expected/api_status_snapshot_skip_day.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-15\", \"weekday\": \"sunday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": true, \"current\": null, \"next\": null, \"timeToNext\": null, \"events\": [], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 14, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 2, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 5, \"status\": \"soon\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 15, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 46, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-15\", \"weekday\": \"sunday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": true, \"current\": null, \"next\": null, \"timeToNext\": null, \"events\": [], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 14, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 2, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 5, \"status\": \"soon\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 15, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 46, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-17\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/tests/golden/expected/api_status_snapshot_thursday.json b/tests/golden/expected/api_status_snapshot_thursday.json index 4441c67..0ef6d54 100644 --- a/tests/golden/expected/api_status_snapshot_thursday.json +++ b/tests/golden/expected/api_status_snapshot_thursday.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-12\", \"weekday\": \"thursday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"pomodoro at 14:00\", \"next\": \"pomodoro at 14:30\", \"timeToNext\": \"20m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"14:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"16:00\", \"label\": \"long_break\", \"block\": \"long_break\", \"syncable\": false}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 11, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 5, \"status\": \"soon\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 8, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 18, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 49, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-12\", \"weekday\": \"thursday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"pomodoro at 14:00\", \"next\": \"pomodoro at 14:30\", \"timeToNext\": \"20m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"14:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"16:00\", \"label\": \"long_break\", \"block\": \"long_break\", \"syncable\": false}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 11, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}], \"deadlines\": [{\"event\": \"Team sync\", \"deadline\": \"2026-11-17\", \"daysLeft\": 5, \"status\": \"soon\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 8, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 18, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 49, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-17\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/tests/golden/expected/api_status_snapshot_with_plan.json b/tests/golden/expected/api_status_snapshot_with_plan.json index 2891aac..e7a0dbb 100644 --- a/tests/golden/expected/api_status_snapshot_with_plan.json +++ b/tests/golden/expected/api_status_snapshot_with_plan.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 10:00\", \"next\": \"pomodoro: Review pull requests at 11:00\", \"timeToNext\": \"30m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro: Call the bank\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": true}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"potato at 10:00\", \"next\": \"pomodoro: Review pull requests at 11:00\", \"timeToNext\": \"30m\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro: Call the bank\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": true}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1m\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Yesterday thing\",\n \"deadline\": \"2026-11-08\",\n \"added\": \"2026-10-20T17:06:00+00:00\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-10\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/tests/golden/expected/api_status_snapshot_zh.json b/tests/golden/expected/api_status_snapshot_zh.json index 77b6050..9c873e2 100644 --- a/tests/golden/expected/api_status_snapshot_zh.json +++ b/tests/golden/expected/api_status_snapshot_zh.json @@ -1,6 +1,6 @@ { "exit": 0, - "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"10:00 potato\", \"next\": \"11:00 pomodoro: Review pull requests\", \"timeToNext\": \"30分钟\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1分钟\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}}}\n", + "stdout": "{\"ok\": true, \"data\": {\"config\": {\"rootDir\": \"\", \"activeId\": 0, \"activeConfigDir\": \"/user_config_0\", \"tasksPath\": \"/tasks/tasks.json\", \"deadlinesPath\": \"/user_config_0/ddl.json\", \"habitsPath\": \"/user_config_0/habits.toml\", \"recordsPath\": \"/tasks/record.json\", \"error\": null}, \"today\": {\"date\": \"2026-11-09\", \"weekday\": \"monday\", \"parity\": \"even\"}, \"schedule\": {\"isSkipped\": false, \"current\": \"10:00 potato\", \"next\": \"11:00 pomodoro: Review pull requests\", \"timeToNext\": \"30分钟\", \"events\": [{\"time\": \"08:30\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"09:30\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"10:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"11:00\", \"label\": \"pomodoro: Review pull requests\", \"block\": \"pomodoro\", \"syncable\": false}, {\"time\": \"12:00\", \"label\": \"lunch_time\", \"block\": \"lunch_time\", \"syncable\": false}, {\"time\": \"13:20\", \"label\": \"napping\", \"block\": \"napping\", \"syncable\": false}, {\"time\": \"14:00\", \"label\": \"potato\", \"block\": \"potato\", \"syncable\": true}, {\"time\": \"15:00\", \"label\": \"meeting\", \"block\": \"meeting\", \"syncable\": false}, {\"time\": \"16:00\", \"label\": \"pomodoro\", \"block\": \"pomodoro\", \"syncable\": true}, {\"time\": \"22:30\", \"label\": \"go_to_bed\", \"block\": \"go_to_bed\", \"syncable\": false}], \"hasSyncedOverlay\": false}, \"tasks\": [{\"description\": \"Fix CI pipeline\", \"priority\": 7, \"type\": \"3\", \"typeName\": \"coding\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": 8, \"due\": null, \"progress\": 40, \"subtasks\": []}, {\"description\": \"Call the bank\", \"priority\": 6, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": true, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Write grant report\", \"priority\": 9, \"type\": \"1\", \"typeName\": \"read papers\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"Plan gym routine v2\", \"priority\": 5, \"type\": \"2\", \"typeName\": \"gym work\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}, {\"description\": \"整理笔记\", \"priority\": 5, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": null, \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 33, \"subtasks\": [{\"text\": \"Sort notes\", \"done\": true}, {\"text\": \"Tag notes\", \"done\": false}, {\"text\": \"Archive\", \"done\": false}]}, {\"description\": \"Book flights\", \"priority\": 8, \"type\": \"4\", \"typeName\": \"other\", \"alarmFrom\": \"2026-11-11\", \"procrastinated\": false, \"procrastinateDays\": null, \"due\": null, \"progress\": 0, \"subtasks\": []}], \"deadlines\": [{\"event\": \"Yesterday thing\", \"deadline\": \"2026-11-08\", \"daysLeft\": -1, \"status\": \"overdue\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Team sync\", \"deadline\": \"2026-11-10\", \"daysLeft\": 1, \"status\": \"urgent\", \"type\": \"3\", \"typeName\": \"coding\", \"color\": \"blue\", \"repeat\": \"weekly\", \"repeatDay\": null}, {\"event\": \"Grant report\", \"deadline\": \"2026-11-20\", \"daysLeft\": 11, \"status\": \"ok\", \"type\": \"1\", \"typeName\": \"read papers\", \"color\": null, \"repeat\": null, \"repeatDay\": null}, {\"event\": \"Rent\", \"deadline\": \"2026-11-30\", \"daysLeft\": 21, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": \"monthly\", \"repeatDay\": 30}, {\"event\": \"论文截止\", \"deadline\": \"2026-12-31\", \"daysLeft\": 52, \"status\": \"ok\", \"type\": null, \"typeName\": null, \"color\": null, \"repeat\": null, \"repeatDay\": null}], \"habits\": [{\"id\": \"1\", \"description\": \"Go to sleep on time\", \"completed\": false}, {\"id\": \"2\", \"description\": \"Exercise for 30 minutes\", \"completed\": false}, {\"id\": \"3\", \"description\": \"Drink 1.5L water\", \"completed\": false}, {\"id\": \"4\", \"description\": \"Read for 20 minutes\", \"completed\": false}, {\"id\": \"5\", \"description\": \"冥想\", \"completed\": false}], \"taskTypes\": {\"1\": \"read papers\", \"2\": \"gym work\", \"3\": \"coding\", \"4\": \"other\"}, \"taskTypeColors\": {}, \"history\": [{\"description\": \"Weekly review notes\", \"priority\": 2, \"startedAt\": \"2026-11-06T20:00:00\", \"endedAt\": \"2026-11-07T17:00:00\", \"duration\": \"21h\", \"status\": \"completed\", \"type\": \"4\", \"typeName\": \"other\"}, {\"description\": \"Learn Rust macros\", \"priority\": 5, \"startedAt\": \"2026-10-28T11:00:00\", \"endedAt\": \"2026-11-02T16:00:00\", \"duration\": \"5d 5h\", \"status\": \"dropped\", \"type\": \"3\", \"typeName\": \"coding\"}, {\"description\": \"Typo task\", \"priority\": 3, \"startedAt\": \"2026-10-26T09:30:00\", \"endedAt\": \"2026-10-26T09:31:00\", \"duration\": \"1分钟\", \"status\": \"cancelled\", \"type\": \"1\", \"typeName\": \"read papers\"}, {\"description\": \"Read attention paper\", \"priority\": 6, \"startedAt\": \"2026-10-21T15:00:00\", \"endedAt\": \"2026-10-22T18:00:00\", \"duration\": \"1d 3h\", \"status\": \"completed\", \"type\": \"1\", \"typeName\": \"read papers\"}], \"timedDone\": [], \"suggestions\": [], \"plugins\": [], \"ai\": {\"ready\": false, \"agent\": \"Claude\"}, \"memory\": {\"available\": false, \"access\": null, \"wants\": \"write\", \"reachable\": null, \"error\": null, \"change\": \"lx memory access rmd write\", \"schedule\": null}}}\n", "stderr": "", "files": { "user_config_0/ddl.json": "[\n {\n \"event\": \"Rent\",\n \"deadline\": \"2026-11-30\",\n \"added\": \"2026-09-01T17:00:00+00:00\",\n \"repeat\": \"monthly\",\n \"repeat_day\": 30\n },\n {\n \"event\": \"Grant report\",\n \"deadline\": \"2026-11-20\",\n \"added\": \"2026-10-20T17:05:00+00:00\",\n \"type\": \"1\"\n },\n {\n \"event\": \"Yesterday thing\",\n \"deadline\": \"2026-11-08\",\n \"added\": \"2026-10-20T17:06:00+00:00\"\n },\n {\n \"event\": \"Team sync\",\n \"deadline\": \"2026-11-10\",\n \"added\": \"2026-10-30T17:00:00+00:00\",\n \"type\": \"3\",\n \"color\": \"blue\",\n \"repeat\": \"weekly\"\n },\n {\n \"event\": \"论文截止\",\n \"deadline\": \"2026-12-31\",\n \"added\": \"2026-11-02T18:00:00+00:00\"\n }\n]" diff --git a/web/src/locales/es.json b/web/src/locales/es.json index 55bd6dd..b5c48f8 100644 --- a/web/src/locales/es.json +++ b/web/src/locales/es.json @@ -123,6 +123,7 @@ "Asks OpenAI through the Codex CLI on this computer, with the account it is signed in to (codex login). Each press runs codex exec in an empty folder, with a read-only sandbox.": "Pregunta a OpenAI a través de la CLI de Codex de este ordenador, con la cuenta con la que ha iniciado sesión (codex login). Cada pulsación ejecuta codex exec en una carpeta vacía, con un entorno aislado de solo lectura.", "Auth token": "Token de autenticación", "Auto": "Automático", + "Available when Schedule Everything runs under LaunchX, which shares it with your other apps.": "Disponible cuando Schedule Everything se ejecuta con LaunchX, que la comparte con tus otras aplicaciones.", "Average": "Promedio", "Average importance": "Importancia media", "Average importance {n} out of 10": "Importancia media {n} de 10", @@ -167,12 +168,14 @@ "Cancelled and dropped tasks are left out of both.": "Las tareas canceladas y descartadas no cuentan en ninguno de los dos.", "Cardio": "Cardio", "Change": "Cambiar", + "Change it on Schedule Everything’s card in LaunchX.": "Puedes cambiarlo en la tarjeta de Schedule Everything en LaunchX.", "Change it, then add it": "Cámbiala y luego añádela", "Change the finish time…": "Cambiar la hora límite…", "Check date": "Revisa la fecha", "Check off at least one set first, or discard the workout.": "Marca al menos una serie primero o descarta el entrenamiento.", "Check off the next subtask": "Marcar la siguiente subtarea", "Check-ins": "Registros", + "Checking with LaunchX…": "Consultando a LaunchX…", "Chest": "Pecho", "Choose AI conferences": "Elegir congresos de IA", "Choose a model to turn on Suggest.": "Elige un modelo para activar Sugerir.", @@ -440,6 +443,7 @@ "Install the Schedule Everything plugin in Claude Code, Codex, or Antigravity. It interviews you, writes your weekly routine, fills today’s focus blocks, and suggests tasks from your email and calendar for you to review on the board, through the local rmd CLI. Your agent sends what it reads to its own model provider.": "Instala el plugin de Schedule Everything en Claude Code, Codex o Antigravity. Te entrevista, escribe tu rutina semanal, rellena los bloques de enfoque de hoy y te sugiere tareas a partir de tu correo y tu calendario para que las revises en el tablero, a través de la CLI local rmd. Tu agente envía lo que lee a su propio proveedor de modelos.", "Interface language": "Idioma de la interfaz", "It also counts as a finished task in your activity.": "También cuenta como tarea terminada en tu actividad.", + "It also sends your shared memory’s index and its profile and preferences pages.": "También envía el índice de tu memoria compartida y sus páginas de perfil y preferencias.", "It was added by mistake, or isn’t needed anymore.": "Se añadió por error o ya no hace falta.", "It weighs your workload, picks your highlights, and can weigh today’s progress.": "Pesa en tu carga de trabajo, elige tus destacados y puede ponderar el progreso de hoy.", "Its own metrics when Activity is viewed by its category.": "Sus propias métricas al ver Actividad por su categoría.", @@ -473,6 +477,8 @@ "Latest {weight}": "Último: {weight}", "Lats": "Dorsales", "Launch the browser workspace again.": "Vuelve a abrir el espacio de trabajo del navegador.", + "LaunchX keeps one memory for your apps and AI agents: pages about who you are, how you like to work, and your schedule.": "LaunchX guarda una memoria para tus aplicaciones y agentes de IA: páginas sobre quién eres, cómo te gusta trabajar y tu horario.", + "LaunchX’s memory did not answer, so Suggest goes without it for now.": "La memoria de LaunchX no respondió, así que Sugerir funciona sin ella por ahora.", "Leg press": "Prensa de piernas", "Legs": "Piernas", "Less": "Menos", @@ -591,7 +597,9 @@ "Number": "Número", "Obliques": "Oblicuos", "Odd week schedule": "Horario de semana impar", + "Off: this workspace neither reads nor writes your memory.": "Desactivada: este espacio de trabajo no lee ni escribe en tu memoria.", "Oldest first": "Más antiguas primero", + "On: Suggest reads your profile and preferences, and your routine and deadlines are kept current on the schedule page.": "Activada: Sugerir lee tu perfil y tus preferencias, y tu rutina y tus fechas límite se mantienen al día en la página de horario.", "One bar for everything you planned for a time today, filling as that work gets done.": "Una barra para todo lo que planeaste a una hora hoy, que se llena a medida que lo haces.", "One day, one thing at a time.": "Un día, una cosa a la vez.", "One square for each day of the last 22 weeks. The deeper the color, the more you finished.": "Un cuadro por cada día de las últimas 22 semanas. Cuanto más intenso el color, más terminaste.", @@ -683,6 +691,7 @@ "Quicker than {percent}% of your other completed tasks.": "Más rápida que el {percent}% de tus otras tareas completadas.", "RIGHT NOW": "AHORA MISMO", "Rate": "Tasa", + "Read only: Suggest reads your profile and preferences. Allow writing to keep your routine and deadlines on the schedule page.": "Solo lectura: Sugerir lee tu perfil y tus preferencias. Permite la escritura para mantener tu rutina y tus fechas límite en la página de horario.", "Reading": "Lectura", "Reading time": "Tiempo de lectura", "Ready now": "Listas ya", @@ -760,6 +769,7 @@ "Saved. That was an auth token, so Suggest signs in with it.": "Guardado. Era un token de autenticación, así que Sugerir inicia sesión con él.", "Schedule": "Horario", "Schedule Everything overview": "Resumen de Schedule Everything", + "Schedule page last checked {time}.": "Página de horario revisada por última vez: {time}.", "Schedule paused today": "Horario en pausa hoy", "Schedule {id}": "Horario {id}", "Search exercises": "Buscar ejercicios", @@ -777,6 +787,7 @@ "Settings": "Ajustes", "Share of everything": "Parte del total", "Share still left": "Parte que falta", + "Shared memory": "Memoria compartida", "Shoulders": "Hombros", "Show AI conference submission deadlines, rebuttal periods, and conference dates": "Mostrar las fechas límite de envío, los periodos de réplica y las fechas de los congresos de IA", "Show conferences": "Mostrar congresos", @@ -944,6 +955,7 @@ "Try again": "Reintentar", "Try it": "Pruébalo", "Turn it down, and get fewer ideas like it": "Recházala y recibe menos ideas como esta", + "Turn it on in LaunchX, on Schedule Everything’s card, or run {command}.": "Actívala en LaunchX, en la tarjeta de Schedule Everything, o ejecuta {command}.", "Turn on “Tracked in Activity” for this plugin to see its own metrics here.": "Activa «Seguimiento en Actividad» en este plugin para ver aquí sus propias métricas.", "Two measurements draw a line.": "Con dos mediciones se traza una línea.", "Type": "Tipo", diff --git a/web/src/locales/ko.json b/web/src/locales/ko.json index 722b7e7..bb10663 100644 --- a/web/src/locales/ko.json +++ b/web/src/locales/ko.json @@ -123,6 +123,7 @@ "Asks OpenAI through the Codex CLI on this computer, with the account it is signed in to (codex login). Each press runs codex exec in an empty folder, with a read-only sandbox.": "이 컴퓨터의 Codex CLI로, 로그인된 계정(codex login)을 써서 OpenAI에 물어봐요. 누를 때마다 빈 폴더에서 읽기 전용 샌드박스로 codex exec를 실행해요.", "Auth token": "인증 토큰", "Auto": "자동", + "Available when Schedule Everything runs under LaunchX, which shares it with your other apps.": "Schedule Everything을 LaunchX에서 실행하면 쓸 수 있어요. LaunchX가 다른 앱들과 함께 나눠 써요.", "Average": "평균", "Average importance": "평균 중요도", "Average importance {n} out of 10": "평균 중요도 10점 중 {n}점", @@ -167,12 +168,14 @@ "Cancelled and dropped tasks are left out of both.": "취소하거나 포기한 할 일은 양쪽 모두에서 빼요.", "Cardio": "유산소", "Change": "변경", + "Change it on Schedule Everything’s card in LaunchX.": "LaunchX의 Schedule Everything 카드에서 바꿀 수 있어요.", "Change it, then add it": "수정한 뒤 추가", "Change the finish time…": "마감 시간 변경…", "Check date": "날짜 확인", "Check off at least one set first, or discard the workout.": "먼저 한 세트 이상 체크하거나 운동을 버리세요.", "Check off the next subtask": "다음 하위 할 일 체크", "Check-ins": "체크인", + "Checking with LaunchX…": "LaunchX에 확인하는 중…", "Chest": "가슴", "Choose AI conferences": "AI 학회 선택", "Choose a model to turn on Suggest.": "모델을 고르면 제안받기를 쓸 수 있어요.", @@ -440,6 +443,7 @@ "Install the Schedule Everything plugin in Claude Code, Codex, or Antigravity. It interviews you, writes your weekly routine, fills today’s focus blocks, and suggests tasks from your email and calendar for you to review on the board, through the local rmd CLI. Your agent sends what it reads to its own model provider.": "Claude Code, Codex 또는 Antigravity에 Schedule Everything 플러그인을 설치하세요. 로컬 rmd CLI를 통해 인터뷰를 하고, 주간 루틴을 작성하고, 오늘의 집중 블록을 채우고, 이메일과 캘린더에서 할 일을 제안해 보드에서 검토할 수 있게 해요. 에이전트는 읽은 내용을 자체 모델 제공업체로 보내요.", "Interface language": "인터페이스 언어", "It also counts as a finished task in your activity.": "활동에서도 마친 할 일로 집계돼요.", + "It also sends your shared memory’s index and its profile and preferences pages.": "공유 메모리의 목차와 프로필·선호 페이지도 함께 보내요.", "It was added by mistake, or isn’t needed anymore.": "실수로 추가했거나 더는 필요 없어요.", "It weighs your workload, picks your highlights, and can weigh today’s progress.": "업무량의 무게를 정하고, 하이라이트를 고르고, 오늘의 진행률에 가중치를 줄 수도 있어요.", "Its own metrics when Activity is viewed by its category.": "활동을 해당 카테고리로 볼 때 자체 지표를 보여 줘요.", @@ -473,6 +477,8 @@ "Latest {weight}": "최근 {weight}", "Lats": "광배근", "Launch the browser workspace again.": "브라우저 작업 공간을 다시 실행해 주세요.", + "LaunchX keeps one memory for your apps and AI agents: pages about who you are, how you like to work, and your schedule.": "LaunchX는 앱과 AI 에이전트가 함께 쓰는 메모리를 하나 보관해요. 내가 누구인지, 어떻게 일하길 좋아하는지, 일정은 어떤지 담은 페이지들이에요.", + "LaunchX’s memory did not answer, so Suggest goes without it for now.": "LaunchX 메모리가 응답하지 않아서, 지금은 제안받기가 메모리 없이 동작해요.", "Leg press": "레그 프레스", "Legs": "하체", "Less": "적음", @@ -591,7 +597,9 @@ "Number": "숫자", "Obliques": "복사근", "Odd week schedule": "홀수 주 일정", + "Off: this workspace neither reads nor writes your memory.": "꺼짐: 이 작업 공간은 메모리를 읽지도 쓰지도 않아요.", "Oldest first": "오래된 순", + "On: Suggest reads your profile and preferences, and your routine and deadlines are kept current on the schedule page.": "켜짐: 제안받기가 프로필과 선호를 읽고, 루틴과 마감일은 일정 페이지에 최신으로 유지돼요.", "One bar for everything you planned for a time today, filling as that work gets done.": "오늘 시간을 정해 둔 일을 모두 담은 막대 하나로, 일을 해낼수록 차올라요.", "One day, one thing at a time.": "하루에, 한 번에 하나씩.", "One square for each day of the last 22 weeks. The deeper the color, the more you finished.": "지난 22주의 하루하루가 칸 하나씩이에요. 색이 진할수록 많이 끝냈어요.", @@ -683,6 +691,7 @@ "Quicker than {percent}% of your other completed tasks.": "다른 완료한 할 일의 {percent}%보다 빨랐어요.", "RIGHT NOW": "지금", "Rate": "달성률", + "Read only: Suggest reads your profile and preferences. Allow writing to keep your routine and deadlines on the schedule page.": "읽기만: 제안받기가 프로필과 선호를 읽어요. 루틴과 마감일을 일정 페이지에 두려면 쓰기를 허용하세요.", "Reading": "독서", "Reading time": "독서 시간", "Ready now": "지금 시작 가능", @@ -760,6 +769,7 @@ "Saved. That was an auth token, so Suggest signs in with it.": "저장했어요. 인증 토큰이라서 제안받기가 이 토큰으로 로그인해요.", "Schedule": "일정", "Schedule Everything overview": "Schedule Everything 개요", + "Schedule page last checked {time}.": "일정 페이지를 마지막으로 확인한 때: {time}.", "Schedule paused today": "오늘 일정 일시 중지됨", "Schedule {id}": "일정 {id}", "Search exercises": "운동 검색", @@ -777,6 +787,7 @@ "Settings": "설정", "Share of everything": "전체 중 비율", "Share still left": "남은 비율", + "Shared memory": "공유 메모리", "Shoulders": "어깨", "Show AI conference submission deadlines, rebuttal periods, and conference dates": "AI 학회의 제출 마감일, rebuttal 기간, 학회 일정 표시", "Show conferences": "표시할 학회", @@ -944,6 +955,7 @@ "Try again": "다시 시도", "Try it": "직접 해 보기", "Turn it down, and get fewer ideas like it": "거절하고 이런 아이디어는 덜 받아요", + "Turn it on in LaunchX, on Schedule Everything’s card, or run {command}.": "LaunchX의 Schedule Everything 카드에서 켜거나 {command}를 실행하세요.", "Turn on “Tracked in Activity” for this plugin to see its own metrics here.": "이 플러그인의 “활동에서 추적”을 켜면 여기서 자체 지표를 볼 수 있어요.", "Two measurements draw a line.": "두 번 기록하면 선이 그려져요.", "Type": "유형", diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index 914d299..e1e6ff1 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -123,6 +123,7 @@ "Asks OpenAI through the Codex CLI on this computer, with the account it is signed in to (codex login). Each press runs codex exec in an empty folder, with a read-only sandbox.": "通过这台电脑上的 Codex CLI,用它已登录的账号(codex login)向 OpenAI 提问。每次按下都会在一个空文件夹中以只读沙盒运行 codex exec。", "Auth token": "认证令牌", "Auto": "自动", + "Available when Schedule Everything runs under LaunchX, which shares it with your other apps.": "在 LaunchX 下运行 Schedule Everything 时可用,LaunchX 会把它与你的其他应用共享。", "Average": "平均", "Average importance": "平均重要度", "Average importance {n} out of 10": "平均重要度 {n}/10", @@ -167,12 +168,14 @@ "Cancelled and dropped tasks are left out of both.": "已取消和已放弃的任务两边都不计入。", "Cardio": "有氧", "Change": "更改", + "Change it on Schedule Everything’s card in LaunchX.": "可以在 LaunchX 中 Schedule Everything 的卡片上更改。", "Change it, then add it": "先修改,再添加", "Change the finish time…": "更改截止时间…", "Check date": "检查日期", "Check off at least one set first, or discard the workout.": "请至少先勾选一组,或者放弃这次训练。", "Check off the next subtask": "勾选下一个子任务", "Check-ins": "打卡次数", + "Checking with LaunchX…": "正在向 LaunchX 确认…", "Chest": "胸部", "Choose AI conferences": "选择 AI 会议", "Choose a model to turn on Suggest.": "选择一个模型即可启用“建议”。", @@ -440,6 +443,7 @@ "Install the Schedule Everything plugin in Claude Code, Codex, or Antigravity. It interviews you, writes your weekly routine, fills today’s focus blocks, and suggests tasks from your email and calendar for you to review on the board, through the local rmd CLI. Your agent sends what it reads to its own model provider.": "在 Claude Code、Codex 或 Antigravity 中安装 Schedule Everything 插件。它会通过本地的 rmd CLI 向你了解情况、写好每周日常、填好今天的专注时间块,并从你的邮件和日历中建议任务,放到任务板上等你审阅。你的智能体会把它读取的内容发送给它自己的模型提供商。", "Interface language": "界面语言", "It also counts as a finished task in your activity.": "它也会作为一项已完成的任务计入你的活动。", + "It also sends your shared memory’s index and its profile and preferences pages.": "它还会发送你共享记忆的索引,以及其中的个人资料和偏好页面。", "It was added by mistake, or isn’t needed anymore.": "误加的,或者已经不需要了。", "It weighs your workload, picks your highlights, and can weigh today’s progress.": "它决定工作量的分量,挑出你的亮点,也可以为今天的进度加权。", "Its own metrics when Activity is viewed by its category.": "按类别查看活动时,显示它自己的指标。", @@ -473,6 +477,8 @@ "Latest {weight}": "最新 {weight}", "Lats": "背阔肌", "Launch the browser workspace again.": "请重新启动浏览器工作区。", + "LaunchX keeps one memory for your apps and AI agents: pages about who you are, how you like to work, and your schedule.": "LaunchX 为你的应用和 AI 智能体保存一份共同的记忆:关于你是谁、喜欢怎样工作以及你的日程的页面。", + "LaunchX’s memory did not answer, so Suggest goes without it for now.": "LaunchX 的记忆没有响应,所以“建议”暂时不使用它。", "Leg press": "腿举", "Legs": "腿", "Less": "少", @@ -591,7 +597,9 @@ "Number": "数字", "Obliques": "腹斜肌", "Odd week schedule": "单周日程", + "Off: this workspace neither reads nor writes your memory.": "已关闭:这个工作区不会读取或写入你的记忆。", "Oldest first": "最早优先", + "On: Suggest reads your profile and preferences, and your routine and deadlines are kept current on the schedule page.": "已开启:“建议”会读取你的个人资料和偏好,你的作息和截止日期也会在日程页面上保持最新。", "One bar for everything you planned for a time today, filling as that work gets done.": "一条进度条涵盖你今天定了时间的所有任务,随着完成逐渐填满。", "One day, one thing at a time.": "一天一天来,一次一件事。", "One square for each day of the last 22 weeks. The deeper the color, the more you finished.": "过去 22 周里,每天一个方格。颜色越深,完成得越多。", @@ -683,6 +691,7 @@ "Quicker than {percent}% of your other completed tasks.": "比你其他已完成任务中的 {percent}% 更快。", "RIGHT NOW": "此刻", "Rate": "完成率", + "Read only: Suggest reads your profile and preferences. Allow writing to keep your routine and deadlines on the schedule page.": "只读:“建议”会读取你的个人资料和偏好。允许写入后,你的作息和截止日期会保存在日程页面上。", "Reading": "阅读", "Reading time": "阅读时长", "Ready now": "现在就能做", @@ -760,6 +769,7 @@ "Saved. That was an auth token, so Suggest signs in with it.": "已保存。这是一个认证令牌,“建议”将用它登录。", "Schedule": "日程", "Schedule Everything overview": "Schedule Everything 概览", + "Schedule page last checked {time}.": "日程页面上次检查于 {time}。", "Schedule paused today": "今天日程已暂停", "Schedule {id}": "日程 {id}", "Search exercises": "搜索动作", @@ -777,6 +787,7 @@ "Settings": "设置", "Share of everything": "占全部的比例", "Share still left": "剩余比例", + "Shared memory": "共享记忆", "Shoulders": "肩部", "Show AI conference submission deadlines, rebuttal periods, and conference dates": "显示 AI 会议的投稿截止日期、rebuttal 期和会议日期", "Show conferences": "显示会议", @@ -944,6 +955,7 @@ "Try again": "重试", "Try it": "试一试", "Turn it down, and get fewer ideas like it": "拒绝它,并减少类似的点子", + "Turn it on in LaunchX, on Schedule Everything’s card, or run {command}.": "可以在 LaunchX 中 Schedule Everything 的卡片上开启,或运行 {command}。", "Turn on “Tracked in Activity” for this plugin to see its own metrics here.": "为这个插件打开“在活动中追踪”,即可在这里看到它自己的指标。", "Two measurements draw a line.": "记录两次即可画出曲线。", "Type": "类型", diff --git a/web/src/pages.test.ts b/web/src/pages.test.ts index 58287a7..3cfca33 100644 --- a/web/src/pages.test.ts +++ b/web/src/pages.test.ts @@ -5,7 +5,7 @@ import { GLOSSARY_IDS } from "./glossary"; import { axisTones, layoutTree, packLabels, treeLanes } from "./tree"; import { deadlinesByDay, deadlineSwatch, monthCells, nextOccurrence } from "./calendar"; import { renderApp } from "./render"; -import type { AiSettings, BridgeClient, ConferencePayload, DailyOverview, HistoryItem, Snapshot, WeekDay, WeeklyOverview, WeekStats } from "./types"; +import type { AiSettings, BridgeClient, ConferencePayload, DailyOverview, HistoryItem, MemoryStatus, Snapshot, WeekDay, WeeklyOverview, WeekStats } from "./types"; import { addDays } from "./ui"; const snapshot: Snapshot = { @@ -334,6 +334,62 @@ describe("AI suggestions", () => { }); }); +describe("shared memory", () => { + const memory = (extra: Partial = {}): MemoryStatus => ({ + available: true, access: "write", wants: "write", reachable: true, error: null, change: "lx memory access rmd write", + schedule: {page: "schedule", rev: "a1b2c3d4e5f6", syncedAt: "2026-10-05T09:30:00", error: null}, ...extra + }); + const aiSettings: AiSettings = { + provider: "anthropic", count: 5, instructions: "", ready: true, agent: "Claude", model: "claude-opus-5-5", + providers: { + anthropic: {model: "", baseUrl: "", hasKey: true, keyHint: "…abcd", defaultModel: "claude-opus-5-5", defaultBaseUrl: "https://api.anthropic.com"}, + openai: {model: "", baseUrl: "", hasKey: false, keyHint: null, defaultModel: null, defaultBaseUrl: "https://api.openai.com/v1"} + }, + limits: {maxCount: 10, instructions: 1000} + }; + async function settingsWith(status: MemoryStatus | undefined) { + send.mockImplementation(async (command: string) => { + if (command === "status_snapshot") return {...structuredClone(snapshot), memory: status}; + if (command === "workspace_info") return {configIds: [0], activeId: 0, mode, rootDir: "/local/config"}; + if (command === "ai_settings_read") return aiSettings; + return {}; + }); + document.body.innerHTML = '
'; + root = document.querySelector("#app")!; + await renderApp(root, client); + click('[data-page="settings"]'); await flush(); await flush(); + return root.querySelector("#memory-card")!; + } + + it("says what LaunchX lets the workspace do with memory, and where to change it", async () => { + let card = await settingsWith(memory()); + expect(card.querySelector(".memory-status.is-ready")?.textContent).toContain("On: Suggest reads your profile and preferences"); + expect(card.querySelector(".memory-synced")?.textContent).toMatch(/^Schedule page last checked Mon.*9:30/); + expect(card.querySelector(".memory-change")?.textContent).toBe("Change it on Schedule Everything’s card in LaunchX."); + + card = await settingsWith(memory({access: "read"})); + expect(card.querySelector(".memory-status")?.textContent).toContain("Read only:"); + expect(card.querySelector(".memory-synced")).toBeNull(); + expect(card.querySelector(".memory-change code")?.textContent).toBe("lx memory access rmd write"); + expect(root.querySelector(".ai-privacy")?.textContent).toContain("It also sends your shared memory’s index"); + + card = await settingsWith(memory({access: "none"})); + expect(card.querySelector(".memory-status")?.textContent).toBe("Off: this workspace neither reads nor writes your memory."); + expect(card.querySelector(".memory-status.is-ready")).toBeNull(); + expect(root.querySelector(".ai-privacy")?.textContent).not.toContain("shared memory"); + + card = await settingsWith(memory({access: null, reachable: false, error: "LaunchX did not answer: Connection refused"})); + expect(card.querySelector(".memory-status")?.textContent).toBe("LaunchX’s memory did not answer, so Suggest goes without it for now."); + expect(card.querySelector(".memory-error")?.textContent).toBe("LaunchX did not answer: Connection refused"); + + card = await settingsWith(memory({schedule: {page: "schedule", rev: null, syncedAt: null, error: "LaunchX answered 507: full"}})); + expect(card.querySelector(".memory-error")?.innerHTML).toBe("LaunchX answered 507: <b>full</b>"); + + card = await settingsWith(undefined); + expect(card.querySelector(".memory-status")?.textContent).toBe("Available when Schedule Everything runs under LaunchX, which shares it with your other apps."); + }); +}); + describe("opening the workspace", () => { it("chooses how rmd web opens the workspace, a window by default", async () => { await renderApp(root, client); diff --git a/web/src/render.ts b/web/src/render.ts index d9afc02..bba22c5 100644 --- a/web/src/render.ts +++ b/web/src/render.ts @@ -1125,6 +1125,8 @@ export async function renderApp(root: HTMLElement, client: BridgeClient): Promis const privacy = codex ? t("Suggest sends your open tasks, deadlines, today’s schedule and habits, recent work, and profile to OpenAI through the Codex CLI. Codex keeps its own sign-in; this workspace never reads it.") : token ? t("Suggest sends your open tasks, deadlines, today’s schedule and habits, recent work, and profile to {service}. The token stays on this computer, readable only by you.", {service: `${e(service)}`}) : t("Suggest sends your open tasks, deadlines, today’s schedule and habits, recent work, and profile to {service}. The key stays on this computer, readable only by you.", {service: `${e(service)}`}); + const access = state.snapshot?.memory?.access; + const readsMemory = access === "read" || access === "write"; return `
${heading}

${t("The Suggest button on the task board asks a model for tasks you may need, from your situation right now. Its ideas wait on the board as suggestions until you add or reject them.")}

${providers.map(([id, label]) => ``).join("")}
@@ -1140,10 +1142,36 @@ export async function renderApp(root: HTMLElement, client: BridgeClient): Promis -

${privacy}

+

${privacy}${readsMemory ? ` ${t("It also sends your shared memory’s index and its profile and preferences pages.")}` : ""}

`; } + /** Settings → Shared memory: what LaunchX lets this workspace do with the memory it keeps for the user's apps + * and agents, and where to change it. From the state document's `memory`; the token never reaches the page. */ + function memoryCard(s: Snapshot) { + const memory = s.memory; + const heading = `

${icons.memory} ${t("Shared memory")}

+

${t("LaunchX keeps one memory for your apps and AI agents: pages about who you are, how you like to work, and your schedule.")}

`; + if (!memory?.available) { + return `
${heading}

${t("Available when Schedule Everything runs under LaunchX, which shares it with your other apps.")}

`; + } + const [ready, text] = memory.access === "write" + ? [true, t("On: Suggest reads your profile and preferences, and your routine and deadlines are kept current on the schedule page.")] + : memory.access === "read" + ? [true, t("Read only: Suggest reads your profile and preferences. Allow writing to keep your routine and deadlines on the schedule page.")] + : memory.access === "none" + ? [false, t("Off: this workspace neither reads nor writes your memory.")] + : [false, memory.reachable === false ? t("LaunchX’s memory did not answer, so Suggest goes without it for now.") : t("Checking with LaunchX…")]; + const status = `

${ready ? icons.check : ""}${text}

`; + const syncedAt = memory.access === "write" ? memory.schedule?.syncedAt : null; + const synced = syncedAt ? `

${t("Schedule page last checked {time}.", {time: e(formatDate(syncedAt, {weekday: "short", hour: "numeric", minute: "2-digit"}))})}

` : ""; + const problem = memory.schedule?.error ?? (memory.reachable === false ? memory.error : null); + const error = problem ? `

${e(problem)}

` : ""; + const change = memory.access === memory.wants + ? t("Change it on Schedule Everything’s card in LaunchX.") + : t("Turn it on in LaunchX, on Schedule Everything’s card, or run {command}.", {command: `${e(memory.change)}`}); + return `
${heading}${status}${synced}${error}

${change}

`; + } /** Who receives what Suggest sends: Anthropic, or the host at the address of an OpenAI-compatible service. */ function serviceOf(provider: AiProvider, address: string) { if (provider === "anthropic") return "Anthropic"; @@ -1835,7 +1863,7 @@ export async function renderApp(root: HTMLElement, client: BridgeClient): Promis } function settings(s: Snapshot) { const files = {settings: t("General settings"), odd: t("Odd week schedule"), even: t("Even week schedule"), habits: t("Habits"), deadlines: t("Deadlines"), profile: t("Profile")}; - return `

${t("MAKE IT YOURS")}

${t("Your workspace, your rules")}.

${t("All changes are saved to your computer.")}

${languageCard()}${openCard()}${aiCard()}${pluginsCard(s)}

${t("Reminder preferences")}

${modeOf() === "p" ? t("P mode · selected event alarms paused · overview shows tasks only") : t("J mode · all reminders allowed · full structured overview")}

${button("mode", modeOf() === "p" ? t("Switch to J mode") : t("Switch to P mode"), icons.settings)}
${button("switch", t("Activate"))}${button("update", t("Reload reminders"), icons.refresh)}${button("stop", t("Stop reminders"), "", "button ghost danger")}

${e(s.config.rootDir)}


${t("Task & deadline types")}

${t("Types are managed on the task board: add one with New type on the shelf below the board, and rename or delete one from its ⋯ menu. Deadlines share the same types.")}


${button("shutdown", t("Close browser service"), "", "button ghost")}
${displayCard(s)}

${t("Configuration editor")}

${t("Edit your schedules, habits, settings, or profile here. Syntax is checked before saving.")}

${state.config ? `${button("config-save", t("Save changes"), icons.check, "button primary")}` : button("open-config", t("Open editor"), icons.settings)}

${t("Saved edits reload the installed reminder service when available.")}

`; + return `

${t("MAKE IT YOURS")}

${t("Your workspace, your rules")}.

${t("All changes are saved to your computer.")}

${languageCard()}${openCard()}${aiCard()}${memoryCard(s)}${pluginsCard(s)}

${t("Reminder preferences")}

${modeOf() === "p" ? t("P mode · selected event alarms paused · overview shows tasks only") : t("J mode · all reminders allowed · full structured overview")}

${button("mode", modeOf() === "p" ? t("Switch to J mode") : t("Switch to P mode"), icons.settings)}
${button("switch", t("Activate"))}${button("update", t("Reload reminders"), icons.refresh)}${button("stop", t("Stop reminders"), "", "button ghost danger")}

${e(s.config.rootDir)}


${t("Task & deadline types")}

${t("Types are managed on the task board: add one with New type on the shelf below the board, and rename or delete one from its ⋯ menu. Deadlines share the same types.")}


${button("shutdown", t("Close browser service"), "", "button ghost")}
${displayCard(s)}

${t("Configuration editor")}

${t("Edit your schedules, habits, settings, or profile here. Syntax is checked before saving.")}

${state.config ? `${button("config-save", t("Save changes"), icons.check, "button primary")}` : button("open-config", t("Open editor"), icons.settings)}

${t("Saved edits reload the installed reminder service when available.")}

`; } // ----- Activity bindings --------------------------------------------------- diff --git a/web/src/styles.css b/web/src/styles.css index 2012ea7..fd769a2 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -1719,8 +1719,8 @@ button.heat-cell:hover { transform: scale(1.35); z-index: 5; } .content.enter .day-panel .highlight { animation: rise .6s var(--ease) both; animation-delay: calc(.2s + var(--i) * 90ms); } /* Settings: the board's layout, the workload theme with its levels, and how today's progress counts tasks. */ -.display-card h2, .language-card h2, .ai-card h2, .open-card h2 { display: flex; align-items: center; gap: 8px; } -.display-card h2 svg, .language-card h2 svg, .ai-card h2 svg, .open-card h2 svg { color: var(--accent); } +.display-card h2, .language-card h2, .ai-card h2, .open-card h2, .memory-card h2 { display: flex; align-items: center; gap: 8px; } +.display-card h2 svg, .language-card h2 svg, .ai-card h2 svg, .open-card h2 svg, .memory-card h2 svg { color: var(--accent); } /* Settings → AI suggestions. */ .ai-providers { width: fit-content; max-width: 100%; flex-wrap: wrap; margin-top: 14px; } .ai-provider-note { margin: 8px 0 0; font-size: 12px; } @@ -1730,6 +1730,11 @@ button.heat-cell:hover { transform: scale(1.35); z-index: 5; } .ai-codex svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--accent); } .ai-codex code, .ai-privacy code { font-size: 11.5px; } .ai-provider-note code { font-size: 11.5px; } +.memory-status { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; padding: 9px 12px; border-radius: 14px; background: var(--surface-sunk); color: var(--muted); font-size: 12px; line-height: 1.45; } +.memory-status.is-ready { background: color-mix(in oklab, var(--accent) 9%, transparent); color: var(--text); } +.memory-status svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent); } +.memory-card .memory-synced, .memory-card .memory-error, .memory-card .memory-change { margin: 10px 0 0; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; } +.memory-card code { font-size: 11.5px; } .ai-status { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; padding: 9px 12px; border-radius: 14px; background: var(--surface-sunk); color: var(--muted); font-size: 12px; line-height: 1.45; } .ai-status.is-ready { background: color-mix(in oklab, var(--accent) 9%, transparent); color: var(--text); } .ai-status svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent); } diff --git a/web/src/types.ts b/web/src/types.ts index db0ba74..8857730 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -257,9 +257,23 @@ export type Snapshot = { plugins?: PluginItem[]; /** Whether the Suggest button is connected to a model, and who it asks. */ ai?: AiStatus; + /** What LaunchX lets this workspace do with the user's shared memory. */ + memory?: MemoryStatus; }; export type AiStatus = {ready: boolean; agent: string}; +export type MemoryAccess = "none" | "read" | "write"; +/** The shared memory LaunchX keeps for the user's apps (`memory` in the state document). `available` is false outside + * LaunchX; `access` is null until LaunchX has answered. `change` is the command that grants what the app asks for. */ +export type MemoryStatus = { + available: boolean; + access: MemoryAccess | null; + wants: MemoryAccess; + reachable: boolean | null; + error: string | null; + change: string; + schedule: {page: string; rev: string | null; syncedAt: string | null; error: string | null} | null; +}; export type AiProvider = "anthropic" | "openai"; /** One provider's connection as the browser sees it: whether a key is saved and how it ends, never the key. */ /** How Suggest signs in to Anthropic: an API key, or an auth token such as `claude setup-token` prints. */ diff --git a/web/src/ui.ts b/web/src/ui.ts index 4b74522..df1ebb7 100644 --- a/web/src/ui.ts +++ b/web/src/ui.ts @@ -3,7 +3,7 @@ import { AlarmClock, AppWindow, ArrowDownRight, ArrowLeft, Ban, BicepsFlexed, Blocks, BookOpenText, CalendarClock, CalendarDays, CalendarRange, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsDownUp, BellRing, ChevronsUpDown, CircleCheck, Clock3, Coffee, Copy, CornerDownLeft, CornerDownRight, Crown, - Dumbbell, Ellipsis, Feather, Repeat, Flag, Flame, Gauge, GalleryHorizontalEnd, GripVertical, History, Hourglass, Languages, LayoutDashboard, + Dumbbell, Ellipsis, Feather, Repeat, Flag, Flame, Gauge, GalleryHorizontalEnd, GripVertical, History, Hourglass, Languages, LayoutDashboard, Library, LayoutGrid, Leaf, Lightbulb, ListChecks, ListPlus, ListTodo, MapPin, Medal, Monitor, Moon, Orbit, Palette, PartyPopper, Pencil, Percent, Plus, Puzzle, RefreshCw, Scale, Search, Settings2, Shuffle, Sigma, Sparkles, Sprout, Sun, Target, Trash2, TreeDeciduous, TrendingDown, TrendingUp, ThumbsDown, ThumbsUp, Trophy, Undo2, Waves, X, Zap @@ -36,7 +36,7 @@ export const icons = { gauge: icon(Gauge), language: icon(Languages), orbit: icon(Orbit), grid: icon(LayoutGrid), leaf: icon(Leaf), waves: icon(Waves), scale: icon(Scale), glossary: icon(BookOpenText), blocks: icon(Blocks), week: icon(CalendarRange), history: icon(History), puzzle: icon(Puzzle), sigma: icon(Sigma), bulb: icon(Lightbulb), pin: icon(MapPin), crown: icon(Crown), percent: icon(Percent), dumbbell: icon(Dumbbell), medal: icon(Medal), - muscle: icon(BicepsFlexed), window: icon(AppWindow), thumbsUp: icon(ThumbsUp), thumbsDown: icon(ThumbsDown) + muscle: icon(BicepsFlexed), window: icon(AppWindow), thumbsUp: icon(ThumbsUp), thumbsDown: icon(ThumbsDown), memory: icon(Library) }; /** A clock face whose hands sweep round (see .live-clock in styles.css): the icon of a running timer. */