@nairon-ai/aegis 0.2.0 → 0.4.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 +76 -11
- package/dist-node/cli/commands/disconnect.d.ts +3 -0
- package/dist-node/cli/commands/disconnect.d.ts.map +1 -0
- package/dist-node/cli/commands/disconnect.js +59 -0
- package/dist-node/cli/commands/disconnect.js.map +1 -0
- package/dist-node/cli/commands/init.d.ts.map +1 -1
- package/dist-node/cli/commands/init.js +15 -6
- package/dist-node/cli/commands/init.js.map +1 -1
- package/dist-node/cli/commands/setup.d.ts.map +1 -1
- package/dist-node/cli/commands/setup.js +199 -26
- package/dist-node/cli/commands/setup.js.map +1 -1
- package/dist-node/cli/github-app-flow.d.ts +9 -0
- package/dist-node/cli/github-app-flow.d.ts.map +1 -0
- package/dist-node/cli/github-app-flow.js +190 -0
- package/dist-node/cli/github-app-flow.js.map +1 -0
- package/dist-node/cli/index.js +16 -1
- package/dist-node/cli/index.js.map +1 -1
- package/dist-node/cli/state.d.ts.map +1 -1
- package/dist-node/cli/state.js +5 -0
- package/dist-node/cli/state.js.map +1 -1
- package/dist-node/github/manifest.d.ts +13 -3
- package/dist-node/github/manifest.d.ts.map +1 -1
- package/dist-node/github/manifest.js +19 -10
- package/dist-node/github/manifest.js.map +1 -1
- package/docs/SETUP.md +73 -7
- package/package.json +1 -1
- package/src/cli/commands/disconnect.ts +70 -0
- package/src/cli/commands/init.ts +15 -6
- package/src/cli/commands/setup.ts +205 -42
- package/src/cli/github-app-flow.ts +248 -0
- package/src/cli/index.ts +18 -1
- package/src/cli/state.ts +5 -0
- package/src/github/manifest.ts +26 -10
package/src/cli/index.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
3
5
|
import { defineCommand, runMain } from "citty";
|
|
4
6
|
import { deployCommand } from "./commands/deploy.js";
|
|
7
|
+
import { disconnectCommand } from "./commands/disconnect.js";
|
|
5
8
|
import { initCommand } from "./commands/init.js";
|
|
6
9
|
import { pickupCommand } from "./commands/pickup.js";
|
|
7
10
|
import { setupCommand } from "./commands/setup.js";
|
|
8
11
|
import { statusCommand } from "./commands/status.js";
|
|
12
|
+
import { findPackageRoot } from "./paths.js";
|
|
9
13
|
|
|
10
14
|
const main = defineCommand({
|
|
11
15
|
meta: {
|
|
12
16
|
name: "aegis",
|
|
13
|
-
version:
|
|
17
|
+
version: getPackageVersion(),
|
|
14
18
|
description: "Aegis - self-hosted AFK bug-fixing agent",
|
|
15
19
|
},
|
|
16
20
|
default: "menu",
|
|
@@ -20,6 +24,7 @@ const main = defineCommand({
|
|
|
20
24
|
pickup: pickupCommand,
|
|
21
25
|
status: statusCommand,
|
|
22
26
|
deploy: deployCommand,
|
|
27
|
+
disconnect: disconnectCommand,
|
|
23
28
|
menu: defineCommand({
|
|
24
29
|
meta: { name: "menu", description: "Open the interactive menu", hidden: true },
|
|
25
30
|
async run() {
|
|
@@ -36,3 +41,15 @@ const main = defineCommand({
|
|
|
36
41
|
});
|
|
37
42
|
|
|
38
43
|
runMain(main);
|
|
44
|
+
|
|
45
|
+
function getPackageVersion(): string {
|
|
46
|
+
try {
|
|
47
|
+
const packageRoot = findPackageRoot(import.meta.url);
|
|
48
|
+
const pkg = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf-8")) as {
|
|
49
|
+
version?: string;
|
|
50
|
+
};
|
|
51
|
+
return pkg.version ?? "0.0.0";
|
|
52
|
+
} catch {
|
|
53
|
+
return "0.0.0";
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/cli/state.ts
CHANGED
|
@@ -207,6 +207,7 @@ export async function runInteractiveMenu(): Promise<void> {
|
|
|
207
207
|
{ label: "Run setup", value: "setup" },
|
|
208
208
|
{ label: "View status", value: "status" },
|
|
209
209
|
{ label: "Deploy worker", value: "deploy" },
|
|
210
|
+
{ label: "Disconnect Aegis", value: "disconnect" },
|
|
210
211
|
],
|
|
211
212
|
});
|
|
212
213
|
if (choice === "pickup") {
|
|
@@ -225,4 +226,8 @@ export async function runInteractiveMenu(): Promise<void> {
|
|
|
225
226
|
const { runDeploy } = await import("./commands/deploy.js");
|
|
226
227
|
await runDeploy();
|
|
227
228
|
}
|
|
229
|
+
if (choice === "disconnect") {
|
|
230
|
+
const { runDisconnectGuide } = await import("./commands/disconnect.js");
|
|
231
|
+
runDisconnectGuide();
|
|
232
|
+
}
|
|
228
233
|
}
|
package/src/github/manifest.ts
CHANGED
|
@@ -22,6 +22,7 @@ const MANIFEST_EVENTS = ["issues", "issue_comment", "pull_request"];
|
|
|
22
22
|
|
|
23
23
|
export type ManifestResult = {
|
|
24
24
|
appId: string;
|
|
25
|
+
slug: string;
|
|
25
26
|
appName: string;
|
|
26
27
|
privateKey: string;
|
|
27
28
|
webhookSecret: string;
|
|
@@ -33,16 +34,25 @@ export type ManifestResult = {
|
|
|
33
34
|
/**
|
|
34
35
|
* Generate the GitHub App manifest JSON.
|
|
35
36
|
*/
|
|
36
|
-
export function generateManifest(
|
|
37
|
+
export function generateManifest(options: {
|
|
38
|
+
appName: string;
|
|
39
|
+
redirectUrl: string;
|
|
40
|
+
setupUrl: string;
|
|
41
|
+
webhookUrl: string;
|
|
42
|
+
webhookActive: boolean;
|
|
43
|
+
}): Record<string, unknown> {
|
|
37
44
|
return {
|
|
38
|
-
name:
|
|
45
|
+
name: options.appName,
|
|
39
46
|
url: "https://github.com/Nairon-AI/aegis",
|
|
47
|
+
description: "Self-hosted AFK bug-fixing agent for ready GitHub issues.",
|
|
40
48
|
hook_attributes: {
|
|
41
|
-
url:
|
|
42
|
-
active:
|
|
49
|
+
url: options.webhookUrl,
|
|
50
|
+
active: options.webhookActive,
|
|
43
51
|
},
|
|
44
|
-
redirect_url:
|
|
45
|
-
callback_urls: [
|
|
52
|
+
redirect_url: options.redirectUrl,
|
|
53
|
+
callback_urls: [options.redirectUrl, options.setupUrl],
|
|
54
|
+
setup_url: options.setupUrl,
|
|
55
|
+
setup_on_update: true,
|
|
46
56
|
public: false,
|
|
47
57
|
default_permissions: MANIFEST_PERMISSIONS,
|
|
48
58
|
default_events: MANIFEST_EVENTS,
|
|
@@ -79,6 +89,7 @@ export async function exchangeManifestCode(code: string): Promise<ManifestResult
|
|
|
79
89
|
|
|
80
90
|
return {
|
|
81
91
|
appId: String(data.id),
|
|
92
|
+
slug: data.slug,
|
|
82
93
|
appName: data.name,
|
|
83
94
|
privateKey: data.pem,
|
|
84
95
|
webhookSecret: data.webhook_secret,
|
|
@@ -89,9 +100,14 @@ export async function exchangeManifestCode(code: string): Promise<ManifestResult
|
|
|
89
100
|
}
|
|
90
101
|
|
|
91
102
|
/**
|
|
92
|
-
* Get the manifest creation URL
|
|
103
|
+
* Get the manifest creation URL for manual fallback.
|
|
104
|
+
*
|
|
105
|
+
* GitHub requires the manifest to be POSTed to this URL. Do not send users here
|
|
106
|
+
* directly without a form body.
|
|
93
107
|
*/
|
|
94
|
-
export function getManifestCreationUrl(
|
|
95
|
-
const
|
|
96
|
-
|
|
108
|
+
export function getManifestCreationUrl(owner?: string, state?: string): string {
|
|
109
|
+
const base = owner
|
|
110
|
+
? `https://github.com/organizations/${owner}/settings/apps/new`
|
|
111
|
+
: "https://github.com/settings/apps/new";
|
|
112
|
+
return state ? `${base}?state=${encodeURIComponent(state)}` : base;
|
|
97
113
|
}
|