@aui.io/apollo 0.1.4
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/bin/apollo.js +13 -0
- package/node_modules/@aui.io/apollo-cli/bin/apollo.js +79 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/auth.d.ts +4 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/auth.js +99 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/auth.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js +234 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/env.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/env.js +34 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/env.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/hierarchy.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/hierarchy.js +175 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/hierarchy.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/mockdb.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/mockdb.js +251 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/mockdb.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js +138 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/operate.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/profile.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/profile.js +51 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/profile.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/prompts.d.ts +6 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/prompts.js +20 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/prompts.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime.d.ts +6 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime.js +2 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/shell.d.ts +10 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/shell.js +36 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/shell.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/status.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/status.js +57 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/status.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/upgrade.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/upgrade.js +35 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/upgrade.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/workspace.d.ts +3 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/workspace.js +170 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/workspace.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/index.d.ts +10 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js +107 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/meta.d.ts +4 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/meta.js +65 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/meta.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/welcome.d.ts +13 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/welcome.js +53 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/output/welcome.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/package.json +47 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.d.ts +6 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.js +23 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/client-types.d.ts +23 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/client-types.js +2 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/client-types.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/identity.d.ts +48 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/identity.js +131 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/identity.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.d.ts +92 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.js +126 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/mock-db.d.ts +65 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/mock-db.js +183 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/mock-db.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.d.ts +98 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js +70 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/runtime-api.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.d.ts +40 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js +205 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/argv.d.ts +5 -0
- package/node_modules/@aui.io/apollo-core/dist/src/argv.js +43 -0
- package/node_modules/@aui.io/apollo-core/dist/src/argv.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/baseline.d.ts +17 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/baseline.js +48 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/baseline.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/files.d.ts +7 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/files.js +69 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/files.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/materialize.d.ts +14 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/materialize.js +196 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/materialize.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/validate.d.ts +30 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/validate.js +36 -0
- package/node_modules/@aui.io/apollo-core/dist/src/bundle/validate.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.d.ts +11 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.js +193 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/mockdb-keys.d.ts +14 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/mockdb-keys.js +54 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/mockdb-keys.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.d.ts +18 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.js +99 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/types.d.ts +62 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/types.js +2 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/types.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.d.ts +42 -0
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.js +74 -0
- package/node_modules/@aui.io/apollo-core/dist/src/errors/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/index.d.ts +32 -0
- package/node_modules/@aui.io/apollo-core/dist/src/index.js +32 -0
- package/node_modules/@aui.io/apollo-core/dist/src/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.d.ts +29 -0
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.js +49 -0
- package/node_modules/@aui.io/apollo-core/dist/src/output/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/auth.d.ts +10 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/auth.js +83 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/auth.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.d.ts +37 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.js +161 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.d.ts +15 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.js +95 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/env.service.d.ts +11 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/env.service.js +19 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/env.service.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.d.ts +29 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.js +117 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.d.ts +17 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js +99 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/messaging.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/mockdb.d.ts +71 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/mockdb.js +274 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/mockdb.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/profile.service.d.ts +16 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/profile.service.js +29 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/profile.service.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.d.ts +26 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.js +109 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/upgrade.d.ts +23 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/upgrade.js +74 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/upgrade.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/workspace.service.d.ts +44 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/workspace.service.js +148 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/workspace.service.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/skills/install.d.ts +6 -0
- package/node_modules/@aui.io/apollo-core/dist/src/skills/install.js +48 -0
- package/node_modules/@aui.io/apollo-core/dist/src/skills/install.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/workspace/store.d.ts +33 -0
- package/node_modules/@aui.io/apollo-core/dist/src/workspace/store.js +246 -0
- package/node_modules/@aui.io/apollo-core/dist/src/workspace/store.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/package.json +48 -0
- package/node_modules/@aui.io/apollo-tui/bin/apollo-tui.js +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/components/glyph.d.ts +19 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/components/glyph.js +41 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/components/glyph.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/index.d.ts +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/index.js +46 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/attractor.d.ts +82 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/attractor.js +231 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/attractor.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.d.ts +34 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js +100 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.d.ts +14 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js +25 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.d.ts +25 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.js +99 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/sheet.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.d.ts +10 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.js +19 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/tabs.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js +449 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/bundle.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/bundle.js +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/bundle.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/chat.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/chat.js +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/chat.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/index.d.ts +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/index.js +6 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/mockdb.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/mockdb.js +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/mockdb.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/overview.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/overview.js +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/overview.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/scope.d.ts +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/scope.js +4 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/tabs/scope.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/package.json +53 -0
- package/package.json +42 -0
- package/scripts/setup-shell.mjs +68 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { currentProfile, listProfiles, useProfile, } from "@aui.io/apollo-core/services/profile.service.js";
|
|
2
|
+
export function registerProfile(program, runtime) {
|
|
3
|
+
const profile = program
|
|
4
|
+
.command("profile")
|
|
5
|
+
.description("Show or select the active credential profile")
|
|
6
|
+
.action(() => showCurrent(runtime()));
|
|
7
|
+
profile
|
|
8
|
+
.command("current")
|
|
9
|
+
.description("Show the active profile")
|
|
10
|
+
.action(() => showCurrent(runtime()));
|
|
11
|
+
profile
|
|
12
|
+
.command("list")
|
|
13
|
+
.description("List credential profiles")
|
|
14
|
+
.action(async () => {
|
|
15
|
+
const { context, output } = runtime();
|
|
16
|
+
const profiles = await listProfiles(context);
|
|
17
|
+
output.result(profiles, (value) => renderProfiles(value));
|
|
18
|
+
});
|
|
19
|
+
profile
|
|
20
|
+
.command("use")
|
|
21
|
+
.description("Select the default profile")
|
|
22
|
+
.argument("<name>")
|
|
23
|
+
.action(async (name) => {
|
|
24
|
+
const { output } = runtime();
|
|
25
|
+
const result = await useProfile(name);
|
|
26
|
+
output.result(result, () => `Using profile "${name}". Run \`apollo status\` to check its authentication.`);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function showCurrent({ context, output }) {
|
|
30
|
+
const current = currentProfile(context);
|
|
31
|
+
output.result(current, (value) => renderCurrent(value));
|
|
32
|
+
}
|
|
33
|
+
function renderCurrent(profile) {
|
|
34
|
+
return [
|
|
35
|
+
`Profile: ${profile.name}`,
|
|
36
|
+
`Environment: ${profile.environment}`,
|
|
37
|
+
`Authenticated: ${profile.authenticated ? "yes" : "no"}`,
|
|
38
|
+
].join("\n");
|
|
39
|
+
}
|
|
40
|
+
function renderProfiles(profiles) {
|
|
41
|
+
return profiles
|
|
42
|
+
.map((profile) => {
|
|
43
|
+
const marker = profile.active ? "*" : " ";
|
|
44
|
+
const environments = profile.environments.length > 0
|
|
45
|
+
? profile.environments.join(", ")
|
|
46
|
+
: "no credentials";
|
|
47
|
+
return `${marker} ${profile.name}\t${environments}`;
|
|
48
|
+
})
|
|
49
|
+
.join("\n");
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/commands/profile.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,GAGX,MAAM,iDAAiD,CAAC;AAGzD,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,OAA6B;IAE7B,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,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kBAAkB,OAAO,CAAC,IAAI,EAAE;QAChC,kBAAkB,OAAO,CAAC,WAAW,EAAE;QACvC,kBAAkB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;KACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,QAA0B;IAChD,OAAO,QAAQ;SACZ,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC1C,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;YAC7B,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACjC,CAAC,CAAC,gBAAgB,CAAC;QACvB,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;IACtD,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { ConfigError } from "@aui.io/apollo-core/errors/index.js";
|
|
3
|
+
export function canPrompt(input = process.stdin, output = process.stdout) {
|
|
4
|
+
return Boolean(input.isTTY && output.isTTY);
|
|
5
|
+
}
|
|
6
|
+
export async function prompt(question, defaultValue) {
|
|
7
|
+
if (!canPrompt()) {
|
|
8
|
+
throw new ConfigError(`Missing required input: ${question}`, "Pass the value as a flag.");
|
|
9
|
+
}
|
|
10
|
+
const readline = createInterface({ input: process.stdin, output: process.stderr });
|
|
11
|
+
try {
|
|
12
|
+
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
13
|
+
const answer = (await readline.question(`${question}${suffix}: `)).trim();
|
|
14
|
+
return answer || defaultValue || "";
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
readline.close();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/commands/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,MAAM,UAAU,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM;IACtE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB,EAAE,YAAqB;IAClE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,WAAW,CAAC,2BAA2B,QAAQ,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC5F,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1E,OAAO,MAAM,IAAI,YAAY,IAAI,EAAE,CAAC;IACtC,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/commands/runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Shell wrapper sourced via `eval "$(apollo shell-init)"` (installed into the
|
|
4
|
+
* user's rc file by the @aui.io/apollo postinstall). A child process cannot
|
|
5
|
+
* change the parent shell's cwd, so auto-cd after `workspace create/use` has
|
|
6
|
+
* to live in the shell itself. APOLLO_SHELL_WRAPPED lets the CLI drop the
|
|
7
|
+
* "cd <path>" tip when the wrapper is about to do it anyway.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SHELL_INIT_SCRIPT = "# apollo shell integration (zsh/bash)\napollo() {\n APOLLO_SHELL_WRAPPED=1 command apollo \"$@\"\n local apollo_exit=$?\n if [ \"$apollo_exit\" -eq 0 ] && [ \"$1\" = \"workspace\" ]; then\n case \"$2\" in\n create|use)\n # create/use just updated the default pointer; resolve it so name\n # arguments and the interactive picker land in the right directory.\n local apollo_target\n apollo_target=\"$(APOLLO_SHELL_WRAPPED=1 command apollo workspace default 2>/dev/null)\"\n if [ -n \"$apollo_target\" ] && [ -d \"$apollo_target\" ]; then\n cd \"$apollo_target\" || return\n fi\n ;;\n esac\n fi\n return \"$apollo_exit\"\n}\n";
|
|
10
|
+
export declare function registerShellInit(program: Command): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell wrapper sourced via `eval "$(apollo shell-init)"` (installed into the
|
|
3
|
+
* user's rc file by the @aui.io/apollo postinstall). A child process cannot
|
|
4
|
+
* change the parent shell's cwd, so auto-cd after `workspace create/use` has
|
|
5
|
+
* to live in the shell itself. APOLLO_SHELL_WRAPPED lets the CLI drop the
|
|
6
|
+
* "cd <path>" tip when the wrapper is about to do it anyway.
|
|
7
|
+
*/
|
|
8
|
+
export const SHELL_INIT_SCRIPT = `# apollo shell integration (zsh/bash)
|
|
9
|
+
apollo() {
|
|
10
|
+
APOLLO_SHELL_WRAPPED=1 command apollo "$@"
|
|
11
|
+
local apollo_exit=$?
|
|
12
|
+
if [ "$apollo_exit" -eq 0 ] && [ "$1" = "workspace" ]; then
|
|
13
|
+
case "$2" in
|
|
14
|
+
create|use)
|
|
15
|
+
# create/use just updated the default pointer; resolve it so name
|
|
16
|
+
# arguments and the interactive picker land in the right directory.
|
|
17
|
+
local apollo_target
|
|
18
|
+
apollo_target="$(APOLLO_SHELL_WRAPPED=1 command apollo workspace default 2>/dev/null)"
|
|
19
|
+
if [ -n "$apollo_target" ] && [ -d "$apollo_target" ]; then
|
|
20
|
+
cd "$apollo_target" || return
|
|
21
|
+
fi
|
|
22
|
+
;;
|
|
23
|
+
esac
|
|
24
|
+
fi
|
|
25
|
+
return "$apollo_exit"
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export function registerShellInit(program) {
|
|
29
|
+
program
|
|
30
|
+
.command("shell-init")
|
|
31
|
+
.description("Print the shell wrapper enabling auto-cd on workspace create/use")
|
|
32
|
+
.action(() => {
|
|
33
|
+
process.stdout.write(SHELL_INIT_SCRIPT);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../src/commands/shell.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,kEAAkE,CAAC;SAC/E,MAAM,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getStatus } from "@aui.io/apollo-core/services/status.service.js";
|
|
2
|
+
export function registerStatus(program, runtime) {
|
|
3
|
+
program
|
|
4
|
+
.command("status")
|
|
5
|
+
.description("Show the active Apollo context")
|
|
6
|
+
.option("--check", "check service connectivity and authorization")
|
|
7
|
+
.action(async (options) => {
|
|
8
|
+
const { context, output } = runtime();
|
|
9
|
+
if (options.check === true)
|
|
10
|
+
output.progress("Checking Apollo services...");
|
|
11
|
+
const status = await getStatus(context, { check: options.check });
|
|
12
|
+
output.result(status, (value) => renderStatus(value));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function renderStatus(status) {
|
|
16
|
+
const lines = [
|
|
17
|
+
`Environment: ${status.environment}`,
|
|
18
|
+
`Profile: ${status.profile}`,
|
|
19
|
+
`Workspace: ${renderWorkspace(status)}`,
|
|
20
|
+
`Authenticated: ${status.authenticated ? "yes" : "no"}`,
|
|
21
|
+
`Organization: ${renderOrganization(status)}`,
|
|
22
|
+
`Project: ${status.projectId ?? "not selected"}`,
|
|
23
|
+
`Agent: ${status.agentId ?? "not selected"}`,
|
|
24
|
+
`Version: ${status.versionTag ?? "not selected"}`,
|
|
25
|
+
`Token expiry: ${status.tokenExpiresAt ?? "unknown"}`,
|
|
26
|
+
];
|
|
27
|
+
if (status.checks !== undefined) {
|
|
28
|
+
lines.push("", "Services:");
|
|
29
|
+
for (const check of status.checks) {
|
|
30
|
+
const auth = check.authenticated === null
|
|
31
|
+
? "auth unknown"
|
|
32
|
+
: check.authenticated
|
|
33
|
+
? "authorized"
|
|
34
|
+
: "unauthorized";
|
|
35
|
+
lines.push(` ${check.service}: ${check.reachable ? "reachable" : "unreachable"}, ${auth}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return lines.join("\n");
|
|
39
|
+
}
|
|
40
|
+
function renderWorkspace(status) {
|
|
41
|
+
if (!status.workspaceRoot) {
|
|
42
|
+
return "none (cd into a workspace, or apollo workspace create <path>)";
|
|
43
|
+
}
|
|
44
|
+
return status.workspaceRoot;
|
|
45
|
+
}
|
|
46
|
+
function renderOrganization(status) {
|
|
47
|
+
const selected = status.orgId ?? status.tokenOrgId;
|
|
48
|
+
if (!selected)
|
|
49
|
+
return "not selected";
|
|
50
|
+
if (status.orgId &&
|
|
51
|
+
status.tokenOrgId &&
|
|
52
|
+
status.orgId !== status.tokenOrgId) {
|
|
53
|
+
return `${status.orgId} (token is scoped to ${status.tokenOrgId})`;
|
|
54
|
+
}
|
|
55
|
+
return selected;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAqB,MAAM,gDAAgD,CAAC;AAG9F,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,OAA6B;IAE7B,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,SAAS,EAAE,8CAA8C,CAAC;SACjE,MAAM,CAAC,KAAK,EAAE,OAA4B,EAAE,EAAE;QAC7C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI;YAAE,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAqB,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,YAAY,CAAC,MAAoB;IACxC,MAAM,KAAK,GAAG;QACZ,kBAAkB,MAAM,CAAC,WA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;IAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC;IACnD,IAAI,CAAC,QAAQ;QAAE,OAAO,cAAc,CAAC;IACrC,IACE,MAAM,CAAC,KAAK;QACZ,MAAM,CAAC,UAAU;QACjB,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,UAAU,EAClC,CAAC;QACD,OAAO,GAAG,MAAM,CAAC,KAAK,wBAAwB,MAAM,CAAC,UAAU,GAAG,CAAC;IACrE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { upgradeCli } from "@aui.io/apollo-core/services/upgrade.js";
|
|
2
|
+
import { CLI_PACKAGE_NAME, CLI_VERSION } from "../meta.js";
|
|
3
|
+
export function registerUpgrade(program, runtime) {
|
|
4
|
+
program
|
|
5
|
+
.command("upgrade")
|
|
6
|
+
.description("Upgrade Apollo from npm (@aui.io/apollo)")
|
|
7
|
+
.argument("[version]", "npm version or tag to install", "latest")
|
|
8
|
+
.option("--check", "show the available version without installing")
|
|
9
|
+
.option("--force", "reinstall even when already on the requested version")
|
|
10
|
+
.action(async (version, options) => {
|
|
11
|
+
const { output } = runtime();
|
|
12
|
+
if (options.check !== true) {
|
|
13
|
+
output.progress(options.force === true
|
|
14
|
+
? `Reinstalling Apollo (${version})...`
|
|
15
|
+
: `Upgrading Apollo (${version})...`);
|
|
16
|
+
}
|
|
17
|
+
const result = await upgradeCli(version, {
|
|
18
|
+
check: options.check === true,
|
|
19
|
+
force: options.force === true,
|
|
20
|
+
packageName: CLI_PACKAGE_NAME,
|
|
21
|
+
currentVersion: CLI_VERSION,
|
|
22
|
+
});
|
|
23
|
+
output.result(result, (value) => renderUpgrade(value));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function renderUpgrade(result) {
|
|
27
|
+
if (result.upgraded) {
|
|
28
|
+
return `Upgraded ${result.package} ${result.current} → ${result.available}.`;
|
|
29
|
+
}
|
|
30
|
+
if (result.current === result.available) {
|
|
31
|
+
return `${result.package} is already at ${result.current}.`;
|
|
32
|
+
}
|
|
33
|
+
return `${result.package} ${result.current} → ${result.available} available.`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../../src/commands/upgrade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAsB,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG3D,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,OAA6B;IAE7B,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,0CAA0C,CAAC;SACvD,QAAQ,CAAC,WAAW,EAAE,+BAA+B,EAAE,QAAQ,CAAC;SAChE,MAAM,CAAC,SAAS,EAAE,+CAA+C,CAAC;SAClE,MAAM,CAAC,SAAS,EAAE,sDAAsD,CAAC;SACzE,MAAM,CACL,KAAK,EACH,OAAe,EACf,OAA6C,EAC7C,EAAE;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,CACb,OAAO,CAAC,KAAK,KAAK,IAAI;gBACpB,CAAC,CAAC,wBAAwB,OAAO,MAAM;gBACvC,CAAC,CAAC,qBAAqB,OAAO,MAAM,CACvC,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE;YACvC,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,IAAI;YAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,IAAI;YAC7B,WAAW,EAAE,gBAAgB;YAC7B,cAAc,EAAE,WAAW;SAC5B,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAsB,CAAC,CAAC,CAAC;IAC1E,CAAC,CACF,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,MAAqB;IAC1C,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,YAAY,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,MAAM,MAAM,CAAC,SAAS,GAAG,CAAC;IAC/E,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;QACxC,OAAO,GAAG,MAAM,CAAC,OAAO,kBAAkB,MAAM,CAAC,OAAO,GAAG,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,MAAM,MAAM,CAAC,SAAS,aAAa,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { ConfigError } from "@aui.io/apollo-core/errors/index.js";
|
|
5
|
+
import { currentWorkspace, defaultWorkspacePath, forgetWorkspace, listWorkspaces, resolveWorkspacePath, selectWorkspace, } from "@aui.io/apollo-core/services/workspace.service.js";
|
|
6
|
+
import { findWorkspaceRoot } from "@aui.io/apollo-core/workspace/store.js";
|
|
7
|
+
import { canPrompt, prompt } from "./prompts.js";
|
|
8
|
+
export function registerWorkspace(program, runtime) {
|
|
9
|
+
const workspace = program
|
|
10
|
+
.command("workspace")
|
|
11
|
+
.description("Manage local Apollo workspaces")
|
|
12
|
+
.action(async () => showCurrent(runtime()));
|
|
13
|
+
workspace
|
|
14
|
+
.command("current")
|
|
15
|
+
.description("Show the workspace containing the current directory")
|
|
16
|
+
.action(async () => showCurrent(runtime()));
|
|
17
|
+
workspace
|
|
18
|
+
.command("list")
|
|
19
|
+
.description("List known workspaces (* default, > current) for the profile and environment")
|
|
20
|
+
.action(async () => {
|
|
21
|
+
const { context, output } = runtime();
|
|
22
|
+
const workspaces = await listWorkspaces(context);
|
|
23
|
+
output.result(workspaces, (value) => renderWorkspaces(value, context.workspaceRoot));
|
|
24
|
+
});
|
|
25
|
+
workspace
|
|
26
|
+
.command("create")
|
|
27
|
+
.description("Create a workspace and mark it as the default")
|
|
28
|
+
.argument("<path>")
|
|
29
|
+
.option("--name <name>", "display name (defaults to profile-env or the directory name)")
|
|
30
|
+
.action(async (root, options) => {
|
|
31
|
+
const { context, output } = runtime();
|
|
32
|
+
const result = await selectWorkspace(context, root, {
|
|
33
|
+
create: true,
|
|
34
|
+
...(options.name ? { name: options.name } : {}),
|
|
35
|
+
});
|
|
36
|
+
const notes = await selectionNotes(result.path);
|
|
37
|
+
output.result(result, () => [
|
|
38
|
+
`Created workspace ${label(result)}.`,
|
|
39
|
+
...notes,
|
|
40
|
+
`Then: apollo agent import <agent-id> or apollo agent create <name>.`,
|
|
41
|
+
].join("\n"));
|
|
42
|
+
});
|
|
43
|
+
workspace
|
|
44
|
+
.command("use")
|
|
45
|
+
.description("Pick the default workspace by name or path (interactive without an argument)")
|
|
46
|
+
.argument("[target]", "workspace name or path")
|
|
47
|
+
.action(async (target) => {
|
|
48
|
+
const { context, output } = runtime();
|
|
49
|
+
const root = target
|
|
50
|
+
? await resolveWorkspacePath(context, target)
|
|
51
|
+
: await pickWorkspace(runtime(), program);
|
|
52
|
+
const result = await selectWorkspace(context, root);
|
|
53
|
+
const notes = await selectionNotes(result.path);
|
|
54
|
+
output.result(result, () => [`Default workspace set to ${label(result)}.`, ...notes].join("\n"));
|
|
55
|
+
});
|
|
56
|
+
workspace
|
|
57
|
+
.command("forget")
|
|
58
|
+
.description("Drop a workspace from the known list (files stay on disk)")
|
|
59
|
+
.argument("<target>", "workspace name or path")
|
|
60
|
+
.action(async (target) => {
|
|
61
|
+
const { context, output } = runtime();
|
|
62
|
+
const result = await forgetWorkspace(context, target);
|
|
63
|
+
output.result(result, () => [
|
|
64
|
+
`Forgot workspace ${result.path}.`,
|
|
65
|
+
...(result.was_default ? ["It was the default — set a new one with apollo workspace use."] : []),
|
|
66
|
+
"Files were not deleted.",
|
|
67
|
+
].join("\n"));
|
|
68
|
+
});
|
|
69
|
+
workspace
|
|
70
|
+
.command("default")
|
|
71
|
+
.description("Print the default workspace path (used by shell integration)")
|
|
72
|
+
.action(async () => {
|
|
73
|
+
const { context, output } = runtime();
|
|
74
|
+
const root = await defaultWorkspacePath(context);
|
|
75
|
+
output.result({ path: root }, () => root);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** Numbered picker over known workspaces for bare `workspace use`. */
|
|
79
|
+
async function pickWorkspace({ context }, program) {
|
|
80
|
+
const global = program.opts();
|
|
81
|
+
if (global.json === true || !global.input || !canPrompt()) {
|
|
82
|
+
throw new ConfigError("A workspace name or path is required.", "Interactive selection needs a TTY without --json/--no-input.");
|
|
83
|
+
}
|
|
84
|
+
const workspaces = await listWorkspaces(context);
|
|
85
|
+
if (workspaces.length === 0) {
|
|
86
|
+
throw new ConfigError("No known workspaces.", "Run `apollo workspace create <path>` first.");
|
|
87
|
+
}
|
|
88
|
+
process.stderr.write(`${workspaces
|
|
89
|
+
.map((item, index) => `${index + 1}) ${item.active ? "*" : " "} ${displayName(item)} ${item.path}`)
|
|
90
|
+
.join("\n")}\n`);
|
|
91
|
+
const answer = await prompt(`Workspace [1-${workspaces.length}]`, "1");
|
|
92
|
+
const index = Number(answer);
|
|
93
|
+
if (!Number.isInteger(index) || index < 1 || index > workspaces.length) {
|
|
94
|
+
throw new ConfigError(`Invalid selection: ${answer}`);
|
|
95
|
+
}
|
|
96
|
+
return workspaces[index - 1].path;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Commands always follow the workspace containing the cwd, so selection only
|
|
100
|
+
* takes effect once the user actually moves there. Under the shell wrapper
|
|
101
|
+
* (APOLLO_SHELL_WRAPPED, see `apollo shell-init`) the shell auto-cds for us.
|
|
102
|
+
*/
|
|
103
|
+
async function selectionNotes(selected) {
|
|
104
|
+
if (process.env.APOLLO_SHELL_WRAPPED === "1")
|
|
105
|
+
return [];
|
|
106
|
+
const cwdRoot = await findWorkspaceRoot(process.cwd());
|
|
107
|
+
if (cwdRoot === selected)
|
|
108
|
+
return [];
|
|
109
|
+
const inside = cwdRoot
|
|
110
|
+
? [`You are currently inside workspace ${cwdRoot}.`]
|
|
111
|
+
: [];
|
|
112
|
+
return [
|
|
113
|
+
...inside,
|
|
114
|
+
`Commands follow your current directory — cd ${selected} to work in it.`,
|
|
115
|
+
shellIntegrationHint(),
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Reaching this point means the auto-cd wrapper is not active in this shell
|
|
120
|
+
* session. npm hides postinstall output, so this is the user's only signal;
|
|
121
|
+
* tell them whether a one-time source or a full setup is needed.
|
|
122
|
+
*/
|
|
123
|
+
function shellIntegrationHint() {
|
|
124
|
+
const home = os.homedir();
|
|
125
|
+
const installed = [".zshrc", ".bashrc", ".bash_profile"].some((name) => {
|
|
126
|
+
try {
|
|
127
|
+
return readFileSync(path.join(home, name), "utf8").includes("apollo shell-init");
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return installed
|
|
134
|
+
? "Tip: auto-cd is installed but not active in this session — open a new terminal or source your shell rc (e.g. `source ~/.zshrc`)."
|
|
135
|
+
: 'Tip: enable auto-cd with `eval "$(apollo shell-init)"` (add it to your shell rc to make it permanent).';
|
|
136
|
+
}
|
|
137
|
+
async function showCurrent({ context, output }) {
|
|
138
|
+
const current = await currentWorkspace(context);
|
|
139
|
+
output.result(current, (value) => renderCurrent(value));
|
|
140
|
+
}
|
|
141
|
+
function displayName(workspace) {
|
|
142
|
+
return workspace.name ?? path.basename(workspace.path);
|
|
143
|
+
}
|
|
144
|
+
function label(workspace) {
|
|
145
|
+
return workspace.name
|
|
146
|
+
? `${workspace.name} (${workspace.path})`
|
|
147
|
+
: workspace.path;
|
|
148
|
+
}
|
|
149
|
+
function renderCurrent(workspace) {
|
|
150
|
+
return [
|
|
151
|
+
`Workspace: ${workspace.path}`,
|
|
152
|
+
`Name: ${displayName(workspace)}`,
|
|
153
|
+
`Agents: ${workspace.agent_count ?? "unavailable"}`,
|
|
154
|
+
`Active agent: ${workspace.active_agent_id ?? "not selected"}`,
|
|
155
|
+
`Active project: ${workspace.active_project_id ?? "not selected"}`,
|
|
156
|
+
].join("\n");
|
|
157
|
+
}
|
|
158
|
+
function renderWorkspaces(workspaces, currentRoot) {
|
|
159
|
+
if (workspaces.length === 0)
|
|
160
|
+
return "No workspaces configured.";
|
|
161
|
+
const lines = workspaces.map((workspace) => {
|
|
162
|
+
const markers = `${workspace.active ? "*" : " "}${workspace.path === currentRoot ? ">" : " "}`;
|
|
163
|
+
const agents = workspace.agent_count === null
|
|
164
|
+
? "missing?"
|
|
165
|
+
: `${workspace.agent_count} agents`;
|
|
166
|
+
return `${markers} ${displayName(workspace).padEnd(24)} ${workspace.path}\t${agents}`;
|
|
167
|
+
});
|
|
168
|
+
return [...lines, "", "* default · > current directory"].join("\n");
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/commands/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,GAEhB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,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command } from "commander";
|
|
2
|
+
import { type Context } from "@aui.io/apollo-core/config/index.js";
|
|
3
|
+
import { Output } from "@aui.io/apollo-core/output/index.js";
|
|
4
|
+
interface ProgramState {
|
|
5
|
+
context?: Context;
|
|
6
|
+
output?: Output;
|
|
7
|
+
}
|
|
8
|
+
export declare function createProgram(state?: ProgramState): Command;
|
|
9
|
+
export declare function main(argv?: string[]): Promise<number>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Command, CommanderError, Option } from "commander";
|
|
2
|
+
import { normalizeArgv } from "@aui.io/apollo-core/argv.js";
|
|
3
|
+
import { registerEnv } from "./commands/env.js";
|
|
4
|
+
import { registerAuth } from "./commands/auth.js";
|
|
5
|
+
import { registerBundles } from "./commands/bundles.js";
|
|
6
|
+
import { registerHierarchy } from "./commands/hierarchy.js";
|
|
7
|
+
import { registerOperate } from "./commands/operate.js";
|
|
8
|
+
import { registerProfile } from "./commands/profile.js";
|
|
9
|
+
import { registerStatus } from "./commands/status.js";
|
|
10
|
+
import { registerUpgrade } from "./commands/upgrade.js";
|
|
11
|
+
import { registerMockDb } from "./commands/mockdb.js";
|
|
12
|
+
import { registerShellInit } from "./commands/shell.js";
|
|
13
|
+
import { registerWorkspace } from "./commands/workspace.js";
|
|
14
|
+
import { resolveContext, } from "@aui.io/apollo-core/config/index.js";
|
|
15
|
+
import { ConfigError, toCliError } from "@aui.io/apollo-core/errors/index.js";
|
|
16
|
+
import { CLI_VERSION } from "./meta.js";
|
|
17
|
+
import { Output } from "@aui.io/apollo-core/output/index.js";
|
|
18
|
+
import { renderWelcome, welcomeData } from "./output/welcome.js";
|
|
19
|
+
export function createProgram(state = {}) {
|
|
20
|
+
const program = new Command()
|
|
21
|
+
.name("apollo")
|
|
22
|
+
.description("Manage and operate Apollo agents")
|
|
23
|
+
.version(CLI_VERSION)
|
|
24
|
+
.option("--json", "emit a stable JSON envelope")
|
|
25
|
+
.option("--quiet", "suppress progress and warnings")
|
|
26
|
+
.option("--verbose", "show diagnostic details")
|
|
27
|
+
.option("--no-input", "disable interactive input")
|
|
28
|
+
.option("--yes", "confirm prompts")
|
|
29
|
+
.option("--profile <name>", "override the active profile for this command")
|
|
30
|
+
.option("--project <id>", "override the active project")
|
|
31
|
+
.option("--org <id>", "override the active organization")
|
|
32
|
+
.addOption(new Option("--workspace <path-or-name>", "run as if inside this workspace (for scripts/CI)").env("APOLLO_WORKSPACE"))
|
|
33
|
+
.addOption(new Option("--timeout <ms>", "request timeout in milliseconds").env("APOLLO_TIMEOUT_MS"))
|
|
34
|
+
.showHelpAfterError()
|
|
35
|
+
.exitOverride()
|
|
36
|
+
.configureOutput({ writeErr: () => undefined })
|
|
37
|
+
.action(() => {
|
|
38
|
+
// Bare `apollo` (no subcommand): branded intro instead of raw help.
|
|
39
|
+
// Without a root action, Commander treats missing command as an error.
|
|
40
|
+
const { output } = runtime();
|
|
41
|
+
const color = Boolean(process.stdout.isTTY) && !output.options.json;
|
|
42
|
+
output.result(welcomeData(), () => renderWelcome(color));
|
|
43
|
+
});
|
|
44
|
+
program.hook("preAction", async () => {
|
|
45
|
+
const options = program.opts();
|
|
46
|
+
state.output = new Output({
|
|
47
|
+
json: options.json === true,
|
|
48
|
+
quiet: options.quiet === true,
|
|
49
|
+
verbose: options.verbose === true,
|
|
50
|
+
});
|
|
51
|
+
const flags = {
|
|
52
|
+
...(options.profile === undefined ? {} : { profile: options.profile }),
|
|
53
|
+
...(options.project === undefined ? {} : { project: options.project }),
|
|
54
|
+
...(options.org === undefined ? {} : { org: options.org }),
|
|
55
|
+
...(options.timeout === undefined ? {} : { timeout: options.timeout }),
|
|
56
|
+
...(options.workspace === undefined ? {} : { workspace: options.workspace }),
|
|
57
|
+
};
|
|
58
|
+
state.context = await resolveContext({ flags });
|
|
59
|
+
});
|
|
60
|
+
const runtime = () => {
|
|
61
|
+
if (state.context === undefined || state.output === undefined) {
|
|
62
|
+
throw new ConfigError("Command context was not initialized.");
|
|
63
|
+
}
|
|
64
|
+
return { context: state.context, output: state.output };
|
|
65
|
+
};
|
|
66
|
+
registerStatus(program, runtime);
|
|
67
|
+
registerUpgrade(program, runtime);
|
|
68
|
+
registerEnv(program, runtime);
|
|
69
|
+
registerProfile(program, runtime);
|
|
70
|
+
registerWorkspace(program, runtime);
|
|
71
|
+
registerAuth(program, runtime);
|
|
72
|
+
registerHierarchy(program, runtime);
|
|
73
|
+
registerBundles(program, runtime);
|
|
74
|
+
registerOperate(program, runtime);
|
|
75
|
+
registerMockDb(program, runtime);
|
|
76
|
+
registerShellInit(program);
|
|
77
|
+
return program;
|
|
78
|
+
}
|
|
79
|
+
export async function main(argv = process.argv) {
|
|
80
|
+
const state = {};
|
|
81
|
+
const program = createProgram(state);
|
|
82
|
+
try {
|
|
83
|
+
await program.parseAsync(normalizeArgv(argv));
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (error instanceof CommanderError &&
|
|
88
|
+
(error.exitCode === 0 ||
|
|
89
|
+
error.code === "commander.helpDisplayed" ||
|
|
90
|
+
error.code === "commander.help")) {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
const cliError = error instanceof CommanderError
|
|
94
|
+
? new ConfigError(error.message)
|
|
95
|
+
: toCliError(error);
|
|
96
|
+
const options = program.opts();
|
|
97
|
+
const output = state.output ??
|
|
98
|
+
new Output({
|
|
99
|
+
json: options.json === true,
|
|
100
|
+
quiet: options.quiet === true,
|
|
101
|
+
verbose: options.verbose === true,
|
|
102
|
+
});
|
|
103
|
+
output.error(cliError);
|
|
104
|
+
return cliError.exitCode;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;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