@calvin.magezi/agent-hq 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 +77 -0
- package/bin/hq +94 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# agent-hq CLI
|
|
2
|
+
|
|
3
|
+
> Local-first AI agent hub — Claude, Gemini & Discord, all from one command.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
### via bunx / npx (zero-install)
|
|
8
|
+
```bash
|
|
9
|
+
bunx agent-hq
|
|
10
|
+
# or
|
|
11
|
+
npx agent-hq
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### via Homebrew
|
|
15
|
+
```bash
|
|
16
|
+
brew tap calvinmagezi/agent-hq
|
|
17
|
+
brew install hq
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Manual (inside the repo)
|
|
21
|
+
```bash
|
|
22
|
+
hq install-cli # symlinks scripts/hq.ts → ~/.local/bin/hq
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## First-time setup
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Interactive (asks questions)
|
|
29
|
+
hq init
|
|
30
|
+
|
|
31
|
+
# Unattended — safe for agent/CI execution
|
|
32
|
+
hq init --non-interactive
|
|
33
|
+
|
|
34
|
+
# Custom vault location
|
|
35
|
+
hq init --vault /path/to/my/vault --non-interactive
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
| Command | Description |
|
|
41
|
+
|---------|-------------|
|
|
42
|
+
| `hq` | Start interactive chat |
|
|
43
|
+
| `hq init` | Full first-time setup |
|
|
44
|
+
| `hq setup` | Scaffold vault only |
|
|
45
|
+
| `hq status` | Service status |
|
|
46
|
+
| `hq start [agent\|relay\|all]` | Start services |
|
|
47
|
+
| `hq stop [agent\|relay\|all]` | Stop services |
|
|
48
|
+
| `hq restart` | Restart everything |
|
|
49
|
+
| `hq daemon start\|stop\|logs` | Background daemon |
|
|
50
|
+
| `hq logs [target] [N]` | View logs |
|
|
51
|
+
| `hq follow` | Live-tail logs |
|
|
52
|
+
| `hq health` | Full health check |
|
|
53
|
+
| `hq ps` | All managed processes |
|
|
54
|
+
| `hq install` | Install launchd daemons |
|
|
55
|
+
| `hq coo status` | COO orchestrator status |
|
|
56
|
+
|
|
57
|
+
## Agent-installable
|
|
58
|
+
|
|
59
|
+
This CLI is designed to be fully installable by an AI agent:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Prerequisites: bun, git
|
|
63
|
+
bunx agent-hq init --non-interactive \
|
|
64
|
+
--vault ~/.agent-hq-vault
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The init command will:
|
|
68
|
+
1. Check prerequisites (bun, git)
|
|
69
|
+
2. Install dependencies
|
|
70
|
+
3. Scaffold the vault
|
|
71
|
+
4. Create `.env.local` templates
|
|
72
|
+
5. Install macOS launchd daemons
|
|
73
|
+
6. Add `hq` to your PATH
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT © Calvin Magezi
|
package/bin/hq
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* agent-hq entry point
|
|
4
|
+
*
|
|
5
|
+
* When installed via `bunx agent-hq` or `npx agent-hq`:
|
|
6
|
+
* - If run from inside the monorepo, delegates to scripts/hq.ts
|
|
7
|
+
* - Otherwise, bootstraps the installation with `hq init`
|
|
8
|
+
*
|
|
9
|
+
* Install globally: bunx agent-hq install-cli
|
|
10
|
+
* Homebrew: brew install calvinmagezi/agent-hq/hq
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
import { spawnSync } from "child_process";
|
|
16
|
+
|
|
17
|
+
// ── Locate the monorepo root ──────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
function findRepoRoot(start: string): string | null {
|
|
20
|
+
let dir = start;
|
|
21
|
+
for (let i = 0; i < 8; i++) {
|
|
22
|
+
const pkg = path.join(dir, "package.json");
|
|
23
|
+
const apps = path.join(dir, "apps/agent");
|
|
24
|
+
if (fs.existsSync(pkg) && fs.existsSync(apps)) return dir;
|
|
25
|
+
const parent = path.dirname(dir);
|
|
26
|
+
if (parent === dir) return null;
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// When installed via npm/bun globally, this file lives at:
|
|
33
|
+
// node_modules/.bin/hq → node_modules/agent-hq/bin/hq.ts
|
|
34
|
+
// So walk up from __dirname to find the repo, or fall back to CWD.
|
|
35
|
+
const repoFromPackage = findRepoRoot(path.resolve(import.meta.dir, "../../.."));
|
|
36
|
+
const repoFromCwd = findRepoRoot(process.cwd());
|
|
37
|
+
const REPO_ROOT = repoFromPackage ?? repoFromCwd;
|
|
38
|
+
|
|
39
|
+
// ── Delegate or bootstrap ─────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
if (REPO_ROOT) {
|
|
42
|
+
// We're inside (or near) the monorepo — exec the full CLI
|
|
43
|
+
const fullCli = path.join(REPO_ROOT, "scripts/hq.ts");
|
|
44
|
+
if (fs.existsSync(fullCli)) {
|
|
45
|
+
const result = spawnSync(process.execPath, [fullCli, ...process.argv.slice(2)], {
|
|
46
|
+
stdio: "inherit",
|
|
47
|
+
env: process.env,
|
|
48
|
+
});
|
|
49
|
+
process.exit(result.status ?? 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── Not in repo — run init to bootstrap ──────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
console.log(`
|
|
56
|
+
┌─────────────────────────────────────────────────────┐
|
|
57
|
+
│ agent-hq — first run │
|
|
58
|
+
│ │
|
|
59
|
+
│ No agent-hq repository found near this location. │
|
|
60
|
+
│ Let's set everything up. │
|
|
61
|
+
└─────────────────────────────────────────────────────┘
|
|
62
|
+
`);
|
|
63
|
+
|
|
64
|
+
const isNonInteractive =
|
|
65
|
+
process.argv.includes("--non-interactive") ||
|
|
66
|
+
process.argv.includes("-y") ||
|
|
67
|
+
!process.stdout.isTTY;
|
|
68
|
+
|
|
69
|
+
const installDir = path.join(
|
|
70
|
+
process.env.AGENT_HQ_DIR ?? (process.env.HOME ?? "~"),
|
|
71
|
+
"agent-hq"
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
console.log(`Cloning agent-hq to: ${installDir}`);
|
|
75
|
+
const clone = spawnSync("git", [
|
|
76
|
+
"clone", "https://github.com/CalvinMagezi/agent-hq.git", installDir
|
|
77
|
+
], { stdio: "inherit" });
|
|
78
|
+
|
|
79
|
+
if (clone.status !== 0) {
|
|
80
|
+
console.error("\nClone failed. Check your internet connection.");
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const installArgs = [
|
|
85
|
+
path.join(installDir, "scripts/hq.ts"),
|
|
86
|
+
"init",
|
|
87
|
+
...(isNonInteractive ? ["--non-interactive"] : []),
|
|
88
|
+
];
|
|
89
|
+
const init = spawnSync(process.execPath, installArgs, {
|
|
90
|
+
cwd: installDir,
|
|
91
|
+
stdio: "inherit",
|
|
92
|
+
env: process.env,
|
|
93
|
+
});
|
|
94
|
+
process.exit(init.status ?? 0);
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@calvin.magezi/agent-hq",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "HQ CLI — local-first AI agent hub for Claude, Gemini & Discord",
|
|
5
|
+
"homepage": "https://github.com/CalvinMagezi/agent-hq",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/CalvinMagezi/agent-hq.git",
|
|
9
|
+
"directory": "packages/hq-cli"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": ["ai", "agent", "claude", "gemini", "discord", "local-first", "obsidian"],
|
|
13
|
+
"bin": {
|
|
14
|
+
"hq": "./bin/hq"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/hq",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"bun": ">=1.1.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepublishOnly": "echo 'Publishing hq CLI...'"
|
|
25
|
+
}
|
|
26
|
+
}
|