@a5c-ai/babysitter-codex 0.1.6-staging.8d6ddb29 → 0.1.6-staging.8da8527f
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/postinstall.js +5 -47
- package/package.json +2 -2
- package/scripts/team-install.js +33 -38
package/bin/postinstall.js
CHANGED
|
@@ -43,10 +43,6 @@ function getGlobalStateDir() {
|
|
|
43
43
|
return path.join(os.homedir(), '.a5c');
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function readJson(filePath) {
|
|
47
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
function writeFileIfChanged(filePath, contents) {
|
|
51
47
|
if (fs.existsSync(filePath)) {
|
|
52
48
|
const current = fs.readFileSync(filePath, 'utf8');
|
|
@@ -156,56 +152,18 @@ function runBabysitterCli(packageRoot, cliArgs, options = {}) {
|
|
|
156
152
|
return result.stdout;
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
function resolveProcessLibrarySpec(packageRoot) {
|
|
160
|
-
const lock = readJson(path.join(packageRoot, 'babysitter.lock.json'));
|
|
161
|
-
const processLibraryConfig =
|
|
162
|
-
(lock && lock.content && (lock.content.processLibrary || lock.content.upstream)) || {};
|
|
163
|
-
const repo = process.env.BABYSITTER_PROCESS_LIBRARY_REPO || processLibraryConfig.repo;
|
|
164
|
-
if (!repo) {
|
|
165
|
-
throw new Error('missing process-library repo configuration in babysitter.lock.json');
|
|
166
|
-
}
|
|
167
|
-
const ref = process.env.BABYSITTER_PROCESS_LIBRARY_REF || processLibraryConfig.ref || '';
|
|
168
|
-
const stateDir = getGlobalStateDir();
|
|
169
|
-
const cloneDir = path.join(stateDir, 'process-library', 'babysitter-repo');
|
|
170
|
-
const processSubpath =
|
|
171
|
-
process.env.BABYSITTER_PROCESS_LIBRARY_SUBPATH ||
|
|
172
|
-
processLibraryConfig.processSubpath ||
|
|
173
|
-
'library';
|
|
174
|
-
return {
|
|
175
|
-
repo,
|
|
176
|
-
ref: ref || undefined,
|
|
177
|
-
stateDir,
|
|
178
|
-
cloneDir,
|
|
179
|
-
processRoot: path.join(cloneDir, ...processSubpath.split('/')),
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
155
|
function ensureGlobalProcessLibrary(packageRoot) {
|
|
184
|
-
const spec = resolveProcessLibrarySpec(packageRoot);
|
|
185
|
-
const cloneExists = fs.existsSync(path.join(spec.cloneDir, '.git'));
|
|
186
|
-
const cloneArgs = cloneExists
|
|
187
|
-
? ['process-library:update', '--dir', spec.cloneDir, '--json']
|
|
188
|
-
: ['process-library:clone', '--repo', spec.repo, '--dir', spec.cloneDir, '--json'];
|
|
189
|
-
if (spec.ref) {
|
|
190
|
-
cloneArgs.splice(cloneExists ? 3 : 5, 0, '--ref', spec.ref);
|
|
191
|
-
}
|
|
192
|
-
runBabysitterCli(packageRoot, cloneArgs, { cwd: packageRoot });
|
|
193
|
-
if (!fs.existsSync(spec.processRoot)) {
|
|
194
|
-
throw new Error(`fetched process library root is missing: ${spec.processRoot}`);
|
|
195
|
-
}
|
|
196
|
-
runBabysitterCli(
|
|
197
|
-
packageRoot,
|
|
198
|
-
['process-library:use', '--dir', spec.processRoot, '--state-dir', spec.stateDir, '--json'],
|
|
199
|
-
{ cwd: packageRoot },
|
|
200
|
-
);
|
|
201
156
|
const active = JSON.parse(
|
|
202
157
|
runBabysitterCli(
|
|
203
158
|
packageRoot,
|
|
204
|
-
['process-library:active', '--state-dir',
|
|
159
|
+
['process-library:active', '--state-dir', getGlobalStateDir(), '--json'],
|
|
205
160
|
{ cwd: packageRoot },
|
|
206
161
|
),
|
|
207
162
|
);
|
|
208
|
-
console.log(`[babysitter-codex] process library: ${
|
|
163
|
+
console.log(`[babysitter-codex] process library: ${active.binding?.dir}`);
|
|
164
|
+
if (active.defaultSpec?.cloneDir) {
|
|
165
|
+
console.log(`[babysitter-codex] process library clone: ${active.defaultSpec.cloneDir}`);
|
|
166
|
+
}
|
|
209
167
|
console.log(`[babysitter-codex] process library state: ${active.stateFile}`);
|
|
210
168
|
}
|
|
211
169
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a5c-ai/babysitter-codex",
|
|
3
|
-
"version": "0.1.6-staging.
|
|
3
|
+
"version": "0.1.6-staging.8da8527f",
|
|
4
4
|
"description": "Babysitter Codex skill bundle and integration package for OpenAI Codex CLI with SDK-managed process-library bootstrapping, 15 orchestration modes, and BOM-safe SKILL installation",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node test/integration.test.js && node test/packaged-install.test.js",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/a5c-ai/babysitter/tree/main/plugins/babysitter-codex#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@a5c-ai/babysitter-sdk": "0.0.183-staging.
|
|
44
|
+
"@a5c-ai/babysitter-sdk": "0.0.183-staging.8da8527f"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/scripts/team-install.js
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const path = require('path');
|
|
6
7
|
const { spawnSync } = require('child_process');
|
|
7
8
|
|
|
8
9
|
const SKILL_NAME = 'babysit';
|
|
10
|
+
const DEFAULT_PROCESS_LIBRARY_REPO = 'https://github.com/a5c-ai/babysitter.git';
|
|
11
|
+
const DEFAULT_PROCESS_LIBRARY_SUBPATH = 'library';
|
|
12
|
+
const DEFAULT_PROCESS_LIBRARY_REFERENCE_SUBPATH = 'library/reference';
|
|
9
13
|
const WORKSPACE_SKILL_ENTRIES = [
|
|
10
14
|
{ source: 'SKILL.md', target: 'SKILL.md' },
|
|
11
15
|
{ source: 'README.md', target: 'README.md' },
|
|
@@ -41,6 +45,20 @@ function parseArgs(argv) {
|
|
|
41
45
|
return args;
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
function getGlobalStateDir() {
|
|
49
|
+
if (process.env.BABYSITTER_GLOBAL_STATE_DIR) {
|
|
50
|
+
return path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR);
|
|
51
|
+
}
|
|
52
|
+
return path.join(os.homedir(), '.a5c');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function splitProcessLibrarySubpath(value) {
|
|
56
|
+
return String(value)
|
|
57
|
+
.split(/[\\/]+/)
|
|
58
|
+
.map((part) => part.trim())
|
|
59
|
+
.filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
function renderWorkspaceConfigToml() {
|
|
45
63
|
return [
|
|
46
64
|
'approval_policy = "on-request"',
|
|
@@ -256,48 +274,30 @@ function runBabysitterCli(packageRoot, cliArgs, options = {}) {
|
|
|
256
274
|
return result.stdout;
|
|
257
275
|
}
|
|
258
276
|
|
|
259
|
-
function resolveProcessLibrarySpec(
|
|
260
|
-
const
|
|
261
|
-
const repo = process.env.BABYSITTER_PROCESS_LIBRARY_REPO ||
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const cloneDir = path.join(workspaceRoot, '.a5c', 'process-library', 'babysitter-repo');
|
|
267
|
-
const processSubpath = process.env.BABYSITTER_PROCESS_LIBRARY_SUBPATH ||
|
|
268
|
-
processLibraryConfig.processSubpath ||
|
|
269
|
-
'library';
|
|
270
|
-
const referenceSubpath = process.env.BABYSITTER_PROCESS_LIBRARY_REFERENCE_SUBPATH ||
|
|
271
|
-
processLibraryConfig.referenceSubpath ||
|
|
272
|
-
'library/reference';
|
|
277
|
+
function resolveProcessLibrarySpec() {
|
|
278
|
+
const stateDir = getGlobalStateDir();
|
|
279
|
+
const repo = process.env.BABYSITTER_PROCESS_LIBRARY_REPO || DEFAULT_PROCESS_LIBRARY_REPO;
|
|
280
|
+
const ref = process.env.BABYSITTER_PROCESS_LIBRARY_REF || '';
|
|
281
|
+
const cloneDir = path.join(stateDir, 'process-library', 'babysitter-repo');
|
|
282
|
+
const processSubpath = process.env.BABYSITTER_PROCESS_LIBRARY_SUBPATH || DEFAULT_PROCESS_LIBRARY_SUBPATH;
|
|
283
|
+
const referenceSubpath = process.env.BABYSITTER_PROCESS_LIBRARY_REFERENCE_SUBPATH || DEFAULT_PROCESS_LIBRARY_REFERENCE_SUBPATH;
|
|
273
284
|
return {
|
|
274
285
|
repo,
|
|
275
286
|
ref: ref || undefined,
|
|
276
287
|
cloneDir,
|
|
277
|
-
processRoot: path.join(cloneDir, ...processSubpath
|
|
278
|
-
referenceRoot: path.join(cloneDir, ...referenceSubpath
|
|
279
|
-
stateDir
|
|
288
|
+
processRoot: path.join(cloneDir, ...splitProcessLibrarySubpath(processSubpath)),
|
|
289
|
+
referenceRoot: path.join(cloneDir, ...splitProcessLibrarySubpath(referenceSubpath)),
|
|
290
|
+
stateDir,
|
|
280
291
|
};
|
|
281
292
|
}
|
|
282
293
|
|
|
283
|
-
function ensureActiveProcessLibrary(packageRoot,
|
|
284
|
-
const spec = resolveProcessLibrarySpec(
|
|
285
|
-
const cloneExists = fs.existsSync(path.join(spec.cloneDir, '.git'));
|
|
286
|
-
const cloneArgs = cloneExists
|
|
287
|
-
? ['process-library:update', '--dir', spec.cloneDir, '--json']
|
|
288
|
-
: ['process-library:clone', '--repo', spec.repo, '--dir', spec.cloneDir, '--json'];
|
|
289
|
-
if (spec.ref) {
|
|
290
|
-
cloneArgs.splice(cloneExists ? 3 : 5, 0, '--ref', spec.ref);
|
|
291
|
-
}
|
|
292
|
-
const useArgs = ['process-library:use', '--dir', spec.processRoot, '--state-dir', spec.stateDir, '--json'];
|
|
294
|
+
function ensureActiveProcessLibrary(packageRoot, dryRun) {
|
|
295
|
+
const spec = resolveProcessLibrarySpec();
|
|
293
296
|
const activeArgs = ['process-library:active', '--state-dir', spec.stateDir, '--json'];
|
|
294
|
-
|
|
295
297
|
if (dryRun) {
|
|
296
298
|
return {
|
|
297
299
|
...spec,
|
|
298
300
|
plannedCommands: [
|
|
299
|
-
`babysitter ${cloneArgs.join(' ')}`,
|
|
300
|
-
`babysitter ${useArgs.join(' ')}`,
|
|
301
301
|
`babysitter ${activeArgs.join(' ')}`,
|
|
302
302
|
],
|
|
303
303
|
activeStateFile: path.join(spec.stateDir, 'active', 'process-library.json'),
|
|
@@ -305,12 +305,7 @@ function ensureActiveProcessLibrary(packageRoot, lock, workspaceRoot, dryRun) {
|
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
runBabysitterCli(packageRoot,
|
|
309
|
-
if (!fs.existsSync(spec.processRoot)) {
|
|
310
|
-
throw new Error(`fetched process library root is missing: ${spec.processRoot}`);
|
|
311
|
-
}
|
|
312
|
-
runBabysitterCli(packageRoot, useArgs, { cwd: workspaceRoot });
|
|
313
|
-
const active = JSON.parse(runBabysitterCli(packageRoot, activeArgs, { cwd: workspaceRoot }));
|
|
308
|
+
const active = JSON.parse(runBabysitterCli(packageRoot, activeArgs, { cwd: packageRoot }));
|
|
314
309
|
return {
|
|
315
310
|
...spec,
|
|
316
311
|
plannedCommands: [],
|
|
@@ -371,7 +366,7 @@ function main() {
|
|
|
371
366
|
const workspaceHooksConfigPath = path.join(workspaceRoot, '.codex', 'hooks.json');
|
|
372
367
|
const workspaceConfigPath = path.join(workspaceRoot, '.codex', 'config.toml');
|
|
373
368
|
const { workspaceSkillRoot, workspaceHookScriptsRoot, workspacePromptsRoot } = installWorkspaceSkill(packageRoot, workspaceRoot, args.dryRun);
|
|
374
|
-
const processLibrary = ensureActiveProcessLibrary(packageRoot,
|
|
369
|
+
const processLibrary = ensureActiveProcessLibrary(packageRoot, args.dryRun);
|
|
375
370
|
const installInfo = {
|
|
376
371
|
installedAt: new Date().toISOString(),
|
|
377
372
|
runtime: lock.runtime,
|
|
@@ -429,7 +424,7 @@ function main() {
|
|
|
429
424
|
workspaceConfigPath,
|
|
430
425
|
workspaceHooksConfigPath,
|
|
431
426
|
hookScriptsRoot: workspaceHookScriptsRoot,
|
|
432
|
-
processLibraryLookupCommand: 'babysitter process-library:active --
|
|
427
|
+
processLibraryLookupCommand: 'babysitter process-library:active --json',
|
|
433
428
|
}, null, 2), 'utf8');
|
|
434
429
|
}
|
|
435
430
|
|