Skip to content

Commit c12d3d7

Browse files
authored
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.
1 parent a0ad38e commit c12d3d7

8 files changed

Lines changed: 25 additions & 43 deletions

File tree

‎extensions/oc-path/src/oc-path/oc-path.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export function resolvePositionalSeg(seg: string, container: PositionalContainer
397397
/**
398398
* Wildcard tokens permitted in `findOcPaths` patterns.
399399
* `*` matches one sub-segment; `**` matches zero or more (recursive).
400-
* Reject in resolve/set via `hasWildcard`.
400+
* Reject in resolve/set via `isPattern`.
401401
*/
402402
export const WILDCARD_SINGLE = "*";
403403
export const WILDCARD_RECURSIVE = "**";
@@ -407,7 +407,7 @@ export const WILDCARD_RECURSIVE = "**";
407407
* union `{a,b,c}`, or predicate `[k=v]`). Single-match verbs reject
408408
* these; only `findOcPaths` consumes them.
409409
*/
410-
function isPattern(path: OcPath): boolean {
410+
export function isPattern(path: OcPath): boolean {
411411
for (const slot of [path.section, path.item, path.field]) {
412412
if (slot === undefined) {
413413
continue;
@@ -429,9 +429,6 @@ function isPattern(path: OcPath): boolean {
429429
return false;
430430
}
431431

432-
/** @deprecated v1 — use {@link isPattern}. Behaviorally identical. */
433-
export const hasWildcard = isPattern;
434-
435432
/** Union segment `{a,b,c}` matches each comma-separated alternative. */
436433
export function isUnionSeg(seg: string): boolean {
437434
return seg.length >= 2 && seg.startsWith("{") && seg.endsWith("}");

‎extensions/oc-path/src/oc-path/tests/find.test.ts‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@ import { describe, expect, it } from "vitest";
44
import { findOcPaths } from "../find.js";
55
import { parseJsonc } from "../jsonc/parse.js";
66
import { parseJsonl } from "../jsonl/parse.js";
7-
import { formatOcPath, hasWildcard, OcPathError, parseOcPath } from "../oc-path.js";
7+
import { formatOcPath, isPattern, OcPathError, parseOcPath } from "../oc-path.js";
88
import { parseMd } from "../parse.js";
99
import { resolveOcPath, setOcPath } from "../universal.js";
1010

1111
function requireFirstResult<T>(results: readonly T[]): T {
1212
return expectDefined(results[0], "first OC path match");
1313
}
1414

15-
describe("hasWildcard", () => {
15+
describe("isPattern", () => {
1616
it("detects single-segment * in any slot", () => {
17-
expect(hasWildcard(parseOcPath("oc://X/*/y"))).toBe(true);
18-
expect(hasWildcard(parseOcPath("oc://X/a/*"))).toBe(true);
19-
expect(hasWildcard(parseOcPath("oc://X/a/b/*"))).toBe(true);
17+
expect(isPattern(parseOcPath("oc://X/*/y"))).toBe(true);
18+
expect(isPattern(parseOcPath("oc://X/a/*"))).toBe(true);
19+
expect(isPattern(parseOcPath("oc://X/a/b/*"))).toBe(true);
2020
});
2121

2222
it("detects ** in any slot", () => {
23-
expect(hasWildcard(parseOcPath("oc://X/**"))).toBe(true);
24-
expect(hasWildcard(parseOcPath("oc://X/a/**/c"))).toBe(true);
23+
expect(isPattern(parseOcPath("oc://X/**"))).toBe(true);
24+
expect(isPattern(parseOcPath("oc://X/a/**/c"))).toBe(true);
2525
});
2626

2727
it("detects wildcards inside dotted sub-segments", () => {
28-
expect(hasWildcard(parseOcPath("oc://X/a.*.c"))).toBe(true);
29-
expect(hasWildcard(parseOcPath("oc://X/a.**.c"))).toBe(true);
28+
expect(isPattern(parseOcPath("oc://X/a.*.c"))).toBe(true);
29+
expect(isPattern(parseOcPath("oc://X/a.**.c"))).toBe(true);
3030
});
3131

3232
it("returns false for plain paths", () => {
33-
expect(hasWildcard(parseOcPath("oc://X/a/b/c"))).toBe(false);
34-
expect(hasWildcard(parseOcPath("oc://X/a.b.c"))).toBe(false);
33+
expect(isPattern(parseOcPath("oc://X/a/b/c"))).toBe(false);
34+
expect(isPattern(parseOcPath("oc://X/a.b.c"))).toBe(false);
3535
});
3636

3737
it("treats `*` inside an identifier as literal", () => {
38-
expect(hasWildcard(parseOcPath("oc://X/foo*bar"))).toBe(false);
39-
expect(hasWildcard(parseOcPath("oc://X/a*"))).toBe(false);
38+
expect(isPattern(parseOcPath("oc://X/foo*bar"))).toBe(false);
39+
expect(isPattern(parseOcPath("oc://X/a*"))).toBe(false);
4040
});
4141
});
4242

@@ -253,9 +253,9 @@ describe("positional primitives — $first / $last", () => {
253253
expect(m?.kind === "leaf" && m.valueText).toBe("end");
254254
});
255255

256-
it("hasWildcard returns false for positional tokens", () => {
257-
expect(hasWildcard(parseOcPath("oc://X/$first/id"))).toBe(false);
258-
expect(hasWildcard(parseOcPath("oc://X/$last/id"))).toBe(false);
256+
it("isPattern returns false for positional tokens", () => {
257+
expect(isPattern(parseOcPath("oc://X/$first/id"))).toBe(false);
258+
expect(isPattern(parseOcPath("oc://X/$last/id"))).toBe(false);
259259
});
260260
});
261261

‎extensions/oc-path/src/oc-path/tests/scenarios/oc-path-parse-edges.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// OC Path tests cover oc path parse edges plugin behavior.
22
import { describe, expect, it } from "vitest";
3-
import { OcPathError, formatOcPath, hasWildcard, parseOcPath } from "../../oc-path.js";
3+
import { OcPathError, formatOcPath, isPattern, parseOcPath } from "../../oc-path.js";
44

55
function expectErr(fn: () => unknown, code: string): void {
66
try {
@@ -176,8 +176,8 @@ describe("oc-path-parse-edges", () => {
176176

177177
it("wildcard detection is quote-aware (literal `*` inside quoted segment)", () => {
178178
const concrete = parseOcPath('oc://config.jsonc/"items.*.glob"');
179-
expect(hasWildcard(concrete)).toBe(false);
179+
expect(isPattern(concrete)).toBe(false);
180180
const wildcard = parseOcPath("oc://config.jsonc/items/*");
181-
expect(hasWildcard(wildcard)).toBe(true);
181+
expect(isPattern(wildcard)).toBe(true);
182182
});
183183
});

‎extensions/oc-path/src/oc-path/universal.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { appendJsonlOcPath as appendJsonlLine, setJsonlOcPath } from "./jsonl/ed
2727
import { emitJsonl } from "./jsonl/emit.js";
2828
import { resolveJsonlOcPath } from "./jsonl/resolve.js";
2929
import type { OcPath } from "./oc-path.js";
30-
import { formatOcPath, hasWildcard, OcPathError, parseArrayIndexSegment } from "./oc-path.js";
30+
import { formatOcPath, isPattern, OcPathError, parseArrayIndexSegment } from "./oc-path.js";
3131
import { resolveMdOcPath } from "./resolve.js";
3232
import type { YamlAst } from "./yaml/ast.js";
3333
import { insertYamlOcPath, setYamlOcPath } from "./yaml/edit.js";
@@ -146,7 +146,7 @@ function detectInsertion(path: OcPath): InsertionInfo | null {
146146
export function resolveOcPath(ast: OcAst, path: OcPath): OcMatch | null {
147147
// Single-match verb: wildcards belong to findOcPaths. Throw with a
148148
// structured code so consumers can route to the right verb.
149-
if (hasWildcard(path)) {
149+
if (isPattern(path)) {
150150
throw new OcPathError(
151151
`resolveOcPath received a wildcard pattern; use findOcPaths instead: ${formatOcPath(path)}`,
152152
formatOcPath(path),
@@ -426,7 +426,7 @@ export function setOcPath(
426426
value: string,
427427
options: SetOcPathOptions = {},
428428
): SetResult {
429-
if (hasWildcard(path)) {
429+
if (isPattern(path)) {
430430
return {
431431
ok: false,
432432
reason: "wildcard-not-allowed",

‎extensions/openai/api.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export {
1111
OPENAI_DEFAULT_TTS_VOICE,
1212
} from "./default-models.js";
1313
export { openaiMediaUnderstandingProvider } from "./media-understanding-provider.js";
14-
export { buildOpenAICodexProvider } from "./openai-chatgpt-catalog.js";
1514
export { loginOpenAICodexOAuth } from "./openai-chatgpt-oauth.runtime.js";
1615
export { refreshOpenAICodexToken } from "./openai-chatgpt-provider.runtime.js";
1716
export { buildOpenAIProvider } from "./openai-provider.js";

‎extensions/openai/openai-chatgpt-catalog.ts‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/plugin-sdk/test-helpers/public-artifacts.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const EXTRA_GUARDED_EXTENSION_PUBLIC_SURFACE_BASENAMES = assertUniqueValues(
2222
"index.js",
2323
"login-qr-api.js",
2424
"onboard.js",
25-
"openai-chatgpt-catalog.js",
2625
"provider-catalog.js",
2726
"session-key-api.js",
2827
"setup-api.js",

‎src/plugins/contracts/plugin-sdk-subpaths.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ describe("plugin-sdk subpath exports", () => {
12721272
});
12731273
expectSourceContract("provider-catalog-shared", {
12741274
mentions: ["buildSingleProviderApiKeyCatalog", "buildPairedProviderApiKeyCatalog"],
1275-
omits: ["buildDeepSeekProvider", "buildOpenAICodexProvider", "buildVeniceProvider"],
1275+
omits: ["buildDeepSeekProvider", "buildVeniceProvider"],
12761276
});
12771277

12781278
expectSourceMentions("setup", [

0 commit comments

Comments
 (0)