agentapprove 0.1.2 → 0.1.4

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/dist/cli.js +29 -13
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2318,7 +2318,7 @@ import { homedir, hostname, platform } from "os";
2318
2318
  import { join, dirname, basename } from "path";
2319
2319
  import { execSync, spawnSync } from "child_process";
2320
2320
  import { randomBytes, createHash } from "crypto";
2321
- var VERSION = "0.1.1";
2321
+ var VERSION = "0.1.4";
2322
2322
  function getApiUrl() {
2323
2323
  return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
2324
2324
  }
@@ -3077,7 +3077,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
3077
3077
  return { success: true, backupPath, hooks: installedHooks };
3078
3078
  }
3079
3079
  if (agentId === "opencode") {
3080
- if (!config.plugin) {
3080
+ if (!Array.isArray(config.plugin)) {
3081
3081
  config.plugin = [];
3082
3082
  }
3083
3083
  const pluginArray = config.plugin;
@@ -3085,12 +3085,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
3085
3085
  pluginArray.push("@agentapprove/opencode");
3086
3086
  }
3087
3087
  writeJsonConfig(agent.configPath, config);
3088
- const opencodePkgDir = join(getOpenCodeConfigDir(), ".opencode");
3089
- const opencodePkgPath = join(opencodePkgDir, "package.json");
3088
+ const opencodePkgPath = join(getOpenCodeConfigDir(), "package.json");
3090
3089
  try {
3091
- if (!existsSync(opencodePkgDir)) {
3092
- mkdirSync(opencodePkgDir, { recursive: true });
3093
- }
3094
3090
  let pkgJson = {};
3095
3091
  if (existsSync(opencodePkgPath)) {
3096
3092
  pkgJson = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
@@ -3103,7 +3099,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
3103
3099
  `);
3104
3100
  } catch (err) {
3105
3101
  if (err instanceof Error) {
3106
- console.warn(`Warning: Could not update .opencode/package.json: ${err.message}`);
3102
+ console.warn(`Warning: Could not update package.json: ${err.message}`);
3107
3103
  }
3108
3104
  }
3109
3105
  installedHooks.push("agentapprove");
@@ -3429,7 +3425,7 @@ function getManualInstructions(agentId, hooksDir) {
3429
3425
  "",
3430
3426
  configJson,
3431
3427
  "",
3432
- "Then add the dependency to .opencode/package.json:",
3428
+ "Then add the dependency to your OpenCode package.json (same directory):",
3433
3429
  "",
3434
3430
  ' { "dependencies": { "@agentapprove/opencode": "latest" } }',
3435
3431
  "",
@@ -4058,6 +4054,9 @@ AGENTAPPROVE_E2E_MODE=${installMode}
4058
4054
  for (const agentId of selectedAgents) {
4059
4055
  const agent = AGENTS[agentId];
4060
4056
  filesToModify.push(agent.configPath);
4057
+ if (agentId === "opencode") {
4058
+ filesToModify.push(join(getOpenCodeConfigDir(), "package.json"));
4059
+ }
4061
4060
  if (agentId === "vscode-agent") {
4062
4061
  const vsCodeVariants = findInstalledVSCodeVariants();
4063
4062
  for (const { path: settingsPath, variant } of vsCodeVariants) {
@@ -4171,6 +4170,20 @@ async function statusCommand() {
4171
4170
  for (const [agentId, agent] of Object.entries(AGENTS)) {
4172
4171
  if (existsSync(agent.configPath)) {
4173
4172
  const config = readJsonConfig(agent.configPath);
4173
+ if (agentId === "opencode") {
4174
+ const pluginConfig = config.plugin;
4175
+ if (Array.isArray(pluginConfig) && pluginConfig.some((entry) => typeof entry === "string" && entry.includes("@agentapprove/opencode"))) {
4176
+ console.log(` ${source_default.green("✓")} ${agent.name}: agentapprove plugin`);
4177
+ }
4178
+ continue;
4179
+ }
4180
+ if (agentId === "openclaw") {
4181
+ const entries = config.plugins?.entries;
4182
+ if (entries?.agentapprove) {
4183
+ console.log(` ${source_default.green("✓")} ${agent.name}: agentapprove plugin`);
4184
+ }
4185
+ continue;
4186
+ }
4174
4187
  const hooksConfig = config[agent.hooksKey];
4175
4188
  if (hooksConfig) {
4176
4189
  const installedHooks = agent.hooks.filter((h2) => {
@@ -4236,20 +4249,23 @@ async function uninstallCommand() {
4236
4249
  continue;
4237
4250
  const config = readJsonConfig(agent.configPath);
4238
4251
  const hooksConfig = config[agent.hooksKey];
4239
- if (!hooksConfig)
4252
+ if (!hooksConfig && agentId !== "opencode")
4240
4253
  continue;
4241
4254
  let modified = false;
4242
4255
  if (agentId === "opencode") {
4243
4256
  const pluginArray = config.plugin;
4244
4257
  if (Array.isArray(pluginArray)) {
4245
- const filtered = pluginArray.filter((p) => !p.includes("agentapprove"));
4258
+ const filtered = pluginArray.filter((p) => {
4259
+ if (typeof p !== "string")
4260
+ return true;
4261
+ return !p.includes("agentapprove");
4262
+ });
4246
4263
  if (filtered.length !== pluginArray.length) {
4247
4264
  config.plugin = filtered;
4248
4265
  modified = true;
4249
4266
  }
4250
4267
  }
4251
- const opencodePkgDir = join(getOpenCodeConfigDir(), ".opencode");
4252
- const opencodePkgPath = join(opencodePkgDir, "package.json");
4268
+ const opencodePkgPath = join(getOpenCodeConfigDir(), "package.json");
4253
4269
  try {
4254
4270
  if (existsSync(opencodePkgPath)) {
4255
4271
  const pkgJson = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentapprove",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Approve AI agent actions from your iPhone or Apple Watch",
5
5
  "type": "module",
6
6
  "bin": {