opencode-agent-modes 0.1.0

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 @@
1
+ export { ModeManager } from './manager.ts';
@@ -0,0 +1,54 @@
1
+ import type { OpencodeClient } from '@opencode-ai/sdk';
2
+ import type { ModePreset } from '../config/types.ts';
3
+ /**
4
+ * Manages agent mode switching between different presets
5
+ */
6
+ export declare class ModeManager {
7
+ private readonly client;
8
+ private config;
9
+ constructor(client: OpencodeClient);
10
+ /**
11
+ * Initialize the mode manager and load configuration
12
+ */
13
+ initialize(): Promise<void>;
14
+ /**
15
+ * Ensure configuration is loaded
16
+ */
17
+ private ensureConfig;
18
+ /**
19
+ * Get the current mode name
20
+ */
21
+ getCurrentMode(): Promise<string>;
22
+ /**
23
+ * Get a specific preset by name
24
+ */
25
+ getPreset(modeName: string): Promise<ModePreset | undefined>;
26
+ /**
27
+ * Get all available mode names
28
+ */
29
+ listModes(): Promise<string>;
30
+ /**
31
+ * Get current status including mode and agent configurations
32
+ */
33
+ getStatus(): Promise<string>;
34
+ /**
35
+ * Switch to a different mode
36
+ */
37
+ switchMode(modeName: string): Promise<string>;
38
+ /**
39
+ * Update opencode.json with global model and agent section
40
+ * @param globalModel - Global model setting (optional)
41
+ * @param agentPresets - Agent-specific model settings
42
+ * @returns Result status: "updated", "skipped (not found)", or "error: ..."
43
+ */
44
+ private updateOpencodeConfig;
45
+ /**
46
+ * Update oh-my-opencode.json agents section with preset values
47
+ * @returns Result status: "updated", "skipped (not found)", or "error: ..."
48
+ */
49
+ private updateOhMyOpencodeConfig;
50
+ /**
51
+ * Check if toast should be shown on startup
52
+ */
53
+ shouldShowToastOnStartup(): Promise<boolean>;
54
+ }
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ // scripts/postinstall.ts
4
+ import { copyFileSync, mkdirSync, readdirSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { dirname, join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ var __dirname2 = dirname(fileURLToPath(import.meta.url));
9
+ var COMMANDS_SRC = join(__dirname2, "..", "commands");
10
+ var COMMANDS_DEST = join(homedir(), ".config", "opencode", "command");
11
+ try {
12
+ mkdirSync(COMMANDS_DEST, { recursive: true });
13
+ const files = readdirSync(COMMANDS_SRC).filter((f) => f.endsWith(".md"));
14
+ for (const file of files) {
15
+ copyFileSync(join(COMMANDS_SRC, file), join(COMMANDS_DEST, file));
16
+ }
17
+ console.log(`[opencode-agent-modes] Copied ${files.length} command files to ${COMMANDS_DEST}`);
18
+ } catch (error) {
19
+ console.warn("[opencode-agent-modes] Warning: Could not copy command files:", error);
20
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "opencode-agent-modes",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin to switch agent modes between performance and economy presets",
5
+ "module": "src/index.ts",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "private": false,
10
+ "files": [
11
+ "dist/*.js",
12
+ "dist/*.d.ts",
13
+ "dist/config",
14
+ "dist/modes",
15
+ "commands"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/j4rviscmd/opencode-agent-modes.git"
20
+ },
21
+ "homepage": "https://github.com/j4rviscmd/opencode-agent-modes#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/j4rviscmd/opencode-agent-modes/issues"
24
+ },
25
+ "scripts": {
26
+ "typecheck": "tsc --noEmit",
27
+ "build": "bun build src/index.ts --outdir dist --format esm && bun build scripts/postinstall.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json",
28
+ "lint": "bunx biome check src/",
29
+ "format": "prettier --write 'src/**/*.ts'",
30
+ "format:check": "prettier --check 'src/**/*.ts'",
31
+ "test": "bun test",
32
+ "test:watch": "bun test --watch",
33
+ "test:coverage": "bun test --coverage",
34
+ "postinstall": "node dist/postinstall.js",
35
+ "prepublishOnly": "bun run build"
36
+ },
37
+ "keywords": [
38
+ "opencode",
39
+ "plugin",
40
+ "agent",
41
+ "mode",
42
+ "switcher"
43
+ ],
44
+ "author": "j4rviscmd",
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "devDependencies": {
50
+ "@types/bun": "latest",
51
+ "prettier": "^3.8.0"
52
+ },
53
+ "peerDependencies": {
54
+ "typescript": "^5"
55
+ },
56
+ "dependencies": {
57
+ "@opencode-ai/plugin": "^1.1.25",
58
+ "@opencode-ai/sdk": "^1.1.25",
59
+ "jsonc-parser": "^3.3.1"
60
+ }
61
+ }