Add rule code to list summaries and schemas

This commit is contained in:
gitea committed 2026-08-19 10:59:34 +08:00
1 parent f0522b72da
commit 39de757042
6 files changed
+20 -6

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ const DEFAULT_APP_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url))
const STATE_DIR = join(homedir(), ".config", "seal-home");
const RULE_LIST_FULL_COUNT_LIMIT = 100;
const RULE_LIST_FULL_BYTES_LIMIT = 120_000;
const RULE_SUMMARY_FIELDS = ["id", "status", "strictness", "scope", "createdAt", "updatedAt"];
const RULE_SUMMARY_FIELDS = ["id", "code", "status", "strictness", "scope", "createdAt", "updatedAt"];
const DEFAULT_OUTPUT_BYTES_LIMIT = 200_000;
const KNOWN_AREAS = new Set([
"config",
+10 -3
View File
@@ -134,7 +134,7 @@ describe("sealTools", () => {
const handler = tool!.handler as ToolHandler;
const result = await handler(
fakeRulesClient(),
{ fields: ["id", "status", "strictness", "scope"], limit: 1 },
{ fields: ["id", "code", "status", "strictness", "scope"], limit: 1 },
fakeContext()
) as { count: number; rules: Array<Record<string, unknown>> };
@@ -142,6 +142,7 @@ describe("sealTools", () => {
expect(result.rules).toEqual([
{
id: "rule-1",
code: 29,
status: "active",
strictness: "MUST_FOLLOW",
scope: "travel"
@@ -620,12 +621,12 @@ describe("sealTools", () => {
const handler = tool!.handler as ToolHandler;
const result = await handler(
fakeRulesClient(),
{ versionNumber: 16, code: "#0002" },
{ versionNumber: 16, code: "#0044" },
fakeContext()
) as { ruleCode?: string; description?: string; versionNumber?: number };
expect(result).toMatchObject({
ruleCode: "#0002",
ruleCode: "#0044",
description: "Second published rule",
versionNumber: 16
});
@@ -762,11 +763,13 @@ function fakeRulesClient(): KyInstance {
publishedByName: "Tester",
rules: [
{
code: "rule-29",
description: "First published rule",
scope: "travel",
strictness: "MUST_FOLLOW"
},
{
code: "rule-44",
description: "Second published rule",
scope: "meal",
strictness: "SHOULD_FOLLOW"
@@ -780,6 +783,7 @@ function fakeRulesClient(): KyInstance {
{
id: "rule-1",
tenantId: "tenant-1",
code: 29,
description: "Must include full invoice detail",
scope: "travel",
strictness: "MUST_FOLLOW",
@@ -790,6 +794,7 @@ function fakeRulesClient(): KyInstance {
{
id: "rule-2",
tenantId: "tenant-1",
code: 44,
description: "Prefer matching attendee names",
scope: "meal",
strictness: "SHOULD_FOLLOW",
@@ -809,6 +814,7 @@ function fakeClearRulesClient(): KyInstance {
{
id: "rule-1",
tenantId: "tenant-1",
code: 29,
description: "Must include full invoice detail",
scope: "travel",
strictness: "MUST_FOLLOW",
@@ -817,6 +823,7 @@ function fakeClearRulesClient(): KyInstance {
{
id: "rule-2",
tenantId: "tenant-1",
code: 44,
description: "Prefer matching attendee names",
scope: "meal",
strictness: "SHOULD_FOLLOW",
+1
View File
@@ -182,6 +182,7 @@ export const sealTools = [
countOnly: z.boolean().optional().describe("只返回规则数量,不返回规则列表"),
fields: z.array(z.enum([
"id",
"code",
"tenantId",
"status",
"strictness",
+2
View File
@@ -73,6 +73,7 @@ export const SealSessionDataSchema = z.object({
export const ApprovalRuleSchema = z.object({
id: z.string(),
tenantId: z.string().optional(),
code: z.number().optional(),
description: z.string(),
scope: z.string(),
strictness: z.string(),
@@ -87,6 +88,7 @@ export const ApprovalRulesDataSchema = z.object({
});
export const PublishedRuleSnapshotSchema = z.object({
code: z.string().optional(),
description: z.string(),
scope: z.string(),
strictness: z.string()