habithive-code 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/LICENSE ADDED
@@ -0,0 +1,35 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 maliv-code contributors
4
+
5
+ This is a fork/derivative of maliv-code, maintained as habithive-code.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ ---
26
+
27
+ maliv-code is an independent control layer. It does not bundle or redistribute
28
+ opencode or oh-my-opencode; it installs/points to them from their official
29
+ sources under their own licenses:
30
+
31
+ - opencode — https://github.com/sst/opencode
32
+ - oh-my-opencode — https://github.com/code-yeongyu/oh-my-openagent
33
+ (Sustainable Use License 1.0)
34
+
35
+ All credit for those projects belongs to their respective authors.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # habithive-code
2
+
3
+ A thin **control layer for [opencode](https://github.com/sst/opencode)** that makes
4
+ two things effortless:
5
+
6
+ 1. **Mode switching** — flip between **complex** (full [oh-my-opencode](https://github.com/code-yeongyu/oh-my-openagent) — for hard tasks) and **simple** (vanilla opencode — for everyday use) with one command or an in-app menu, **resuming the same session**.
7
+ 2. **A model tree** — set models across oh-my-opencode's many agents/categories from a single menu instead of hand-editing JSON.
8
+
9
+ > habithive-code does **not** bundle opencode or oh-my-opencode. It installs / points to
10
+ > them from their official sources under their own licenses. All credit for those
11
+ > projects belongs to their authors (see [Credits](#credits)).
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm i -g habithive-code
17
+ habithive setup # full stack (below). add --minimal to skip the extras
18
+ ```
19
+
20
+ `habithive setup` sets up, from each tool's **official source** (nothing but the two
21
+ skills is bundled):
22
+
23
+ | # | Component | How | Type |
24
+ |---|-----------|-----|------|
25
+ | 1 | **opencode** | `npm i -g opencode-ai` (if missing) | required |
26
+ | 2 | **oh-my-opencode** | pinned `oh-my-openagent@4.19.1` wired into config | required |
27
+ | 3 | **habithive** plugin | wired into `tui.json` | required |
28
+ | 4 | **playwright MCP** | added to the opencode `mcp` config | extra |
29
+ | 5 | **openspec** | `npm i -g @fission-ai/openspec` (MIT) | extra |
30
+ | 6 | **graphify** | `graphifyy` from PyPI via `uv`/`pip` (MIT) | extra |
31
+ | 7 | **skills** | `karpathy-guidelines` (MIT) + `graphify` → `~/.config/opencode/skills/` | extra |
32
+
33
+ Extras load/run in **complex mode**. `habithive setup --minimal` installs only 1–3.
34
+ Bundled skills and their licenses are listed in [THIRD-PARTY-NOTICES.md](./THIRD-PARTY-NOTICES.md).
35
+ > Note: the bundled `graphify` skill was authored for Claude Code's subagent runtime;
36
+ > it drives the `graphify` (graphifyy) CLI and may need tuning under opencode.
37
+
38
+ ## Use
39
+
40
+ ```sh
41
+ habithive # complex mode, NEW session
42
+ habithive simple # vanilla opencode (oh-my-opencode off; the habithive switcher stays)
43
+ habithive complex # full mode
44
+ habithive -c # continue the last session
45
+ habithive -s <id> # continue a specific session
46
+ habithive status # show current mode
47
+ ```
48
+
49
+ Inside opencode:
50
+
51
+ - `/habithive` — menu (set model · switch mode · reset)
52
+ - `/model` — the model tree (below)
53
+ - `/habithive-mode` — switch simple ⇄ complex (relaunches, same session)
54
+
55
+ The home screen shows a **HABITHIVE** wordmark, and the launcher prints a clean
56
+ `▸ habithive` line on start and on exit (with the exact `habithive -c` / `habithive -s <id>`
57
+ resume commands).
58
+
59
+ ## The model tree (`/model`)
60
+
61
+ ```
62
+ Quick
63
+ Main agent — this screen → opencode's on-screen model (model.json)
64
+ ALL — on-screen + subagents+tiers
65
+ Main agents (primary) → also set the on-screen model
66
+ ★ All main agents (set together)
67
+ sisyphus · prometheus · atlas · hephaestus (GPT-only)
68
+ Subagents → oh-my-openagent.json (own model each)
69
+ ★ All sub agents (set together)
70
+ oracle · explore · librarian · multimodal-looker · metis · momus · sisyphus-junior
71
+ Categories (tiers) → oh-my-openagent.json
72
+ ultrabrain · deep · quick · visual-engineering · artistry · writing · unspecified-low · unspecified-high
73
+ ```
74
+
75
+ Precedence: **agent > category > all > default**. Each group has a **★ set-together**
76
+ row. Changes to subagents/tiers live in `oh-my-openagent.json` and apply on the next
77
+ launch (habithive reopens your session automatically after a change).
78
+
79
+ ## How it works
80
+
81
+ - **Mode switch** toggles `oh-my-openagent` in your opencode config (keeping the habithive
82
+ plugin loaded in both modes) and relaunches opencode. A mode change can't be live —
83
+ oh-my-opencode initializes at startup — so habithive relaunches you into the **same session**.
84
+ - **On-screen model** = opencode's picker state (`~/.local/state/opencode/model.json`).
85
+ **Subagent/category models** = `oh-my-openagent.json`. habithive writes the right layer for
86
+ each level of the tree.
87
+ - Your original `oh-my-openagent.json` is snapshotted to `~/.habithive/baseline.json`
88
+ (with a byte-copy backup) so **Reset** restores it exactly.
89
+
90
+ ## Compatibility
91
+
92
+ Tested against: **opencode 1.18.x**, **oh-my-openagent 4.19.x** (pinned in the installer).
93
+ opencode auto-updates its own binary; if a release changes internals, open an issue.
94
+
95
+ ## Uninstall
96
+
97
+ ```sh
98
+ habithive simple # (optional) drop back to vanilla first
99
+ npm rm -g habithive-code
100
+ rm -rf ~/.habithive
101
+ ```
102
+ Then remove the `habithive` / `oh-my-openagent` lines from `~/.config/opencode/tui.json`
103
+ and `opencode.jsonc` if you want them gone.
104
+
105
+ ## Credits
106
+
107
+ Built entirely on the work of others — habithive-code only orchestrates them:
108
+
109
+ - **[opencode](https://github.com/sst/opencode)** — the AI coding agent this runs on.
110
+ - **[oh-my-opencode / oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent)** by **code-yeongyu** — the agent harness that "complex" mode enables (Sustainable Use License 1.0).
111
+
112
+ ## License
113
+
114
+ habithive-code is [MIT](./LICENSE). opencode and oh-my-opencode remain under their own licenses.
@@ -0,0 +1,41 @@
1
+ # Third-Party Notices
2
+
3
+ habithive-code bundles the following third-party content. All other dependencies
4
+ (opencode, oh-my-opencode) are **not** bundled — they are installed from their
5
+ official sources under their own licenses.
6
+
7
+ ## karpathy-guidelines (skills/karpathy-guidelines)
8
+
9
+ - **Source:** andrej-karpathy-skills by forrestchang — https://github.com/forrestchang/andrej-karpathy-skills
10
+ - **License:** MIT
11
+ - Bundled unmodified (frontmatter aside). Derived from Andrej Karpathy's observations on LLM coding pitfalls.
12
+
13
+ ```
14
+ MIT License
15
+
16
+ Copyright (c) forrestchang
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ of this software and associated documentation files (the "Software"), to deal
20
+ in the Software without restriction, including without limitation the rights
21
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ copies of the Software, and to permit persons to whom the Software is
23
+ furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in all
26
+ copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
+ SOFTWARE.
35
+ ```
36
+
37
+ ## playwright MCP (wired by the installer, not bundled)
38
+
39
+ habithive-code's installer adds the `@playwright/mcp` server to your opencode config
40
+ (`mcp` section). The package itself is fetched via `npx` from npm under its own
41
+ license (Apache-2.0) — habithive-code does not bundle it.
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ // habithive-code launcher — cross-shell CLI (replaces the old zsh function).
3
+ // habithive complex mode, NEW session
4
+ // habithive simple vanilla opencode (oh-my-opencode off, switcher kept)
5
+ // habithive complex full mode
6
+ // habithive -c continue the last session
7
+ // habithive -s <id> continue a specific session
8
+ // habithive new fresh session (default)
9
+ // habithive setup install opencode (if missing) + wire oh-my-opencode + habithive
10
+ // habithive status show current mode + any queued in-app switch
11
+ //
12
+ // Default is a fresh session. In-app /habithive-mode queues a switch + quits; this
13
+ // loop relaunches in the queued mode with --continue (same session).
14
+
15
+ import { spawnSync } from "node:child_process";
16
+ import { readFileSync } from "node:fs";
17
+ import { setMode, currentMode } from "../src/config.js";
18
+ import { readNextMode, readNextSession, clearNextMode } from "../src/core.js";
19
+ import { runSetup } from "../src/setup.js";
20
+
21
+ const C = {
22
+ reset: "\x1b[0m", dim: "\x1b[2m", bold: "\x1b[1m", cyan: "\x1b[36m",
23
+ violet: "\x1b[38;2;124;58;237m", // #7c3aed
24
+ white: "\x1b[97m",
25
+ };
26
+ let VERSION = "0.1.0";
27
+ try { VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version || VERSION; } catch {}
28
+
29
+ // One clean line before launch — the big HABITHIVE wordmark lives INSIDE the TUI
30
+ // (a multi-line terminal banner just gets wiped by opencode's full-screen redraw).
31
+ function banner(mode, resuming) {
32
+ const { reset: R, violet, white } = C;
33
+ process.stdout.write(`${violet}▸ habithive${R}${white} · ${mode} mode${resuming ? " · resuming session" : ""}${R}\n`);
34
+ }
35
+
36
+ function help() {
37
+ process.stdout.write(
38
+ `habithive-code v${VERSION}\n\n` +
39
+ `usage: habithive [simple|complex] [-c | -s <id>] [project]\n` +
40
+ ` habithive setup install opencode + oh-my-opencode + habithive\n` +
41
+ ` habithive status show current mode\n\n` +
42
+ `default: complex mode, new session. -c continue last, -s <id> continue specific.\n`,
43
+ );
44
+ }
45
+
46
+ function runOpencode(args) {
47
+ return spawnSync("opencode", args, { stdio: "inherit", shell: process.platform === "win32" }).status ?? 0;
48
+ }
49
+
50
+ // Newest session id (the one just used) — `opencode session list` is newest-first.
51
+ function lastSessionId() {
52
+ try {
53
+ const r = spawnSync("opencode", ["session", "list"], { encoding: "utf8", shell: process.platform === "win32", timeout: 2500 });
54
+ const m = (r.stdout || "").match(/ses_[A-Za-z0-9]+/);
55
+ return m ? m[0] : null;
56
+ } catch { return null; }
57
+ }
58
+
59
+ async function main() {
60
+ const argv = process.argv.slice(2);
61
+
62
+ // subcommands
63
+ if (argv[0] === "setup") { process.exit(await runSetup({ yes: argv.includes("--yes") || argv.includes("-y"), minimal: argv.includes("--minimal") })); }
64
+ if (argv[0] === "status") {
65
+ const q = readNextMode();
66
+ process.stdout.write(`habithive: ${currentMode()} mode${q ? ` · queued → ${q}` : ""}\n`);
67
+ process.exit(0);
68
+ }
69
+ if (argv.includes("-h") || argv.includes("--help")) { help(); process.exit(0); }
70
+
71
+ // parse launch args — fresh session by default
72
+ let mode = "complex";
73
+ let contArgs = [];
74
+ const passthru = [];
75
+ for (let i = 0; i < argv.length; i++) {
76
+ const a = argv[i];
77
+ if (a === "simple" || a === "--simple") mode = "simple";
78
+ else if (a === "complex" || a === "full" || a === "--complex") mode = "complex";
79
+ else if (a === "-c" || a === "--continue" || a === "continue") contArgs = ["--continue"];
80
+ else if (a === "-s" || a === "--session") { const id = argv[++i]; contArgs = id ? ["--session", id] : ["--continue"]; }
81
+ else if (a === "new" || a === "-n" || a === "--new") contArgs = [];
82
+ else passthru.push(a);
83
+ }
84
+
85
+ clearNextMode();
86
+ // relaunch loop: honor an in-app queued mode switch, preserving the session
87
+ for (;;) {
88
+ setMode(mode);
89
+ banner(mode, contArgs.length > 0);
90
+ runOpencode([...contArgs, ...passthru]);
91
+ const next = readNextMode();
92
+ if (next) {
93
+ const sess = readNextSession();
94
+ clearNextMode();
95
+ mode = next;
96
+ contArgs = sess ? ["--session", sess] : []; // recorded session, else fresh (never --continue)
97
+ passthru.length = 0;
98
+ continue;
99
+ }
100
+ break;
101
+ }
102
+
103
+ // habithive-branded exit hint — the RIGHT resume commands (opencode prints its own
104
+ // "opencode -s ..." above; these are the habithive equivalents that actually work).
105
+ const { white, reset, violet } = C;
106
+ const id = lastSessionId();
107
+ const sCmd = id ? `habithive -s ${id}` : "habithive -s <id>";
108
+ process.stdout.write(
109
+ `\n${violet}▸ habithive${reset}${white} · resume: habithive -c · ${sCmd} · new: habithive${reset}\n`,
110
+ );
111
+ }
112
+
113
+ main().catch((e) => { process.stderr.write(`habithive error: ${String(e?.message || e)}\n`); process.exit(1); });
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "habithive-code",
3
+ "version": "0.2.0",
4
+ "description": "A control layer for opencode: one-command install, live simple/complex mode switching, and a model tree for oh-my-opencode agents.",
5
+ "type": "module",
6
+ "bin": {
7
+ "habithive": "bin/habithive.mjs"
8
+ },
9
+ "main": "src/plugin.js",
10
+ "exports": {
11
+ ".": "./src/plugin.js",
12
+ "./plugin": "./src/plugin.js"
13
+ },
14
+ "files": [
15
+ "src",
16
+ "bin",
17
+ "skills",
18
+ "README.md",
19
+ "LICENSE",
20
+ "THIRD-PARTY-NOTICES.md"
21
+ ],
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "scripts": {
26
+ "test": "node test/core.test.mjs"
27
+ },
28
+ "keywords": [
29
+ "opencode",
30
+ "oh-my-opencode",
31
+ "plugin",
32
+ "tui",
33
+ "ai-agents",
34
+ "model-switcher"
35
+ ],
36
+ "author": "Keshav Sharma",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://repository.hclhealthcare.in/hive/habit-hive-code.git"
40
+ },
41
+ "homepage": "https://repository.hclhealthcare.in/hive/habit-hive-code",
42
+ "bugs": {
43
+ "url": "https://repository.hclhealthcare.in/hive/habit-hive-code/-/issues"
44
+ },
45
+ "license": "MIT"
46
+ }