@flowmind/cli 0.0.0-stage → 0.2.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,170 @@
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
+ 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 `flowmind agent hook`, which records each agent turn under the CLI config folder.
17
+ In a linked repository, the session-start hook tells the agent which project it works on.
18
+ Codex runs new hooks only after you trust them once in `/hooks`. `hooks status` shows both installs,
19
+ and `hooks uninstall` removes only the Flowmind entries.
20
+
21
+ Then ask your agent to "set up Flowmind". The skill has it inventory your repositories, propose
22
+ projects, and create and link them after you approve the list.
23
+
24
+ ## Projects and repository links
25
+
26
+ ```sh
27
+ flowmind projects --json
28
+ flowmind projects add "Bead Focus" --description "Focus timer for iOS" --json
29
+ flowmind link "Bead Focus" # writes .flowmind.json at the repository root
30
+ flowmind link <project-id> --dir ~/projects/bead-focus
31
+ flowmind link # shows the current link
32
+ ```
33
+
34
+ A link names the project by id and keeps its name as a label. `link` accepts an id or an exact
35
+ project name and checks it against the projects visible to agents. Commit `.flowmind.json` to share
36
+ the link with other machines and agents.
37
+
38
+ Log completed work by project name and duration:
39
+
40
+ ```sh
41
+ fm log --project Flowmind --hours 1.5 --outcome "Shipped the reader"
42
+ ```
43
+
44
+ Without a start time, the session ends when saved: 90 minutes saved at 10:00
45
+ records 08:30–10:00. To supply the actual start, use an ISO 8601 timestamp with
46
+ a timezone:
47
+
48
+ ```sh
49
+ fm log --project Flowmind --hours 1.5 --started-at 2026-10-02T08:30:00+02:00 --outcome "Shipped the reader"
50
+ ```
51
+
52
+ Future session ends are rejected before contacting the API. The API enforces
53
+ the seven-day logging window in your stored timezone. `--started-at` applies to
54
+ structured project/hours logging. Natural language logging uses its reviewed
55
+ AI confirmation time. Run `fm log --help` for all options.
56
+
57
+ ## Stage an agent proof
58
+
59
+ Agents stage completed work for explicit human approval. In a linked repository with the session
60
+ hooks installed, the intention and outcome are enough:
61
+
62
+ ```sh
63
+ flowmind agent stage --intention "Finish the reader" --outcome "Shipped the reader" \
64
+ --artifact-url https://example.com/proof --json
65
+ ```
66
+
67
+ The CLI reads the project from `.flowmind.json` and the session from `CODEX_THREAD_ID` or the one
68
+ session with a turn in progress in the repository. The duration is the recorded agent turn time
69
+ since the session's last staged proof; idle time between turns does not count. Fewer than one
70
+ recorded minute is an error. The source kind is `codex` or `claude_code` from the recording host.
71
+ `--dry-run` prints the request and its retry key without staging anything.
72
+
73
+ Without hooks, pass observed values:
74
+
75
+ ```sh
76
+ fm agent stage --project <project-id> --minutes 45 \
77
+ --intention "Finish the reader" --outcome "Shipped the reader" \
78
+ --started-at 2026-10-02T08:30:00+02:00 --source-kind claude_code \
79
+ --artifact-url https://example.com/proof --session-id <stable-session-id> --json
80
+ ```
81
+
82
+ Source kinds: `calendar`, `claude_code`, `cli`, `codex`, `github`, `linear`,
83
+ `manual`, `session_log`, `other`. `claude` is not an alias. Use `--source-label`
84
+ to override the Claude Code display label. Run `fm agent stage --help` for all options.
85
+ Staging adds no hours; approve in Activity individually or confirm **Approve all with links (N)**.
86
+
87
+ The retry key derives from the session id, project id, and start time, so each work unit in a
88
+ session gets its own key. `agent capabilities`, `agent projects`, `agent routines`, `agent proposals`,
89
+ and `agent cancel` accept `--json`. `auth status` shows the API URL and accepts `--json`.
90
+
91
+ ## Momentum brief
92
+
93
+ ```sh
94
+ fm momentum
95
+ fm momentum --week 2026-10-12
96
+ fm momentum --json
97
+ ```
98
+
99
+ See eight weeks of outcomes, personal and agent hours, project trends, and signals
100
+ with source outcomes. Brackets mark the selected week; each sparkline uses its own
101
+ peak. Quiet projects show the age of their last outcome. Commitment ideas are
102
+ suggestions only and save nothing.
103
+
104
+ `--week` requires `YYYY-MM-DD`. The API checks that it is a Monday and is not in
105
+ the future. Without it, the API selects your current personal week.
106
+ `--json` prints only the response data as pretty JSON. Errors go to stderr and
107
+ exit with status 1. Colors require a terminal and an unset `NO_COLOR` variable.
108
+
109
+ ## Project ship log
110
+
111
+ ```sh
112
+ fm ship-log "My Project"
113
+ fm ship-log <project-id> --json
114
+ ```
115
+
116
+ Use a project id or an exact project name, ignoring case. Duplicate names require
117
+ an id; unknown names list the available projects. Both errors exit with status 1.
118
+ Archived projects remain available.
119
+
120
+ The text view shows publication status, public title and summary, and the API's
121
+ public, new, and changed counts. Existing publications include page, card, and
122
+ Atom feed links, plus README badge Markdown. Unpublished links remain listed,
123
+ but public readers receive 404 until the log has published outcomes.
124
+
125
+ Public counts include only selected outcomes that still match their saved digest.
126
+ Changed counts include edited selections and eligible corrections of selected outcomes.
127
+ New counts include other eligible, unselected outcomes created after the last save.
128
+ New is zero before the first publication. Saving clears new counts for omitted outcomes.
129
+ When new or changed outcomes exist, the command points you to review in the web app.
130
+
131
+ This command is read-only. A project id accepts a `read_only` API key; resolving
132
+ a name uses the existing project list, which requires `full_personal`. Publish,
133
+ update, or unpublish in the web app. `--json` prints the API data unchanged as pretty JSON.
134
+ Errors go to stderr and exit with status 1.
135
+
136
+ ## Response failures
137
+
138
+ [`src/api.ts`](src/api.ts) exposes `apiRequest(descriptor, args, options)` through the shared response decoder.
139
+ [`src/contracts.ts`](src/contracts.ts) binds command workflows to generated descriptors and `@flowmind/contracts/wire` types.
140
+ Every API request validates the media type, envelope, status agreement, and response schema.
141
+ 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).
142
+ Do not cast response data, write payload parsers, or add generic request helpers.
143
+ Commands exit with status 1 when transport, JSON, media type, envelope, or payload checks fail.
144
+ A valid API rejection also exits with status 1.
145
+ One diagnostic names the action, operation, schema location, and request ID when available.
146
+ Diagnostics omit response values, credentials, query values, and server messages.
147
+
148
+ A write with a transport failure, timeout, or contract failure is not confirmed.
149
+ The client never retries it. Check Activity before submitting it again.
150
+ Natural logging no longer offers a retry prompt after an uncertain save.
151
+ Authentication stops immediately on a failed poll. Pending authorization continues polling.
152
+ Expired authorization exits with status 1. No failed authorization saves a credential.
153
+ Use `fm auth login --no-browser` to open the printed authorization URL yourself.
154
+
155
+ ## Verify the CLI
156
+
157
+ Run `pnpm --filter @flowmind/cli test` from the repository root.
158
+ This builds the CLI, runs command tests against loopback HTTP fixtures, and tests an installed package.
159
+ The package check uses `npm pack` and a local npm install into a temporary prefix.
160
+ A loopback package fixture serves the runtime dependencies already installed in this workspace.
161
+ The install uses an empty npm cache and never contacts a public registry.
162
+ Installed commands run outside the repository.
163
+
164
+ Reports are saved under `tools/cli/test-results/`:
165
+
166
+ - `response-contracts-packed.json`: installed command inputs, build hash, results, and request counts.
167
+ - `pack-install.txt`: package installation and hook lifecycle results.
168
+
169
+ The response matrix also checks credential persistence, diagnostic redaction, and write counts.
170
+ Fixtures are synthetic. These tests do not prove production API availability.
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: flowmind
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
+ homepage: https://www.flowmind.pro/
5
+ metadata: { "openclaw": { "emoji": "⏱️" } }
6
+ ---
7
+
8
+ # Flowmind
9
+
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
+
12
+ ## Set up Flowmind
13
+
14
+ Use this when the user says "set up Flowmind", "connect my projects to Flowmind", or similar.
15
+
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.
29
+
30
+ ## Log agent work
31
+
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.
33
+
34
+ ```bash
35
+ flowmind agent stage --intention "<what you set out to do>" --outcome "<what changed or shipped>" --artifact-url <commit, PR, or document URL> --json
36
+ ```
37
+
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.
44
+
45
+ ## Log the user's own work
46
+
47
+ Use `flowmind log` only when the user asks you to log work that they did themselves:
48
+
49
+ ```bash
50
+ flowmind log -p "<project>" -h <hours> -i "<intention>" -o "<outcome>" [--started-at <ISO date-time>] [-a <artifact URL>]
51
+ ```
52
+
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.
54
+
55
+ ## Read progress
56
+
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.
61
+
62
+ ## Troubleshooting
63
+
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
+ - "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.
67
+ - "Several agent sessions have a turn in progress": pass `--session-id`.
68
+ - "No project given": run `flowmind link <project>` in the repository, or pass `--project`.