@gaia-ai/gaia 0.5.5 → 0.6.1

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/gaia CHANGED
@@ -1,2 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import('@gaia-ai/conductor').then((m) => m.main(process.argv));
2
+ // GAIA-201: the `gaia` entrypoint lives in the meta package now (AC-1). It runs
3
+ // the plugin host, which dynamically mounts the ui/conductor/dropsh command
4
+ // plugins — conductor is no longer the CLI owner.
5
+ import('../dist/src/host.js').then((m) => m.main(process.argv));
@@ -0,0 +1,31 @@
1
+ import { type CommandDescriptor } from '@gaia-ai/core';
2
+ import { Command } from 'commander';
3
+ /** The built-in command registry. `$GAIA_COMMANDS` (JSON array of descriptors)
4
+ * overrides it wholesale. */
5
+ export declare const DEFAULT_COMMANDS: CommandDescriptor[];
6
+ /** Resolve the registry: `$GAIA_COMMANDS` override else the built-in set. */
7
+ export declare function resolveCommands(): CommandDescriptor[];
8
+ /** The installed CLI version (the meta package version). */
9
+ export declare function resolveCliVersion(): string;
10
+ /** Host bases for ESLint-style sibling resolution: the meta install → cwd. */
11
+ export declare function hostBases(): string[];
12
+ /**
13
+ * Value-aware argv pre-scan: find the first positional token that names a
14
+ * registered command. Skips the host's value-taking global (`--conductor <v>`)
15
+ * and maps `help <name>` → `<name>`. Returns undefined for `--help`, an unknown
16
+ * first positional, or a bare invocation.
17
+ */
18
+ export declare function scanTarget(argv: string[], names: string[]): string | undefined;
19
+ /** Build the top-level host program, mounting only the target command (the rest
20
+ * are describe-only stubs). */
21
+ export declare function buildHostProgram(argv: string[], opts?: {
22
+ forceTarget?: string;
23
+ bases?: string[];
24
+ }): Promise<Command>;
25
+ /** Parse argv against the host program, mapping commander's clean exits. */
26
+ export declare function runHost(argv: string[], opts?: {
27
+ forceTarget?: string;
28
+ bases?: string[];
29
+ }): Promise<void>;
30
+ /** The `gaia` entrypoint: drop node + script path, run the host. */
31
+ export declare function main(argv: string[]): Promise<void>;
@@ -0,0 +1,228 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
+ import { commands as deploymentCommands } from '@gaia-ai/addon-deployment/preset';
5
+ import { commands as dropshCommands } from '@gaia-ai/addon-dropsh/preset';
6
+ import { commands as conductorCommands } from '@gaia-ai/conductor/preset';
7
+ import { resolveModuleEslintStyle, } from '@gaia-ai/core';
8
+ import { commands as uiCommands } from '@gaia-ai/ui/preset';
9
+ import { Command } from 'commander';
10
+ import { registerUpgrade } from './upgrade.js';
11
+ // GAIA-201: the `gaia` plugin HOST. The meta package `@gaia-ai/gaia` owns the
12
+ // CLI entrypoint (AC-1); ui / conductor / dropsh / deployment are declared,
13
+ // ESLint-style resolved, LAZILY mounted command plugins (AC-2). The host
14
+ // discovers + mounts; it hard-wires nothing. Only the invoked subcommand's module
15
+ // is imported — `gaia --help` lists all four via describe-only stubs and imports
16
+ // none; `gaia conductor …` imports only the conductor module.
17
+ //
18
+ // GAIA-215: the registry is DERIVED from the command surface — the command
19
+ // addons' preset `commands` accumulators — rather than a hand-written list.
20
+ // Those presets are LIGHT (they import no runtime, only return descriptors), so
21
+ // composing them at boot keeps `gaia --help` import-light. `$GAIA_COMMANDS`
22
+ // still overrides the whole registry. GAIA-224 (Finding 7) added the fourth
23
+ // command surface, `@gaia-ai/addon-deployment` (`gaia deployment …`), which the
24
+ // `conductor` command plugin used to register as a side effect.
25
+ /** Compose the built-in command registry from the command addons' presets. The
26
+ * accumulators are synchronous descriptor builders (light presets), threaded in
27
+ * the conductor → ui → dropsh → deployment order. */
28
+ function composeCommandSurface() {
29
+ const accumulators = [
30
+ conductorCommands,
31
+ uiCommands,
32
+ dropshCommands,
33
+ deploymentCommands,
34
+ ];
35
+ let acc = [];
36
+ for (const fn of accumulators) {
37
+ if (typeof fn === 'function')
38
+ acc = fn(acc, undefined);
39
+ }
40
+ return acc;
41
+ }
42
+ /** The built-in command registry. `$GAIA_COMMANDS` (JSON array of descriptors)
43
+ * overrides it wholesale. */
44
+ export const DEFAULT_COMMANDS = composeCommandSurface();
45
+ /** Resolve the registry: `$GAIA_COMMANDS` override else the built-in set. */
46
+ export function resolveCommands() {
47
+ const override = process.env.GAIA_COMMANDS;
48
+ if (override && override.trim() !== '') {
49
+ const parsed = JSON.parse(override);
50
+ if (!Array.isArray(parsed)) {
51
+ throw new Error('$GAIA_COMMANDS must be a JSON array of command descriptors');
52
+ }
53
+ return parsed;
54
+ }
55
+ return DEFAULT_COMMANDS;
56
+ }
57
+ /** The meta package root (holds package.json), for version + resolveBases. */
58
+ function metaPackageRoot() {
59
+ let dir = dirname(fileURLToPath(import.meta.url));
60
+ for (;;) {
61
+ try {
62
+ readFileSync(join(dir, 'package.json'), 'utf8');
63
+ return dir;
64
+ }
65
+ catch {
66
+ const parent = dirname(dir);
67
+ if (parent === dir)
68
+ return dir;
69
+ dir = parent;
70
+ }
71
+ }
72
+ }
73
+ /** The installed CLI version (the meta package version). */
74
+ export function resolveCliVersion() {
75
+ try {
76
+ const pkg = JSON.parse(readFileSync(join(metaPackageRoot(), 'package.json'), 'utf8'));
77
+ return pkg.version ?? '0.0.0';
78
+ }
79
+ catch {
80
+ return '0.0.0';
81
+ }
82
+ }
83
+ /** Host bases for ESLint-style sibling resolution: the meta install → cwd. */
84
+ export function hostBases() {
85
+ return [import.meta.url, pathToFileURL(`${process.cwd()}/`).href];
86
+ }
87
+ /** Load a command descriptor's `GaiaCommandPlugin` (default export, or the named
88
+ * `export`), resolving the module over the host bases. */
89
+ async function loadCommandPlugin(entry, bases) {
90
+ const resolved = resolveModuleEslintStyle(entry.plugin, bases);
91
+ if (resolved === undefined) {
92
+ throw new Error(`gaia: cannot resolve command plugin '${entry.plugin}' (command '${entry.name}')`);
93
+ }
94
+ const mod = (await import(pathToFileURL(resolved).href));
95
+ const factory = entry.export ? mod[entry.export] : mod.default;
96
+ if (factory === undefined || factory === null) {
97
+ throw new Error(`gaia: command plugin '${entry.plugin}' has no ${entry.export ?? 'default'} export`);
98
+ }
99
+ return factory;
100
+ }
101
+ /**
102
+ * Value-aware argv pre-scan: find the first positional token that names a
103
+ * registered command. Skips the host's value-taking global (`--conductor <v>`)
104
+ * and maps `help <name>` → `<name>`. Returns undefined for `--help`, an unknown
105
+ * first positional, or a bare invocation.
106
+ */
107
+ export function scanTarget(argv, names) {
108
+ for (let i = 0; i < argv.length; i++) {
109
+ const a = argv[i];
110
+ if (a === '--conductor') {
111
+ i++; // skip its value
112
+ continue;
113
+ }
114
+ if (a === 'help') {
115
+ const next = argv[i + 1];
116
+ return next !== undefined && names.includes(next) ? next : undefined;
117
+ }
118
+ if (a.startsWith('-'))
119
+ continue; // any other flag
120
+ return names.includes(a) ? a : undefined;
121
+ }
122
+ return undefined;
123
+ }
124
+ /** Add a describe-only stub for a not-loaded command so `--help` stays complete.
125
+ * If it is ever dispatched (a mis-scan), its action self-loads the real plugin
126
+ * and re-runs the host forcing that target. */
127
+ function addStub(program, entry, bases, argv) {
128
+ program
129
+ .command(entry.name)
130
+ .description(pluginDescribe(entry))
131
+ .allowUnknownOption(true)
132
+ .allowExcessArguments(true)
133
+ .helpOption(false)
134
+ .action(async () => {
135
+ await runHost(argv, { forceTarget: entry.name, bases });
136
+ });
137
+ }
138
+ /** Best-effort describe text for a stub without importing the plugin. GAIA-215:
139
+ * the descriptor now carries its own `describe` (from the addon's preset); this
140
+ * falls back only for a `$GAIA_COMMANDS` entry that omits it. */
141
+ function pluginDescribe(entry) {
142
+ if (typeof entry.describe === 'string' && entry.describe.trim() !== '') {
143
+ return entry.describe;
144
+ }
145
+ switch (entry.name) {
146
+ case 'conductor':
147
+ return 'node-agent lifecycle + local registry';
148
+ case 'ui':
149
+ return 'interactive terminal UI: project dashboard, ticket list, ticket detail';
150
+ case 'dropsh':
151
+ return 'JSON:API shell (dropsh) bound to the GAIA connection config';
152
+ case 'deployment':
153
+ return 'release / deployment helpers';
154
+ default:
155
+ return `${entry.name} command`;
156
+ }
157
+ }
158
+ /** Build the top-level host program, mounting only the target command (the rest
159
+ * are describe-only stubs). */
160
+ export async function buildHostProgram(argv, opts = {}) {
161
+ const bases = opts.bases ?? hostBases();
162
+ const host = { resolveBases: bases };
163
+ const commands = resolveCommands();
164
+ const names = commands.map((c) => c.name);
165
+ const program = new Command();
166
+ // exitOverride so commander surfaces help/version/unknown-command as thrown
167
+ // CommanderErrors (mapped in runHost) instead of calling process.exit —
168
+ // otherwise an unknown command would kill the host process directly.
169
+ program.exitOverride();
170
+ program
171
+ .name('gaia')
172
+ .description('GAIA conductor + client CLI')
173
+ .option('--conductor <name>', 'select a conductor by stem (conductor→conductor.config.js, else <name>.conductor.config.js; env $GAIA_CONDUCTOR)');
174
+ // The global --conductor flag threads into $GAIA_CONDUCTOR (flag wins over env)
175
+ // so every command selects the named engine config without per-command wiring.
176
+ program.hook('preAction', () => {
177
+ const name = program.opts().conductor;
178
+ if (typeof name === 'string' && name !== '') {
179
+ process.env.GAIA_CONDUCTOR = name;
180
+ }
181
+ });
182
+ const cliVersion = resolveCliVersion();
183
+ program.version(cliVersion); // -V, --version
184
+ program
185
+ .command('version')
186
+ .description('output the gaia CLI version')
187
+ .action(() => {
188
+ console.log(cliVersion);
189
+ });
190
+ registerUpgrade(program);
191
+ const target = opts.forceTarget ?? scanTarget(argv, names);
192
+ for (const entry of commands) {
193
+ if (entry.name === target) {
194
+ const plugin = await loadCommandPlugin(entry, bases);
195
+ await plugin.register(program, host);
196
+ }
197
+ else {
198
+ addStub(program, entry, bases, argv);
199
+ }
200
+ }
201
+ return program;
202
+ }
203
+ /** Parse argv against the host program, mapping commander's clean exits. */
204
+ export async function runHost(argv, opts = {}) {
205
+ const program = await buildHostProgram(argv, opts);
206
+ try {
207
+ await program.parseAsync(argv, { from: 'user' });
208
+ }
209
+ catch (err) {
210
+ const e = err;
211
+ if (e.code === 'commander.helpDisplayed' ||
212
+ e.code === 'commander.version') {
213
+ return;
214
+ }
215
+ if (typeof e.code === 'string' && e.code.startsWith('commander.')) {
216
+ if (!process.exitCode)
217
+ process.exitCode = 1;
218
+ return;
219
+ }
220
+ process.stderr.write(`${e.message ?? String(err)}\n`);
221
+ if (!process.exitCode)
222
+ process.exitCode = 1;
223
+ }
224
+ }
225
+ /** The `gaia` entrypoint: drop node + script path, run the host. */
226
+ export async function main(argv) {
227
+ await runHost(argv.slice(2));
228
+ }
@@ -1 +1,4 @@
1
- export * from '@gaia-ai/core/plugins';
1
+ export { basicAuthProvider } from '@gaia-ai/addon-auth-basic';
2
+ export { DrupalGaiaRemote, drupalRemote } from '@gaia-ai/addon-remote-drupal';
3
+ export { GitWorkspace, gitWorkspace, loadInstructions, } from '@gaia-ai/addon-workspace-git';
4
+ export { type AgentCandidate, type ResolvedAgent, selectAgent, selectAgents, selectExecutor, selectRemote, selectWorkspace, } from '@gaia-ai/conductor/contract';
@@ -1 +1,16 @@
1
- export * from '@gaia-ai/core/plugins';
1
+ // GAIA-224 (Finding 6, decision 11): the `@gaia-ai/gaia/plugins` BACK-COMPAT
2
+ // barrel. It used to be a single `export * from '@gaia-ai/core/plugins'`; that
3
+ // core barrel is deleted, because core no longer ships plugin implementations.
4
+ // The barrel itself stays (published configs may still name
5
+ // `{ plugin: '@gaia-ai/gaia/plugins', export: 'drupalRemote' }`), but it now
6
+ // aggregates the CONTRIBUTIONS from where they actually live: the impl addons +
7
+ // the conductor-surface selectors. "plugins" is the right word for a
8
+ // contribution barrel (decision 16) — only the *package* prefix became `addon-`.
9
+ //
10
+ // The fakes (`fakeRemote`/`fakeWorkspace`) are deliberately NOT re-exported:
11
+ // they moved into `@gaia-ai/addon-fake`, a workspace-only test fixture that is
12
+ // never published, so the published meta package must not depend on it.
13
+ export { basicAuthProvider } from '@gaia-ai/addon-auth-basic';
14
+ export { DrupalGaiaRemote, drupalRemote } from '@gaia-ai/addon-remote-drupal';
15
+ export { GitWorkspace, gitWorkspace, loadInstructions, } from '@gaia-ai/addon-workspace-git';
16
+ export { selectAgent, selectAgents, selectExecutor, selectRemote, selectWorkspace, } from '@gaia-ai/conductor/contract';
@@ -0,0 +1,21 @@
1
+ import { type ProjectConnectionChoice } from '@gaia-ai/conductor';
2
+ import type { Command } from 'commander';
3
+ /**
4
+ * GAIA-218 (AC-3, AC-4): resolve what to do with the PROJECT connection override.
5
+ * Default no in every branch — only an explicit yes opts in. Non-interactive
6
+ * (no TTY) ⇒ always `skip`. The prompt is injected so the host test can stub it.
7
+ *
8
+ * - existing project `gaia.config.js` → "remove this override? [y/N]" → `remove`|`skip`
9
+ * - none → "create an override? [y/N]" → `create`|`skip`
10
+ */
11
+ export declare function resolveProjectConnectionChoice(opts: {
12
+ existing: string | undefined;
13
+ isTTY: boolean;
14
+ prompt: (question: string) => Promise<boolean>;
15
+ }): Promise<ProjectConnectionChoice>;
16
+ /** Register `gaia upgrade` on the host program. `deps` is injectable for tests. */
17
+ export declare function registerUpgrade(program: Command, deps?: {
18
+ prompt?: (question: string) => Promise<boolean>;
19
+ isTTY?: boolean;
20
+ cwd?: string;
21
+ }): void;
@@ -0,0 +1,64 @@
1
+ import { createInterface } from 'node:readline';
2
+ import { hasProjectConnection, runUpgrade, } from '@gaia-ai/conductor';
3
+ // GAIA-216: the `gaia upgrade` migration/seed routine was hoisted DOWN into the
4
+ // engine (`@gaia-ai/conductor`) so `conductor init` can call it intra-package
5
+ // without a host→engine→host cycle. The host keeps the thin CLI registration
6
+ // below plus the GAIA-218 TTY interaction that resolves the PROJECT connection
7
+ // decision. See `gaia-cli/conductor/src/cli/upgrade.ts` for `runUpgrade` +
8
+ // `UpgradeReport`.
9
+ /** Ask a yes/no question on the terminal; anything but an explicit yes is no. */
10
+ async function promptYesNo(question) {
11
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
12
+ try {
13
+ const answer = await new Promise((resolve) => rl.question(question, resolve));
14
+ const a = answer.trim().toLowerCase();
15
+ return a === 'y' || a === 'yes';
16
+ }
17
+ finally {
18
+ rl.close();
19
+ }
20
+ }
21
+ /**
22
+ * GAIA-218 (AC-3, AC-4): resolve what to do with the PROJECT connection override.
23
+ * Default no in every branch — only an explicit yes opts in. Non-interactive
24
+ * (no TTY) ⇒ always `skip`. The prompt is injected so the host test can stub it.
25
+ *
26
+ * - existing project `gaia.config.js` → "remove this override? [y/N]" → `remove`|`skip`
27
+ * - none → "create an override? [y/N]" → `create`|`skip`
28
+ */
29
+ export async function resolveProjectConnectionChoice(opts) {
30
+ if (!opts.isTTY)
31
+ return 'skip';
32
+ if (opts.existing !== undefined) {
33
+ const yes = await opts.prompt(`remove this project connection override (${opts.existing})? [y/N] `);
34
+ return yes ? 'remove' : 'skip';
35
+ }
36
+ const yes = await opts.prompt('create a project connection override for this repo? [y/N] ');
37
+ return yes ? 'create' : 'skip';
38
+ }
39
+ /** Register `gaia upgrade` on the host program. `deps` is injectable for tests. */
40
+ export function registerUpgrade(program, deps = {}) {
41
+ program
42
+ .command('upgrade')
43
+ .description('migrate this install: the split config model (gaia.config.js connection + conductor.config.js engine; ~/.gaia/machine.config.js) and the GAIA-224 addon package names (@gaia-ai/plugin-*, @gaia-ai/core/builtins and @gaia-ai/core/plugins → @gaia-ai/addon-*). Prompts before creating/removing a project connection override.')
44
+ .option('--dry-run', 'print the migration plan without writing anything', false)
45
+ .action(async (opts) => {
46
+ const cwd = deps.cwd ?? process.cwd();
47
+ const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
48
+ const prompt = deps.prompt ?? promptYesNo;
49
+ const projectConnection = await resolveProjectConnectionChoice({
50
+ existing: hasProjectConnection(cwd),
51
+ isTTY,
52
+ prompt,
53
+ });
54
+ const report = runUpgrade({ dryRun: opts.dryRun, projectConnection });
55
+ for (const line of report.actions)
56
+ console.log(line);
57
+ if (report.alreadyCurrent)
58
+ console.log('gaia upgrade: already current');
59
+ else if (opts.dryRun)
60
+ console.log('gaia upgrade: dry run (no changes written)');
61
+ else
62
+ console.log('gaia upgrade: done');
63
+ });
64
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gaia-ai/gaia",
3
- "version": "0.5.5",
4
- "description": "GAIA meta package: installs the conductor CLI + all runtime plugins. Global install target.",
3
+ "version": "0.6.1",
4
+ "description": "GAIA meta package: the `gaia` plugin-host CLI + all runtime plugins. Global install target.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -11,6 +11,7 @@
11
11
  "gaia": "./bin/gaia"
12
12
  },
13
13
  "exports": {
14
+ "./host": "./dist/src/host.js",
14
15
  "./plugins": "./dist/src/plugins-barrel.js",
15
16
  "./package.json": "./package.json"
16
17
  },
@@ -26,7 +27,7 @@
26
27
  "repository": {
27
28
  "type": "git",
28
29
  "url": "git+https://git.key-tec.de/keytec/gaia.git",
29
- "directory": "conductor/packages/gaia"
30
+ "directory": "gaia-cli/host"
30
31
  },
31
32
  "keywords": [
32
33
  "gaia",
@@ -37,13 +38,22 @@
37
38
  "jsonapi"
38
39
  ],
39
40
  "dependencies": {
40
- "@gaia-ai/conductor": "^0.5.5",
41
- "@gaia-ai/core": "^0.5.5",
42
- "@gaia-ai/plugin-claude": "^0.5.5",
43
- "@gaia-ai/plugin-codex": "^0.5.5",
44
- "@gaia-ai/plugin-essentials": "^0.5.5",
45
- "@gaia-ai/plugin-herdr": "^0.5.5",
46
- "@gaia-ai/plugin-kimi": "^0.5.5",
47
- "@gaia-ai/plugin-opencode": "^0.5.5"
41
+ "@gaia-ai/addon-auth-basic": "^0.6.1",
42
+ "@gaia-ai/addon-claude": "^0.6.1",
43
+ "@gaia-ai/addon-codex": "^0.6.1",
44
+ "@gaia-ai/addon-deployment": "^0.6.1",
45
+ "@gaia-ai/addon-dropsh": "^0.6.1",
46
+ "@gaia-ai/addon-essentials": "^0.6.1",
47
+ "@gaia-ai/addon-gaia-ui": "^0.6.1",
48
+ "@gaia-ai/addon-herdr": "^0.6.1",
49
+ "@gaia-ai/addon-kimi": "^0.6.1",
50
+ "@gaia-ai/addon-opencode": "^0.6.1",
51
+ "@gaia-ai/addon-pi": "^0.6.1",
52
+ "@gaia-ai/addon-remote-drupal": "^0.6.1",
53
+ "@gaia-ai/addon-workspace-git": "^0.6.1",
54
+ "@gaia-ai/conductor": "^0.6.1",
55
+ "@gaia-ai/core": "^0.6.1",
56
+ "@gaia-ai/ui": "^0.6.1",
57
+ "commander": "^12.1.0"
48
58
  }
49
59
  }