diff --git a/src/cli/command-path-matches.test.ts b/src/cli/command-path-matches.test.ts index 238e17f54ccb..4befab16ccd2 100644 --- a/src/cli/command-path-matches.test.ts +++ b/src/cli/command-path-matches.test.ts @@ -1,9 +1,6 @@ // Command path match tests cover CLI command path matching and normalization. import { describe, expect, it } from "vitest"; -import { - matchesCommandPath, - matchesCommandPathRule, -} from "./command-path-matches.js"; +import { matchesCommandPath } from "./command-path-matches.js"; describe("command-path-matches", () => { it("matches prefix and exact command paths", () => { @@ -13,28 +10,4 @@ describe("command-path-matches", () => { expect(matchesCommandPath(["config", "get"], ["config", "get"], { exact: true })).toBe(true); }); - it("matches declarative rules", () => { - expect(matchesCommandPathRule(["plugins", "update"], ["plugins"])).toBe(true); - expect( - matchesCommandPathRule(["plugins", "update"], { - pattern: ["plugins", "update"], - exact: true, - }), - ).toBe(true); - expect( - matchesCommandPathRule(["plugins", "update", "now"], { - pattern: ["plugins", "update"], - exact: true, - }), - ).toBe(false); - }); - - it("treats structured rules without exact as prefix matches", () => { - expect( - matchesCommandPathRule(["plugins", "update", "now"], { - pattern: ["plugins", "update"], - }), - ).toBe(true); - }); - }); diff --git a/src/cli/command-path-matches.ts b/src/cli/command-path-matches.ts index f585e9abf129..f90b03b54f82 100644 --- a/src/cli/command-path-matches.ts +++ b/src/cli/command-path-matches.ts @@ -1,28 +1,4 @@ // Shared command-path matching helpers for CLI startup and registration policy. -type StructuredCommandPathMatchRule = { - pattern: readonly string[]; - exact?: boolean; -}; - -type CommandPathMatchRule = readonly string[] | StructuredCommandPathMatchRule; - -type NormalizedCommandPathMatchRule = { - pattern: readonly string[]; - exact: boolean; -}; - -function isStructuredCommandPathMatchRule( - rule: CommandPathMatchRule, -): rule is StructuredCommandPathMatchRule { - return !Array.isArray(rule); -} - -function normalizeCommandPathMatchRule(rule: CommandPathMatchRule): NormalizedCommandPathMatchRule { - if (!isStructuredCommandPathMatchRule(rule)) { - return { pattern: rule, exact: false }; - } - return { pattern: rule.pattern, exact: rule.exact ?? false }; -} /** Matches a command path prefix, or the full path when `exact` is requested. */ export function matchesCommandPath( @@ -35,11 +11,3 @@ export function matchesCommandPath( } return !params?.exact || commandPath.length === pattern.length; } - -/** Applies the shared command-path rule shape used by startup and help policies. */ -export function matchesCommandPathRule(commandPath: string[], rule: CommandPathMatchRule): boolean { - const normalizedRule = normalizeCommandPathMatchRule(rule); - return matchesCommandPath(commandPath, normalizedRule.pattern, { - exact: normalizedRule.exact, - }); -} diff --git a/src/cli/npm-resolution.test.ts b/src/cli/npm-resolution.test.ts index 99608ac2f6a0..2924cb3ad712 100644 --- a/src/cli/npm-resolution.test.ts +++ b/src/cli/npm-resolution.test.ts @@ -4,7 +4,6 @@ import { describe, expect, it } from "vitest"; import { buildNpmInstallRecordFields, logPinnedNpmSpecMessages, - mapNpmResolutionMetadata, resolvePinnedNpmInstallRecord, resolvePinnedNpmInstallRecordForCli, resolvePinnedNpmSpec, @@ -58,26 +57,6 @@ describe("npm-resolution helpers", () => { }); }); - it("maps npm resolution metadata to install fields", () => { - expect( - mapNpmResolutionMetadata({ - name: "@openclaw/plugin-alpha", - version: "1.2.3", - resolvedSpec: "@openclaw/plugin-alpha@1.2.3", - integrity: "sha512-abc", - shasum: "deadbeef", - resolvedAt: "2026-02-21T00:00:00.000Z", - }), - ).toEqual({ - resolvedName: "@openclaw/plugin-alpha", - resolvedVersion: "1.2.3", - resolvedSpec: "@openclaw/plugin-alpha@1.2.3", - integrity: "sha512-abc", - shasum: "deadbeef", - resolvedAt: "2026-02-21T00:00:00.000Z", - }); - }); - it("builds common npm install record fields", () => { expect( buildNpmInstallRecordFields({ diff --git a/src/cli/npm-resolution.ts b/src/cli/npm-resolution.ts index c241facb0487..2b19b32fe243 100644 --- a/src/cli/npm-resolution.ts +++ b/src/cli/npm-resolution.ts @@ -26,18 +26,6 @@ export function resolvePinnedNpmSpec(params: { }; } -/** Convert npm resolver metadata into persisted install-record fields. */ -export function mapNpmResolutionMetadata(resolution?: NpmResolutionMetadata): { - resolvedName?: string; - resolvedVersion?: string; - resolvedSpec?: string; - integrity?: string; - shasum?: string; - resolvedAt?: string; -} { - return buildNpmResolutionFields(resolution); -} - /** Build the npm section of a plugin install record. */ export function buildNpmInstallRecordFields(params: { spec: string;