@flowmind/cli 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # Flowmind CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Log completed work by project name and duration:
4
+
5
+ ```sh
6
+ fm log --project Flowmind --hours 1.5 --outcome "Shipped the reader"
7
+ ```
8
+
9
+ Without a start time, the session ends when saved: 90 minutes saved at 10:00
10
+ records 08:30–10:00. To supply the actual start, use an ISO 8601 timestamp with
11
+ a timezone:
12
+
13
+ ```sh
14
+ fm log --project Flowmind --hours 1.5 --started-at 2026-10-02T08:30:00+02:00 --outcome "Shipped the reader"
15
+ ```
16
+
17
+ Future session ends are rejected before contacting the API. The API enforces
18
+ the seven-day logging window in your stored timezone. `--started-at` applies to
19
+ structured project/hours logging. Natural language logging uses its reviewed
20
+ AI confirmation time. Run `fm log --help` for all options.
21
+
22
+ ## Stage an agent proof
23
+
24
+ Claude Code can stage completed work for explicit human approval:
25
+
26
+ ```sh
27
+ fm agent stage --project <project-id> --minutes 45 \
28
+ --intention "Finish the reader" --outcome "Shipped the reader" \
29
+ --started-at 2026-10-02T08:30:00+02:00 --source-kind claude_code \
30
+ --artifact-url https://example.com/proof --session-id <stable-session-id> --json
31
+ ```
32
+
33
+ Source kinds: `calendar`, `claude_code`, `cli`, `codex`, `github`, `linear`,
34
+ `manual`, `session_log`, `other`. `claude` is not an alias. Use `--source-label`
35
+ to override the Claude Code display label. Run `fm agent stage --help` for all options.
36
+ Staging adds no hours; approve in Activity individually or confirm **Approve all with links (N)**.
37
+
38
+ ## Momentum brief
39
+
40
+ ```sh
41
+ fm momentum
42
+ fm momentum --week 2026-10-12
43
+ fm momentum --json
44
+ ```
45
+
46
+ See eight weeks of outcomes, personal and agent hours, project trends, and signals
47
+ with source outcomes. Brackets mark the selected week; each sparkline uses its own
48
+ peak. Quiet projects show the age of their last outcome. Commitment ideas are
49
+ suggestions only and save nothing.
50
+
51
+ `--week` requires `YYYY-MM-DD`. The API checks that it is a Monday and is not in
52
+ the future. Without it, the API selects your current personal week.
53
+ `--json` prints only the response data as pretty JSON. Errors go to stderr and
54
+ exit with status 1. Colors require a terminal and an unset `NO_COLOR` variable.
55
+
56
+ ## Response failures
57
+
58
+ [`src/api.ts`](src/api.ts) exposes `apiRequest(descriptor, args, options)` through the shared response decoder.
59
+ [`src/contracts.ts`](src/contracts.ts) binds command workflows to generated descriptors and `@flowmind/contracts/wire` types.
60
+ Every API request validates the media type, envelope, status agreement, and response schema.
61
+ See the [contract generation flow](../../docs/reference/codebase/ARCHITECTURE.md#api-contract-generation-and-decoding) and [endpoint procedure](../../docs/reference/codebase/CONVENTIONS.md#add-or-change-an-endpoint).
62
+ Do not cast response data, write payload parsers, or add generic request helpers.
63
+ Commands exit with status 1 when transport, JSON, media type, envelope, or payload checks fail.
64
+ A valid API rejection also exits with status 1.
65
+ One diagnostic names the action, operation, schema location, and request ID when available.
66
+ Diagnostics omit response values, credentials, query values, and server messages.
67
+
68
+ A write with a transport failure, timeout, or contract failure is not confirmed.
69
+ The client never retries it. Check Activity before submitting it again.
70
+ Natural logging no longer offers a retry prompt after an uncertain save.
71
+ Authentication stops immediately on a failed poll. Pending authorization continues polling.
72
+ Expired authorization exits with status 1. No failed authorization saves a credential.
73
+ Use `fm auth login --no-browser` to open the printed authorization URL yourself.
74
+
75
+ ## Verify the CLI
76
+
77
+ Run `pnpm --filter @flowmind/cli test` from the repository root.
78
+ This builds the CLI, runs command tests against loopback HTTP fixtures, and tests an installed package.
79
+ The package check uses `npm pack` and a local npm install into a temporary prefix.
80
+ A loopback package fixture serves the runtime dependencies already installed in this workspace.
81
+ The install uses an empty npm cache and never contacts a public registry.
82
+ Installed commands run outside the repository.
83
+
84
+ Reports are saved under `tools/cli/test-results/`:
85
+
86
+ - `response-contracts-packed.json`: installed command inputs, build hash, results, and request counts.
87
+ - `pack-install.txt`: package installation and hook lifecycle results.
88
+
89
+ The response matrix also checks credential persistence, diagnostic redaction, and write counts.
90
+ Fixtures are synthetic. These tests do not prove production API availability.
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: flowmind
3
+ description: "Use the fm CLI or Flowmind API to log user-requested time, stage completed agent work for review, or inspect Flowmind projects and progress. Skip generic time tracking or project questions that do not request Flowmind data."
4
+ homepage: https://www.flowmind.pro/
5
+ metadata: { "openclaw": { "emoji": "⏱️" } }
6
+ ---
7
+
8
+ # Flowmind Skill
9
+
10
+ Use Flowmind to quickly log work sessions, track streaks/XP, and review weekly progress.
11
+
12
+ ## When to Use
13
+
14
+ ✅ **USE this skill when the user asks to:**
15
+
16
+ - Log time or add a time entry
17
+ - Track time against a project
18
+ - Check streak, XP, or level
19
+ - Get a weekly hours/progress summary
20
+ - List available projects before logging
21
+
22
+ Typical trigger phrases:
23
+
24
+ - "log 2 hours on my project"
25
+ - "add a time entry"
26
+ - "how's my streak"
27
+ - "what did I work on this week"
28
+
29
+ ## When NOT to Use
30
+
31
+ ❌ **DON'T use this skill for:**
32
+
33
+ - Calendar scheduling (use calendar tools)
34
+ - Payroll/accounting reports unless user explicitly wants Flowmind data only
35
+ - Generic project management tasks not related to time logging or Flowmind progress
36
+
37
+ ## Setup
38
+
39
+ ### 1) Install the CLI
40
+
41
+ ```bash
42
+ npm install -g @flowmind/cli
43
+ ```
44
+
45
+ ### 2) Authenticate
46
+
47
+ ```bash
48
+ fm auth login
49
+ ```
50
+
51
+ ### 3) Install agent skills
52
+
53
+ ```bash
54
+ fm hooks install
55
+ ```
56
+
57
+ This installs the same staging instructions for Codex and Claude Code. Check them with:
58
+
59
+ ```bash
60
+ fm hooks status
61
+ ```
62
+
63
+ <!-- Codex personal skills: https://learn.chatgpt.com/docs/build-skills -->
64
+ <!-- Claude Code personal skills: https://code.claude.com/docs/en/skills -->
65
+ Codex reads `~/.agents/skills/flowmind/SKILL.md`; Claude Code reads `~/.claude/skills/flowmind/SKILL.md`. An older Codex copy at `~/.codex/skills/flowmind/SKILL.md` is reported by `fm hooks status` but never changed by install or uninstall.
66
+
67
+ ## Core Commands
68
+
69
+ ### Log time (preferred: natural language)
70
+
71
+ ```bash
72
+ fm log "2h working on the backend API"
73
+ ```
74
+
75
+ The command shows the original input and lets you correct project, whole minutes and outcome. Choose the work date explicitly, then confirm the final preview. Only today in your saved timezone is eligible. Parsing never writes; saving sends the reviewed fields to `/v1/ai/log/confirm` without another model call. If the save response is lost, retry from the same prompt to reuse its idempotency key. After leaving an uncertain save, check Activity before starting a new capture.
76
+
77
+
78
+ ### Log time (structured)
79
+
80
+ ```bash
81
+ fm log -p "ProjectName" -h 2 -i "Ship the API slice" -o "Implemented and validated the API slice" -a <optional-artifact-url>
82
+ ```
83
+
84
+ ### Check progress/streak
85
+
86
+ ```bash
87
+ fm status
88
+ ```
89
+
90
+ ### Weekly summary
91
+
92
+ ```bash
93
+ fm stats
94
+ ```
95
+
96
+ ### List projects
97
+
98
+ ```bash
99
+ fm projects
100
+ ```
101
+
102
+ ### Agent Toolkit V2 (automatic staged proof)
103
+
104
+ ```bash
105
+ fm agent capabilities
106
+ fm agent projects
107
+ fm agent routines
108
+ fm agent stage --project <project-id> --minutes 120 --intention "Ship the API slice" --outcome "Implemented and validated the API slice" --artifact-url <optional-url> --session-evidence "API slice completed and tested" --session-id <thread-or-run-id> --started-at <iso-date-time> --json
109
+ fm agent proposals
110
+ fm agent cancel <proposal-id> --idempotency-key <stable-key>
111
+ ```
112
+
113
+ ## Agent Behavior Guidelines
114
+
115
+ - After completing a material project work session, automatically stage one proof when `fm agent capabilities` reports `flowmind-agent-toolkit-v2` and includes `log_proposals:create`.
116
+ - Staging does not mutate the Hour Bank, so do not interrupt the user for confirmation before staging. Share the returned review URL.
117
+ - Stage only when project, actual elapsed minutes, session start, intention, and outcome are known. Do not invent missing values or infer duration from token/tool usage.
118
+ - Use one stable session/run/thread id per completed work unit. The CLI derives the retry key when both `--session-id` and `--started-at` are present.
119
+ - Never stage routine or unassigned work through the project proof command.
120
+ - Use direct `fm log` only when the current user request or standing preference explicitly authorizes the complete entry and the current account/API permits that write. Reuse that authorization; clarify missing or ambiguous fields instead of asking twice. Agent-originated staged proofs still require human approval in Flowmind Activity; never bypass that product boundary or substitute a direct write.
121
+ - If automatic staging fails, report the failure. Never fall back to a direct ledger write.
122
+ - After logging, confirm success and include **XP earned** when available.
123
+ - If the logged session is a flow session (≥ 90 minutes), mention that the deep-work bonus applies only to time beyond the first 90 minutes.
124
+
125
+ ## Agent Toolkit V2 Status
126
+
127
+ Flowmind Agent Toolkit V2 is defined in `docs/specs/2026-08-31-flowmind-agent-proof-staging-v2.md`. Scoped API-key storage exists for `read_only`, `log_only`, and `full_personal`. Backend staged proof routes and matching `fm agent` commands exist for:
128
+
129
+ - capability discovery
130
+ - agent-visible project/routine context
131
+ - canonical project-proof creation with intention, outcome, and optional artifact
132
+ - proposal listing
133
+ - proposal cancellation
134
+ - session-log provenance and automatically derived retry identity
135
+ - machine-readable stage output for agent hooks
136
+
137
+ Agents should first call `fm agent capabilities`. If it reports `flowmind-agent-toolkit-v2` and includes `log_proposals:create`, use staged proofs for completed agent-originated project work. Proposal approval is intentionally not an API-key CLI command; a human approves staged proofs in Flowmind Activity.
138
+
139
+ For coding/session work, pass a short `--session-evidence` summary, stable `--session-id`, actual `--started-at`, and optional `--session-url`. Pass a canonical artifact through `--artifact-url`. Do not store raw terminal logs, transcript text, commit messages, issue titles, calendar titles, emails, or other sensitive raw source text as evidence.
140
+
141
+ Agent-specific parse, proof-status, and weekly-summary commands are not shipped yet. If staging is unavailable, report that limitation. A separate, fully specified user request may authorize a supported direct entry; missing staging capability never authorizes an agent-originated ledger write.
142
+
143
+ ### Missing entry details
144
+
145
+ Ask only for the fields needed to make the requested entry unambiguous, such as the project, duration, intention, or outcome. Preserve the CLI preview when natural-language parsing still requires review.
146
+
147
+ ## Direct API Fallback (No CLI)
148
+
149
+ If `fm` is unavailable, use the Flowmind API directly.
150
+
151
+ - Default local base URL: `http://localhost:8080`
152
+ - Auth header: `Authorization: Bearer $FLOWMIND_API_KEY`
153
+ - If a different environment is configured, use that base URL instead.
154
+
155
+ ```bash
156
+ curl -X POST http://localhost:8080/v1/agent/log-proposals \
157
+ -H "Authorization: Bearer $FLOWMIND_API_KEY" \
158
+ -H "Idempotency-Key: <stable-session-key>" \
159
+ -H "Content-Type: application/json" \
160
+ -d '{"targetKind":"project","projectId":"...","startedAt":"2026-08-31T10:00:00Z","durationMinutes":120,"description":"Ship the API slice","note":"Implemented and validated the API slice","artifactUrl":"https://github.com/example/repo/pull/42","source":{"kind":"session_log","label":"Agent session","externalId":"session-or-thread-id"},"evidence":[{"kind":"session_log","label":"API slice completed and tested","externalId":"session-or-thread-id","url":null}]}'
161
+ ```
162
+
163
+ ## Practical Workflow
164
+
165
+ 1. Run `fm agent capabilities` once per environment or after an integration error.
166
+ 2. If V2 staged proofs are available and `log_proposals:create` is present, run `fm agent projects` to resolve the project id.
167
+ 3. At the end of a material completed work unit, stage it with canonical proof fields, actual timing, `--session-id`, and `--json`.
168
+ 4. Share the proposal review URL with the user for approval.
169
+ 5. If staged proofs are unavailable, report the limitation. For a separately authorized direct entry, resolve its complete fields and use the supported `fm log ...` path without a redundant confirmation.