@fenglimg/fabric-server 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,29 @@
1
1
  import { Server } from 'node:http';
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { AuditMode, LedgerEntry, HumanLockEntry } from '@fenglimg/fabric-shared';
3
+ import { AgentsMeta, RuleTestIndex, AgentsLayer, AgentsTopologyType } from '@fenglimg/fabric-shared';
4
4
 
5
5
  declare const LEDGER_PATH = ".fabric/.intent-ledger.jsonl";
6
6
  declare const LEGACY_LEDGER_PATH = ".intent-ledger.jsonl";
7
+ declare const EVENT_LEDGER_PATH = ".fabric/events.jsonl";
7
8
  declare function getLedgerPath(projectRoot: string): string;
8
9
  declare function getLegacyLedgerPath(projectRoot: string): string;
10
+ declare function getEventLedgerPath(projectRoot: string): string;
9
11
 
10
12
  type DoctorStatus = "ok" | "warn" | "error";
13
+ type DoctorIssueKind = "fixable_error" | "manual_error" | "warning";
11
14
  type DoctorCheck = {
12
15
  name: string;
13
16
  status: DoctorStatus;
14
17
  message: string;
18
+ kind?: DoctorIssueKind;
19
+ code?: string;
20
+ fixable?: boolean;
21
+ };
22
+ type DoctorIssue = {
23
+ code: string;
24
+ name: string;
25
+ message: string;
26
+ path?: string;
15
27
  };
16
28
  type DoctorSummary = {
17
29
  target: string;
@@ -24,81 +36,51 @@ type DoctorSummary = {
24
36
  path: string;
25
37
  reason: string;
26
38
  }>;
27
- driftCount: number;
28
- protectedPathCount: number;
29
- protectedPathsIntact: boolean;
30
- lastLedgerEntryTs: number | null;
31
- lastLedgerEntryAgeMs: number | null;
32
39
  metaRevision: string | null;
33
- ledgerPath: string;
34
- legacyLedgerPath: string;
35
- legacyLedgerDetected: boolean;
36
- audit: {
37
- enabled: boolean;
38
- mode: AuditMode;
39
- checkedPathCount: number;
40
- violationCount: number;
41
- windowMs: number;
42
- } | null;
40
+ computedMetaRevision: string | null;
41
+ ruleCount: number;
42
+ eventLedgerPath: string;
43
+ fixableErrorCount: number;
44
+ manualErrorCount: number;
45
+ warningCount: number;
46
+ targetFiles: Record<string, boolean>;
43
47
  };
44
48
  type DoctorReport = {
45
49
  status: DoctorStatus;
46
50
  checks: DoctorCheck[];
51
+ fixable_errors: DoctorIssue[];
52
+ manual_errors: DoctorIssue[];
53
+ warnings: DoctorIssue[];
47
54
  summary: DoctorSummary;
48
- audit: DoctorAuditReport | null;
49
55
  };
50
56
  type DoctorFixReport = {
51
57
  changed: boolean;
52
- migratedLedger: boolean;
58
+ fixed: DoctorIssue[];
59
+ remaining_manual_errors: DoctorIssue[];
60
+ warnings: DoctorIssue[];
53
61
  message: string;
54
62
  report: DoctorReport;
55
63
  };
56
- type DoctorAuditViolation = {
57
- editTs: number;
58
- entryId: string;
59
- intent: string;
60
- lastRuleAccessTs: number | null;
61
- path: string;
62
- };
63
- type DoctorAuditReport = {
64
- mode: AuditMode;
65
- skipped: boolean;
66
- windowMs: number;
67
- checkedPathCount: number;
68
- violationCount: number;
69
- violations: DoctorAuditViolation[];
70
- };
71
64
  declare function runDoctorReport(target: string): Promise<DoctorReport>;
72
65
  declare function runDoctorFix(target: string): Promise<DoctorFixReport>;
73
- declare function runDoctorAuditReport(target: string, options?: {
74
- force?: boolean;
75
- mode?: AuditMode;
76
- windowMs?: number;
77
- }): Promise<DoctorAuditReport>;
78
66
 
79
- type StoredLedgerEntry = LedgerEntry & {
80
- id: string;
81
- };
82
-
83
- type HumanLockStatus = HumanLockEntry & {
84
- drift: boolean;
85
- current_hash: string;
86
- };
87
- declare function readHumanLock(projectRoot: string): Promise<HumanLockStatus[]>;
88
- declare function readHumanLockEntry(projectRoot: string, file: string): Promise<HumanLockStatus | null>;
89
-
90
- type ApproveHumanLockInput = {
91
- file: string;
92
- start_line: number;
93
- end_line: number;
94
- new_hash: string;
67
+ type RuleMetaBuildSource = "doctor_fix" | "sync_meta";
68
+ type RuleMetaBuildResult = {
69
+ meta: AgentsMeta;
70
+ ruleTestIndex: RuleTestIndex;
71
+ changed: boolean;
95
72
  };
96
- type ApproveHumanLockResult = {
97
- updated: boolean;
98
- entry: HumanLockStatus;
99
- ledger_entry?: StoredLedgerEntry;
73
+ type WriteRuleMetaOptions = {
74
+ source: RuleMetaBuildSource;
100
75
  };
101
- declare function approveHumanLock(projectRoot: string, input: ApproveHumanLockInput): Promise<ApproveHumanLockResult>;
76
+ declare function buildRuleMeta(projectRootInput: string): Promise<RuleMetaBuildResult>;
77
+ declare function writeRuleMeta(projectRootInput: string, options: WriteRuleMetaOptions): Promise<RuleMetaBuildResult>;
78
+ declare function computeRulesBasedAgentsMeta(projectRootInput: string, existingMeta?: AgentsMeta): Promise<AgentsMeta>;
79
+ declare function computeRuleTestIndex(projectRootInput: string, computedMeta: AgentsMeta, previousIndex?: RuleTestIndex): Promise<RuleTestIndex>;
80
+ declare function deriveRuleMetaLayer(relativePath: string): AgentsLayer;
81
+ declare function deriveRuleMetaTopologyType(relativePath: string): AgentsTopologyType;
82
+ declare function isSameRuleTestIndex(left: RuleTestIndex, right: RuleTestIndex): boolean;
83
+ declare function stableStringify(value: unknown): string;
102
84
 
103
85
  /**
104
86
  * Shared constants used across the server package.
@@ -117,4 +99,4 @@ declare function startHttpServer(options: {
117
99
  dev?: boolean;
118
100
  }): Promise<Server>;
119
101
 
120
- export { AGENTS_MD_RESOURCE_URI, type ApproveHumanLockInput, type ApproveHumanLockResult, type DoctorAuditReport, type DoctorFixReport, type DoctorReport, type HumanLockStatus, LEDGER_PATH, LEGACY_LEDGER_PATH, approveHumanLock, createFabricServer, getLedgerPath, getLegacyLedgerPath, readHumanLock, readHumanLockEntry, runDoctorAuditReport, runDoctorFix, runDoctorReport, startHttpServer, startStdioServer };
102
+ export { AGENTS_MD_RESOURCE_URI, type DoctorFixReport, type DoctorIssue, type DoctorReport, EVENT_LEDGER_PATH, LEDGER_PATH, LEGACY_LEDGER_PATH, type RuleMetaBuildResult, type RuleMetaBuildSource, type WriteRuleMetaOptions, buildRuleMeta, computeRuleTestIndex, computeRulesBasedAgentsMeta, createFabricServer, deriveRuleMetaLayer, deriveRuleMetaTopologyType, getEventLedgerPath, getLedgerPath, getLegacyLedgerPath, isSameRuleTestIndex, runDoctorFix, runDoctorReport, stableStringify, startHttpServer, startStdioServer, writeRuleMeta };