@withakay/opencode-autopilot 0.3.0 → 0.3.1

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.
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Control session autopilot or hand off a long-running task
3
+ ---
4
+ Use the `autopilot` tool to control session autopilot.
5
+
6
+ Interpret `$ARGUMENTS` like this:
7
+ - `on` => enable autopilot for the rest of the session
8
+ - `off` or `stop` => disable autopilot
9
+ - `status` => show autopilot status
10
+ - `help` => show autopilot usage
11
+ - anything else => treat it as the delegated task and start it immediately
12
+
13
+ Additional parsing rules:
14
+ - If the user includes `allow-all` or `allow all`, set `permissionMode` to `allow-all`
15
+ - If the user includes `limited`, set `permissionMode` to `limited`
16
+ - If the user includes a continuation cap such as `max 3`, `max=3`, or `continue 3 times`, pass it as `maxContinues`
17
+ - If the user includes `agent <name>`, `use <name>`, or `agent=<name>`, pass it as `workerAgent`
18
+ - If the user includes `conservative`, `balanced`, or `aggressive`, pass it as `autonomousStrength`
19
+
20
+ Return only the tool result.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withakay/opencode-autopilot",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Autopilot mode plugin for OpenCode - autonomous multi-step task execution with safety guarantees",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,9 @@
14
14
  },
15
15
  "files": [
16
16
  "dist",
17
- "README.md"
17
+ "README.md",
18
+ ".opencode/commands/autopilot.md",
19
+ "scripts/install-slash-command.mjs"
18
20
  ],
19
21
  "scripts": {
20
22
  "build": "bun build ./index.ts --outdir ./dist --target node --sourcemap --external @opencode-ai/plugin --external @opencode-ai/sdk",
@@ -23,7 +25,8 @@
23
25
  "lint": "biome check .",
24
26
  "format": "biome format . --write",
25
27
  "check": "bun run lint && bun run typecheck",
26
- "prepublishOnly": "bun run build"
28
+ "prepublishOnly": "bun run build",
29
+ "postinstall": "node scripts/install-slash-command.mjs"
27
30
  },
28
31
  "keywords": [
29
32
  "opencode",
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Post-install script for @withakay/opencode-autopilot
4
+ * Automatically copies the autopilot slash command to the project's .opencode/commands/ directory
5
+ */
6
+
7
+ import { existsSync } from "node:fs";
8
+ import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
9
+ import { dirname, join, resolve } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ async function installSlashCommand() {
16
+ try {
17
+ // Find the project root (look for package.json)
18
+ let projectRoot = process.cwd();
19
+ let foundRoot = false;
20
+
21
+ // Walk up to find project root with package.json
22
+ for (let i = 0; i < 10; i++) {
23
+ if (existsSync(join(projectRoot, "package.json"))) {
24
+ foundRoot = true;
25
+ break;
26
+ }
27
+ const parent = dirname(projectRoot);
28
+ if (parent === projectRoot) break;
29
+ projectRoot = parent;
30
+ }
31
+
32
+ if (!foundRoot) {
33
+ console.log("⚠️ Could not find project root (no package.json found)");
34
+ console.log(" Skipping slash command installation");
35
+ return;
36
+ }
37
+
38
+ const commandsDir = join(projectRoot, ".opencode", "commands");
39
+ const targetFile = join(commandsDir, "autopilot.md");
40
+
41
+ // Source file location (in the installed package)
42
+ const sourceFile = resolve(__dirname, "..", ".opencode", "commands", "autopilot.md");
43
+
44
+ // Check if source exists
45
+ if (!existsSync(sourceFile)) {
46
+ console.log("⚠️ Source slash command not found at:", sourceFile);
47
+ return;
48
+ }
49
+
50
+ // Create .opencode/commands directory if it doesn't exist
51
+ await mkdir(commandsDir, { recursive: true });
52
+
53
+ // Check if target already exists
54
+ if (existsSync(targetFile)) {
55
+ const existing = await readFile(targetFile, "utf-8");
56
+ const source = await readFile(sourceFile, "utf-8");
57
+
58
+ if (existing === source) {
59
+ console.log("✅ Autopilot slash command already up to date");
60
+ return;
61
+ }
62
+
63
+ console.log("📝 Updating autopilot slash command...");
64
+ } else {
65
+ console.log("🚀 Installing autopilot slash command...");
66
+ }
67
+
68
+ // Copy the file
69
+ await copyFile(sourceFile, targetFile);
70
+ console.log("✅ Autopilot slash command installed to:", targetFile);
71
+ console.log(" You can now use: /autopilot on");
72
+ } catch (error) {
73
+ console.error("❌ Failed to install slash command:", error.message);
74
+ console.log(" You can manually copy it from: .opencode/commands/autopilot.md");
75
+ }
76
+ }
77
+
78
+ installSlashCommand();