swarmkit 0.0.1 → 0.0.2

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -1
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +33 -0
  5. package/dist/commands/add.d.ts +2 -0
  6. package/dist/commands/add.js +55 -0
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.js +100 -0
  9. package/dist/commands/hive.d.ts +2 -0
  10. package/dist/commands/hive.js +248 -0
  11. package/dist/commands/init/phases/configure.d.ts +2 -0
  12. package/dist/commands/init/phases/configure.js +85 -0
  13. package/dist/commands/init/phases/global-setup.d.ts +2 -0
  14. package/dist/commands/init/phases/global-setup.js +81 -0
  15. package/dist/commands/init/phases/packages.d.ts +2 -0
  16. package/dist/commands/init/phases/packages.js +30 -0
  17. package/dist/commands/init/phases/project.d.ts +2 -0
  18. package/dist/commands/init/phases/project.js +54 -0
  19. package/dist/commands/init/phases/use-case.d.ts +2 -0
  20. package/dist/commands/init/phases/use-case.js +41 -0
  21. package/dist/commands/init/state.d.ts +11 -0
  22. package/dist/commands/init/state.js +8 -0
  23. package/dist/commands/init/state.test.d.ts +1 -0
  24. package/dist/commands/init/state.test.js +20 -0
  25. package/dist/commands/init/wizard.d.ts +1 -0
  26. package/dist/commands/init/wizard.js +56 -0
  27. package/dist/commands/init.d.ts +2 -0
  28. package/dist/commands/init.js +10 -0
  29. package/dist/commands/login.d.ts +2 -0
  30. package/dist/commands/login.js +91 -0
  31. package/dist/commands/logout.d.ts +2 -0
  32. package/dist/commands/logout.js +19 -0
  33. package/dist/commands/remove.d.ts +2 -0
  34. package/dist/commands/remove.js +49 -0
  35. package/dist/commands/status.d.ts +2 -0
  36. package/dist/commands/status.js +87 -0
  37. package/dist/commands/update.d.ts +2 -0
  38. package/dist/commands/update.js +54 -0
  39. package/dist/commands/whoami.d.ts +2 -0
  40. package/dist/commands/whoami.js +40 -0
  41. package/dist/config/global.d.ts +24 -0
  42. package/dist/config/global.js +71 -0
  43. package/dist/config/global.test.d.ts +1 -0
  44. package/dist/config/global.test.js +167 -0
  45. package/dist/config/keys.d.ts +10 -0
  46. package/dist/config/keys.js +47 -0
  47. package/dist/config/keys.test.d.ts +1 -0
  48. package/dist/config/keys.test.js +87 -0
  49. package/dist/doctor/checks.d.ts +31 -0
  50. package/dist/doctor/checks.js +210 -0
  51. package/dist/doctor/checks.test.d.ts +1 -0
  52. package/dist/doctor/checks.test.js +276 -0
  53. package/dist/doctor/types.d.ts +29 -0
  54. package/dist/doctor/types.js +1 -0
  55. package/dist/hub/auth-flow.d.ts +16 -0
  56. package/dist/hub/auth-flow.js +118 -0
  57. package/dist/hub/auth-flow.test.d.ts +1 -0
  58. package/dist/hub/auth-flow.test.js +98 -0
  59. package/dist/hub/client.d.ts +51 -0
  60. package/dist/hub/client.js +107 -0
  61. package/dist/hub/client.test.d.ts +1 -0
  62. package/dist/hub/client.test.js +177 -0
  63. package/dist/hub/credentials.d.ts +14 -0
  64. package/dist/hub/credentials.js +41 -0
  65. package/dist/hub/credentials.test.d.ts +1 -0
  66. package/dist/hub/credentials.test.js +102 -0
  67. package/dist/index.d.ts +16 -1
  68. package/dist/index.js +9 -2
  69. package/dist/packages/installer.d.ts +33 -0
  70. package/dist/packages/installer.js +127 -0
  71. package/dist/packages/installer.test.d.ts +1 -0
  72. package/dist/packages/installer.test.js +200 -0
  73. package/dist/packages/registry.d.ts +37 -0
  74. package/dist/packages/registry.js +179 -0
  75. package/dist/packages/registry.test.d.ts +1 -0
  76. package/dist/packages/registry.test.js +199 -0
  77. package/dist/packages/setup.d.ts +48 -0
  78. package/dist/packages/setup.js +309 -0
  79. package/dist/packages/setup.test.d.ts +1 -0
  80. package/dist/packages/setup.test.js +717 -0
  81. package/dist/utils/ui.d.ts +10 -0
  82. package/dist/utils/ui.js +47 -0
  83. package/dist/utils/ui.test.d.ts +1 -0
  84. package/dist/utils/ui.test.js +102 -0
  85. package/package.json +29 -6
@@ -0,0 +1,10 @@
1
+ export declare function heading(text: string): void;
2
+ export declare function success(text: string): void;
3
+ export declare function warn(text: string): void;
4
+ export declare function fail(text: string): void;
5
+ export declare function info(text: string): void;
6
+ export declare function bullet(text: string): void;
7
+ export declare function blank(): void;
8
+ export declare function table(rows: string[][], { indent }?: {
9
+ indent?: number;
10
+ }): void;
@@ -0,0 +1,47 @@
1
+ import chalk from "chalk";
2
+ export function heading(text) {
3
+ console.log();
4
+ console.log(chalk.bold(text));
5
+ }
6
+ export function success(text) {
7
+ console.log(chalk.green(" ✓") + " " + text);
8
+ }
9
+ export function warn(text) {
10
+ console.log(chalk.yellow(" ⚠") + " " + text);
11
+ }
12
+ export function fail(text) {
13
+ console.log(chalk.red(" ✗") + " " + text);
14
+ }
15
+ export function info(text) {
16
+ console.log(chalk.dim(" " + text));
17
+ }
18
+ export function bullet(text) {
19
+ console.log(" " + text);
20
+ }
21
+ export function blank() {
22
+ console.log();
23
+ }
24
+ export function table(rows, { indent = 4 } = {}) {
25
+ if (rows.length === 0)
26
+ return;
27
+ const colCount = Math.max(...rows.map((r) => r.length));
28
+ const colWidths = [];
29
+ for (let col = 0; col < colCount; col++) {
30
+ colWidths[col] = Math.max(...rows.map((r) => stripAnsi(r[col] ?? "").length));
31
+ }
32
+ const pad = " ".repeat(indent);
33
+ for (const row of rows) {
34
+ const cells = row.map((cell, i) => {
35
+ if (i === row.length - 1)
36
+ return cell;
37
+ const visible = stripAnsi(cell).length;
38
+ return cell + " ".repeat(colWidths[i] - visible);
39
+ });
40
+ console.log(pad + cells.join(" "));
41
+ }
42
+ }
43
+ // Simple ANSI strip — covers the codes chalk produces
44
+ function stripAnsi(str) {
45
+ // eslint-disable-next-line no-control-regex
46
+ return str.replace(/\x1b\[[0-9;]*m/g, "");
47
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,102 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import * as ui from "./ui.js";
3
+ describe("utils/ui", () => {
4
+ let output;
5
+ beforeEach(() => {
6
+ output = [];
7
+ vi.spyOn(console, "log").mockImplementation((...args) => {
8
+ output.push(args.map(String).join(" "));
9
+ });
10
+ });
11
+ describe("heading", () => {
12
+ it("prints a blank line then the text", () => {
13
+ ui.heading("Test Heading");
14
+ expect(output).toHaveLength(2);
15
+ expect(output[0]).toBe("");
16
+ // Second line should contain the text (may have ANSI codes for bold)
17
+ expect(output[1]).toContain("Test Heading");
18
+ });
19
+ });
20
+ describe("success", () => {
21
+ it("prints with a checkmark prefix", () => {
22
+ ui.success("it worked");
23
+ expect(output).toHaveLength(1);
24
+ expect(output[0]).toContain("✓");
25
+ expect(output[0]).toContain("it worked");
26
+ });
27
+ });
28
+ describe("warn", () => {
29
+ it("prints with a warning prefix", () => {
30
+ ui.warn("careful");
31
+ expect(output).toHaveLength(1);
32
+ expect(output[0]).toContain("⚠");
33
+ expect(output[0]).toContain("careful");
34
+ });
35
+ });
36
+ describe("fail", () => {
37
+ it("prints with a cross prefix", () => {
38
+ ui.fail("broken");
39
+ expect(output).toHaveLength(1);
40
+ expect(output[0]).toContain("✗");
41
+ expect(output[0]).toContain("broken");
42
+ });
43
+ });
44
+ describe("info", () => {
45
+ it("prints indented text", () => {
46
+ ui.info("some info");
47
+ expect(output).toHaveLength(1);
48
+ expect(output[0]).toContain("some info");
49
+ });
50
+ });
51
+ describe("bullet", () => {
52
+ it("prints indented text", () => {
53
+ ui.bullet("a point");
54
+ expect(output).toHaveLength(1);
55
+ expect(output[0]).toContain("a point");
56
+ });
57
+ });
58
+ describe("blank", () => {
59
+ it("prints an empty line", () => {
60
+ ui.blank();
61
+ expect(output).toHaveLength(1);
62
+ expect(output[0]).toBe("");
63
+ });
64
+ });
65
+ describe("table", () => {
66
+ it("does nothing for empty rows", () => {
67
+ ui.table([]);
68
+ expect(output).toHaveLength(0);
69
+ });
70
+ it("prints rows with column alignment", () => {
71
+ ui.table([
72
+ ["short", "a"],
73
+ ["longer-name", "b"],
74
+ ]);
75
+ expect(output).toHaveLength(2);
76
+ // Both rows should start with indent (4 spaces default)
77
+ expect(output[0]).toMatch(/^ {4}/);
78
+ expect(output[1]).toMatch(/^ {4}/);
79
+ });
80
+ it("respects custom indent", () => {
81
+ ui.table([["cell"]], { indent: 8 });
82
+ expect(output).toHaveLength(1);
83
+ expect(output[0]).toMatch(/^ {8}/);
84
+ });
85
+ it("aligns columns correctly with plain text", () => {
86
+ ui.table([
87
+ ["ab", "x"],
88
+ ["abcd", "y"],
89
+ ]);
90
+ // First column width should be 4 (length of "abcd")
91
+ // "ab" should be padded to 4 chars
92
+ // With indent of 4 and 2-space gap between columns:
93
+ // " ab x" and " abcd y"
94
+ expect(output[0]).toContain("ab");
95
+ expect(output[1]).toContain("abcd");
96
+ // Both "x" and "y" should start at the same column position
97
+ const xPos = output[0].indexOf("x");
98
+ const yPos = output[1].indexOf("y");
99
+ expect(xPos).toBe(yPos);
100
+ });
101
+ });
102
+ });
package/package.json CHANGED
@@ -1,20 +1,43 @@
1
1
  {
2
2
  "name": "swarmkit",
3
- "version": "0.0.1",
4
- "description": "",
3
+ "version": "0.0.2",
4
+ "description": "Multi-agent infa toolkit",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "swarmkit": "./dist/cli.js"
10
+ },
7
11
  "files": [
8
12
  "dist"
9
13
  ],
10
14
  "scripts": {
11
- "build": "tsc",
15
+ "build": "tsc && chmod +x dist/cli.js",
12
16
  "dev": "tsc --watch",
13
- "prepublishOnly": "npm run build"
17
+ "test": "vitest run",
18
+ "test:watch": "vitest",
19
+ "preversion": "npm run test && npm run build",
20
+ "version": "git add -A",
21
+ "postversion": "git push && git push --tags",
22
+ "version:patch": "npm version patch",
23
+ "version:minor": "npm version minor",
24
+ "version:major": "npm version major",
25
+ "prepublishOnly": "npm run build",
26
+ "release:patch": "npm run version:patch && npm publish",
27
+ "release:minor": "npm run version:minor && npm publish",
28
+ "release:major": "npm run version:major && npm publish",
29
+ "release:dry": "npm publish --dry-run"
14
30
  },
15
31
  "keywords": [],
16
- "license": "ISC",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@inquirer/prompts": "^8.0.0",
35
+ "chalk": "^5.0.0",
36
+ "commander": "^14.0.0"
37
+ },
17
38
  "devDependencies": {
18
- "typescript": "^5.9.3"
39
+ "@types/node": "^22.0.0",
40
+ "typescript": "^5.9.3",
41
+ "vitest": "^4.0.18"
19
42
  }
20
43
  }