@hybridlabor-api/aos 4.6.1 → 4.6.3

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.
Files changed (2) hide show
  1. package/installer.js +103 -6
  2. package/package.json +1 -1
package/installer.js CHANGED
@@ -59,6 +59,12 @@ const {
59
59
  log
60
60
  } = clack;
61
61
 
62
+ // Defensive alias: @clack/prompts provides log.success, not log.ok.
63
+ // Ensure any legacy or third-party call to log.ok safely routes to log.success.
64
+ if (log && typeof log === 'object' && !log.ok) {
65
+ log.ok = log.success;
66
+ }
67
+
62
68
  const {
63
69
  renderKineticIntro,
64
70
  buildHeroHeader,
@@ -2002,8 +2008,27 @@ async function installOpenWikiVisualizer() {
2002
2008
  return;
2003
2009
  }
2004
2010
  if (!hasExecutable('openwiki')) {
2005
- log.warn('Skipping OpenWiki Visualizer setup: the openwiki CLI was not found on PATH. Install it with: npm install -g openwiki@latest');
2006
- return;
2011
+ // Fresh machines always land here -- skipping leaves :4321 dead with
2012
+ // only a warn line. Offer the global install instead.
2013
+ let installCli = isAutoYes;
2014
+ if (!isAutoYes) {
2015
+ const answer = await askConfirm({
2016
+ message: 'OpenWiki CLI not found. Install it globally (npm install -g openwiki@latest) so the :4321 visualizer daemon can run?',
2017
+ initialValue: true,
2018
+ });
2019
+ installCli = !isCancel(answer) && !!answer;
2020
+ }
2021
+ if (installCli) {
2022
+ try {
2023
+ log.step('Installing OpenWiki CLI globally (npm install -g openwiki@latest)...');
2024
+ execSync('npm install -g openwiki@latest', { stdio: 'ignore' });
2025
+ } catch (e) { logDebug(e, 'openwiki cli install'); }
2026
+ }
2027
+ if (!hasExecutable('openwiki')) {
2028
+ log.warn('Skipping OpenWiki Visualizer setup: the openwiki CLI is not on PATH. Install it with: npm install -g openwiki@latest');
2029
+ return;
2030
+ }
2031
+ log.success('OpenWiki CLI installed.');
2007
2032
  }
2008
2033
  // launchd starts agents with a minimal PATH that never includes npm's global
2009
2034
  // bin dir, so resolve the absolute binary path now instead of relying on PATH at boot.
@@ -2013,6 +2038,79 @@ async function installOpenWikiVisualizer() {
2013
2038
  openwikiBin = execSync(lookup, { encoding: 'utf8' }).split(/\r?\n/)[0].trim() || 'openwiki';
2014
2039
  } catch (e) { logDebug(e, 'openwiki path lookup'); }
2015
2040
 
2041
+ // The openwiki CLI is a Node script (#!/usr/bin/env node shebang). Under
2042
+ // launchd's minimal PATH there is no node either, so the agent died with
2043
+ // "env: node: No such file or directory" (exit 127) on every boot until
2044
+ // the interpreter itself is baked in as an absolute path.
2045
+ let nodeBin = 'node';
2046
+ try {
2047
+ const lookup = process.platform === 'win32' ? 'where node' : 'command -v node';
2048
+ nodeBin = execSync(lookup, { encoding: 'utf8' }).split(/\r?\n/)[0].trim() || 'node';
2049
+ } catch (e) { logDebug(e, 'node path lookup'); }
2050
+
2051
+ // Which wiki :4321 serves is per-machine setup configuration, not a
2052
+ // hardcoded path: every computer tracks different projects, and bare
2053
+ // `openwiki visualize` only serves ~/openwiki, which never exists (the
2054
+ // agent then exits 1 with "Wiki directory not found"). The choice is
2055
+ // persisted in ~/.openwiki/visualizer.json so Quick Update reuses it
2056
+ // without asking again; the bundled ecosystem aggregate is only the
2057
+ // first-run default.
2058
+ const visualizerConfigPath = path.join(homeDir, '.openwiki', 'visualizer.json');
2059
+ const looksLikeWiki = (dir) => fs.existsSync(path.join(dir, 'index.md'))
2060
+ || fs.existsSync(path.join(dir, 'openwiki'))
2061
+ || fs.existsSync(path.join(dir, '.openwiki'));
2062
+ const readVisualizerConfig = () => {
2063
+ try {
2064
+ const raw = JSON.parse(fs.readFileSync(visualizerConfigPath, 'utf8'));
2065
+ if (raw && typeof raw.wikiPath === 'string' && fs.existsSync(raw.wikiPath)) return raw.wikiPath;
2066
+ } catch (e) { logDebug(e, 'visualizer config read'); }
2067
+ return null;
2068
+ };
2069
+ const writeVisualizerConfig = (wikiPath) => {
2070
+ try {
2071
+ fs.mkdirSync(path.dirname(visualizerConfigPath), { recursive: true });
2072
+ fs.writeFileSync(visualizerConfigPath, JSON.stringify({ wikiPath, updatedAt: new Date().toISOString() }, null, 2));
2073
+ } catch (e) { logDebug(e, 'visualizer config write'); }
2074
+ };
2075
+ let wikiPath = readVisualizerConfig();
2076
+ const ecosystemWiki = path.join(homeDir, '.openwiki', 'ecosystem-wiki');
2077
+ const syncScript = path.join(srcDir, 'skills', 'global_config', 'openwiki-skill', 'scripts', 'sync_ecosystem_wiki.py');
2078
+ if (!wikiPath) {
2079
+ if (looksLikeWiki(ecosystemWiki)) {
2080
+ wikiPath = ecosystemWiki;
2081
+ } else if (fs.existsSync(syncScript) && hasExecutable('python3')) {
2082
+ try {
2083
+ execSync(`python3 "${syncScript}"`, { stdio: 'ignore' });
2084
+ if (looksLikeWiki(ecosystemWiki)) wikiPath = ecosystemWiki;
2085
+ } catch (e) { logDebug(e, 'ecosystem wiki sync'); }
2086
+ }
2087
+ if (!wikiPath && !isAutoYes) {
2088
+ const answer = await text({
2089
+ message: `Which wiki should the :4321 visualizer serve? (directory) [default: ${ecosystemWiki}]`,
2090
+ placeholder: ecosystemWiki,
2091
+ });
2092
+ if (!isCancel(answer) && answer && answer.trim()) {
2093
+ const candidate = answer.trim().replace(/^~(?=$|\/|\\)/, homeDir);
2094
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
2095
+ wikiPath = candidate;
2096
+ if (!looksLikeWiki(candidate)) {
2097
+ log.warn(`No wiki markers found in ${candidate} — the daemon may exit until a wiki is generated there.`);
2098
+ }
2099
+ } else {
2100
+ log.warn(`Directory not found: ${candidate} — continuing without a visualizer path.`);
2101
+ }
2102
+ }
2103
+ }
2104
+ }
2105
+ if (wikiPath) {
2106
+ writeVisualizerConfig(wikiPath);
2107
+ } else {
2108
+ log.warn('OpenWiki Visualizer: no servable wiki configured — registering without a path, the daemon will exit until a wiki exists.');
2109
+ }
2110
+ const visualizeArgs = wikiPath
2111
+ ? `<string>${nodeBin}</string>\n <string>${openwikiBin}</string>\n <string>visualize</string>\n <string>${wikiPath}</string>\n <string>--port</string>`
2112
+ : `<string>${nodeBin}</string>\n <string>${openwikiBin}</string>\n <string>visualize</string>\n <string>--port</string>`;
2113
+
2016
2114
  if (process.platform === 'darwin') {
2017
2115
  const plistPath = path.join(homeDir, 'Library', 'LaunchAgents', 'com.bdb.openwiki-visualize.plist');
2018
2116
  const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
@@ -2023,9 +2121,7 @@ async function installOpenWikiVisualizer() {
2023
2121
  <string>com.bdb.openwiki-visualize</string>
2024
2122
  <key>ProgramArguments</key>
2025
2123
  <array>
2026
- <string>${openwikiBin}</string>
2027
- <string>visualize</string>
2028
- <string>--port</string>
2124
+ ${visualizeArgs}
2029
2125
  <string>4321</string>
2030
2126
  <string>--no-open</string>
2031
2127
  </array>
@@ -2061,7 +2157,8 @@ async function installOpenWikiVisualizer() {
2061
2157
  const stdoutLog = path.join(visualizerLogDir, 'visualize.stdout.log');
2062
2158
  const stderrLog = path.join(visualizerLogDir, 'visualize.stderr.log');
2063
2159
  const batPath = path.join(visualizerLogDir, 'run-openwiki-visualize.bat');
2064
- const runCmd = `"${openwikiBin}" visualize --port 4321 --no-open`;
2160
+ const targetWikiArg = wikiPath ? `"${wikiPath}" ` : '';
2161
+ const runCmd = `"${openwikiBin}" visualize ${targetWikiArg}--port 4321 --no-open`;
2065
2162
  const batContent = `@echo off\r\ncd /d "${homeDir}"\r\n${runCmd} >> "${stdoutLog}" 2>> "${stderrLog}"\r\n`;
2066
2163
  const vbsPath = path.join(startupDir, 'com.bdb.openwiki-visualize.vbs');
2067
2164
  const vbsContent = `Set WshShell = CreateObject("WScript.Shell")\r\nWshShell.CurrentDirectory = "${homeDir}"\r\nWshShell.Run """${batPath}""", 0, False\r\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridlabor-api/aos",
3
- "version": "4.6.1",
3
+ "version": "4.6.3",
4
4
  "description": "AOS — A Curated AI AGENT OS. Optimized agent skills and add-ons like memB, OpenWiki, Heimdall Token Saver, and Godmode architectures.",
5
5
  "main": "installer.js",
6
6
  "engines": {