@koreanhole/opencodex 3.2.25 → 3.2.27
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/AGENTS_INSTALL.md +5 -3
- package/README.md +8 -4
- package/package.json +2 -1
- package/src/cli/entry.ts +16 -21
- package/src/cli/update.ts +140 -0
package/AGENTS_INSTALL.md
CHANGED
|
@@ -84,9 +84,11 @@ The adapter gateway is loopback-only and uses a per-run bearer token. The
|
|
|
84
84
|
original opencodex listener and management surface follow upstream policy,
|
|
85
85
|
including the dashboard and non-loopback authentication rule.
|
|
86
86
|
|
|
87
|
-
`ocx update` is managed by this distribution
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
`ocx update` is managed by this distribution and runs the npm global install
|
|
88
|
+
for `@koreanhole/opencodex` itself. `--tag latest|preview` and `--json` are
|
|
89
|
+
supported; `ocx system update` is the same operation. Restart any running
|
|
90
|
+
`ocx` process after updating. Never let the upstream updater target
|
|
91
|
+
`@bitkyc08/opencodex`.
|
|
90
92
|
|
|
91
93
|
## Verification
|
|
92
94
|
|
package/README.md
CHANGED
|
@@ -145,14 +145,18 @@ To adopt an upstream release:
|
|
|
145
145
|
|
|
146
146
|
No patch series or upstream source tree is maintained in this repository.
|
|
147
147
|
|
|
148
|
-
`ocx update` and `ocx system update` are
|
|
149
|
-
updater is hardcoded to the original package name.
|
|
148
|
+
`ocx update` and `ocx system update` are owned by this distribution because the
|
|
149
|
+
upstream updater is hardcoded to the original package name. They install the
|
|
150
|
+
selected release of this fork:
|
|
150
151
|
|
|
151
152
|
```bash
|
|
152
|
-
|
|
153
|
+
ocx update
|
|
154
|
+
ocx update --tag preview
|
|
155
|
+
ocx update --json
|
|
153
156
|
```
|
|
154
157
|
|
|
155
|
-
|
|
158
|
+
Restart any running `ocx` process after an update. Automatic upstream update
|
|
159
|
+
checks are disabled for the delegated runtime.
|
|
156
160
|
|
|
157
161
|
## Release
|
|
158
162
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koreanhole/opencodex",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.27",
|
|
4
4
|
"description": "Full opencodex runtime with Cline 2.2.0+ JSON and Gemini CLI headless provider adapters",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./bin/package-main.mjs",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"start": "bun run src/cli/entry.ts start",
|
|
31
31
|
"test": "bun test tests",
|
|
32
32
|
"test:e2e": "bun test tests/e2e/cline-only.test.ts",
|
|
33
|
+
"test:e2e:update": "bun test tests/e2e/update.test.ts",
|
|
33
34
|
"test:e2e:cline-live": "bun test ./tests/e2e/cline-live.live.ts",
|
|
34
35
|
"test:e2e:gemini": "bun test ./tests/e2e/gemini-codex.live.ts -t \"full-stack:\"",
|
|
35
36
|
"test:e2e:gemini-oauth-only": "bun test ./tests/e2e/gemini-oauth-only.test.ts",
|
package/src/cli/entry.ts
CHANGED
|
@@ -22,20 +22,21 @@ import { ConfigError } from "../config";
|
|
|
22
22
|
import { UpstreamPackageError, resolveUpstreamPackage } from "../upstream/package";
|
|
23
23
|
import { loadUpstreamCli } from "../upstream/cli";
|
|
24
24
|
import { runAdapterCli } from "./index";
|
|
25
|
+
import { runDistributionUpdate } from "./update";
|
|
25
26
|
import packageInfo from "../../package.json";
|
|
26
27
|
|
|
27
28
|
type AdapterCli = (argv: string[]) => Promise<number>;
|
|
28
29
|
type UpstreamLoader = () => Promise<void>;
|
|
29
30
|
type StartPreparer = (env: NodeJS.ProcessEnv) => Promise<unknown>;
|
|
31
|
+
type UpdateRunner = (argv: string[]) => Promise<number>;
|
|
30
32
|
|
|
31
33
|
export interface EntryDeps {
|
|
32
34
|
adapterCli?: AdapterCli;
|
|
33
35
|
loadUpstream?: UpstreamLoader;
|
|
34
36
|
prepareStart?: StartPreparer;
|
|
37
|
+
update?: UpdateRunner;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
const DISTRIBUTION_PACKAGE = "@koreanhole/opencodex";
|
|
38
|
-
|
|
39
40
|
function isAdapterId(value: string | undefined): value is AdapterProviderId {
|
|
40
41
|
return value === "gemini-cli" || value === "cline-cli";
|
|
41
42
|
}
|
|
@@ -97,33 +98,22 @@ async function detachAdapter(env: NodeJS.ProcessEnv): Promise<number> {
|
|
|
97
98
|
return 0;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
function printDistributionUpdate(argv: readonly string[]): number {
|
|
101
|
-
const command = "npm install -g " + DISTRIBUTION_PACKAGE + "@latest";
|
|
102
|
-
if (argv.includes("--json")) {
|
|
103
|
-
console.log(JSON.stringify({
|
|
104
|
-
ok: false,
|
|
105
|
-
reason: "distribution_managed",
|
|
106
|
-
package: DISTRIBUTION_PACKAGE,
|
|
107
|
-
command,
|
|
108
|
-
}));
|
|
109
|
-
} else {
|
|
110
|
-
console.error("ocx: updates are managed by " + DISTRIBUTION_PACKAGE + ".");
|
|
111
|
-
console.error("Run: " + command);
|
|
112
|
-
}
|
|
113
|
-
return 2;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
101
|
function printVersion(): number {
|
|
117
102
|
console.log("opencodex " + packageInfo.version);
|
|
118
103
|
return 0;
|
|
119
104
|
}
|
|
120
105
|
|
|
121
|
-
async function runAdapterCommand(
|
|
106
|
+
async function runAdapterCommand(
|
|
107
|
+
argv: string[],
|
|
108
|
+
env: NodeJS.ProcessEnv,
|
|
109
|
+
adapterCli: AdapterCli,
|
|
110
|
+
update: UpdateRunner,
|
|
111
|
+
): Promise<number> {
|
|
122
112
|
if (argv[0] === "__cli-agent-mcp") return adapterCli(argv);
|
|
123
113
|
if (argv[0] === "version" || argv[0] === "--version" || argv[0] === "-v") return printVersion();
|
|
124
114
|
if (argv[0] === "login") return adapterCli(argv);
|
|
125
115
|
if (argv[0] === "update" || (argv[0] === "system" && argv.slice(1).includes("update"))) {
|
|
126
|
-
return
|
|
116
|
+
return update(argv);
|
|
127
117
|
}
|
|
128
118
|
if (argv[0] === "adapter" && argv[1] === "detach") return detachAdapter(env);
|
|
129
119
|
if (argv[0] === "provider") return adapterProviderCommand(argv.slice(1), env);
|
|
@@ -203,7 +193,12 @@ export async function runEntry(argv: string[], deps: EntryDeps = {}): Promise<vo
|
|
|
203
193
|
const env = process.env;
|
|
204
194
|
env.OCX_DISABLE_UPDATE_CHECK ??= "1";
|
|
205
195
|
if (isAdapterOwnedCommand(argv)) {
|
|
206
|
-
process.exitCode = await runAdapterCommand(
|
|
196
|
+
process.exitCode = await runAdapterCommand(
|
|
197
|
+
argv,
|
|
198
|
+
env,
|
|
199
|
+
deps.adapterCli ?? runAdapterCli,
|
|
200
|
+
deps.update ?? runDistributionUpdate,
|
|
201
|
+
);
|
|
207
202
|
return;
|
|
208
203
|
}
|
|
209
204
|
if (argv[0] === "start") {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
const DISTRIBUTION_PACKAGE = "@koreanhole/opencodex";
|
|
4
|
+
|
|
5
|
+
type UpdateTag = "latest" | "preview";
|
|
6
|
+
|
|
7
|
+
interface UpdateRequest {
|
|
8
|
+
help: boolean;
|
|
9
|
+
json: boolean;
|
|
10
|
+
tag: UpdateTag;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface NpmOutcome {
|
|
14
|
+
code: number;
|
|
15
|
+
error?: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const USAGE = [
|
|
20
|
+
"Usage: ocx update [--tag <latest|preview>] [--json]",
|
|
21
|
+
" ocx system update [--tag <latest|preview>] [--json]",
|
|
22
|
+
].join("\n");
|
|
23
|
+
|
|
24
|
+
class UpdateUsageError extends Error {}
|
|
25
|
+
|
|
26
|
+
function normalizeArgs(argv: readonly string[]): string[] {
|
|
27
|
+
const args = [...argv];
|
|
28
|
+
const command = args.shift();
|
|
29
|
+
if (command === "update") return args;
|
|
30
|
+
if (command === "system") {
|
|
31
|
+
const index = args.indexOf("update");
|
|
32
|
+
if (index >= 0) {
|
|
33
|
+
args.splice(index, 1);
|
|
34
|
+
return args;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw new UpdateUsageError("Unknown update command.");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function parseArgs(argv: readonly string[]): UpdateRequest {
|
|
41
|
+
const args = normalizeArgs(argv);
|
|
42
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
43
|
+
return { help: true, json: false, tag: "latest" };
|
|
44
|
+
}
|
|
45
|
+
let json = false;
|
|
46
|
+
let tag: UpdateTag = "latest";
|
|
47
|
+
for (let index = 0; index < args.length; index++) {
|
|
48
|
+
const arg = args[index]!;
|
|
49
|
+
if (arg === "--json") {
|
|
50
|
+
json = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (arg === "--tag") {
|
|
54
|
+
const value = args[++index];
|
|
55
|
+
if (value !== "latest" && value !== "preview") {
|
|
56
|
+
throw new UpdateUsageError("--tag must be latest or preview.");
|
|
57
|
+
}
|
|
58
|
+
tag = value;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (arg.startsWith("--tag=")) {
|
|
62
|
+
const value = arg.slice("--tag=".length);
|
|
63
|
+
if (value !== "latest" && value !== "preview") {
|
|
64
|
+
throw new UpdateUsageError("--tag must be latest or preview.");
|
|
65
|
+
}
|
|
66
|
+
tag = value;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
throw new UpdateUsageError("Unknown update option: " + arg);
|
|
70
|
+
}
|
|
71
|
+
return { help: false, json, tag };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function npmOutcome(args: readonly string[], capture: boolean): Promise<NpmOutcome> {
|
|
75
|
+
return new Promise(resolvePromise => {
|
|
76
|
+
let settled = false;
|
|
77
|
+
let stderr = "";
|
|
78
|
+
const finish = (outcome: NpmOutcome): void => {
|
|
79
|
+
if (settled) return;
|
|
80
|
+
settled = true;
|
|
81
|
+
resolvePromise(outcome);
|
|
82
|
+
};
|
|
83
|
+
const child = spawn("npm", [...args], {
|
|
84
|
+
env: process.env,
|
|
85
|
+
shell: process.platform === "win32",
|
|
86
|
+
stdio: capture ? ["ignore", "pipe", "pipe"] : "inherit",
|
|
87
|
+
windowsHide: true,
|
|
88
|
+
});
|
|
89
|
+
if (capture) {
|
|
90
|
+
child.stdout?.resume();
|
|
91
|
+
child.stderr?.on("data", chunk => {
|
|
92
|
+
stderr = (stderr + Buffer.from(chunk).toString()).slice(-8192);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
child.once("error", error => finish({ code: 1, error: error.message, stderr }));
|
|
96
|
+
child.once("close", (code, signal) => finish({
|
|
97
|
+
code: code ?? 1,
|
|
98
|
+
...(signal ? { error: "npm terminated by " + signal } : {}),
|
|
99
|
+
stderr,
|
|
100
|
+
}));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function runDistributionUpdate(argv: readonly string[]): Promise<number> {
|
|
105
|
+
let request: UpdateRequest;
|
|
106
|
+
try {
|
|
107
|
+
request = parseArgs(argv);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error("ocx: " + (error instanceof Error ? error.message : String(error)));
|
|
110
|
+
console.error(USAGE);
|
|
111
|
+
return 2;
|
|
112
|
+
}
|
|
113
|
+
if (request.help) {
|
|
114
|
+
console.log(USAGE);
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const target = DISTRIBUTION_PACKAGE + "@" + request.tag;
|
|
119
|
+
const args = ["install", "-g", target];
|
|
120
|
+
const command = "npm " + args.join(" ");
|
|
121
|
+
const outcome = await npmOutcome(args, request.json);
|
|
122
|
+
const ok = outcome.code === 0;
|
|
123
|
+
if (request.json) {
|
|
124
|
+
const detail = outcome.error ?? outcome.stderr.trim();
|
|
125
|
+
console.log(JSON.stringify({
|
|
126
|
+
ok,
|
|
127
|
+
package: DISTRIBUTION_PACKAGE,
|
|
128
|
+
tag: request.tag,
|
|
129
|
+
command,
|
|
130
|
+
exitCode: outcome.code,
|
|
131
|
+
...(!ok && detail ? { error: detail } : {}),
|
|
132
|
+
}));
|
|
133
|
+
} else if (ok) {
|
|
134
|
+
console.log("Updated " + target + ". Restart any running ocx process.");
|
|
135
|
+
} else {
|
|
136
|
+
const detail = outcome.error ?? outcome.stderr.trim();
|
|
137
|
+
console.error("ocx: update failed with exit status " + outcome.code + (detail ? ": " + detail : "") + ".");
|
|
138
|
+
}
|
|
139
|
+
return outcome.code;
|
|
140
|
+
}
|