@omagents/omagents-codex 0.0.0-stage → 0.14.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.
package/bin/install.js ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * OmAgents Codex installer.
4
+ *
5
+ * Run via: npx @omagents/omagents-codex
6
+ */
7
+
8
+ import fs from "node:fs"
9
+ import { installCodex } from "../src/setup.js"
10
+
11
+ const USAGE = "Usage: npx @omagents/omagents-codex [options]"
12
+
13
+ function printHelp() {
14
+ console.log(`${USAGE}
15
+
16
+ Install OmAgents for Codex without a positional host argument.
17
+
18
+ Options:
19
+ --help Show this help message
20
+ --version Show the package version`)
21
+ }
22
+
23
+ async function main(args) {
24
+ if (args.length === 0) {
25
+ await installCodex()
26
+ return
27
+ }
28
+
29
+ if (args.length === 1 && args[0] === "--help") {
30
+ printHelp()
31
+ return
32
+ }
33
+
34
+ if (args.length === 1 && args[0] === "--version") {
35
+ const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"))
36
+ console.log(pkg.version)
37
+ return
38
+ }
39
+
40
+ console.error(`[omagents] Unknown or unexpected arguments: ${args.join(" ")}`)
41
+ console.error(USAGE)
42
+ process.exitCode = 1
43
+ }
44
+
45
+ main(process.argv.slice(2)).catch((err) => {
46
+ console.error("[omagents]", err.message)
47
+ process.exitCode = 1
48
+ })
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@omagents/omagents-codex",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.14.1",
4
+ "description": "Codex agent toolkit: bundled skills, MCP servers, native subagents, and superpowers",
5
+ "type": "module",
6
+ "main": "src/setup.js",
7
+ "bin": {
8
+ "omagents-codex": "bin/install.js"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "src/"
13
+ ],
14
+ "keywords": [
15
+ "codex",
16
+ "plugin",
17
+ "skills",
18
+ "mcp",
19
+ "agents"
20
+ ],
21
+ "author": "",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/omagents/omagents"
26
+ },
27
+ "dependencies": {
28
+ "@omagents/core": "0.14.1"
29
+ },
30
+ "scripts": {
31
+ "test": "node --test test/*.test.js"
32
+ }
33
+ }
package/src/setup.js ADDED
@@ -0,0 +1,308 @@
1
+ /**
2
+ * OmAgents Codex installer.
3
+ *
4
+ * Run via: npx @omagents/omagents-codex
5
+ *
6
+ * Copies the OmAgents plugin into ~/.codex/plugins/cache/omagents/omagents/local/
7
+ * and enables it in ~/.codex/config.toml. No marketplace required.
8
+ */
9
+
10
+ import fs from "node:fs"
11
+ import path from "node:path"
12
+ import os from "node:os"
13
+ import { fileURLToPath } from "node:url"
14
+ import {
15
+ getCorePaths,
16
+ listSkillDefinitions,
17
+ renderSkillForHost,
18
+ resolveMcpServers,
19
+ } from "@omagents/core"
20
+
21
+ const HOOKS_CONFIG = {
22
+ hooks: {
23
+ SessionStart: [
24
+ {
25
+ matcher: "startup|resume",
26
+ hooks: [
27
+ {
28
+ type: "command",
29
+ command: "node ${PLUGIN_ROOT}/hooks/setup-venv.js",
30
+ timeout: 120,
31
+ },
32
+ ],
33
+ },
34
+ ],
35
+ },
36
+ }
37
+
38
+ // ─── Helpers ────────────────────────────────────────────────────────────────
39
+
40
+ function readJson(filePath) {
41
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"))
42
+ }
43
+
44
+ function mkdirp(dir) {
45
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 })
46
+ }
47
+
48
+ function copyDir(src, dest) {
49
+ mkdirp(dest)
50
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
51
+ const srcPath = path.join(src, entry.name)
52
+ const destPath = path.join(dest, entry.name)
53
+ if (entry.isDirectory()) {
54
+ if (entry.name === "__pycache__" || entry.name === ".DS_Store") continue
55
+ copyDir(srcPath, destPath)
56
+ } else {
57
+ fs.copyFileSync(srcPath, destPath)
58
+ }
59
+ }
60
+ }
61
+
62
+ // ─── .mcp.json generation ───────────────────────────────────────────────────
63
+
64
+ function generateMcpJson(env) {
65
+ const servers = {}
66
+ for (const [name, definition] of Object.entries(resolveMcpServers({ env }))) {
67
+ if (definition.command) {
68
+ servers[name] = {
69
+ command: definition.command[0],
70
+ args: definition.command.slice(1),
71
+ ...(definition.environment ? { env: definition.environment } : {}),
72
+ }
73
+ } else {
74
+ servers[name] = { url: definition.url }
75
+ if (definition.headers?.Authorization) {
76
+ servers[name].bearer_token_env_var = "GITHUB_TOKEN"
77
+ } else if (definition.headers) {
78
+ servers[name].headers = definition.headers
79
+ }
80
+ }
81
+ }
82
+ return { mcpServers: servers }
83
+ }
84
+
85
+ // ─── plugin.json generation ─────────────────────────────────────────────────
86
+
87
+ function generatePluginJson(version, description) {
88
+ return {
89
+ name: "omagents",
90
+ version,
91
+ description,
92
+ author: { name: "OmAgents" },
93
+ homepage: "https://github.com/omagents/omagents",
94
+ repository: "https://github.com/omagents/omagents",
95
+ license: "MIT",
96
+ keywords: ["skills", "mcp", "agents", "research"],
97
+ skills: "./skills/",
98
+ mcpServers: "./.mcp.json",
99
+ hooks: "./hooks/hooks.json",
100
+ interface: {
101
+ displayName: "OmAgents",
102
+ shortDescription: description,
103
+ longDescription: description,
104
+ developerName: "OmAgents",
105
+ category: "Developer Tools",
106
+ capabilities: ["Read", "Write"],
107
+ },
108
+ }
109
+ }
110
+
111
+ // ─── marketplace.json generation ────────────────────────────────────────────
112
+
113
+ function generateMarketplaceJson() {
114
+ return {
115
+ name: "omagents",
116
+ interface: { displayName: "OmAgents" },
117
+ plugins: [
118
+ {
119
+ name: "omagents",
120
+ source: "./omagents",
121
+ category: "Developer Tools",
122
+ policy: { installation: "AVAILABLE" },
123
+ },
124
+ ],
125
+ }
126
+ }
127
+
128
+ // ─── config.toml management ─────────────────────────────────────────────────
129
+
130
+ /** JSON and TOML basic strings share the escapes emitted here, except DEL. */
131
+ export function serializeTomlBasicString(value) {
132
+ if (typeof value !== "string") throw new TypeError("TOML string value must be a string")
133
+ return JSON.stringify(value).replace(/\u007f/g, "\\u007F")
134
+ }
135
+
136
+ const MARKER_START = "# >>> omagents >>>"
137
+ const MARKER_END = "# <<< omagents <<<"
138
+
139
+ // Section prefixes to strip (matches header and all sub-tables)
140
+ const MANAGED_PREFIXES = ["[marketplaces.omagents", '[plugins."omagents@omagents']
141
+
142
+ function stripManagedSections(config) {
143
+ const lines = config.split("\n")
144
+ const result = []
145
+ let skipping = false
146
+
147
+ for (const line of lines) {
148
+ const trimmed = line.trim()
149
+ if (trimmed.startsWith("[")) {
150
+ skipping = MANAGED_PREFIXES.some((p) => trimmed.startsWith(p))
151
+ }
152
+ if (!skipping) result.push(line)
153
+ }
154
+
155
+ // Trim trailing blank lines
156
+ while (result.length > 0 && result[result.length - 1].trim() === "") {
157
+ result.pop()
158
+ }
159
+ return result.join("\n")
160
+ }
161
+
162
+ function updateConfigToml(configPath, pluginSection) {
163
+ let config = ""
164
+ if (fs.existsSync(configPath)) {
165
+ config = fs.readFileSync(configPath, "utf-8")
166
+ }
167
+
168
+ // Remove existing marker block
169
+ const startIdx = config.indexOf(MARKER_START)
170
+ const endIdx = config.indexOf(MARKER_END)
171
+ if (startIdx !== -1 && endIdx !== -1) {
172
+ config = config.substring(0, startIdx) + config.substring(endIdx + MARKER_END.length)
173
+ }
174
+
175
+ // Strip ALL orphaned omagents sections (from older installs without markers)
176
+ config = stripManagedSections(config)
177
+
178
+ // Append fresh marker block
179
+ const block = `${MARKER_START}\n${pluginSection}\n${MARKER_END}\n`
180
+ const sep = config.length > 0 && !config.endsWith("\n") ? "\n\n" : "\n"
181
+ config = config + sep + block
182
+
183
+ mkdirp(path.dirname(configPath))
184
+ fs.writeFileSync(configPath, config, "utf-8")
185
+ }
186
+
187
+ // ─── Main install ───────────────────────────────────────────────────────────
188
+
189
+ export async function installCodex(options = {}) {
190
+ const env = options.env ?? process.env
191
+ const codexHome = options.codexHome ?? env.CODEX_HOME ?? path.join(os.homedir(), ".codex")
192
+ const corePaths = getCorePaths()
193
+
194
+ if (!fs.existsSync(codexHome)) {
195
+ console.error(`[omagents] Codex home not found at ${codexHome}`)
196
+ console.error("[omagents] Install Codex CLI first: https://developers.openai.com/codex")
197
+ process.exit(1)
198
+ }
199
+
200
+ const pkg = readJson(fileURLToPath(new URL("../package.json", import.meta.url)))
201
+ const mcpJson = generateMcpJson(env)
202
+
203
+ // Use "local" as version dir - Codex always prefers it over semver versions
204
+ const cacheDir = path.join(codexHome, "plugins", "cache", "omagents", "omagents", "local")
205
+ const marketplaceRoot = path.join(codexHome, "plugins", "cache", "omagents")
206
+
207
+ console.log(`[omagents] Installing to ${cacheDir}`)
208
+
209
+ // Clean and recreate cache dir
210
+ fs.rmSync(cacheDir, { recursive: true, force: true })
211
+ mkdirp(cacheDir)
212
+
213
+ // 0. marketplace.json at cache root
214
+ mkdirp(marketplaceRoot)
215
+ fs.writeFileSync(
216
+ path.join(marketplaceRoot, "marketplace.json"),
217
+ JSON.stringify(generateMarketplaceJson(), null, 2) + "\n"
218
+ )
219
+
220
+ // 1. plugin.json
221
+ const pluginDir = path.join(cacheDir, ".codex-plugin")
222
+ mkdirp(pluginDir)
223
+ fs.writeFileSync(
224
+ path.join(pluginDir, "plugin.json"),
225
+ JSON.stringify(generatePluginJson(pkg.version, pkg.description), null, 2) + "\n"
226
+ )
227
+
228
+ // 2. .mcp.json (Exa/Context7 values may be credentials)
229
+ const mcpPath = path.join(cacheDir, ".mcp.json")
230
+ fs.writeFileSync(mcpPath, JSON.stringify(mcpJson, null, 2) + "\n", {
231
+ encoding: "utf8",
232
+ mode: 0o600,
233
+ })
234
+ fs.chmodSync(mcpPath, 0o600)
235
+
236
+ // 3. hooks
237
+ const hooksDir = path.join(cacheDir, "hooks")
238
+ mkdirp(hooksDir)
239
+ fs.writeFileSync(path.join(hooksDir, "hooks.json"), JSON.stringify(HOOKS_CONFIG, null, 2) + "\n")
240
+ for (const hookName of ["python-env.js", "setup-venv.js", "project-venv.js"]) {
241
+ const hookSrc = path.join(corePaths.hooksDir, hookName)
242
+ if (fs.existsSync(hookSrc)) {
243
+ fs.copyFileSync(hookSrc, path.join(hooksDir, hookName))
244
+ }
245
+ }
246
+
247
+ // 4. Render every discovered skill through Core for Codex.
248
+ const skillsSrc = corePaths.skillsDir
249
+ const skillsDest = path.join(cacheDir, "skills")
250
+ mkdirp(skillsDest)
251
+
252
+ const skillDefinitions = listSkillDefinitions({ host: "codex" })
253
+ for (const definition of skillDefinitions) {
254
+ const skillDestDir =
255
+ definition.source === "superpowers"
256
+ ? path.join(skillsDest, "superpowers", definition.id)
257
+ : path.join(skillsDest, definition.id)
258
+ mkdirp(skillDestDir)
259
+
260
+ if (definition.source === "superpowers") {
261
+ copyDir(definition.directory, skillDestDir)
262
+ } else {
263
+ for (const subdir of ["scripts", "templates", "agents"]) {
264
+ const subdirSrc = path.join(definition.directory, subdir)
265
+ if (fs.existsSync(subdirSrc)) copyDir(subdirSrc, path.join(skillDestDir, subdir))
266
+ }
267
+ }
268
+
269
+ const rendered = renderSkillForHost(definition, "codex")
270
+ fs.writeFileSync(path.join(skillDestDir, "SKILL.md"), rendered.content)
271
+ }
272
+
273
+ // 5. Copy _shared scripts
274
+ const sharedSrc = path.join(skillsSrc, "_shared")
275
+ if (fs.existsSync(sharedSrc)) {
276
+ copyDir(sharedSrc, path.join(skillsDest, "_shared"))
277
+ }
278
+
279
+ if (!skillDefinitions.some((definition) => definition.source === "superpowers")) {
280
+ console.warn("[omagents] warning: superpowers skills not found, skipping")
281
+ }
282
+
283
+ // 6. Update config.toml (marketplace registration + plugin enable)
284
+ const configPath = path.join(codexHome, "config.toml")
285
+ const pluginSection = [
286
+ `[marketplaces.omagents]`,
287
+ `source_type = "local"`,
288
+ `source = ${serializeTomlBasicString(marketplaceRoot)}`,
289
+ ``,
290
+ `[plugins."omagents@omagents"]`,
291
+ `enabled = true`,
292
+ ].join("\n")
293
+ updateConfigToml(configPath, pluginSection)
294
+ console.log(`[omagents] Updated ${configPath}`)
295
+
296
+ // 7. Done
297
+ console.log("")
298
+ console.log("[omagents] Installation complete!")
299
+ console.log(`[omagents] Plugin: ${cacheDir}`)
300
+ console.log(`[omagents] MCP servers: ${Object.keys(mcpJson.mcpServers).join(", ")}`)
301
+ if (mcpJson.mcpServers.github) {
302
+ console.log("[omagents] GitHub MCP enabled (GITHUB_TOKEN detected)")
303
+ } else {
304
+ console.log("[omagents] Using grep_app for code search (set GITHUB_TOKEN for full GitHub MCP)")
305
+ }
306
+ console.log("")
307
+ console.log("[omagents] Restart Codex to activate the plugin.")
308
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.