akm-opencode 0.0.21 → 0.2.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.
- package/README.md +2 -2
- package/index.ts +68 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ At least one of `ref` or `query` is required.
|
|
|
75
75
|
|
|
76
76
|
## Prerequisites
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
When the plugin loads, it runs `bun install -g akm-cli@latest` so it always picks up the latest published npm package. It then prefers the Bun-installed binary and falls back to an existing `akm` on PATH when needed. It does not run the standalone shell installers automatically.
|
|
79
79
|
|
|
80
80
|
```sh
|
|
81
81
|
# macOS / Linux
|
|
@@ -84,7 +84,7 @@ curl -fsSL https://raw.githubusercontent.com/itlackey/agentikit/main/install.sh
|
|
|
84
84
|
irm https://raw.githubusercontent.com/itlackey/agentikit/main/install.ps1 -OutFile install.ps1; ./install.ps1
|
|
85
85
|
|
|
86
86
|
# Or via Bun
|
|
87
|
-
bun install -g akm-cli
|
|
87
|
+
bun install -g akm-cli@latest
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
## Stash model
|
package/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { execFileSync, execSync } from "node:child_process"
|
|
|
3
3
|
import path from "node:path"
|
|
4
4
|
|
|
5
5
|
let resolvedAkmCommand = "akm"
|
|
6
|
-
|
|
6
|
+
const autoInstallPackageRef = "akm-cli@latest"
|
|
7
7
|
|
|
8
8
|
type LogLevel = "debug" | "info" | "warn" | "error"
|
|
9
9
|
|
|
@@ -77,59 +77,84 @@ function getCommandStatus(command: string): "ok" | "missing" | "error" {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
function getBunGlobalAkmCommand(): string | null {
|
|
81
|
+
try {
|
|
82
|
+
const globalBin = execFileSync("bun", ["pm", "bin", "-g"], {
|
|
83
|
+
encoding: "utf8",
|
|
84
|
+
timeout: 10_000,
|
|
85
|
+
}).trim()
|
|
86
|
+
if (!globalBin || !path.isAbsolute(globalBin)) return null
|
|
87
|
+
return process.platform === "win32"
|
|
88
|
+
? path.join(globalBin, "akm.exe")
|
|
89
|
+
: path.join(globalBin, "akm")
|
|
90
|
+
} catch {
|
|
91
|
+
return null
|
|
86
92
|
}
|
|
87
|
-
|
|
93
|
+
}
|
|
88
94
|
|
|
95
|
+
async function ensureLatestAkmInstalled(client: LogCapableClient): Promise<void> {
|
|
89
96
|
try {
|
|
90
97
|
execFileSync("bun", ["--version"], {
|
|
91
98
|
encoding: "utf8",
|
|
92
99
|
timeout: 10_000,
|
|
93
100
|
})
|
|
94
|
-
} catch {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
} catch (error: unknown) {
|
|
102
|
+
await writePluginLog(client, "warn", "AKM auto-install skipped", {
|
|
103
|
+
subsystem: "akm",
|
|
104
|
+
installer: "bun",
|
|
105
|
+
error: `Bun is not available: ${formatCliError(error)}`,
|
|
106
|
+
})
|
|
107
|
+
return
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
try {
|
|
102
|
-
execFileSync("bun", ["install", "-g",
|
|
111
|
+
execFileSync("bun", ["install", "-g", autoInstallPackageRef], {
|
|
103
112
|
encoding: "utf8",
|
|
104
113
|
timeout: 120_000,
|
|
105
114
|
stdio: "pipe",
|
|
106
115
|
})
|
|
107
116
|
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const candidate = path.join(globalBin, process.platform === "win32" ? "akm.exe" : "akm")
|
|
114
|
-
if (getCommandStatus(candidate) === "ok") {
|
|
115
|
-
resolvedAkmCommand = candidate
|
|
116
|
-
return resolvedAkmCommand
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (getCommandStatus("akm") === "ok") {
|
|
117
|
+
const bunGlobalAkm = getBunGlobalAkmCommand()
|
|
118
|
+
if (bunGlobalAkm && getCommandStatus(bunGlobalAkm) === "ok") {
|
|
119
|
+
resolvedAkmCommand = bunGlobalAkm
|
|
120
|
+
} else if (getCommandStatus("akm") === "ok") {
|
|
120
121
|
resolvedAkmCommand = "akm"
|
|
121
|
-
return resolvedAkmCommand
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
await writePluginLog(client, "info", "AKM CLI install check completed", {
|
|
125
|
+
subsystem: "akm",
|
|
126
|
+
installer: "bun",
|
|
127
|
+
package: autoInstallPackageRef,
|
|
128
|
+
command: resolvedAkmCommand,
|
|
129
|
+
})
|
|
128
130
|
} catch (error: unknown) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
await writePluginLog(client, "warn", "AKM auto-install failed", {
|
|
132
|
+
subsystem: "akm",
|
|
133
|
+
installer: "bun",
|
|
134
|
+
package: autoInstallPackageRef,
|
|
135
|
+
error: formatCliError(error),
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function resolveAkmCommand(): string | CliError {
|
|
141
|
+
const currentStatus = getCommandStatus(resolvedAkmCommand)
|
|
142
|
+
if (currentStatus === "ok" || currentStatus === "error") return resolvedAkmCommand
|
|
143
|
+
|
|
144
|
+
const bunGlobalAkm = getBunGlobalAkmCommand()
|
|
145
|
+
if (bunGlobalAkm && getCommandStatus(bunGlobalAkm) === "ok") {
|
|
146
|
+
resolvedAkmCommand = bunGlobalAkm
|
|
147
|
+
return resolvedAkmCommand
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (getCommandStatus("akm") === "ok") {
|
|
151
|
+
resolvedAkmCommand = "akm"
|
|
152
|
+
return resolvedAkmCommand
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
ok: false,
|
|
157
|
+
error: `The 'akm' CLI could not be resolved after attempting to install '${autoInstallPackageRef}' with Bun. Install akm from https://github.com/itlackey/agentikit.`,
|
|
133
158
|
}
|
|
134
159
|
}
|
|
135
160
|
|
|
@@ -454,8 +479,11 @@ type PluginClient = {
|
|
|
454
479
|
}
|
|
455
480
|
}
|
|
456
481
|
|
|
457
|
-
export const AgentikitPlugin: Plugin = async ({ client }) =>
|
|
458
|
-
|
|
482
|
+
export const AgentikitPlugin: Plugin = async ({ client }) => {
|
|
483
|
+
await ensureLatestAkmInstalled(client as unknown as LogCapableClient)
|
|
484
|
+
|
|
485
|
+
return {
|
|
486
|
+
tool: {
|
|
459
487
|
akm_search: tool({
|
|
460
488
|
description: "Search your local stash or the akm registry for scripts, skills, commands, agents, and knowledge. Use source='registry' or akm_registry_search for installable community kits.",
|
|
461
489
|
args: {
|
|
@@ -862,5 +890,6 @@ export const AgentikitPlugin: Plugin = async ({ client }) => ({
|
|
|
862
890
|
return runCli(client as unknown as LogCapableClient, args, { toolName: "akm_upgrade" })
|
|
863
891
|
},
|
|
864
892
|
}),
|
|
865
|
-
|
|
866
|
-
}
|
|
893
|
+
},
|
|
894
|
+
}
|
|
895
|
+
}
|