@aerovato/operator-helper 1.3.0 → 1.3.2

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/index.js CHANGED
@@ -17998,7 +17998,7 @@ var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, {
17998
17998
  // package.json
17999
17999
  var package_default = {
18000
18000
  name: "@aerovato/operator-helper",
18001
- version: "1.3.0",
18001
+ version: "1.3.2",
18002
18002
  description: "Installation and setup CLI for Operator Memory",
18003
18003
  license: "BSD-3-Clause",
18004
18004
  author: "Aerovato Research",
@@ -18025,7 +18025,8 @@ var package_default = {
18025
18025
  node: ">=20"
18026
18026
  },
18027
18027
  files: [
18028
- "dist"
18028
+ "dist",
18029
+ "!dist/*.map"
18029
18030
  ],
18030
18031
  keywords: [
18031
18032
  "opencode",
@@ -19202,6 +19203,9 @@ var installCodex = fn2("installCodex")(function* (context) {
19202
19203
  if (!marketplace.ok)
19203
19204
  return marketplace.result;
19204
19205
  const addMarketplace = yield* runProcess("codex", ["plugin", "marketplace", "add", marketplace.path, "--json"], context.cwd, { NPM_CONFIG_MIN_RELEASE_AGE: "0" });
19206
+ if (!addMarketplace.ok && isMissingBinary(addMarketplace.error)) {
19207
+ return yield* registerDesktopMarketplace(context, marketplace.path);
19208
+ }
19205
19209
  const addFailure = commandFailure(addMarketplace, "Codex marketplace installation failed");
19206
19210
  if (addFailure !== null)
19207
19211
  return addFailure;
@@ -19261,6 +19265,68 @@ function writeMarketplace(home) {
19261
19265
  }
19262
19266
  });
19263
19267
  }
19268
+ function isMissingBinary(error) {
19269
+ return error.startsWith("NotFound:");
19270
+ }
19271
+ function registerDesktopMarketplace(context, marketplacePath) {
19272
+ return promise2(async () => {
19273
+ const codexHome = process.env.CODEX_HOME || join3(context.home, ".codex");
19274
+ const config = join3(codexHome, "config.toml");
19275
+ try {
19276
+ const content = await readOptionalFile(config);
19277
+ await mkdir3(codexHome, { recursive: true });
19278
+ await writeFile4(config, upsertMarketplaceTable(content, marketplacePath));
19279
+ } catch (error) {
19280
+ return {
19281
+ exitCode: 1,
19282
+ output: `✗ Could not register the Codex marketplace: ${getErrorMessage(error)}`
19283
+ };
19284
+ }
19285
+ return {
19286
+ exitCode: 0,
19287
+ output: [
19288
+ "✓ Registered the Operator Codex marketplace",
19289
+ "Codex CLI unavailable: install aerovato@operator-memory from the Codex plugins browser, then start a new session and approve the Operator hooks."
19290
+ ].join(`
19291
+ `)
19292
+ };
19293
+ });
19294
+ }
19295
+ function upsertMarketplaceTable(content, source) {
19296
+ const header = `[marketplaces.${MARKETPLACE_NAME}]`;
19297
+ const block = `${header}
19298
+ source_type = "local"
19299
+ source = ${JSON.stringify(source)}
19300
+ `;
19301
+ if (content === null)
19302
+ return block;
19303
+ const lines = content.split(`
19304
+ `);
19305
+ for (const line of lines) {
19306
+ const trimmed = line.trim();
19307
+ if (/^marketplaces\s*=/.test(trimmed) || /^marketplaces\./.test(trimmed)) {
19308
+ throw new Error("config.toml expresses marketplaces without tables; refusing to edit it");
19309
+ }
19310
+ }
19311
+ const headerPattern = new RegExp(`^\\[\\s*marketplaces\\.${MARKETPLACE_NAME}\\s*\\]$`);
19312
+ const headerIndex = lines.findIndex((line) => headerPattern.test(line.trim()));
19313
+ if (headerIndex === -1) {
19314
+ return content.endsWith(`
19315
+ `) || content.length === 0 ? `${content}${block}` : `${content}
19316
+ ${block}`;
19317
+ }
19318
+ let end = lines.length;
19319
+ for (let index = headerIndex + 1;index < lines.length; index += 1) {
19320
+ const line = lines[index];
19321
+ if (line !== undefined && /^\s*\[\[?/.test(line)) {
19322
+ end = index;
19323
+ break;
19324
+ }
19325
+ }
19326
+ return [...lines.slice(0, headerIndex), ...block.split(`
19327
+ `), ...lines.slice(end)].join(`
19328
+ `);
19329
+ }
19264
19330
  function isInstalledAndEnabled(output) {
19265
19331
  try {
19266
19332
  const value = JSON.parse(output);
@@ -20328,95 +20394,10 @@ var userStatus = fn2("userStatus")(function* (context) {
20328
20394
  `) };
20329
20395
  });
20330
20396
 
20331
- // src/cli.ts
20332
- var HELP = `Operator Helper
20333
-
20334
- USER COMMANDS
20335
-
20336
- ${renderTable([
20337
- ["help", "Show help for operator-helper"],
20338
- ["version", "Show the installed version"],
20339
- ["operator-helper install codex", "Install or update the Codex plugin"],
20340
- ["operator-helper install opencode", "Install or update the OpenCode plugin"],
20341
- ["operator-helper install opencode-v2", "Install or update the OpenCode V2 plugin"],
20342
- ["operator-helper install pi", "Install or update the Pi plugin"],
20343
- ["operator-helper install code-puppy", "Install or update the Code Puppy plugin"]
20344
- ])}
20345
-
20346
- AGENT COMMANDS
20347
-
20348
- ${renderTable([
20349
- ["operator-helper user status", "Show User Partition status"],
20350
- ["operator-helper user init", "Initialize User Partition core files without overwriting content"],
20351
- ["operator-helper user guide", "Print the agent guide for completing User Setup"],
20352
- [
20353
- "operator-helper project status",
20354
- "Show Project Private, Shared, Git ignore, and tracking status"
20355
- ],
20356
- ["operator-helper project init", "Initialize project partitions and global Git ignore"],
20357
- ["operator-helper project guide", "Print the agent guide for completing Project Setup"],
20358
- ["operator-helper index status", "Show Private and Shared main Project Index status"],
20359
- ["operator-helper index guide", "Print the agent guide for building or refreshing indexes"],
20360
- ["operator-helper index lint", "Check Project Index structure and frontmatter"],
20361
- ["operator-helper memory check", "Check that all Operator memory can be loaded"],
20362
- ["operator-helper preamble", "Render the Operator preamble"]
20363
- ])}`;
20364
- function runCli(arguments_, context) {
20365
- return gen2(function* () {
20366
- if (arguments_.length === 1 && arguments_[0] === "help") {
20367
- return { exitCode: 0, output: HELP };
20368
- }
20369
- if (arguments_.length === 1 && arguments_[0] === "version") {
20370
- return { exitCode: 0, output: context.version };
20371
- }
20372
- if (arguments_.length === 1 && arguments_[0] === "preamble") {
20373
- return yield* preamble(context);
20374
- }
20375
- if (arguments_.length !== 2) {
20376
- return { exitCode: 2, output: HELP };
20377
- }
20378
- const command = `${arguments_[0]} ${arguments_[1]}`;
20379
- switch (command) {
20380
- case "user status":
20381
- return yield* userStatus(context);
20382
- case "user init":
20383
- return yield* userInit(context);
20384
- case "user guide":
20385
- return yield* userGuide();
20386
- case "project status":
20387
- return yield* projectStatus(context);
20388
- case "project init":
20389
- return yield* projectInit(context);
20390
- case "project guide":
20391
- return yield* projectGuide();
20392
- case "index status":
20393
- return yield* indexStatus(context);
20394
- case "index guide":
20395
- return yield* indexGuide();
20396
- case "index lint":
20397
- return yield* indexLint(context);
20398
- case "memory check":
20399
- return yield* memoryCheck(context);
20400
- case "install codex":
20401
- return yield* installCodex(context);
20402
- case "install opencode":
20403
- return yield* installOpenCode(context);
20404
- case "install opencode-v2":
20405
- return yield* installOpenCodeV2(context);
20406
- case "install pi":
20407
- return yield* installPi(context);
20408
- case "install code-puppy":
20409
- return yield* installCodePuppy(context);
20410
- default:
20411
- return {
20412
- exitCode: 2,
20413
- output: `Unknown command: ${command}
20414
-
20415
- ${HELP}`
20416
- };
20417
- }
20418
- }).pipe(catch_2((error) => succeed6(fileFailure(error))));
20419
- }
20397
+ // src/update.ts
20398
+ import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
20399
+ import { realpathSync } from "node:fs";
20400
+ import { dirname as dirname2, join as join6, sep as sep2 } from "node:path";
20420
20401
 
20421
20402
  // src/npm-registry.ts
20422
20403
  class NpmRegistryError extends TaggedError2("NpmRegistryError") {
@@ -20454,9 +20435,6 @@ var NpmRegistry;
20454
20435
  })(NpmRegistry ||= {});
20455
20436
 
20456
20437
  // src/update.ts
20457
- import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile5 } from "node:fs/promises";
20458
- import { realpathSync } from "node:fs";
20459
- import { dirname as dirname2, join as join6, sep as sep2 } from "node:path";
20460
20438
  var HELPER_PACKAGE = "@aerovato/operator-helper";
20461
20439
  var UPDATE_TIMEOUT = "60 seconds";
20462
20440
  var SUCCESS_COOLDOWN = 60 * 60 * 1000;
@@ -20475,8 +20453,8 @@ function updateCheckPath(context) {
20475
20453
  const cache = process.env.XDG_CACHE_HOME || join6(context.home, ".cache");
20476
20454
  return join6(cache, "operator", "helper-update.json");
20477
20455
  }
20478
- var autoUpdate = fn2("autoUpdate")(function* (currentVersion, context) {
20479
- const cached = yield* promise2(() => readUpdateCheck(context));
20456
+ var autoUpdate = fn2("autoUpdate")(function* (currentVersion, context, bypassCache) {
20457
+ const cached = bypassCache ? null : yield* promise2(() => readUpdateCheck(context));
20480
20458
  if (cached !== null && isFresh(cached)) {
20481
20459
  if (cached.status === "unknown") {
20482
20460
  return { status: "unknown", latest: cached.latest };
@@ -20511,7 +20489,7 @@ var autoUpdate = fn2("autoUpdate")(function* (currentVersion, context) {
20511
20489
  const execution = yield* run3(spawner, command).pipe(timeout2(UPDATE_TIMEOUT), option2);
20512
20490
  if (isSome2(execution) && execution.value.exitCode === 0) {
20513
20491
  yield* promise2(() => writeUpdateCheck(context, { checkedAt: Date.now(), status: "current" }));
20514
- return { status: "updated" };
20492
+ return { status: "updated", latest: latest.value };
20515
20493
  }
20516
20494
  yield* promise2(() => writeUpdateCheck(context, { checkedAt: Date.now(), status: "failed" }));
20517
20495
  return { status: "failed" };
@@ -20595,6 +20573,118 @@ function parseVersion(value) {
20595
20573
  return [Number(match[1]), Number(match[2]), Number(match[3])];
20596
20574
  }
20597
20575
 
20576
+ // src/commands/upgrade.ts
20577
+ var upgrade = fn2("upgrade")(function* (context) {
20578
+ const result = yield* autoUpdate(context.version, context, true);
20579
+ switch (result.status) {
20580
+ case "current":
20581
+ return { exitCode: 0, output: `Operator Helper ${context.version} is up to date.` };
20582
+ case "updated":
20583
+ return { exitCode: 0, output: `Operator Helper updated to ${result.latest}.` };
20584
+ case "unknown":
20585
+ return {
20586
+ exitCode: 1,
20587
+ output: `Operator Helper ${result.latest} is available, but the update could not determine whether Bun or npm owns this installation. Update operator-helper manually using the original installation method.`
20588
+ };
20589
+ case "failed":
20590
+ return { exitCode: 1, output: "Operator Helper update failed." };
20591
+ }
20592
+ });
20593
+
20594
+ // src/cli.ts
20595
+ var HELP = `Operator Helper
20596
+
20597
+ USER COMMANDS
20598
+
20599
+ ${renderTable([
20600
+ ["help", "Show help for operator-helper"],
20601
+ ["version", "Show the installed version"],
20602
+ ["upgrade", "Update Operator Helper to the latest release"],
20603
+ ["operator-helper install codex", "Install or update the Codex plugin"],
20604
+ ["operator-helper install opencode", "Install or update the OpenCode plugin"],
20605
+ ["operator-helper install opencode-v2", "Install or update the OpenCode V2 plugin"],
20606
+ ["operator-helper install pi", "Install or update the Pi plugin"],
20607
+ ["operator-helper install code-puppy", "Install or update the Code Puppy plugin"]
20608
+ ])}
20609
+
20610
+ AGENT COMMANDS
20611
+
20612
+ ${renderTable([
20613
+ ["operator-helper user status", "Show User Partition status"],
20614
+ ["operator-helper user init", "Initialize User Partition core files without overwriting content"],
20615
+ ["operator-helper user guide", "Print the agent guide for completing User Setup"],
20616
+ [
20617
+ "operator-helper project status",
20618
+ "Show Project Private, Shared, Git ignore, and tracking status"
20619
+ ],
20620
+ ["operator-helper project init", "Initialize project partitions and global Git ignore"],
20621
+ ["operator-helper project guide", "Print the agent guide for completing Project Setup"],
20622
+ ["operator-helper index status", "Show Private and Shared main Project Index status"],
20623
+ ["operator-helper index guide", "Print the agent guide for building or refreshing indexes"],
20624
+ ["operator-helper index lint", "Check Project Index structure and frontmatter"],
20625
+ ["operator-helper memory check", "Check that all Operator memory can be loaded"],
20626
+ ["operator-helper preamble", "Render the Operator preamble"]
20627
+ ])}`;
20628
+ function runCli(arguments_, context) {
20629
+ return gen2(function* () {
20630
+ if (arguments_.length === 1 && arguments_[0] === "help") {
20631
+ return { exitCode: 0, output: HELP };
20632
+ }
20633
+ if (arguments_.length === 1 && arguments_[0] === "version") {
20634
+ return { exitCode: 0, output: context.version };
20635
+ }
20636
+ if (arguments_.length === 1 && arguments_[0] === "preamble") {
20637
+ return yield* preamble(context);
20638
+ }
20639
+ if (arguments_.length === 1 && arguments_[0] === "upgrade") {
20640
+ return yield* upgrade(context);
20641
+ }
20642
+ if (arguments_.length !== 2) {
20643
+ return { exitCode: 2, output: HELP };
20644
+ }
20645
+ const command = `${arguments_[0]} ${arguments_[1]}`;
20646
+ switch (command) {
20647
+ case "user status":
20648
+ return yield* userStatus(context);
20649
+ case "user init":
20650
+ return yield* userInit(context);
20651
+ case "user guide":
20652
+ return yield* userGuide();
20653
+ case "project status":
20654
+ return yield* projectStatus(context);
20655
+ case "project init":
20656
+ return yield* projectInit(context);
20657
+ case "project guide":
20658
+ return yield* projectGuide();
20659
+ case "index status":
20660
+ return yield* indexStatus(context);
20661
+ case "index guide":
20662
+ return yield* indexGuide();
20663
+ case "index lint":
20664
+ return yield* indexLint(context);
20665
+ case "memory check":
20666
+ return yield* memoryCheck(context);
20667
+ case "install codex":
20668
+ return yield* installCodex(context);
20669
+ case "install opencode":
20670
+ return yield* installOpenCode(context);
20671
+ case "install opencode-v2":
20672
+ return yield* installOpenCodeV2(context);
20673
+ case "install pi":
20674
+ return yield* installPi(context);
20675
+ case "install code-puppy":
20676
+ return yield* installCodePuppy(context);
20677
+ default:
20678
+ return {
20679
+ exitCode: 2,
20680
+ output: `Unknown command: ${command}
20681
+
20682
+ ${HELP}`
20683
+ };
20684
+ }
20685
+ }).pipe(catch_2((error) => succeed6(fileFailure(error))));
20686
+ }
20687
+
20598
20688
  // src/index.ts
20599
20689
  var SKIP_UPDATE_ENVIRONMENT_VARIABLE = "OPERATOR_HELPER_SKIP_UPDATE";
20600
20690
  var ChildProcessLayer = layer.pipe(provide2(layer3), provide2(layer5));
@@ -20608,7 +20698,7 @@ var main = gen2(function* () {
20608
20698
  version: package_default.version
20609
20699
  };
20610
20700
  if (process.env[SKIP_UPDATE_ENVIRONMENT_VARIABLE] !== "1") {
20611
- const update = yield* autoUpdate(package_default.version, environment);
20701
+ const update = yield* autoUpdate(package_default.version, environment, false);
20612
20702
  if (update.status === "updated") {
20613
20703
  const entrypoint = process.argv[1];
20614
20704
  if (entrypoint !== undefined) {
@@ -20637,4 +20727,4 @@ var main = gen2(function* () {
20637
20727
  }).pipe(provide4(LiveLayers));
20638
20728
  runMain2(main);
20639
20729
 
20640
- //# debugId=EE71A176DAC5289D64756E2164756E21
20730
+ //# debugId=5C64FD78B739360C64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerovato/operator-helper",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Installation and setup CLI for Operator Memory",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Aerovato Research",
@@ -27,7 +27,8 @@
27
27
  "node": ">=20"
28
28
  },
29
29
  "files": [
30
- "dist"
30
+ "dist",
31
+ "!dist/*.map"
31
32
  ],
32
33
  "keywords": [
33
34
  "opencode",