@flowmind/cli 0.1.0 → 0.2.1

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,5 +1,44 @@
1
1
  # Flowmind CLI
2
2
 
3
+ The package installs two equal commands, `flowmind` and `fm`. On macOS, `/usr/bin/fm` can be
4
+ Apple's Foundation Models tool, so agents and hooks call `flowmind`.
5
+
6
+ ## Set up coding agents
7
+
8
+ ```sh
9
+ npm install -g @flowmind/cli
10
+ flowmind auth login
11
+ flowmind hooks install
12
+ ```
13
+
14
+ `hooks install` copies the Flowmind skill to Codex and Claude Code and adds session hooks to
15
+ `~/.codex/hooks.json` and `~/.claude/settings.json`. Other hooks in those files stay as they are.
16
+ The hooks run `agent hook` through the absolute paths of the installing Node binary and CLI file,
17
+ because hooks start without your shell profile and a version manager may not put `node` on PATH.
18
+ Codex on Windows gets a PowerShell command (`& '<node>' '<cli>' agent hook --agent codex`).
19
+ After you upgrade Node or move the CLI, `hooks status` shows `outdated`; run `hooks install` again
20
+ and trust the changed hooks. The hook records each agent turn under the CLI config folder.
21
+ In a linked repository, the session-start hook tells the agent which project it works on.
22
+ Codex runs new hooks only after you trust them once in `/hooks`. `hooks status` shows both installs,
23
+ and `hooks uninstall` removes only the Flowmind entries.
24
+
25
+ Then ask your agent to "set up Flowmind". The skill has it inventory your repositories, propose
26
+ projects, and create and link them after you approve the list.
27
+
28
+ ## Projects and repository links
29
+
30
+ ```sh
31
+ flowmind projects --json
32
+ flowmind projects add "Bead Focus" --description "Focus timer for iOS" --json
33
+ flowmind link "Bead Focus" # writes .flowmind.json at the repository root
34
+ flowmind link <project-id> --dir ~/projects/bead-focus
35
+ flowmind link # shows the current link
36
+ ```
37
+
38
+ A link names the project by id and keeps its name as a label. `link` accepts an id or an exact
39
+ project name and checks it against the projects visible to agents. Commit `.flowmind.json` to share
40
+ the link with other machines and agents.
41
+
3
42
  Log completed work by project name and duration:
4
43
 
5
44
  ```sh
@@ -21,7 +60,21 @@ AI confirmation time. Run `fm log --help` for all options.
21
60
 
22
61
  ## Stage an agent proof
23
62
 
24
- Claude Code can stage completed work for explicit human approval:
63
+ Agents stage completed work for explicit human approval. In a linked repository with the session
64
+ hooks installed, the intention and outcome are enough:
65
+
66
+ ```sh
67
+ flowmind agent stage --intention "Finish the reader" --outcome "Shipped the reader" \
68
+ --artifact-url https://example.com/proof --json
69
+ ```
70
+
71
+ The CLI reads the project from `.flowmind.json` and the session from `CODEX_THREAD_ID` or the one
72
+ session with a turn in progress in the repository. The duration is the recorded agent turn time
73
+ since the session's last staged proof; idle time between turns does not count. Fewer than one
74
+ recorded minute is an error. The source kind is `codex` or `claude_code` from the recording host.
75
+ `--dry-run` prints the request and its retry key without staging anything.
76
+
77
+ Without hooks, pass observed values:
25
78
 
26
79
  ```sh
27
80
  fm agent stage --project <project-id> --minutes 45 \
@@ -35,6 +88,10 @@ Source kinds: `calendar`, `claude_code`, `cli`, `codex`, `github`, `linear`,
35
88
  to override the Claude Code display label. Run `fm agent stage --help` for all options.
36
89
  Staging adds no hours; approve in Activity individually or confirm **Approve all with links (N)**.
37
90
 
91
+ The retry key derives from the session id, project id, and start time, so each work unit in a
92
+ session gets its own key. `agent capabilities`, `agent projects`, `agent routines`, `agent proposals`,
93
+ and `agent cancel` accept `--json`. `auth status` shows the API URL and accepts `--json`.
94
+
38
95
  ## Momentum brief
39
96
 
40
97
  ```sh
@@ -53,6 +110,33 @@ the future. Without it, the API selects your current personal week.
53
110
  `--json` prints only the response data as pretty JSON. Errors go to stderr and
54
111
  exit with status 1. Colors require a terminal and an unset `NO_COLOR` variable.
55
112
 
113
+ ## Project ship log
114
+
115
+ ```sh
116
+ fm ship-log "My Project"
117
+ fm ship-log <project-id> --json
118
+ ```
119
+
120
+ Use a project id or an exact project name, ignoring case. Duplicate names require
121
+ an id; unknown names list the available projects. Both errors exit with status 1.
122
+ Archived projects remain available.
123
+
124
+ The text view shows publication status, public title and summary, and the API's
125
+ public, new, and changed counts. Existing publications include page, card, and
126
+ Atom feed links, plus README badge Markdown. Unpublished links remain listed,
127
+ but public readers receive 404 until the log has published outcomes.
128
+
129
+ Public counts include only selected outcomes that still match their saved digest.
130
+ Changed counts include edited selections and eligible corrections of selected outcomes.
131
+ New counts include other eligible, unselected outcomes created after the last save.
132
+ New is zero before the first publication. Saving clears new counts for omitted outcomes.
133
+ When new or changed outcomes exist, the command points you to review in the web app.
134
+
135
+ This command is read-only. A project id accepts a `read_only` API key; resolving
136
+ a name uses the existing project list, which requires `full_personal`. Publish,
137
+ update, or unpublish in the web app. `--json` prints the API data unchanged as pretty JSON.
138
+ Errors go to stderr and exit with status 1.
139
+
56
140
  ## Response failures
57
141
 
58
142
  [`src/api.ts`](src/api.ts) exposes `apiRequest(descriptor, args, options)` through the shared response decoder.
@@ -1,169 +1,69 @@
1
1
  ---
2
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."
3
+ description: "Set up Flowmind for a builder's coding agents and log agent work to it with the flowmind CLI. Use when the user asks to set up, connect, or onboard Flowmind; to create or link Flowmind projects; to log or stage work in Flowmind; to check Flowmind progress; or when you finish material work in a repository that has a .flowmind.json file. Skip generic time tracking that does not involve Flowmind."
4
4
  homepage: https://www.flowmind.pro/
5
5
  metadata: { "openclaw": { "emoji": "⏱️" } }
6
6
  ---
7
7
 
8
- # Flowmind Skill
8
+ # Flowmind
9
9
 
10
- Use Flowmind to quickly log work sessions, track streaks/XP, and review weekly progress.
10
+ Flowmind records what a builder ships, including work their agents do. Agents use the `flowmind` CLI. It is also installed as `fm`, but on macOS `fm` can be Apple's Foundation Models tool, so always call `flowmind`.
11
11
 
12
- ## When to Use
12
+ ## Set up Flowmind
13
13
 
14
- ✅ **USE this skill when the user asks to:**
14
+ Use this when the user says "set up Flowmind", "connect my projects to Flowmind", or similar.
15
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
16
+ 1. Check the CLI with `flowmind --version`. If it is missing or older than 0.2.0, run `npm install -g @flowmind/cli`.
17
+ 2. Check sign-in with `flowmind auth status --json`. If `authenticated` is false, run `flowmind auth login --no-browser`, give the user the printed URL, and keep the command running while it waits (up to 5 minutes). The user approves in the browser.
18
+ 3. Install the skill and session hooks with `flowmind hooks install`. Tell the user that Codex runs new hooks only after they trust them once in `/hooks`. Claude Code runs them at its next session.
19
+ 4. Inventory the user's local work:
20
+ - Find git repositories in the folders the user works in (for example `~/projects`, `~/code`, `~/src`, and the workspaces your host lists). Read each README or package manifest only far enough to name and describe the project.
21
+ - Read existing Flowmind projects with `flowmind projects --json`.
22
+ - Read existing links with `flowmind link --dir <repo> --json`.
23
+ 5. Propose a table: repository path, Flowmind project name, one-line description, and action (create, link to an existing project, or skip). Put repositories of one product under one project. Ask the user to approve or edit the list. Create nothing before they approve.
24
+ 6. After approval, for each row:
25
+ - Create: `flowmind projects add "<name>" --description "<one line>" --json`. The new id is `project.id`.
26
+ - Link: `flowmind link <project-id> --dir <repo> --json`. This writes `.flowmind.json` at the repository root.
27
+ - Ask whether to commit `.flowmind.json`. A committed link reaches the user's other machines and agents.
28
+ 7. Report what you created and linked, and explain how agent work gets logged from now on.
21
29
 
22
- Typical trigger phrases:
30
+ ## Log agent work
23
31
 
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
32
+ In a linked repository, the session hooks record how long each agent turn runs. When you finish a material unit of work, such as a feature, fix, investigation, or document, stage it. Do not stage every turn.
85
33
 
86
34
  ```bash
87
- fm status
35
+ flowmind agent stage --intention "<what you set out to do>" --outcome "<what changed or shipped>" --artifact-url <commit, PR, or document URL> --json
88
36
  ```
89
37
 
90
- ### Weekly summary
38
+ - The CLI reads the project from `.flowmind.json` and the time from the session record. A second stage in the same session covers only the time after the first.
39
+ - Add `--dry-run` to preview the project and minutes without staging.
40
+ - Pass `--project`, `--minutes`, and `--started-at` only when no session record exists. Use observed times only. Never estimate time from tokens or tool calls.
41
+ - Write the intention and the outcome as one short sentence each. Never paste transcripts, terminal output, commit messages, issue titles, emails, or secrets.
42
+ - Share `proposal.webReviewUrl` with the user. The user approves staged work in Flowmind Activity; **Approve all with links** approves every item with an artifact link at once. Approved agent time counts on the project, not as the user's personal effort or XP.
43
+ - If staging fails, report the error. Never fall back to `flowmind log`, and never approve your own proposals.
91
44
 
92
- ```bash
93
- fm stats
94
- ```
95
-
96
- ### List projects
97
-
98
- ```bash
99
- fm projects
100
- ```
45
+ ## Log the user's own work
101
46
 
102
- ### Agent Toolkit V2 (automatic staged proof)
47
+ Use `flowmind log` only when the user asks you to log work that they did themselves:
103
48
 
104
49
  ```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>
50
+ flowmind log -p "<project>" -h <hours> -i "<intention>" -o "<outcome>" [--started-at <ISO date-time>] [-a <artifact URL>]
111
51
  ```
112
52
 
113
- ## Agent Behavior Guidelines
53
+ Ask only for missing fields. A natural-language entry (`flowmind log "2h on the API"`) needs the user at the terminal to review it.
114
54
 
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.
55
+ ## Read progress
124
56
 
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
- ```
57
+ - `flowmind status` and `flowmind stats`: hours, streak, and level.
58
+ - `flowmind momentum --json`: eight weeks of outcomes, personal and agent hours, and project trends.
59
+ - `flowmind ship-log <project> --json`: a project's public ship log.
60
+ - `flowmind agent proposals --status proposed --json`: staged work that waits for approval.
162
61
 
163
- ## Practical Workflow
62
+ ## Troubleshooting
164
63
 
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.
64
+ - `flowmind auth status` shows the API URL. A normal install uses `https://api.flowmind.pro`.
65
+ - `flowmind hooks status` shows whether the skill and hooks are installed for Codex and Claude Code.
66
+ - `outdated` hooks: run `flowmind hooks install` again (for example after a Node upgrade) and trust the changed hooks.
67
+ - "No recorded agent time": the hooks are missing or not trusted, or the session started before installation. Stage with observed `--minutes` and `--started-at`, or stage in the next session.
68
+ - "Several agent sessions have a turn in progress": pass `--session-id`.
69
+ - "No project given": run `flowmind link <project>` in the repository, or pass `--project`.