@h1veframework/cli 0.12.1 → 0.13.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.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +81 -81
  3. package/dist/index.js +64 -3
  4. package/package.json +61 -61
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 H1VE Framework
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 H1VE Framework
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,81 +1,81 @@
1
- # @h1veframework/cli · `h1ve`
2
-
3
- **The command-line companion for [H1VE](https://h1ve.org) — the governance & memory layer for teams building with AI.**
4
-
5
- Your team ships with AI (Claude Code, Cursor, Copilot). As the codebase grows, the AI and your teammates start
6
- **losing context and drifting from decisions you already made**. H1VE keeps every feature aligned — a shared,
7
- **eternal project memory** plus an **anti-drift engine** that checks each change against what's been decided.
8
- `h1ve` drives that workflow straight from your terminal.
9
-
10
- Part of the H1VE toolchain, alongside the **[MCP server](https://www.npmjs.com/package/@h1veframework/mcp)** for
11
- Claude Code / Cursor.
12
-
13
- → **[h1ve.org](https://h1ve.org)** · **[app.h1ve.org](https://app.h1ve.org)**
14
-
15
- ## Quickstart (zero paste)
16
-
17
- ```bash
18
- npm i -g @h1veframework/cli
19
- h1ve login # opens your browser → you click Authorize → done
20
- h1ve status # state of the current branch's feature
21
- ```
22
-
23
- `h1ve login` stores the credential locally (`~/.config/h1ve/credentials.json`, `600`) — the MCP server reads the
24
- same one, so **one login sets up both**. The project **auto-resolves from your git remote**, so there's nothing
25
- to paste and no `H1VE_PROJECT_ID` to set. `h1ve logout` removes it.
26
-
27
- > The legacy `nf` command still works as an alias — every `h1ve <cmd>` below can be run as `nf <cmd>`.
28
-
29
- > `h1ve health` saying "no snapshots yet" is **success** (you're connected; the project just has no metrics yet).
30
-
31
- ## Commands
32
-
33
- | Command | What it does |
34
- |---|---|
35
- | `h1ve login` / `h1ve logout` | Authorize in the browser and store the credential locally / remove it |
36
- | `h1ve status` | State of the current branch's feature (stage, days active, blockers, sign-offs) |
37
- | `h1ve start [<#\|id>] [--slug <s>]` | Start an assigned feature: create the `feat/{you}/{slug}` branch and record the slug |
38
- | `h1ve spec` | Print the feature's spec (markdown) |
39
- | `h1ve move <stage> [--note]` | Move the feature to another stage |
40
- | `h1ve done [--from <file>] [--no-move]` | Submit the AI declaration (JSON) and move `dev → pr` |
41
- | `h1ve blocker "<desc>"` | Open a blocker on the feature (you become its owner) |
42
- | `h1ve health` | Latest technical-health snapshots for the project |
43
- | `h1ve connect --kind <k> --label <l> --env KEY=VAL` | Write a credential to your **local** `.env.local` and register the inventory (never sent to the server) |
44
- | `h1ve serve [--port 7391]` | Run the local agent (`127.0.0.1`) so the dashboard can apply credentials from the browser |
45
-
46
- Flags: `--json` (raw output for scripts) · `--project <name\|id>` (if you belong to more than one project) · `-h`.
47
-
48
- ## Example
49
-
50
- ```bash
51
- h1ve start # start your assigned feature (creates the branch)
52
- # ... work: git, code, commits ...
53
- h1ve status # check state anytime
54
- h1ve blocker "waiting on the Neon credential" # blocked? open a blocker
55
- h1ve done --from ai-declaration.json # submit the AI declaration + move dev → pr
56
- ```
57
-
58
- ## CI / headless (env vars)
59
-
60
- No browser? Configure by env (takes **precedence** over `h1ve login`):
61
-
62
- ```bash
63
- export H1VE_API_URL="https://app.h1ve.org" # optional (this is the default)
64
- export H1VE_API_KEY="nf_pat_..." # a PAT from app.h1ve.org/api-tokens
65
- # export H1VE_PROJECT_ID="..." # OPTIONAL — the CLI resolves the project from the repo
66
- ```
67
-
68
- ## Troubleshooting
69
-
70
- | Symptom | Fix |
71
- |---|---|
72
- | `h1ve: command not found` | Node missing or wrong terminal. Check `node --version`. On Windows, reopen the shell or use the VS Code terminal. |
73
- | `404` on install | npm propagation right after a publish — wait a few minutes. |
74
- | `NO_PROJECT` | You belong to more than one project — pass `--project <name\|id>`. |
75
- | `401` / `403` | Wrong/missing token. Make sure `H1VE_API_KEY` is a PAT (`nf_pat_…`). `403 SERVICE_CANNOT_WRITE` = a read-only service key used on a write → use a PAT. |
76
-
77
- Requires **Node.js 18.18+**. The legacy `nf` command and env names `NEXUS_FLOW_API_URL` / `NEXUS_FLOW_API_KEY` are still accepted.
78
-
79
- ---
80
-
81
- MIT · built with H1VE, by [H1VE](https://h1ve.org) 🐝
1
+ # @h1veframework/cli · `h1ve`
2
+
3
+ **The command-line companion for [H1VE](https://h1ve.org) — the governance & memory layer for teams building with AI.**
4
+
5
+ Your team ships with AI (Claude Code, Cursor, Copilot). As the codebase grows, the AI and your teammates start
6
+ **losing context and drifting from decisions you already made**. H1VE keeps every feature aligned — a shared,
7
+ **eternal project memory** plus an **anti-drift engine** that checks each change against what's been decided.
8
+ `h1ve` drives that workflow straight from your terminal.
9
+
10
+ Part of the H1VE toolchain, alongside the **[MCP server](https://www.npmjs.com/package/@h1veframework/mcp)** for
11
+ Claude Code / Cursor.
12
+
13
+ → **[h1ve.org](https://h1ve.org)** · **[app.h1ve.org](https://app.h1ve.org)**
14
+
15
+ ## Quickstart (zero paste)
16
+
17
+ ```bash
18
+ npm i -g @h1veframework/cli
19
+ h1ve login # opens your browser → you click Authorize → done
20
+ h1ve status # state of the current branch's feature
21
+ ```
22
+
23
+ `h1ve login` stores the credential locally (`~/.config/h1ve/credentials.json`, `600`) — the MCP server reads the
24
+ same one, so **one login sets up both**. The project **auto-resolves from your git remote**, so there's nothing
25
+ to paste and no `H1VE_PROJECT_ID` to set. `h1ve logout` removes it.
26
+
27
+ > The legacy `nf` command still works as an alias — every `h1ve <cmd>` below can be run as `nf <cmd>`.
28
+
29
+ > `h1ve health` saying "no snapshots yet" is **success** (you're connected; the project just has no metrics yet).
30
+
31
+ ## Commands
32
+
33
+ | Command | What it does |
34
+ |---|---|
35
+ | `h1ve login` / `h1ve logout` | Authorize in the browser and store the credential locally / remove it |
36
+ | `h1ve status` | State of the current branch's feature (stage, days active, blockers, sign-offs) |
37
+ | `h1ve start [<#\|id>] [--slug <s>]` | Start an assigned feature: create the `feat/{you}/{slug}` branch and record the slug |
38
+ | `h1ve spec` | Print the feature's spec (markdown) |
39
+ | `h1ve move <stage> [--note]` | Move the feature to another stage |
40
+ | `h1ve done [--from <file>] [--no-move]` | Submit the AI declaration (JSON) and move `dev → pr` |
41
+ | `h1ve blocker "<desc>"` | Open a blocker on the feature (you become its owner) |
42
+ | `h1ve health` | Latest technical-health snapshots for the project |
43
+ | `h1ve connect --kind <k> --label <l> --env KEY=VAL` | Write a credential to your **local** `.env.local` and register the inventory (never sent to the server) |
44
+ | `h1ve serve [--port 7391]` | Run the local agent (`127.0.0.1`) so the dashboard can apply credentials from the browser |
45
+
46
+ Flags: `--json` (raw output for scripts) · `--project <name\|id>` (if you belong to more than one project) · `-h`.
47
+
48
+ ## Example
49
+
50
+ ```bash
51
+ h1ve start # start your assigned feature (creates the branch)
52
+ # ... work: git, code, commits ...
53
+ h1ve status # check state anytime
54
+ h1ve blocker "waiting on the Neon credential" # blocked? open a blocker
55
+ h1ve done --from ai-declaration.json # submit the AI declaration + move dev → pr
56
+ ```
57
+
58
+ ## CI / headless (env vars)
59
+
60
+ No browser? Configure by env (takes **precedence** over `h1ve login`):
61
+
62
+ ```bash
63
+ export H1VE_API_URL="https://app.h1ve.org" # optional (this is the default)
64
+ export H1VE_API_KEY="nf_pat_..." # a PAT from app.h1ve.org/api-tokens
65
+ # export H1VE_PROJECT_ID="..." # OPTIONAL — the CLI resolves the project from the repo
66
+ ```
67
+
68
+ ## Troubleshooting
69
+
70
+ | Symptom | Fix |
71
+ |---|---|
72
+ | `h1ve: command not found` | Node missing or wrong terminal. Check `node --version`. On Windows, reopen the shell or use the VS Code terminal. |
73
+ | `404` on install | npm propagation right after a publish — wait a few minutes. |
74
+ | `NO_PROJECT` | You belong to more than one project — pass `--project <name\|id>`. |
75
+ | `401` / `403` | Wrong/missing token. Make sure `H1VE_API_KEY` is a PAT (`nf_pat_…`). `403 SERVICE_CANNOT_WRITE` = a read-only service key used on a write → use a PAT. |
76
+
77
+ Requires **Node.js 18.18+**. The legacy `nf` command and env names `NEXUS_FLOW_API_URL` / `NEXUS_FLOW_API_KEY` are still accepted.
78
+
79
+ ---
80
+
81
+ MIT · built with H1VE, by [H1VE](https://h1ve.org) 🐝
package/dist/index.js CHANGED
@@ -61,6 +61,21 @@ async function switchBranch(name, runner = defaultGitRunner) {
61
61
  throw new Error("GIT_SWITCH_FAILED");
62
62
  }
63
63
  }
64
+ async function commitsBehindOriginMain(runner = defaultGitRunner) {
65
+ try {
66
+ await runner(["fetch", "origin"]);
67
+ } catch {
68
+ return null;
69
+ }
70
+ let out;
71
+ try {
72
+ out = await runner(["rev-list", "--count", "HEAD..origin/main"]);
73
+ } catch {
74
+ return null;
75
+ }
76
+ const n = Number(out.trim());
77
+ return Number.isInteger(n) && n >= 0 ? n : null;
78
+ }
64
79
  async function listLocalBranches(runner = defaultGitRunner) {
65
80
  let out;
66
81
  try {
@@ -360,6 +375,26 @@ async function writeEnvVars(pairs, opts = {}) {
360
375
  return { file, keys: Object.keys(pairs) };
361
376
  }
362
377
 
378
+ // ../core/src/format.ts
379
+ var MINUTE_MS = 6e4;
380
+ var HOUR_MS = 36e5;
381
+ var DAY_MS = 864e5;
382
+ function formatDuration(ms) {
383
+ if (ms < MINUTE_MS) return "<1min";
384
+ if (ms < HOUR_MS) return `${Math.floor(ms / MINUTE_MS)}min`;
385
+ if (ms < DAY_MS) {
386
+ const h2 = Math.floor(ms / HOUR_MS);
387
+ const m = Math.floor(ms % HOUR_MS / MINUTE_MS);
388
+ return m > 0 ? `${h2}h ${m}min` : `${h2}h`;
389
+ }
390
+ const d = Math.floor(ms / DAY_MS);
391
+ const h = Math.floor(ms % DAY_MS / HOUR_MS);
392
+ return h > 0 ? `${d}d ${h}h` : `${d}d`;
393
+ }
394
+ function formatMinutes(minutes) {
395
+ return formatDuration(minutes * MINUTE_MS);
396
+ }
397
+
363
398
  // ../core/src/credentials.ts
364
399
  import {
365
400
  readFile as fsReadFile2,
@@ -457,6 +492,9 @@ async function clientFromConfig(cfg) {
457
492
  }
458
493
 
459
494
  // src/format.ts
495
+ function activeTime(d) {
496
+ return d.elapsed_minutes != null ? formatMinutes(d.elapsed_minutes) : `${d.days_active}d`;
497
+ }
460
498
  var STAGE_LABEL = {
461
499
  backlog: "Backlog",
462
500
  spec: "Spec",
@@ -476,7 +514,7 @@ function formatStatus(d) {
476
514
  const lines = [
477
515
  `${f.name} [${f.priority}]`,
478
516
  `Stage: ${stageLabel(d.stage)}`,
479
- `Dias ativos: ${d.days_active}`,
517
+ `Tempo ativo: ${activeTime(d)}`,
480
518
  `Branch: ${f.branch_slug ?? "\u2014"}`
481
519
  ];
482
520
  if (f.github_pr_url) lines.push(`PR: ${f.github_pr_url}`);
@@ -554,6 +592,13 @@ function formatStart(r, opts) {
554
592
  ...startFlowLines(r)
555
593
  ].join("\n");
556
594
  }
595
+ function formatBehindMainWarning(behind) {
596
+ const plural = behind === 1 ? "commit" : "commits";
597
+ return [
598
+ `\u26A0 Sua base est\xE1 ${behind} ${plural} atr\xE1s de origin/main.`,
599
+ " Sincronize antes de codar: git fetch origin && git rebase origin/main"
600
+ ].join("\n");
601
+ }
557
602
  function formatHealth(snaps) {
558
603
  if (!snaps.length) return "Nenhum snapshot de sa\xFAde t\xE9cnica registrado.";
559
604
  const header = "Semana CI% Deploys Bugs D\xEDvida";
@@ -705,6 +750,17 @@ async function health(io) {
705
750
  }
706
751
 
707
752
  // src/commands/start.ts
753
+ async function behindMainWarning(io) {
754
+ if (!io.checkBehindMain) return "";
755
+ try {
756
+ const behind = await io.checkBehindMain();
757
+ return behind && behind > 0 ? `${formatBehindMainWarning(behind)}
758
+
759
+ ` : "";
760
+ } catch {
761
+ return "";
762
+ }
763
+ }
708
764
  function branchSlugOf(branch) {
709
765
  return branch.match(/^feat\/[^/]+\/(.+)$/)?.[1] ?? null;
710
766
  }
@@ -733,6 +789,7 @@ async function start(io, args) {
733
789
  if (!selected) {
734
790
  return { human: formatStartList(list), data: { features: list } };
735
791
  }
792
+ const warning = await behindMainWarning(io);
736
793
  const resuming = selected.branch_slug !== null;
737
794
  const result = await io.client.startFeature(selected.id, args.slug);
738
795
  try {
@@ -742,7 +799,7 @@ async function start(io, args) {
742
799
  if (code === "BRANCH_EXISTS") await io.switchBranch(result.branch_name);
743
800
  else throw err;
744
801
  }
745
- return { human: formatStart(result, { resumed: resuming }), data: result };
802
+ return { human: `${warning}${formatStart(result, { resumed: resuming })}`, data: result };
746
803
  }
747
804
 
748
805
  // src/commands/connect.ts
@@ -1437,8 +1494,11 @@ async function mcp(io, args) {
1437
1494
  };
1438
1495
  }
1439
1496
 
1497
+ // src/version.ts
1498
+ import { readFileSync } from "fs";
1499
+ var VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
1500
+
1440
1501
  // src/index.ts
1441
- var VERSION = "0.12.1";
1442
1502
  var HELP = `h1ve \u2014 CLI do H1VE
1443
1503
  (o comando legado \`nf\` continua funcionando como alias)
1444
1504
 
@@ -1562,6 +1622,7 @@ ${HELP}`);
1562
1622
  createBranch: (name) => createBranch(name, defaultGitRunner),
1563
1623
  switchBranch: (name) => switchBranch(name, defaultGitRunner),
1564
1624
  listBranches: () => listLocalBranches(defaultGitRunner),
1625
+ checkBehindMain: () => commitsBehindOriginMain(defaultGitRunner),
1565
1626
  readFile: (path) => readFile(path, "utf8"),
1566
1627
  readStdin,
1567
1628
  writeEnvVars: (pairs, opts) => writeEnvVars(pairs, { file: opts?.file }),
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
- {
2
- "name": "@h1veframework/cli",
3
- "version": "0.12.1",
4
- "description": "The CLI for H1VE — the governance & memory layer for teams building with AI. Drive your feature flow (start, status, move, spec, done) from the terminal. Works with Claude Code, Cursor and Copilot.",
5
- "license": "MIT",
6
- "type": "module",
7
- "bin": {
8
- "h1ve": "dist/index.js",
9
- "nf": "dist/index.js"
10
- },
11
- "files": [
12
- "dist",
13
- "README.md"
14
- ],
15
- "engines": {
16
- "node": ">=18.18"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/GusHartz/nexus-flow.git",
21
- "directory": "packages/cli"
22
- },
23
- "homepage": "https://h1ve.org",
24
- "bugs": {
25
- "url": "https://github.com/GusHartz/nexus-flow/issues"
26
- },
27
- "keywords": [
28
- "h1ve",
29
- "cli",
30
- "nf",
31
- "ai",
32
- "claude-code",
33
- "cursor",
34
- "copilot",
35
- "ai-coding",
36
- "ai-agents",
37
- "memory",
38
- "anti-drift",
39
- "context",
40
- "governance",
41
- "developer-tools",
42
- "dev-workflow",
43
- "mcp"
44
- ],
45
- "publishConfig": {
46
- "access": "public"
47
- },
48
- "scripts": {
49
- "build": "tsup",
50
- "typecheck": "tsc --noEmit",
51
- "test": "vitest run",
52
- "prepublishOnly": "npm run build"
53
- },
54
- "devDependencies": {
55
- "@nexus-flow/core": "*",
56
- "@types/node": "^20.19.43",
57
- "tsup": "^8.3.0",
58
- "typescript": "^5.6.0",
59
- "vitest": "^2.1.0"
60
- }
61
- }
1
+ {
2
+ "name": "@h1veframework/cli",
3
+ "version": "0.13.0",
4
+ "description": "The CLI for H1VE — the governance & memory layer for teams building with AI. Drive your feature flow (start, status, move, spec, done) from the terminal. Works with Claude Code, Cursor and Copilot.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "h1ve": "dist/index.js",
9
+ "nf": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "engines": {
16
+ "node": ">=18.18"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/GusHartz/nexus-flow.git",
21
+ "directory": "packages/cli"
22
+ },
23
+ "homepage": "https://h1ve.org",
24
+ "bugs": {
25
+ "url": "https://github.com/GusHartz/nexus-flow/issues"
26
+ },
27
+ "keywords": [
28
+ "h1ve",
29
+ "cli",
30
+ "nf",
31
+ "ai",
32
+ "claude-code",
33
+ "cursor",
34
+ "copilot",
35
+ "ai-coding",
36
+ "ai-agents",
37
+ "memory",
38
+ "anti-drift",
39
+ "context",
40
+ "governance",
41
+ "developer-tools",
42
+ "dev-workflow",
43
+ "mcp"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit",
51
+ "test": "vitest run",
52
+ "prepublishOnly": "npm run build"
53
+ },
54
+ "devDependencies": {
55
+ "@nexus-flow/core": "*",
56
+ "@types/node": "^20.19.43",
57
+ "tsup": "^8.3.0",
58
+ "typescript": "^5.6.0",
59
+ "vitest": "^2.1.0"
60
+ }
61
+ }