Skip to content

✨ Add work command: create work file with daily folder structure and toggle work session #39

Description

@amy-shinsen-openclaw

Context

The new folder-per-day structure is already implemented for default notes (create_note_file_with_folders + build_folder_path_for_now), producing paths like:

<not_path>/<year>/<month>/<week>/<day>/<YYYY-MM-DD>.default.md

The existing start-work and end-work commands still rely on the legacy annotation system (annotations embedded in markdown files). The new work command must not use annotations — it uses the journal.json event system instead (.nost/journal.json). The annotation system is kept as-is for legacy compatibility.

Architecture

Two parallel systems coexist:

System Storage Used by
Legacy Annotations in .md files start-work, end-work (unchanged)
New Events in .nost/journal.json work (new command)

Event names remain: START_WORK and STOP_WORK (matching existing EventName enum).

Behaviour

nost work   # alias: nost w
  1. Resolve the work file path using build_folder_path_for_now, with type work:
    <not_path>/<year>/<month>/<week>/<day>/<YYYY-MM-DD>.work.md
    
  2. Create the file (and folders) if they do not exist — reuse create_note_file_with_folders("work").
  3. Check for an active session — read journal.json and find the last START_WORK or STOP_WORK event:
    • Last event is START_WORKclose the session: record a StopWork event via record_event.
    • Last event is STOP_WORK or no work event found → open a session: record a StartWork event via record_event.
  4. Print a clear confirmation message indicating whether a session was opened or closed.

New module to add

src/events/find.rs — function find_last_work_event() -> Option<Event> that reads journal.json and returns the most recent event whose name is START_WORK or STOP_WORK.

Out of scope

  • Stats refactoring (separate issue).
  • The legacy start-work / end-work commands remain untouched.

Acceptance criteria

  • nost work (alias nost w) creates <not_path>/…/<YYYY-MM-DD>.work.md on first call.
  • Calling nost work twice in a row opens then closes the session.
  • Calling nost work when a session is already open closes it.
  • File and folder creation is idempotent (no error if already present).
  • Session state is read from and written to journal.json, not from annotations.
  • CI passes.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions