refactor: export canonical oc-path isPattern and drop retired openai-codex catalog (#121621)

Completes the hasWildcard -> isPattern rename in oc-path (exports the
canonical predicate, migrates all callers, deletes the deprecated alias)
and removes the retired buildOpenAICodexProvider catalog module with its
api.ts re-export and contract-list entries. The dead-option-flag half of
this branch converged with an equivalent change that landed on main first.
This commit is contained in:
Peter Steinberger
2026-08-10 08:19:51 -07:00
committed by GitHub
parent a0ad38e71a
commit c12d3d7a05
8 changed files with 25 additions and 43 deletions
+2 -5
View File
@@ -397,7 +397,7 @@ export function resolvePositionalSeg(seg: string, container: PositionalContainer
/**
* Wildcard tokens permitted in `findOcPaths` patterns.
* `*` matches one sub-segment; `**` matches zero or more (recursive).
* Reject in resolve/set via `hasWildcard`.
* Reject in resolve/set via `isPattern`.
*/
export const WILDCARD_SINGLE = "*";
export const WILDCARD_RECURSIVE = "**";
@@ -407,7 +407,7 @@ export const WILDCARD_RECURSIVE = "**";
* union `{a,b,c}`, or predicate `[k=v]`). Single-match verbs reject
* these; only `findOcPaths` consumes them.
*/
function isPattern(path: OcPath): boolean {
export function isPattern(path: OcPath): boolean {
for (const slot of [path.section, path.item, path.field]) {
if (slot === undefined) {
continue;
@@ -429,9 +429,6 @@ function isPattern(path: OcPath): boolean {
return false;
}
/** @deprecated v1 — use {@link isPattern}. Behaviorally identical. */
export const hasWildcard = isPattern;
/** Union segment `{a,b,c}` matches each comma-separated alternative. */
export function isUnionSeg(seg: string): boolean {
return seg.length >= 2 && seg.startsWith("{") && seg.endsWith("}");
@@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest";
import { findOcPaths } from "../find.js";
import { parseJsonc } from "../jsonc/parse.js";
import { parseJsonl } from "../jsonl/parse.js";
import { formatOcPath, hasWildcard, OcPathError, parseOcPath } from "../oc-path.js";
import { formatOcPath, isPattern, OcPathError, parseOcPath } from "../oc-path.js";
import { parseMd } from "../parse.js";
import { resolveOcPath, setOcPath } from "../universal.js";
@@ -12,31 +12,31 @@ function requireFirstResult<T>(results: readonly T[]): T {
return expectDefined(results[0], "first OC path match");
}
describe("hasWildcard", () => {
describe("isPattern", () => {
it("detects single-segment * in any slot", () => {
expect(hasWildcard(parseOcPath("oc://X/*/y"))).toBe(true);
expect(hasWildcard(parseOcPath("oc://X/a/*"))).toBe(true);
expect(hasWildcard(parseOcPath("oc://X/a/b/*"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/*/y"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/a/*"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/a/b/*"))).toBe(true);
});
it("detects ** in any slot", () => {
expect(hasWildcard(parseOcPath("oc://X/**"))).toBe(true);
expect(hasWildcard(parseOcPath("oc://X/a/**/c"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/**"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/a/**/c"))).toBe(true);
});
it("detects wildcards inside dotted sub-segments", () => {
expect(hasWildcard(parseOcPath("oc://X/a.*.c"))).toBe(true);
expect(hasWildcard(parseOcPath("oc://X/a.**.c"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/a.*.c"))).toBe(true);
expect(isPattern(parseOcPath("oc://X/a.**.c"))).toBe(true);
});
it("returns false for plain paths", () => {
expect(hasWildcard(parseOcPath("oc://X/a/b/c"))).toBe(false);
expect(hasWildcard(parseOcPath("oc://X/a.b.c"))).toBe(false);
expect(isPattern(parseOcPath("oc://X/a/b/c"))).toBe(false);
expect(isPattern(parseOcPath("oc://X/a.b.c"))).toBe(false);
});
it("treats `*` inside an identifier as literal", () => {
expect(hasWildcard(parseOcPath("oc://X/foo*bar"))).toBe(false);
expect(hasWildcard(parseOcPath("oc://X/a*"))).toBe(false);
expect(isPattern(parseOcPath("oc://X/foo*bar"))).toBe(false);
expect(isPattern(parseOcPath("oc://X/a*"))).toBe(false);
});
});
@@ -253,9 +253,9 @@ describe("positional primitives — $first / $last", () => {
expect(m?.kind === "leaf" && m.valueText).toBe("end");
});
it("hasWildcard returns false for positional tokens", () => {
expect(hasWildcard(parseOcPath("oc://X/$first/id"))).toBe(false);
expect(hasWildcard(parseOcPath("oc://X/$last/id"))).toBe(false);
it("isPattern returns false for positional tokens", () => {
expect(isPattern(parseOcPath("oc://X/$first/id"))).toBe(false);
expect(isPattern(parseOcPath("oc://X/$last/id"))).toBe(false);
});
});
@@ -1,6 +1,6 @@
// OC Path tests cover oc path parse edges plugin behavior.
import { describe, expect, it } from "vitest";
import { OcPathError, formatOcPath, hasWildcard, parseOcPath } from "../../oc-path.js";
import { OcPathError, formatOcPath, isPattern, parseOcPath } from "../../oc-path.js";
function expectErr(fn: () => unknown, code: string): void {
try {
@@ -176,8 +176,8 @@ describe("oc-path-parse-edges", () => {
it("wildcard detection is quote-aware (literal `*` inside quoted segment)", () => {
const concrete = parseOcPath('oc://config.jsonc/"items.*.glob"');
expect(hasWildcard(concrete)).toBe(false);
expect(isPattern(concrete)).toBe(false);
const wildcard = parseOcPath("oc://config.jsonc/items/*");
expect(hasWildcard(wildcard)).toBe(true);
expect(isPattern(wildcard)).toBe(true);
});
});
+3 -3
View File
@@ -27,7 +27,7 @@ import { appendJsonlOcPath as appendJsonlLine, setJsonlOcPath } from "./jsonl/ed
import { emitJsonl } from "./jsonl/emit.js";
import { resolveJsonlOcPath } from "./jsonl/resolve.js";
import type { OcPath } from "./oc-path.js";
import { formatOcPath, hasWildcard, OcPathError, parseArrayIndexSegment } from "./oc-path.js";
import { formatOcPath, isPattern, OcPathError, parseArrayIndexSegment } from "./oc-path.js";
import { resolveMdOcPath } from "./resolve.js";
import type { YamlAst } from "./yaml/ast.js";
import { insertYamlOcPath, setYamlOcPath } from "./yaml/edit.js";
@@ -146,7 +146,7 @@ function detectInsertion(path: OcPath): InsertionInfo | null {
export function resolveOcPath(ast: OcAst, path: OcPath): OcMatch | null {
// Single-match verb: wildcards belong to findOcPaths. Throw with a
// structured code so consumers can route to the right verb.
if (hasWildcard(path)) {
if (isPattern(path)) {
throw new OcPathError(
`resolveOcPath received a wildcard pattern; use findOcPaths instead: ${formatOcPath(path)}`,
formatOcPath(path),
@@ -426,7 +426,7 @@ export function setOcPath(
value: string,
options: SetOcPathOptions = {},
): SetResult {
if (hasWildcard(path)) {
if (isPattern(path)) {
return {
ok: false,
reason: "wildcard-not-allowed",
-1
View File
@@ -11,7 +11,6 @@ export {
OPENAI_DEFAULT_TTS_VOICE,
} from "./default-models.js";
export { openaiMediaUnderstandingProvider } from "./media-understanding-provider.js";
export { buildOpenAICodexProvider } from "./openai-chatgpt-catalog.js";
export { loginOpenAICodexOAuth } from "./openai-chatgpt-oauth.runtime.js";
export { refreshOpenAICodexToken } from "./openai-chatgpt-provider.runtime.js";
export { buildOpenAIProvider } from "./openai-provider.js";
@@ -1,13 +0,0 @@
// Openai plugin module implements openai chatgpt catalog behavior.
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
import { OPENAI_CODEX_RESPONSES_BASE_URL } from "./base-url.js";
const OPENAI_CODEX_BASE_URL = OPENAI_CODEX_RESPONSES_BASE_URL;
export function buildOpenAICodexProvider(): ModelProviderConfig {
return {
baseUrl: OPENAI_CODEX_BASE_URL,
api: "openai-chatgpt-responses",
models: [],
};
}
@@ -22,7 +22,6 @@ const EXTRA_GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES = assertUniqueValues(
"index.js",
"login-qr-api.js",
"onboard.js",
"openai-chatgpt-catalog.js",
"provider-catalog.js",
"session-key-api.js",
"setup-api.js",
@@ -1272,7 +1272,7 @@ describe("plugin-sdk subpath exports", () => {
});
expectSourceContract("provider-catalog-shared", {
mentions: ["buildSingleProviderApiKeyCatalog", "buildPairedProviderApiKeyCatalog"],
omits: ["buildDeepSeekProvider", "buildOpenAICodexProvider", "buildVeniceProvider"],
omits: ["buildDeepSeekProvider", "buildVeniceProvider"],
});
expectSourceMentions("setup", [