@a5c-ai/babysitter-github 5.0.1-staging.542f8525 → 5.0.1-staging.55f6fe69

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/install.js CHANGED
@@ -2,126 +2,86 @@
2
2
  'use strict';
3
3
 
4
4
  const path = require('path');
5
- const { spawnSync } = require('child_process');
6
- const {
7
- copyPluginBundle,
8
- ensureGlobalProcessLibrary,
9
- ensureMarketplaceEntry,
10
- getCopilotHome,
11
- getHomeMarketplacePath,
12
- getHomePluginRoot,
13
- installCloudAgentSurface,
14
- installCopilotSurface,
15
- warnWindowsHooks,
16
- } = require('./install-shared');
5
+ const shared = require('./install-shared');
17
6
 
18
7
  const PACKAGE_ROOT = path.resolve(__dirname, '..');
19
8
 
20
9
  function parseArgs(argv) {
21
- const args = {
22
- cloudAgent: false,
23
- workspace: process.cwd(),
24
- };
10
+ let workspace = null;
11
+ let cloudAgent = false;
25
12
 
26
13
  for (let i = 0; i < argv.length; i += 1) {
27
14
  const arg = argv[i];
28
15
  if (arg === '--cloud-agent') {
29
- args.cloudAgent = true;
16
+ cloudAgent = true;
30
17
  continue;
31
18
  }
32
19
  if (arg === '--workspace') {
33
20
  const next = argv[i + 1];
34
21
  if (next && !next.startsWith('-')) {
35
- args.workspace = path.resolve(next);
22
+ workspace = path.resolve(next);
36
23
  i += 1;
37
24
  } else {
38
- args.workspace = process.cwd();
25
+ workspace = process.cwd();
39
26
  }
40
27
  }
41
28
  }
42
29
 
43
- return args;
44
- }
45
-
46
- /**
47
- * Attempt to register the plugin via `copilot plugin install ./path`.
48
- * Falls back to manual config.json registration if the CLI is not available.
49
- */
50
- function registerViaCopilotCli(pluginRoot) {
51
- const result = spawnSync('copilot', ['plugin', 'install', pluginRoot], {
52
- stdio: ['ignore', 'pipe', 'pipe'],
53
- encoding: 'utf8',
54
- timeout: 30000,
55
- });
56
-
57
- if (result.status === 0) {
58
- console.log(`[babysitter] Registered plugin via 'copilot plugin install'`);
59
- return true;
60
- }
61
-
62
- // CLI not available or failed -- fall back to manual registration
63
- const stderr = (result.stderr || '').trim();
64
- if (result.error || stderr.includes('not found') || stderr.includes('not recognized')) {
65
- console.log(`[babysitter] Copilot CLI not found, using manual registration`);
66
- } else {
67
- console.warn(`[babysitter] 'copilot plugin install' failed: ${stderr || 'unknown error'}, using manual registration`);
68
- }
69
- return false;
30
+ return { cloudAgent, workspace };
70
31
  }
71
32
 
72
33
  function main() {
73
- const args = parseArgs(process.argv.slice(2));
74
- const copilotHome = getCopilotHome();
75
- const pluginRoot = getHomePluginRoot();
76
- const marketplacePath = getHomeMarketplacePath();
34
+ const options = parseArgs(process.argv.slice(2));
77
35
 
78
- if (args.cloudAgent) {
79
- const active = ensureGlobalProcessLibrary(PACKAGE_ROOT);
80
- const installed = installCloudAgentSurface(PACKAGE_ROOT, args.workspace);
81
- console.log(`[babysitter] Installed Copilot cloud-agent support into ${args.workspace}`);
82
- console.log(`[babysitter] plugin bundle: ${installed.bundleRoot}`);
83
- console.log(`[babysitter] skills: ${path.join(args.workspace, '.github', 'skills')}`);
84
- console.log(`[babysitter] instructions: ${installed.copilotInstructionsPath}`);
85
- console.log(`[babysitter] agents: ${installed.agentsPath}`);
86
- if (installed.setupWorkflow.needsManualMerge) {
87
- console.warn(`[babysitter] Existing copilot-setup-steps workflow preserved: ${installed.setupWorkflow.workflowPath}`);
88
- console.warn(`[babysitter] Merge Babysitter setup steps from: ${installed.setupWorkflow.examplePath}`);
89
- } else {
90
- console.log(`[babysitter] setup workflow: ${installed.setupWorkflow.workflowPath}`);
36
+ if (options.cloudAgent) {
37
+ if (!options.workspace) {
38
+ console.error(`[${shared.PLUGIN_NAME}] Failed to install: --cloud-agent requires --workspace <path>.`);
39
+ process.exitCode = 1;
40
+ return;
41
+ }
42
+
43
+ try {
44
+ const installResult = shared.installCloudAgentSurface(PACKAGE_ROOT, options.workspace);
45
+ shared.ensureGlobalProcessLibrary(PACKAGE_ROOT);
46
+ console.log(`[${shared.PLUGIN_NAME}] Installed cloud-agent support into ${options.workspace}`);
47
+ if (installResult.setupWorkflow && installResult.setupWorkflow.examplePath) {
48
+ console.log(
49
+ `[${shared.PLUGIN_NAME}] Existing copilot setup workflow preserved; merge candidate written to ${installResult.setupWorkflow.examplePath}`,
50
+ );
51
+ }
52
+ return;
53
+ } catch (err) {
54
+ console.error(`[${shared.PLUGIN_NAME}] Failed to install cloud-agent support: ${err.message}`);
55
+ process.exitCode = 1;
56
+ return;
91
57
  }
92
- console.log(`[babysitter] process library: ${active.binding?.dir}`);
93
- console.log(`[babysitter] process library state: ${active.stateFile}`);
94
- console.log('[babysitter] Cloud-agent installation complete!');
95
- return;
96
58
  }
97
59
 
98
- console.log(`[babysitter] Installing plugin to ${pluginRoot}`);
60
+ const pluginRoot = shared.getHomePluginRoot();
61
+ const marketplacePath = shared.getHomeMarketplacePath();
99
62
 
100
- try {
101
- copyPluginBundle(PACKAGE_ROOT, pluginRoot);
102
- ensureMarketplaceEntry(marketplacePath, pluginRoot);
63
+ console.log(`[${shared.PLUGIN_NAME}] Installing plugin to ${pluginRoot}`);
103
64
 
104
- // Try native copilot CLI registration first; fall back to manual config.json
105
- if (!registerViaCopilotCli(pluginRoot)) {
106
- const { registerCopilotPlugin } = require('./install-shared');
107
- registerCopilotPlugin(pluginRoot);
65
+ try {
66
+ shared.copyPluginBundle(PACKAGE_ROOT, pluginRoot);
67
+ shared.ensureMarketplaceEntry(marketplacePath, pluginRoot);
68
+ if (typeof shared.registerCopilotPlugin === 'function') {
69
+ shared.registerCopilotPlugin(pluginRoot);
108
70
  }
109
-
110
- installCopilotSurface(PACKAGE_ROOT, copilotHome);
111
-
112
- const active = ensureGlobalProcessLibrary(PACKAGE_ROOT);
113
- console.log(`[babysitter] marketplace: ${marketplacePath}`);
114
- console.log(`[babysitter] copilot config: ${path.join(copilotHome, 'config.json')}`);
115
- console.log(`[babysitter] process library: ${active.binding?.dir}`);
116
- if (active.defaultSpec?.cloneDir) {
117
- console.log(`[babysitter] process library clone: ${active.defaultSpec.cloneDir}`);
71
+ if (typeof shared.installCopilotSurface === 'function' && typeof shared.getCopilotHome === 'function') {
72
+ shared.installCopilotSurface(PACKAGE_ROOT, shared.getCopilotHome());
73
+ }
74
+ if (typeof shared.warnWindowsHooks === 'function') {
75
+ shared.warnWindowsHooks();
76
+ }
77
+ if (typeof shared.harnessInstall === 'function') {
78
+ shared.harnessInstall(PACKAGE_ROOT, pluginRoot);
118
79
  }
119
- console.log(`[babysitter] process library state: ${active.stateFile}`);
120
- warnWindowsHooks();
121
- console.log('[babysitter] Installation complete!');
122
- console.log('[babysitter] Restart GitHub Copilot CLI to pick up the installed plugin and config changes.');
80
+ shared.runPostInstall && shared.runPostInstall(pluginRoot);
81
+ console.log(`[${shared.PLUGIN_NAME}] Installation complete!`);
82
+ console.log(`[${shared.PLUGIN_NAME}] Restart your IDE/CLI to pick up the plugin.`);
123
83
  } catch (err) {
124
- console.error(`[babysitter] Failed to install plugin: ${err.message}`);
84
+ console.error(`[${shared.PLUGIN_NAME}] Failed to install: ${err.message}`);
125
85
  process.exitCode = 1;
126
86
  }
127
87
  }
package/bin/uninstall.js CHANGED
@@ -1,76 +1,46 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const path = require('path');
4
5
  const fs = require('fs');
5
- const { spawnSync } = require('child_process');
6
- const {
7
- deregisterCopilotPlugin,
8
- getCopilotHome,
9
- getHomeMarketplacePath,
10
- getHomePluginRoot,
11
- removeLegacyHooks,
12
- removeMarketplaceEntry,
13
- } = require('./install-shared');
14
-
15
- const PLUGIN_NAME = 'babysitter';
16
-
17
- /**
18
- * Attempt to unregister the plugin via `copilot plugin uninstall`.
19
- * Falls back to manual config.json cleanup if the CLI is not available.
20
- */
21
- function unregisterViaCopilotCli() {
22
- const result = spawnSync('copilot', ['plugin', 'uninstall', PLUGIN_NAME], {
23
- stdio: ['ignore', 'pipe', 'pipe'],
24
- encoding: 'utf8',
25
- timeout: 30000,
26
- });
27
-
28
- if (result.status === 0) {
29
- console.log(`[${PLUGIN_NAME}] Unregistered plugin via 'copilot plugin uninstall'`);
30
- return true;
31
- }
32
-
33
- // CLI not available or failed
34
- const stderr = (result.stderr || '').trim();
35
- if (result.error || stderr.includes('not found') || stderr.includes('not recognized')) {
36
- console.log(`[${PLUGIN_NAME}] Copilot CLI not found, using manual cleanup`);
37
- } else {
38
- console.warn(`[${PLUGIN_NAME}] 'copilot plugin uninstall' failed: ${stderr || 'unknown error'}, using manual cleanup`);
39
- }
40
- return false;
41
- }
6
+ const shared = require('./install-shared');
42
7
 
43
8
  function main() {
44
- const copilotHome = getCopilotHome();
45
- const pluginRoot = getHomePluginRoot();
46
- const marketplacePath = getHomeMarketplacePath();
47
- let removedPlugin = false;
48
-
49
- if (fs.existsSync(pluginRoot)) {
9
+ const pluginRoot = shared.getHomePluginRoot();
10
+ const marketplacePath = typeof shared.getHomeMarketplacePath === 'function'
11
+ ? shared.getHomeMarketplacePath()
12
+ : null;
13
+ const copilotHome = typeof shared.getCopilotHome === 'function'
14
+ ? shared.getCopilotHome()
15
+ : null;
16
+
17
+ if (!fs.existsSync(pluginRoot)) {
18
+ console.log(`[${shared.PLUGIN_NAME}] Plugin not installed at ${pluginRoot}`);
19
+ } else {
50
20
  try {
51
21
  fs.rmSync(pluginRoot, { recursive: true, force: true });
52
- console.log(`[${PLUGIN_NAME}] Removed ${pluginRoot}`);
53
- removedPlugin = true;
22
+ console.log(`[${shared.PLUGIN_NAME}] Uninstalled from ${pluginRoot}`);
54
23
  } catch (err) {
55
- console.warn(`[${PLUGIN_NAME}] Warning: Could not remove plugin directory ${pluginRoot}: ${err.message}`);
24
+ console.error(`[${shared.PLUGIN_NAME}] Failed to uninstall: ${err.message}`);
25
+ process.exitCode = 1;
26
+ return;
56
27
  }
57
28
  }
58
29
 
59
- removeMarketplaceEntry(marketplacePath);
60
-
61
- // Try native copilot CLI unregistration first; fall back to manual config.json
62
- if (!unregisterViaCopilotCli()) {
63
- deregisterCopilotPlugin(pluginRoot);
64
- }
65
-
66
- removeLegacyHooks(copilotHome);
67
-
68
- if (!removedPlugin) {
69
- console.log(`[${PLUGIN_NAME}] Plugin directory not found, config and hooks cleaned if present.`);
70
- return;
30
+ try {
31
+ if (typeof shared.deregisterCopilotPlugin === 'function') {
32
+ shared.deregisterCopilotPlugin(pluginRoot);
33
+ }
34
+ if (copilotHome && typeof shared.removeManagedHooks === 'function') {
35
+ shared.removeManagedHooks(copilotHome);
36
+ }
37
+ if (marketplacePath && typeof shared.removeMarketplaceEntry === 'function') {
38
+ shared.removeMarketplaceEntry(marketplacePath);
39
+ }
40
+ } catch (err) {
41
+ console.error(`[${shared.PLUGIN_NAME}] Failed to clean up uninstall state: ${err.message}`);
42
+ process.exitCode = 1;
71
43
  }
72
-
73
- console.log(`[${PLUGIN_NAME}] Restart GitHub Copilot CLI to complete uninstallation.`);
74
44
  }
75
45
 
76
46
  main();