@gaia-ai/gaia 0.11.4 → 0.11.5
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/dist/src/upgrade.d.ts +48 -0
- package/dist/src/upgrade.js +121 -0
- package/package.json +20 -20
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ProjectConnectionChoice } from '@gaia-ai/conductor';
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
/** Where the running `gaia` resolved from and what it calls itself. */
|
|
4
|
+
export interface GaiaInstallInfo {
|
|
5
|
+
/** The meta package version (`0.0.0` when the manifest is unreadable). */
|
|
6
|
+
version: string;
|
|
7
|
+
/** Absolute path of the package root this module was loaded from. */
|
|
8
|
+
root: string;
|
|
9
|
+
/** `global install` when that root sits inside `node_modules`, else `dev clone`. */
|
|
10
|
+
kind: 'dev clone' | 'global install';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Identify the running install from THIS module's own URL — walking up to the
|
|
14
|
+
* nearest `package.json` — rather than from `$PATH` or `process.argv`, so a shim
|
|
15
|
+
* that execs a checkout's build reports the checkout, not the shim.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveInstallInfo(): GaiaInstallInfo;
|
|
18
|
+
/**
|
|
19
|
+
* GAIA-218 (AC-3, AC-4): resolve what to do with the PROJECT connection override.
|
|
20
|
+
* Default no in every branch — only an explicit yes opts in. Non-interactive
|
|
21
|
+
* (no TTY) ⇒ always `skip`. The prompt is injected so the host test can stub it.
|
|
22
|
+
*
|
|
23
|
+
* - existing project `gaia.config.js` → "remove this override? [y/N]" → `remove`|`skip`
|
|
24
|
+
* - none → "create an override? [y/N]" → `create`|`skip`
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveProjectConnectionChoice(opts: {
|
|
27
|
+
existing: string | undefined;
|
|
28
|
+
isTTY: boolean;
|
|
29
|
+
prompt: (question: string) => Promise<boolean>;
|
|
30
|
+
}): Promise<ProjectConnectionChoice>;
|
|
31
|
+
/**
|
|
32
|
+
* GAIA-230 (AC-9): the intro lines printed BEFORE the first migration step, on
|
|
33
|
+
* `--dry-run` too. `home` is where the schema `from` is read (the home connection
|
|
34
|
+
* config `~/.gaia/gaia.config.js`, the one every repo inherits); `to` is the
|
|
35
|
+
* version this gaia ships. Pure — returns the lines rather than printing them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderUpgradeIntro(opts: {
|
|
38
|
+
cwd: string;
|
|
39
|
+
home: string;
|
|
40
|
+
install?: GaiaInstallInfo;
|
|
41
|
+
}): string[];
|
|
42
|
+
/** Register `gaia upgrade` on the host program. `deps` is injectable for tests. */
|
|
43
|
+
export declare function registerUpgrade(program: Command, deps?: {
|
|
44
|
+
prompt?: (question: string) => Promise<boolean>;
|
|
45
|
+
isTTY?: boolean;
|
|
46
|
+
cwd?: string;
|
|
47
|
+
home?: string;
|
|
48
|
+
}): void;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { dirname, join, sep } from 'node:path';
|
|
4
|
+
import { createInterface } from 'node:readline';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { GAIA_CONFIG_SCHEMA_VERSION, hasProjectConnection, readConfigSchemaVersion, runUpgrade, } from '@gaia-ai/conductor';
|
|
7
|
+
/**
|
|
8
|
+
* Identify the running install from THIS module's own URL — walking up to the
|
|
9
|
+
* nearest `package.json` — rather than from `$PATH` or `process.argv`, so a shim
|
|
10
|
+
* that execs a checkout's build reports the checkout, not the shim.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveInstallInfo() {
|
|
13
|
+
let root = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
let version = '0.0.0';
|
|
15
|
+
for (;;) {
|
|
16
|
+
try {
|
|
17
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
18
|
+
version = pkg.version ?? '0.0.0';
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
const parent = dirname(root);
|
|
23
|
+
if (parent === root)
|
|
24
|
+
break;
|
|
25
|
+
root = parent;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
version,
|
|
30
|
+
root,
|
|
31
|
+
kind: root.includes(`${sep}node_modules${sep}`)
|
|
32
|
+
? 'global install'
|
|
33
|
+
: 'dev clone',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Ask a yes/no question on the terminal; anything but an explicit yes is no. */
|
|
37
|
+
async function promptYesNo(question) {
|
|
38
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
39
|
+
try {
|
|
40
|
+
const answer = await new Promise((resolve) => rl.question(question, resolve));
|
|
41
|
+
const a = answer.trim().toLowerCase();
|
|
42
|
+
return a === 'y' || a === 'yes';
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
rl.close();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* GAIA-218 (AC-3, AC-4): resolve what to do with the PROJECT connection override.
|
|
50
|
+
* Default no in every branch — only an explicit yes opts in. Non-interactive
|
|
51
|
+
* (no TTY) ⇒ always `skip`. The prompt is injected so the host test can stub it.
|
|
52
|
+
*
|
|
53
|
+
* - existing project `gaia.config.js` → "remove this override? [y/N]" → `remove`|`skip`
|
|
54
|
+
* - none → "create an override? [y/N]" → `create`|`skip`
|
|
55
|
+
*/
|
|
56
|
+
export async function resolveProjectConnectionChoice(opts) {
|
|
57
|
+
if (!opts.isTTY)
|
|
58
|
+
return 'skip';
|
|
59
|
+
if (opts.existing !== undefined) {
|
|
60
|
+
const yes = await opts.prompt(`remove this project connection override (${opts.existing})? [y/N] `);
|
|
61
|
+
return yes ? 'remove' : 'skip';
|
|
62
|
+
}
|
|
63
|
+
const yes = await opts.prompt('create a project connection override for this repo? [y/N] ');
|
|
64
|
+
return yes ? 'create' : 'skip';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* GAIA-230 (AC-9): the intro lines printed BEFORE the first migration step, on
|
|
68
|
+
* `--dry-run` too. `home` is where the schema `from` is read (the home connection
|
|
69
|
+
* config `~/.gaia/gaia.config.js`, the one every repo inherits); `to` is the
|
|
70
|
+
* version this gaia ships. Pure — returns the lines rather than printing them.
|
|
71
|
+
*/
|
|
72
|
+
export function renderUpgradeIntro(opts) {
|
|
73
|
+
const info = opts.install ?? resolveInstallInfo();
|
|
74
|
+
const homeConnection = join(opts.home, '.gaia', 'gaia.config.js');
|
|
75
|
+
const from = readConfigSchemaVersion(homeConnection);
|
|
76
|
+
return [
|
|
77
|
+
`gaia upgrade — gaia v${info.version} (${info.kind})`,
|
|
78
|
+
` resolved from: ${info.root}`,
|
|
79
|
+
` config schema: v${from} → v${GAIA_CONFIG_SCHEMA_VERSION} (${homeConnection})`,
|
|
80
|
+
` the .gaia/ configs of ${opts.cwd} and of ${join(opts.home, '.gaia')} get migrated`,
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
/** Register `gaia upgrade` on the host program. `deps` is injectable for tests. */
|
|
84
|
+
export function registerUpgrade(program, deps = {}) {
|
|
85
|
+
program
|
|
86
|
+
.command('upgrade')
|
|
87
|
+
.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 the @gaia-ai/core/plugins + @gaia-ai/gaia/plugins host barrels → @gaia-ai/addon-*). Prompts before creating/removing a project connection override.')
|
|
88
|
+
.option('--dry-run', 'print the migration plan without writing anything', false)
|
|
89
|
+
.action(async (opts) => {
|
|
90
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
91
|
+
const home = deps.home ?? homedir();
|
|
92
|
+
const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
|
|
93
|
+
const prompt = deps.prompt ?? promptYesNo;
|
|
94
|
+
// GAIA-230 (AC-9): the intro comes first — before the connection prompt and
|
|
95
|
+
// before the first migration step, so it is on the record either way.
|
|
96
|
+
for (const line of renderUpgradeIntro({ cwd, home }))
|
|
97
|
+
console.log(line);
|
|
98
|
+
const projectConnection = await resolveProjectConnectionChoice({
|
|
99
|
+
existing: hasProjectConnection(cwd),
|
|
100
|
+
isTTY,
|
|
101
|
+
prompt,
|
|
102
|
+
});
|
|
103
|
+
// `cwd`/`home` are forwarded so an injected pair really scopes the run —
|
|
104
|
+
// without them `runUpgrade` reached for `process.cwd()`/`homedir()` and
|
|
105
|
+
// rewrote the developer's own `.gaia/` from a test.
|
|
106
|
+
const report = runUpgrade({
|
|
107
|
+
cwd,
|
|
108
|
+
home,
|
|
109
|
+
dryRun: opts.dryRun,
|
|
110
|
+
projectConnection,
|
|
111
|
+
});
|
|
112
|
+
for (const line of report.actions)
|
|
113
|
+
console.log(line);
|
|
114
|
+
if (report.alreadyCurrent)
|
|
115
|
+
console.log('gaia upgrade: already current');
|
|
116
|
+
else if (opts.dryRun)
|
|
117
|
+
console.log('gaia upgrade: dry run (no changes written)');
|
|
118
|
+
else
|
|
119
|
+
console.log('gaia upgrade: done');
|
|
120
|
+
});
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaia-ai/gaia",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
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,25 +38,25 @@
|
|
|
38
38
|
"jsonapi"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@gaia-ai/addon-auth-basic": "^0.11.
|
|
42
|
-
"@gaia-ai/addon-claude": "^0.11.
|
|
43
|
-
"@gaia-ai/addon-codex": "^0.11.
|
|
44
|
-
"@gaia-ai/addon-deployment": "^0.11.
|
|
45
|
-
"@gaia-ai/addon-dropsh": "^0.11.
|
|
46
|
-
"@gaia-ai/addon-essentials": "^0.11.
|
|
47
|
-
"@gaia-ai/addon-gaia-ui": "^0.11.
|
|
48
|
-
"@gaia-ai/addon-gaia-ui-artifacts": "^0.11.
|
|
49
|
-
"@gaia-ai/addon-grok": "^0.11.
|
|
50
|
-
"@gaia-ai/addon-herdr": "^0.11.
|
|
51
|
-
"@gaia-ai/addon-kimi": "^0.11.
|
|
52
|
-
"@gaia-ai/addon-opencode": "^0.11.
|
|
53
|
-
"@gaia-ai/addon-pi": "^0.11.
|
|
54
|
-
"@gaia-ai/addon-remote-drupal": "^0.11.
|
|
55
|
-
"@gaia-ai/addon-workspace": "^0.11.
|
|
56
|
-
"@gaia-ai/addon-workspace-git": "^0.11.
|
|
57
|
-
"@gaia-ai/conductor": "^0.11.
|
|
58
|
-
"@gaia-ai/core": "^0.11.
|
|
59
|
-
"@gaia-ai/ui": "^0.11.
|
|
41
|
+
"@gaia-ai/addon-auth-basic": "^0.11.5",
|
|
42
|
+
"@gaia-ai/addon-claude": "^0.11.5",
|
|
43
|
+
"@gaia-ai/addon-codex": "^0.11.5",
|
|
44
|
+
"@gaia-ai/addon-deployment": "^0.11.5",
|
|
45
|
+
"@gaia-ai/addon-dropsh": "^0.11.5",
|
|
46
|
+
"@gaia-ai/addon-essentials": "^0.11.5",
|
|
47
|
+
"@gaia-ai/addon-gaia-ui": "^0.11.5",
|
|
48
|
+
"@gaia-ai/addon-gaia-ui-artifacts": "^0.11.5",
|
|
49
|
+
"@gaia-ai/addon-grok": "^0.11.5",
|
|
50
|
+
"@gaia-ai/addon-herdr": "^0.11.5",
|
|
51
|
+
"@gaia-ai/addon-kimi": "^0.11.5",
|
|
52
|
+
"@gaia-ai/addon-opencode": "^0.11.5",
|
|
53
|
+
"@gaia-ai/addon-pi": "^0.11.5",
|
|
54
|
+
"@gaia-ai/addon-remote-drupal": "^0.11.5",
|
|
55
|
+
"@gaia-ai/addon-workspace": "^0.11.5",
|
|
56
|
+
"@gaia-ai/addon-workspace-git": "^0.11.5",
|
|
57
|
+
"@gaia-ai/conductor": "^0.11.5",
|
|
58
|
+
"@gaia-ai/core": "^0.11.5",
|
|
59
|
+
"@gaia-ai/ui": "^0.11.5",
|
|
60
60
|
"commander": "^12.1.0"
|
|
61
61
|
}
|
|
62
62
|
}
|