@gaia-ai/gaia 0.7.0 → 0.9.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.
@@ -5,8 +5,7 @@ import { Command } from 'commander';
5
5
  export declare const DEFAULT_COMMANDS: CommandDescriptor[];
6
6
  /** Resolve the registry: `$GAIA_COMMANDS` override else the built-in set. */
7
7
  export declare function resolveCommands(): CommandDescriptor[];
8
- /** The installed CLI version (the meta package version). */
9
- export declare function resolveCliVersion(): string;
8
+ export { resolveCliVersion } from '@gaia-ai/core';
10
9
  /** Host bases for ESLint-style sibling resolution: the meta install → cwd. */
11
10
  export declare function hostBases(): string[];
12
11
  /**
package/dist/src/host.js CHANGED
@@ -1,12 +1,11 @@
1
- import { readFileSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { fileURLToPath, pathToFileURL } from 'node:url';
1
+ import { pathToFileURL } from 'node:url';
4
2
  import { commands as deploymentCommands } from '@gaia-ai/addon-deployment/preset';
5
3
  import { commands as dropshCommands } from '@gaia-ai/addon-dropsh/preset';
6
4
  import { commands as conductorCommands } from '@gaia-ai/conductor/preset';
7
- import { resolveModuleEslintStyle, } from '@gaia-ai/core';
5
+ import { resolveCliVersion, resolveModuleEslintStyle, } from '@gaia-ai/core';
8
6
  import { commands as uiCommands } from '@gaia-ai/ui/preset';
9
7
  import { Command } from 'commander';
8
+ import { registerUpdate } from './update.js';
10
9
  import { registerUpgrade } from './upgrade.js';
11
10
  // GAIA-201: the `gaia` plugin HOST. The meta package `@gaia-ai/gaia` owns the
12
11
  // CLI entrypoint (AC-1); ui / conductor / dropsh / deployment are declared,
@@ -54,32 +53,7 @@ export function resolveCommands() {
54
53
  }
55
54
  return DEFAULT_COMMANDS;
56
55
  }
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
- }
56
+ export { resolveCliVersion } from '@gaia-ai/core';
83
57
  /** Host bases for ESLint-style sibling resolution: the meta install → cwd. */
84
58
  export function hostBases() {
85
59
  return [import.meta.url, pathToFileURL(`${process.cwd()}/`).href];
@@ -188,6 +162,7 @@ export async function buildHostProgram(argv, opts = {}) {
188
162
  console.log(cliVersion);
189
163
  });
190
164
  registerUpgrade(program);
165
+ registerUpdate(program);
191
166
  const target = opts.forceTarget ?? scanTarget(argv, names);
192
167
  for (const entry of commands) {
193
168
  if (entry.name === target) {
@@ -0,0 +1,15 @@
1
+ import type { Command } from 'commander';
2
+ export type SpawnUpdate = (cmd: string, args: string[]) => Promise<number>;
3
+ export type SpawnCapture = (cmd: string, args: string[]) => Promise<{
4
+ code: number;
5
+ stdout: string;
6
+ }>;
7
+ export interface UpdateOptions {
8
+ out?: (line: string) => void;
9
+ }
10
+ export declare function runUpdate(run?: SpawnUpdate, query?: SpawnCapture, options?: UpdateOptions): Promise<{
11
+ ok: boolean;
12
+ before: string | null;
13
+ after: string | null;
14
+ }>;
15
+ export declare function registerUpdate(program: Command): void;
@@ -0,0 +1,59 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { GAIA_PACKAGE } from '@gaia-ai/core';
3
+ const spawnUpdate = (cmd, args) => new Promise((resolve) => {
4
+ const child = spawn(cmd, args, { stdio: 'inherit', shell: false });
5
+ child.on('error', () => resolve(1));
6
+ child.on('close', (code) => resolve(code ?? 1));
7
+ });
8
+ const capture = (cmd, args) => new Promise((resolve) => {
9
+ let stdout = '';
10
+ const child = spawn(cmd, args, {
11
+ stdio: ['ignore', 'pipe', 'ignore'],
12
+ shell: false,
13
+ });
14
+ child.stdout?.on('data', (chunk) => {
15
+ stdout += String(chunk);
16
+ });
17
+ child.on('error', () => resolve({ code: 1, stdout }));
18
+ child.on('close', (code) => resolve({ code: code ?? 1, stdout }));
19
+ });
20
+ async function installedVersion(run) {
21
+ try {
22
+ const result = await run('npm', [
23
+ 'ls',
24
+ '-g',
25
+ GAIA_PACKAGE,
26
+ '--json',
27
+ '--depth',
28
+ '0',
29
+ ]);
30
+ if (result.code !== 0)
31
+ return null;
32
+ const parsed = JSON.parse(result.stdout);
33
+ const version = parsed.dependencies?.[GAIA_PACKAGE]?.version;
34
+ return typeof version === 'string' ? version : null;
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ export async function runUpdate(run = spawnUpdate, query = capture, options = {}) {
41
+ const before = await installedVersion(query);
42
+ if ((await run('npm', ['install', '-g', `${GAIA_PACKAGE}@latest`])) !== 0)
43
+ return { ok: false, before, after: before };
44
+ const after = await installedVersion(query);
45
+ if (after === null)
46
+ return { ok: false, before, after };
47
+ (options.out ?? console.log)(`${before ?? 'unknown'} → ${after}`);
48
+ return { ok: true, before, after };
49
+ }
50
+ export function registerUpdate(program) {
51
+ program
52
+ .command('update')
53
+ .description('install the latest gaia CLI')
54
+ .action(async () => {
55
+ const result = await runUpdate();
56
+ if (!result.ok)
57
+ process.exitCode = 1;
58
+ });
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaia-ai/gaia",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "GAIA meta package: the `gaia` plugin-host CLI + all runtime plugins. Global install target.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,22 +38,23 @@
38
38
  "jsonapi"
39
39
  ],
40
40
  "dependencies": {
41
- "@gaia-ai/addon-auth-basic": "^0.7.0",
42
- "@gaia-ai/addon-claude": "^0.7.0",
43
- "@gaia-ai/addon-codex": "^0.7.0",
44
- "@gaia-ai/addon-deployment": "^0.7.0",
45
- "@gaia-ai/addon-dropsh": "^0.7.0",
46
- "@gaia-ai/addon-essentials": "^0.7.0",
47
- "@gaia-ai/addon-gaia-ui": "^0.7.0",
48
- "@gaia-ai/addon-herdr": "^0.7.0",
49
- "@gaia-ai/addon-kimi": "^0.7.0",
50
- "@gaia-ai/addon-opencode": "^0.7.0",
51
- "@gaia-ai/addon-pi": "^0.7.0",
52
- "@gaia-ai/addon-remote-drupal": "^0.7.0",
53
- "@gaia-ai/addon-workspace-git": "^0.7.0",
54
- "@gaia-ai/conductor": "^0.7.0",
55
- "@gaia-ai/core": "^0.7.0",
56
- "@gaia-ai/ui": "^0.7.0",
41
+ "@gaia-ai/addon-auth-basic": "^0.9.0",
42
+ "@gaia-ai/addon-claude": "^0.9.0",
43
+ "@gaia-ai/addon-codex": "^0.9.0",
44
+ "@gaia-ai/addon-deployment": "^0.9.0",
45
+ "@gaia-ai/addon-dropsh": "^0.9.0",
46
+ "@gaia-ai/addon-essentials": "^0.9.0",
47
+ "@gaia-ai/addon-gaia-ui": "^0.9.0",
48
+ "@gaia-ai/addon-grok": "^0.9.0",
49
+ "@gaia-ai/addon-herdr": "^0.9.0",
50
+ "@gaia-ai/addon-kimi": "^0.9.0",
51
+ "@gaia-ai/addon-opencode": "^0.9.0",
52
+ "@gaia-ai/addon-pi": "^0.9.0",
53
+ "@gaia-ai/addon-remote-drupal": "^0.9.0",
54
+ "@gaia-ai/addon-workspace-git": "^0.9.0",
55
+ "@gaia-ai/conductor": "^0.9.0",
56
+ "@gaia-ai/core": "^0.9.0",
57
+ "@gaia-ai/ui": "^0.9.0",
57
58
  "commander": "^12.1.0"
58
59
  }
59
60
  }