From 39de757042bba62450a514035454fc89126f4fcb Mon Sep 17 00:00:00 2001 From: yunyingk Date: Wed, 19 Aug 2026 10:59:34 +0800 Subject: [PATCH] Add rule code to list summaries and schemas --- .gitignore | 4 ++++ skills/seal-home/references/rule-lightweight.md | 4 ++-- src/cli/runner.ts | 2 +- src/domains/seal/tools.test.ts | 13 ++++++++++--- src/domains/seal/tools.ts | 1 + src/domains/seal/types.ts | 2 ++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e8b3e31..6057e6c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ dist/bin/ # Local enterprise configs can contain credentials. enterprises/*.json !enterprises/example.*.json + +# Local generated reports and exported deliverables. +html/ +reports/ diff --git a/skills/seal-home/references/rule-lightweight.md b/skills/seal-home/references/rule-lightweight.md index bd9179e..977347b 100644 --- a/skills/seal-home/references/rule-lightweight.md +++ b/skills/seal-home/references/rule-lightweight.md @@ -31,12 +31,12 @@ Use summaries for navigation and selection. seal-home rules list --corp --summary ``` -Default summary should include only fields such as `id`, `scope`, `strictness`, `status`, and `updatedAt`. Do not pull `description` unless the user needs rule text. +Default summary should include only fields such as `id`, `code`, `scope`, `strictness`, `status`, and `updatedAt`. Do not pull `description` unless the user needs rule text. Tool-layer equivalent: ```bash -seal-home tool seal_approval_rules_list --corp --json '{"fields":["id","scope","strictness","status","updatedAt"]}' +seal-home tool seal_approval_rules_list --corp --json '{"fields":["id","code","scope","strictness","status","updatedAt"]}' ``` ## Clear Draft Rules Before Import diff --git a/src/cli/runner.ts b/src/cli/runner.ts index bf1752b..0c298be 100755 --- a/src/cli/runner.ts +++ b/src/cli/runner.ts @@ -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", diff --git a/src/domains/seal/tools.test.ts b/src/domains/seal/tools.test.ts index f410e26..2f3635f 100644 --- a/src/domains/seal/tools.test.ts +++ b/src/domains/seal/tools.test.ts @@ -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> }; @@ -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", diff --git a/src/domains/seal/tools.ts b/src/domains/seal/tools.ts index 8b8939e..a79eed3 100644 --- a/src/domains/seal/tools.ts +++ b/src/domains/seal/tools.ts @@ -182,6 +182,7 @@ export const sealTools = [ countOnly: z.boolean().optional().describe("只返回规则数量,不返回规则列表"), fields: z.array(z.enum([ "id", + "code", "tenantId", "status", "strictness", diff --git a/src/domains/seal/types.ts b/src/domains/seal/types.ts index 988f20b..b8cc2db 100644 --- a/src/domains/seal/types.ts +++ b/src/domains/seal/types.ts @@ -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()