@lastweek-work/cli
v0.2.0
Published
The lastweek agent: collects git and coding-agent evidence on your machine and sends it to your lastweek account.
Maintainers
Readme
lastweek
The local agent for lastweek: your timesheet, reconstructed from what you actually did. It runs on your machine and collects evidence of your work (git commits, coding-agent sessions); lastweek turns it into a draft timesheet that you review and approve.
npm install -g @lastweek-work/cli
lastweek connect <CODE> --server https://lastweek.work # the code comes from the setup page in your accountWhat leaves your machine: commit subjects, timestamps and repo paths, plus short summaries of coding-agent activity. Never: diffs, file contents or prompts. Only repos in the folders you chose are read. Requires Node.js 22 or later; the background scan uses launchd on macOS.
Details for developers and power users:
Config: ~/.config/lastweek/config.json (override with LASTWEEK_CONFIG), validated on load:
{ "ingestUrl": "https://<ref>.supabase.co/functions/v1/ingest",
"deviceToken": "<rwd_… from the web app, Devices page>",
"repoRoots": ["~/Work"],
"authorEmails": ["[email protected]", "[email protected]"],
"agentEmails": ["[email protected]", "[email protected]"] }ingestUrl/deviceToken may be omitted for --dry-run. Emails match case-insensitively.
Which commits count: yours as author, committer or Co-authored-by — and commits by a coding agent
(agentEmails; the defaults above apply when the key is omitted) that were made or merged on this machine
(local reflog). Agent work in temporary worktrees counts after you merge it, even once the worktree is gone; a
colleague's agent commits in a shared repo never do. Add other agents' commit addresses (e.g. ChatGPT/Codex) to
agentEmails.
lastweek scan # since the last successful scan (else 8 days)
lastweek scan 2026-10-27T00:00:00Z # explicit since (also --since)
lastweek scan --dry-run # print events as JSON, send nothing, don't move last_scan- Walks
repoRoots3 levels deep, adds every worktree. Commits are keyed on the main repo, so a commit seen from several worktrees is one event; each worktree's HEAD reflog is scanned separately. - Sends in chunks of 500. Exits non-zero on any failure;
last_scan(~/.local/state/lastweek/last_scan, override withLASTWEEK_STATE_DIR) only advances after everything was ingested. Reruns are safe (server dedupes).
Claude Code hook
Add to ~/.claude/settings.json (merge with existing hooks). Fires on every edit and every prompt:
{ "hooks": {
"PostToolUse": [ { "matcher": "Edit|Write|MultiEdit|NotebookEdit",
"hooks": [ { "type": "command", "command": "lastweek log 2>/dev/null || true" } ] } ],
"UserPromptSubmit": [
{ "hooks": [ { "type": "command", "command": "lastweek log 2>/dev/null || true" } ] } ] } }- Coalesced: calls of one session within 60 s extend one burst; a burst becomes one interval event (first call → last call, max 15 min) with counts per tool and up to 10 touched files (repo-relative). An hour of agent work is a handful of events and one block in the review — not 300 rows.
- Private: only session id, timestamps, tool names and file paths are read. Prompt text and tool output are never stored or sent.
- Never blocks Claude: no network in the hook, no config needed, always exits 0. Finished bursts go to
~/.local/state/lastweek/spool.jsonl; a detachedlastweek flushsends them. Offline? They wait in the spool and go out with the next flush or scan. Errors land in~/.local/state/lastweek/agent.log. - Same session as your commits: events carry the repo root (not Claude's working subfolder).
MCP server
Optional, for outcome summaries in the agent's own words. Claude Code:
claude mcp add lastweek --scope user --env LASTWEEK_AGENT_NAME=claude-code -- lastweek mcpCursor (~/.cursor/mcp.json):
{ "mcpServers": { "lastweek": { "command": "lastweek", "args": ["mcp"], "env": { "LASTWEEK_AGENT_NAME": "cursor" } } } }Tools: log_activity(summary, repo?, started_at?, ended_at?), start_task(summary, repo?) →
end_task(task_id?, summary?) (the time in between becomes one block). Events are spooled first, like the hook's.
Other commands
lastweek flush # send spooled hook/MCP events now
lastweek status # config, last scan, spool size, open bursts/tasks, schedule
lastweek schedule install --every 30 # macOS launchd: run `lastweek scan` every 30 min (also flushes the spool)
lastweek schedule uninstallThe schedule logs to ~/.local/state/lastweek/scan.log. It uses the Node and PATH of the shell you install it from;
re-run install after switching Node versions.
