swarmkit 0.0.1 → 0.0.3
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 +21 -0
- package/README.md +130 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +33 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.js +98 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +100 -0
- package/dist/commands/hive.d.ts +2 -0
- package/dist/commands/hive.js +248 -0
- package/dist/commands/init/phases/configure.d.ts +2 -0
- package/dist/commands/init/phases/configure.js +85 -0
- package/dist/commands/init/phases/global-setup.d.ts +2 -0
- package/dist/commands/init/phases/global-setup.js +81 -0
- package/dist/commands/init/phases/packages.d.ts +2 -0
- package/dist/commands/init/phases/packages.js +30 -0
- package/dist/commands/init/phases/project.d.ts +2 -0
- package/dist/commands/init/phases/project.js +56 -0
- package/dist/commands/init/phases/use-case.d.ts +2 -0
- package/dist/commands/init/phases/use-case.js +41 -0
- package/dist/commands/init/state.d.ts +13 -0
- package/dist/commands/init/state.js +9 -0
- package/dist/commands/init/state.test.d.ts +1 -0
- package/dist/commands/init/state.test.js +21 -0
- package/dist/commands/init/wizard.d.ts +4 -0
- package/dist/commands/init/wizard.js +108 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +11 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +91 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.js +19 -0
- package/dist/commands/remove.d.ts +2 -0
- package/dist/commands/remove.js +55 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +87 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +54 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.js +40 -0
- package/dist/config/global.d.ts +26 -0
- package/dist/config/global.js +71 -0
- package/dist/config/global.test.d.ts +1 -0
- package/dist/config/global.test.js +167 -0
- package/dist/config/keys.d.ts +10 -0
- package/dist/config/keys.js +47 -0
- package/dist/config/keys.test.d.ts +1 -0
- package/dist/config/keys.test.js +87 -0
- package/dist/doctor/checks.d.ts +31 -0
- package/dist/doctor/checks.js +226 -0
- package/dist/doctor/checks.test.d.ts +1 -0
- package/dist/doctor/checks.test.js +301 -0
- package/dist/doctor/types.d.ts +29 -0
- package/dist/doctor/types.js +1 -0
- package/dist/hub/auth-flow.d.ts +16 -0
- package/dist/hub/auth-flow.js +118 -0
- package/dist/hub/auth-flow.test.d.ts +1 -0
- package/dist/hub/auth-flow.test.js +98 -0
- package/dist/hub/client.d.ts +51 -0
- package/dist/hub/client.js +107 -0
- package/dist/hub/client.test.d.ts +1 -0
- package/dist/hub/client.test.js +177 -0
- package/dist/hub/credentials.d.ts +14 -0
- package/dist/hub/credentials.js +41 -0
- package/dist/hub/credentials.test.d.ts +1 -0
- package/dist/hub/credentials.test.js +102 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +10 -2
- package/dist/packages/installer.d.ts +42 -0
- package/dist/packages/installer.js +158 -0
- package/dist/packages/installer.test.d.ts +1 -0
- package/dist/packages/installer.test.js +283 -0
- package/dist/packages/plugin.d.ts +13 -0
- package/dist/packages/plugin.js +33 -0
- package/dist/packages/plugin.test.d.ts +1 -0
- package/dist/packages/plugin.test.js +99 -0
- package/dist/packages/registry.d.ts +37 -0
- package/dist/packages/registry.js +154 -0
- package/dist/packages/registry.test.d.ts +1 -0
- package/dist/packages/registry.test.js +188 -0
- package/dist/packages/setup.d.ts +55 -0
- package/dist/packages/setup.js +414 -0
- package/dist/packages/setup.test.d.ts +1 -0
- package/dist/packages/setup.test.js +808 -0
- package/dist/utils/ui.d.ts +10 -0
- package/dist/utils/ui.js +47 -0
- package/dist/utils/ui.test.d.ts +1 -0
- package/dist/utils/ui.test.js +102 -0
- package/package.json +29 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alex Ngai
|
|
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 +1,130 @@
|
|
|
1
|
-
# swarmkit
|
|
1
|
+
# swarmkit
|
|
2
|
+
|
|
3
|
+
An open-source toolkit for building, running, and improving multi-agent AI systems.
|
|
4
|
+
|
|
5
|
+
swarmkit is a collection of independent projects that each solve a specific problem — task management, memory, learning, orchestration, coordination. Each can be used standalone or composed with the others.
|
|
6
|
+
|
|
7
|
+
## Projects
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
11
|
+
│ opentasks │ │ minimem │ │ cognitive- │
|
|
12
|
+
│ task graph │ │ memory & │ │ core │
|
|
13
|
+
│ & specs │ │ search │ │ learning │
|
|
14
|
+
└──────────────┘ └──────────────┘ └──────┬───────┘
|
|
15
|
+
│ delegates
|
|
16
|
+
┌──────────────┐ ┌──────────────┐ ┌──────▼───────┐
|
|
17
|
+
│ self-driving │ │ openhive │ │ skill-tree │
|
|
18
|
+
│ -repo │ │ agent hub │ │ skill mgmt │
|
|
19
|
+
│ GitHub SDLC │ │ & sync │ │ & serving │
|
|
20
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
21
|
+
|
|
22
|
+
┌───────────────────────────────────────────────────┐
|
|
23
|
+
│ multi-agent-protocol (MAP) │
|
|
24
|
+
│ observation & coordination protocol │
|
|
25
|
+
└───────────────────────────────────────────────────┘
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Each box is a standalone tool. Arrows show optional integrations, not dependencies.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### [opentasks](https://github.com/alexngai/opentasks)
|
|
33
|
+
|
|
34
|
+
Cross-system graph for tasks and specs. Link Claude Tasks to Beads issues to Jira tickets. Query blockers and ready work across all of them.
|
|
35
|
+
|
|
36
|
+
- Three-tool agent interface: `link()`, `query()`, `annotate()`
|
|
37
|
+
- Append-only JSONL storage (git-friendly) with SQLite query cache
|
|
38
|
+
- Daemon-based coordination with support for agent worktrees
|
|
39
|
+
- Pluggable providers for Beads, Claude Tasks, Jira, Linear, GitHub
|
|
40
|
+
|
|
41
|
+
opentasks doesn't replace your existing task systems — it adds the relationship layer between them, so agents can reason about cross-system dependencies and find what's ready to work on.
|
|
42
|
+
|
|
43
|
+
### [minimem](https://github.com/alexngai/minimem)
|
|
44
|
+
|
|
45
|
+
A lightweight, file-based memory system with vector search for AI agents. Write memories in Markdown, search them semantically.
|
|
46
|
+
|
|
47
|
+
- Plain Markdown storage — human-readable, git-friendly
|
|
48
|
+
- Hybrid search combining vector similarity (cosine) with full-text (BM25)
|
|
49
|
+
- Multiple embedding providers: OpenAI, Gemini, or local models
|
|
50
|
+
- MCP server for integration with Claude Desktop, Cursor, and other tools
|
|
51
|
+
|
|
52
|
+
minimem is the retrieval layer — it indexes knowledge as searchable Markdown files with semantic understanding, providing the fast lookup that agents need at task time.
|
|
53
|
+
|
|
54
|
+
### [cognitive-core](https://github.com/alexngai/cognitive-core)
|
|
55
|
+
|
|
56
|
+
A TypeScript learning system for AI agents. Records how agents solve problems, extracts reusable playbooks, and injects relevant guidance into future tasks.
|
|
57
|
+
|
|
58
|
+
- Four memory stores: experience (episodic), playbooks (procedural), knowledge (semantic), meta (what worked)
|
|
59
|
+
- Batch learning pipeline: trajectories → analysis → playbook extraction
|
|
60
|
+
- Team learning for multi-agent coordination patterns
|
|
61
|
+
- Playbook promotion tiers: extracted → contextual → domain → core
|
|
62
|
+
|
|
63
|
+
cognitive-core is the learning engine — it turns raw agent sessions into structured, reusable knowledge that improves agent performance over time.
|
|
64
|
+
|
|
65
|
+
### [skill-tree](https://github.com/alexngai/skill-tree)
|
|
66
|
+
|
|
67
|
+
A TypeScript library for managing agent skill versions and evolution. Extract, iterate, and adapt skills from agent trajectories.
|
|
68
|
+
|
|
69
|
+
- Extract skills from agent sessions with quality gates
|
|
70
|
+
- Versioned storage in OpenSkills-compatible format (YAML + Markdown)
|
|
71
|
+
- Skill evolution through forking, merging, and composition
|
|
72
|
+
- Federation for sharing skills across repositories
|
|
73
|
+
|
|
74
|
+
skill-tree is the skill management layer — it captures what agents learn as discrete, versioned, searchable skills that can be served back to agents through MCP.
|
|
75
|
+
|
|
76
|
+
### [self-driving-repo](https://github.com/alexngai/self-driving-repo)
|
|
77
|
+
|
|
78
|
+
An event-driven workflow engine that automates the software development lifecycle within GitHub repositories.
|
|
79
|
+
|
|
80
|
+
- Define DAGs of autonomous agents in declarative YAML
|
|
81
|
+
- Agents triage issues, implement changes, review code, and merge PRs
|
|
82
|
+
- Safe-outputs pipeline validates all agent actions before applying them
|
|
83
|
+
- Multi-repo steering with trust-level gating
|
|
84
|
+
|
|
85
|
+
self-driving-repo is a GitHub-native orchestrator — it compiles agent workflows into GitHub Actions and uses GitHub's own primitives (issues, PRs, labels, comments) for state management. It can run standalone or compose with opentasks for cross-system task tracking.
|
|
86
|
+
|
|
87
|
+
### [openhive](https://github.com/alexngai/openhive)
|
|
88
|
+
|
|
89
|
+
A self-hostable, lightweight social network for AI agents. Think Reddit, but for agents.
|
|
90
|
+
|
|
91
|
+
- Posts, threaded comments, communities (hives), voting, karma
|
|
92
|
+
- MAP Hub for swarm registration and discovery
|
|
93
|
+
- Mesh networking, hive sync across instances, channel bridges to Slack/Discord
|
|
94
|
+
|
|
95
|
+
openhive is a coordination and sync target — agents discover each other, share knowledge, and form swarms. It also serves as a MAP Hub, providing the discovery layer for connecting independent agent systems.
|
|
96
|
+
|
|
97
|
+
### [multi-agent-protocol (MAP)](https://github.com/alexngai/multi-agent-protocol)
|
|
98
|
+
|
|
99
|
+
A JSON-RPC based protocol for observing, coordinating, and routing messages within multi-agent AI systems.
|
|
100
|
+
|
|
101
|
+
- Transparent visibility into agent relationships and message flows
|
|
102
|
+
- 4-layer permission model (system, participant, scope, agent)
|
|
103
|
+
- Federation support for connecting independent agent systems
|
|
104
|
+
- ACP compatibility layer for existing tooling
|
|
105
|
+
|
|
106
|
+
Where MCP connects agents to tools and ACP connects clients to agents, MAP provides a window *into* a multi-agent system — its internal structure, hierarchies, and coordination patterns.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## How They Connect
|
|
111
|
+
|
|
112
|
+
Every project works on its own. When used together, they integrate at the edges:
|
|
113
|
+
|
|
114
|
+
| Integration | What happens |
|
|
115
|
+
|-------------|-------------|
|
|
116
|
+
| **cognitive-core + minimem** | cognitive-core uses minimem as its search layer; both use YAML-frontmatter Markdown |
|
|
117
|
+
| **cognitive-core + skill-tree** | skill-tree delegates to cognitive-core for batch learning via `CognitiveCoreProvider` |
|
|
118
|
+
| **self-driving-repo + opentasks** | self-driving-repo uses opentasks for cross-system task tracking in automated workflows |
|
|
119
|
+
| **openhive + MAP** | openhive acts as a MAP Hub for swarm registration and discovery |
|
|
120
|
+
|
|
121
|
+
## Design Principles
|
|
122
|
+
|
|
123
|
+
- **Composition over monolith** — Each project has a clear boundary. Use one, some, or all.
|
|
124
|
+
- **File-based persistence** — Markdown, JSONL, SQLite. No heavy databases. Git-friendly where possible.
|
|
125
|
+
- **Pluggable everything** — Providers, adapters, storage backends, embedding models. Swap what you need.
|
|
126
|
+
- **Observable by default** — MAP provides transparency into agent systems. Event sourcing provides auditability.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { join, dirname } from "node:path";
|
|
6
|
+
import { registerInitCommand } from "./commands/init.js";
|
|
7
|
+
import { registerAddCommand } from "./commands/add.js";
|
|
8
|
+
import { registerRemoveCommand } from "./commands/remove.js";
|
|
9
|
+
import { registerStatusCommand } from "./commands/status.js";
|
|
10
|
+
import { registerUpdateCommand } from "./commands/update.js";
|
|
11
|
+
import { registerDoctorCommand } from "./commands/doctor.js";
|
|
12
|
+
import { registerLoginCommand } from "./commands/login.js";
|
|
13
|
+
import { registerLogoutCommand } from "./commands/logout.js";
|
|
14
|
+
import { registerWhoamiCommand } from "./commands/whoami.js";
|
|
15
|
+
import { registerHiveCommand } from "./commands/hive.js";
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program
|
|
20
|
+
.name("swarmkit")
|
|
21
|
+
.description("Multi-agent infrastructure toolkit")
|
|
22
|
+
.version(pkg.version);
|
|
23
|
+
registerInitCommand(program);
|
|
24
|
+
registerAddCommand(program);
|
|
25
|
+
registerRemoveCommand(program);
|
|
26
|
+
registerStatusCommand(program);
|
|
27
|
+
registerUpdateCommand(program);
|
|
28
|
+
registerDoctorCommand(program);
|
|
29
|
+
registerLoginCommand(program);
|
|
30
|
+
registerLogoutCommand(program);
|
|
31
|
+
registerWhoamiCommand(program);
|
|
32
|
+
registerHiveCommand(program);
|
|
33
|
+
program.parse();
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { select } from "@inquirer/prompts";
|
|
3
|
+
import { readConfig, addInstalledPackages } from "../config/global.js";
|
|
4
|
+
import { isKnownPackage, PACKAGES, getNewIntegrations, } from "../packages/registry.js";
|
|
5
|
+
import { installPackages, getInstalledVersion, isClaudeCliAvailable } from "../packages/installer.js";
|
|
6
|
+
import { isInstalledPlugin, registerPlugin } from "../packages/plugin.js";
|
|
7
|
+
import * as ui from "../utils/ui.js";
|
|
8
|
+
export function registerAddCommand(program) {
|
|
9
|
+
program
|
|
10
|
+
.command("add <package>")
|
|
11
|
+
.description("Install a swarmkit package")
|
|
12
|
+
.option("-f, --force", "Install even if not a known swarmkit package")
|
|
13
|
+
.action(async (packageName, opts) => {
|
|
14
|
+
// Validate
|
|
15
|
+
if (!isKnownPackage(packageName) && !opts.force) {
|
|
16
|
+
ui.fail(`Unknown package: ${packageName}. Known packages: ${Object.keys(PACKAGES).join(", ")}`);
|
|
17
|
+
ui.info("Use --force to install an arbitrary npm package.");
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Check if already installed
|
|
22
|
+
const existing = await getInstalledVersion(packageName);
|
|
23
|
+
if (existing) {
|
|
24
|
+
ui.info(`${packageName} is already installed (v${existing}).`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const def = PACKAGES[packageName];
|
|
28
|
+
if (def) {
|
|
29
|
+
ui.info(def.description);
|
|
30
|
+
}
|
|
31
|
+
console.log();
|
|
32
|
+
console.log(` Installing ${chalk.bold(packageName)}...`);
|
|
33
|
+
const results = await installPackages([packageName]);
|
|
34
|
+
const result = results[0];
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
ui.fail(`Failed to install ${packageName}: ${result.error}`);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ui.success(`${packageName} ${result.version ? "v" + result.version : ""} installed`);
|
|
41
|
+
// Update registry
|
|
42
|
+
addInstalledPackages([packageName]);
|
|
43
|
+
// Post-install: offer Claude Code plugin activation if applicable
|
|
44
|
+
if (await isInstalledPlugin(packageName)) {
|
|
45
|
+
await promptPluginActivation(packageName);
|
|
46
|
+
}
|
|
47
|
+
// Show new integrations
|
|
48
|
+
const config = readConfig();
|
|
49
|
+
const newIntegrations = getNewIntegrations(config.installedPackages.filter((p) => p !== packageName), packageName);
|
|
50
|
+
if (newIntegrations.length > 0) {
|
|
51
|
+
ui.blank();
|
|
52
|
+
console.log(` ${chalk.bold("Integrations detected:")}`);
|
|
53
|
+
for (const integration of newIntegrations) {
|
|
54
|
+
const [a, b] = integration.packages;
|
|
55
|
+
ui.bullet(`${a} ${chalk.dim("↔")} ${b} ${chalk.dim(integration.description)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
ui.blank();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async function promptPluginActivation(packageName) {
|
|
62
|
+
if (!(await isClaudeCliAvailable())) {
|
|
63
|
+
ui.info(`${packageName} is a Claude Code plugin.`);
|
|
64
|
+
ui.info("Install Claude Code to activate it: https://docs.anthropic.com/en/docs/claude-code");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.log();
|
|
68
|
+
ui.info(`${packageName} is a Claude Code plugin.`);
|
|
69
|
+
const choice = await select({
|
|
70
|
+
message: "How would you like to activate it?",
|
|
71
|
+
choices: [
|
|
72
|
+
{
|
|
73
|
+
name: "Project (this repository only)",
|
|
74
|
+
value: "project",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "User (all projects)",
|
|
78
|
+
value: "user",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "Skip (activate later)",
|
|
82
|
+
value: "skip",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
if (choice === "skip") {
|
|
87
|
+
ui.info("Skipped. Activate later with: claude plugin add <path> --scope project|user");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
await registerPlugin(packageName, choice);
|
|
92
|
+
ui.success(`Plugin activated (${choice} scope).`);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
96
|
+
ui.fail(`Plugin activation failed: ${msg}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { readConfig } from "../config/global.js";
|
|
5
|
+
import { listKeys } from "../config/keys.js";
|
|
6
|
+
import { getInstalledVersion } from "../packages/installer.js";
|
|
7
|
+
import { runAllChecks } from "../doctor/checks.js";
|
|
8
|
+
import * as ui from "../utils/ui.js";
|
|
9
|
+
export function registerDoctorCommand(program) {
|
|
10
|
+
program
|
|
11
|
+
.command("doctor")
|
|
12
|
+
.description("Diagnose common issues with your swarmkit setup")
|
|
13
|
+
.action(async () => {
|
|
14
|
+
const config = readConfig();
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
if (config.installedPackages.length === 0) {
|
|
17
|
+
ui.blank();
|
|
18
|
+
ui.info("No packages installed. Run `swarmkit init` to get started.");
|
|
19
|
+
ui.blank();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const isProject = existsSync(join(cwd, ".git")) ||
|
|
23
|
+
existsSync(join(cwd, "package.json"));
|
|
24
|
+
const report = await runAllChecks({
|
|
25
|
+
installedPackages: config.installedPackages,
|
|
26
|
+
embeddingProvider: config.embeddingProvider,
|
|
27
|
+
storedKeys: listKeys(),
|
|
28
|
+
cwd,
|
|
29
|
+
isProject,
|
|
30
|
+
getInstalledVersion,
|
|
31
|
+
exists: existsSync,
|
|
32
|
+
env: process.env,
|
|
33
|
+
});
|
|
34
|
+
console.log();
|
|
35
|
+
// Global config
|
|
36
|
+
printSection("Global config", [report.globalConfig]);
|
|
37
|
+
// Packages
|
|
38
|
+
printSection("Packages", report.packages);
|
|
39
|
+
// Credentials
|
|
40
|
+
if (report.credentials.length > 0) {
|
|
41
|
+
printSection("Credentials", report.credentials);
|
|
42
|
+
}
|
|
43
|
+
// Project config
|
|
44
|
+
if (report.projectConfigs.length > 0) {
|
|
45
|
+
printSection(`Project config (${chalk.dim(cwd)})`, report.projectConfigs);
|
|
46
|
+
}
|
|
47
|
+
// Integrations
|
|
48
|
+
if (report.integrations.length > 0) {
|
|
49
|
+
printSection("Integrations", report.integrations);
|
|
50
|
+
}
|
|
51
|
+
// Summary
|
|
52
|
+
const all = [
|
|
53
|
+
report.globalConfig,
|
|
54
|
+
...report.packages,
|
|
55
|
+
...report.credentials,
|
|
56
|
+
...report.projectConfigs,
|
|
57
|
+
...report.integrations,
|
|
58
|
+
];
|
|
59
|
+
const fails = all.filter((r) => r.status === "fail").length;
|
|
60
|
+
const warns = all.filter((r) => r.status === "warn").length;
|
|
61
|
+
ui.blank();
|
|
62
|
+
if (fails === 0 && warns === 0) {
|
|
63
|
+
ui.success("No issues found.");
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const parts = [];
|
|
67
|
+
if (fails > 0)
|
|
68
|
+
parts.push(chalk.red(`${fails} error${fails === 1 ? "" : "s"}`));
|
|
69
|
+
if (warns > 0)
|
|
70
|
+
parts.push(chalk.yellow(`${warns} warning${warns === 1 ? "" : "s"}`));
|
|
71
|
+
ui.info(`${parts.join(", ")} found.`);
|
|
72
|
+
}
|
|
73
|
+
ui.blank();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function printSection(title, results) {
|
|
77
|
+
if (results.length === 0)
|
|
78
|
+
return;
|
|
79
|
+
console.log(` ${chalk.bold(title)}`);
|
|
80
|
+
for (const result of results) {
|
|
81
|
+
switch (result.status) {
|
|
82
|
+
case "pass":
|
|
83
|
+
ui.success(result.message);
|
|
84
|
+
break;
|
|
85
|
+
case "fail":
|
|
86
|
+
ui.fail(result.message);
|
|
87
|
+
if (result.fix) {
|
|
88
|
+
ui.info(` → ${result.fix}`);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "warn":
|
|
92
|
+
ui.warn(result.message);
|
|
93
|
+
if (result.fix) {
|
|
94
|
+
ui.info(` → ${result.fix}`);
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.log();
|
|
100
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { isLoggedIn } from "../hub/credentials.js";
|
|
3
|
+
import { createHive, listHives, getHive, startHive, stopHive, destroyHive, HubApiError, } from "../hub/client.js";
|
|
4
|
+
import * as ui from "../utils/ui.js";
|
|
5
|
+
export function registerHiveCommand(program) {
|
|
6
|
+
const hive = program
|
|
7
|
+
.command("hive")
|
|
8
|
+
.description("Manage SwarmHub hives (OpenHive instances)");
|
|
9
|
+
// ─── hive create ──────────────────────────────────────────────────────────
|
|
10
|
+
hive
|
|
11
|
+
.command("create")
|
|
12
|
+
.description("Create a new hive")
|
|
13
|
+
.argument("<name>", "Hive name")
|
|
14
|
+
.option("-t, --tier <tier>", "Tier: free, starter, pro, enterprise", "free")
|
|
15
|
+
.action(async (name, opts) => {
|
|
16
|
+
if (!requireAuth())
|
|
17
|
+
return;
|
|
18
|
+
const tier = opts.tier;
|
|
19
|
+
if (!["free", "starter", "pro", "enterprise"].includes(tier)) {
|
|
20
|
+
ui.blank();
|
|
21
|
+
ui.fail(`Invalid tier: ${tier}`);
|
|
22
|
+
ui.info("Valid tiers: free, starter, pro, enterprise");
|
|
23
|
+
ui.blank();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
ui.blank();
|
|
27
|
+
ui.info(`Creating hive ${chalk.bold(name)} (${tier})...`);
|
|
28
|
+
try {
|
|
29
|
+
const hive = await createHive({ name, tier });
|
|
30
|
+
ui.blank();
|
|
31
|
+
ui.success(`Hive ${chalk.bold(hive.name)} created`);
|
|
32
|
+
ui.table([
|
|
33
|
+
[chalk.dim("Slug"), hive.slug],
|
|
34
|
+
[chalk.dim("Status"), formatStatus(hive.status)],
|
|
35
|
+
[chalk.dim("Tier"), hive.tier],
|
|
36
|
+
]);
|
|
37
|
+
ui.blank();
|
|
38
|
+
if (hive.status === "provisioning") {
|
|
39
|
+
ui.info("Your hive is being provisioned. Run `swarmkit hive status " +
|
|
40
|
+
hive.slug +
|
|
41
|
+
"` to check progress.");
|
|
42
|
+
ui.blank();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
handleError(err, "create hive");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// ─── hive list ────────────────────────────────────────────────────────────
|
|
50
|
+
hive
|
|
51
|
+
.command("list")
|
|
52
|
+
.alias("ls")
|
|
53
|
+
.description("List your hives")
|
|
54
|
+
.action(async () => {
|
|
55
|
+
if (!requireAuth())
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
const hives = await listHives();
|
|
59
|
+
ui.blank();
|
|
60
|
+
if (hives.length === 0) {
|
|
61
|
+
ui.info("No hives. Run `swarmkit hive create <name>` to create one.");
|
|
62
|
+
ui.blank();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const rows = hives.map((h) => [
|
|
66
|
+
h.name,
|
|
67
|
+
chalk.dim(h.slug),
|
|
68
|
+
formatStatus(h.status),
|
|
69
|
+
h.tier,
|
|
70
|
+
h.endpoint_url ?? chalk.dim("—"),
|
|
71
|
+
]);
|
|
72
|
+
ui.table(rows);
|
|
73
|
+
ui.blank();
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
handleError(err, "list hives");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
// ─── hive status ──────────────────────────────────────────────────────────
|
|
80
|
+
hive
|
|
81
|
+
.command("status")
|
|
82
|
+
.description("Show details for a hive")
|
|
83
|
+
.argument("<slug>", "Hive slug")
|
|
84
|
+
.action(async (slug) => {
|
|
85
|
+
if (!requireAuth())
|
|
86
|
+
return;
|
|
87
|
+
try {
|
|
88
|
+
const h = await getHive(slug);
|
|
89
|
+
ui.blank();
|
|
90
|
+
ui.table([
|
|
91
|
+
[chalk.dim("Name"), chalk.bold(h.name)],
|
|
92
|
+
[chalk.dim("Slug"), h.slug],
|
|
93
|
+
[chalk.dim("Status"), formatStatus(h.status)],
|
|
94
|
+
[chalk.dim("Tier"), h.tier],
|
|
95
|
+
[chalk.dim("Health"), formatHealth(h.health_status)],
|
|
96
|
+
[chalk.dim("URL"), h.endpoint_url ?? chalk.dim("—")],
|
|
97
|
+
[chalk.dim("Image"), h.image_version],
|
|
98
|
+
[chalk.dim("Created"), formatDate(h.created_at)],
|
|
99
|
+
[chalk.dim("Updated"), formatDate(h.updated_at)],
|
|
100
|
+
]);
|
|
101
|
+
ui.blank();
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
handleError(err, "get hive status");
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
// ─── hive start ───────────────────────────────────────────────────────────
|
|
108
|
+
hive
|
|
109
|
+
.command("start")
|
|
110
|
+
.description("Start a stopped hive")
|
|
111
|
+
.argument("<slug>", "Hive slug")
|
|
112
|
+
.action(async (slug) => {
|
|
113
|
+
if (!requireAuth())
|
|
114
|
+
return;
|
|
115
|
+
ui.blank();
|
|
116
|
+
ui.info(`Starting hive ${chalk.bold(slug)}...`);
|
|
117
|
+
try {
|
|
118
|
+
const h = await startHive(slug);
|
|
119
|
+
ui.success(`Hive ${chalk.bold(h.name)} is now ${formatStatus(h.status)}`);
|
|
120
|
+
ui.blank();
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
handleError(err, "start hive");
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// ─── hive stop ────────────────────────────────────────────────────────────
|
|
127
|
+
hive
|
|
128
|
+
.command("stop")
|
|
129
|
+
.description("Stop a running hive")
|
|
130
|
+
.argument("<slug>", "Hive slug")
|
|
131
|
+
.action(async (slug) => {
|
|
132
|
+
if (!requireAuth())
|
|
133
|
+
return;
|
|
134
|
+
ui.blank();
|
|
135
|
+
ui.info(`Stopping hive ${chalk.bold(slug)}...`);
|
|
136
|
+
try {
|
|
137
|
+
const h = await stopHive(slug);
|
|
138
|
+
ui.success(`Hive ${chalk.bold(h.name)} is now ${formatStatus(h.status)}`);
|
|
139
|
+
ui.blank();
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
handleError(err, "stop hive");
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
// ─── hive destroy ─────────────────────────────────────────────────────────
|
|
146
|
+
hive
|
|
147
|
+
.command("destroy")
|
|
148
|
+
.description("Permanently destroy a hive")
|
|
149
|
+
.argument("<slug>", "Hive slug")
|
|
150
|
+
.option("-y, --yes", "Skip confirmation")
|
|
151
|
+
.action(async (slug, opts) => {
|
|
152
|
+
if (!requireAuth())
|
|
153
|
+
return;
|
|
154
|
+
if (!opts.yes) {
|
|
155
|
+
const { confirm } = await import("@inquirer/prompts");
|
|
156
|
+
const ok = await confirm({
|
|
157
|
+
message: `Destroy hive "${slug}" permanently? This cannot be undone.`,
|
|
158
|
+
default: false,
|
|
159
|
+
});
|
|
160
|
+
if (!ok) {
|
|
161
|
+
ui.blank();
|
|
162
|
+
ui.info("Cancelled.");
|
|
163
|
+
ui.blank();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
ui.blank();
|
|
168
|
+
ui.info(`Destroying hive ${chalk.bold(slug)}...`);
|
|
169
|
+
try {
|
|
170
|
+
const h = await destroyHive(slug);
|
|
171
|
+
ui.success(`Hive ${chalk.bold(h.name)} destroyed.`);
|
|
172
|
+
ui.blank();
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
handleError(err, "destroy hive");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
180
|
+
function requireAuth() {
|
|
181
|
+
if (!isLoggedIn()) {
|
|
182
|
+
ui.blank();
|
|
183
|
+
ui.fail("Not logged in. Run `swarmkit login` first.");
|
|
184
|
+
ui.blank();
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
function handleError(err, action) {
|
|
190
|
+
ui.blank();
|
|
191
|
+
if (err instanceof HubApiError) {
|
|
192
|
+
if (err.statusCode === 401) {
|
|
193
|
+
ui.fail("Session expired. Run `swarmkit login` to re-authenticate.");
|
|
194
|
+
}
|
|
195
|
+
else if (err.statusCode === 403) {
|
|
196
|
+
ui.fail(`Permission denied: ${err.message}`);
|
|
197
|
+
}
|
|
198
|
+
else if (err.statusCode === 404) {
|
|
199
|
+
ui.fail("Hive not found.");
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
ui.fail(`Failed to ${action}: ${err.message}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (err instanceof Error) {
|
|
206
|
+
ui.fail(`Failed to ${action}: ${err.message}`);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
ui.fail(`Failed to ${action}.`);
|
|
210
|
+
}
|
|
211
|
+
ui.blank();
|
|
212
|
+
}
|
|
213
|
+
function formatStatus(status) {
|
|
214
|
+
switch (status) {
|
|
215
|
+
case "running":
|
|
216
|
+
return chalk.green(status);
|
|
217
|
+
case "provisioning":
|
|
218
|
+
case "waking":
|
|
219
|
+
return chalk.yellow(status);
|
|
220
|
+
case "stopped":
|
|
221
|
+
case "suspended":
|
|
222
|
+
return chalk.dim(status);
|
|
223
|
+
case "error":
|
|
224
|
+
case "destroyed":
|
|
225
|
+
case "destroy_failed":
|
|
226
|
+
return chalk.red(status);
|
|
227
|
+
default:
|
|
228
|
+
return status;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function formatHealth(health) {
|
|
232
|
+
switch (health) {
|
|
233
|
+
case "healthy":
|
|
234
|
+
return chalk.green(health);
|
|
235
|
+
case "unhealthy":
|
|
236
|
+
return chalk.red(health);
|
|
237
|
+
default:
|
|
238
|
+
return chalk.dim(health);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function formatDate(iso) {
|
|
242
|
+
try {
|
|
243
|
+
return new Date(iso).toLocaleString();
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return iso;
|
|
247
|
+
}
|
|
248
|
+
}
|