@fenglimg/fabric-shared 1.8.0-rc.3 → 2.0.0-rc.8
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/{chunk-FEEWLYO3.js → chunk-U2SR2M4L.js} +26 -21
- package/dist/chunk-VQDCDCJA.js +555 -0
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +3398 -1031
- package/dist/index.js +381 -82
- package/dist/node.js +172 -3
- package/dist/schemas/api-contracts.d.ts +822 -114
- package/dist/schemas/api-contracts.js +51 -13
- package/dist/types/index.d.ts +37 -6
- package/package.json +3 -7
- package/dist/chunk-GI6L6VTT.js +0 -176
- package/dist/chunk-KV27CZH3.js +0 -223
- package/dist/node/bootstrap-guide.d.ts +0 -12
- package/dist/node/bootstrap-guide.js +0 -52
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./chunk-LXNCAKJZ.js";
|
|
2
1
|
import {
|
|
3
2
|
PROTECTED_TOKENS,
|
|
4
3
|
createTranslator,
|
|
@@ -7,25 +6,45 @@ import {
|
|
|
7
6
|
enMessages,
|
|
8
7
|
normalizeLocale,
|
|
9
8
|
zhCNMessages
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-U2SR2M4L.js";
|
|
11
10
|
import {
|
|
11
|
+
FabExtractKnowledgeInputSchema,
|
|
12
|
+
FabExtractKnowledgeInputShape,
|
|
13
|
+
FabExtractKnowledgeOutputSchema,
|
|
14
|
+
FabReviewInputSchema,
|
|
15
|
+
FabReviewOutputSchema,
|
|
16
|
+
KNOWLEDGE_TYPE_CODES,
|
|
17
|
+
KnowledgeEntryFrontmatterSchema,
|
|
18
|
+
KnowledgeTypeSchema,
|
|
19
|
+
LayerSchema,
|
|
20
|
+
MaturitySchema,
|
|
21
|
+
PROPOSED_REASON_DESCRIPTIONS,
|
|
22
|
+
ProposedReasonSchema,
|
|
23
|
+
StableIdSchema,
|
|
12
24
|
annotateIntentRequestSchema,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
fabExtractKnowledgeAnnotations,
|
|
26
|
+
fabReviewAnnotations,
|
|
27
|
+
formatKnowledgeId,
|
|
28
|
+
getKnowledgeAnnotations,
|
|
29
|
+
getKnowledgeInputSchema,
|
|
30
|
+
getKnowledgeOutputSchema,
|
|
16
31
|
historyStateQuerySchema,
|
|
17
32
|
humanLockApproveRequestSchema,
|
|
18
33
|
humanLockFileParamsSchema,
|
|
34
|
+
knowledgeSectionsAnnotations,
|
|
35
|
+
knowledgeSectionsInputSchema,
|
|
36
|
+
knowledgeSectionsOutputSchema,
|
|
19
37
|
ledgerQuerySchema,
|
|
20
38
|
ledgerSourceSchema,
|
|
39
|
+
parseKnowledgeId,
|
|
21
40
|
planContextAnnotations,
|
|
41
|
+
planContextHintNarrowEntrySchema,
|
|
42
|
+
planContextHintOutputSchema,
|
|
22
43
|
planContextInputSchema,
|
|
23
44
|
planContextOutputSchema,
|
|
24
|
-
ruleSectionsAnnotations,
|
|
25
|
-
ruleSectionsInputSchema,
|
|
26
|
-
ruleSectionsOutputSchema,
|
|
27
45
|
structuredWarningSchema
|
|
28
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-VQDCDCJA.js";
|
|
47
|
+
import "./chunk-LXNCAKJZ.js";
|
|
29
48
|
|
|
30
49
|
// src/schemas/agents-meta.ts
|
|
31
50
|
import { z } from "zod";
|
|
@@ -42,7 +61,22 @@ var ruleDescriptionSchema = z.object({
|
|
|
42
61
|
tech_stack: z.array(z.string()),
|
|
43
62
|
impact: z.array(z.string()),
|
|
44
63
|
must_read_if: z.string(),
|
|
45
|
-
entities: z.array(z.string()).optional()
|
|
64
|
+
entities: z.array(z.string()).optional(),
|
|
65
|
+
// v2.0 knowledge entry fields (TASK-002 schemas). All optional for backward compat.
|
|
66
|
+
id: z.string().optional(),
|
|
67
|
+
knowledge_type: z.enum(["model", "decision", "guideline", "pitfall", "process"]).optional(),
|
|
68
|
+
maturity: z.enum(["draft", "verified", "proven"]).optional(),
|
|
69
|
+
knowledge_layer: z.enum(["personal", "team"]).optional(),
|
|
70
|
+
layer_reason: z.string().optional(),
|
|
71
|
+
created_at: z.string().optional(),
|
|
72
|
+
// v2/rc.2: flat flow-style YAML array; populated by init-scan from forensic tech stack and editable by user. Used by rc.3 review skill for tag-filter search.
|
|
73
|
+
tags: z.array(z.string()).default([]).optional(),
|
|
74
|
+
// v2.0-rc.5 (C1): relevance scope/paths drive plan-context-hint narrowing.
|
|
75
|
+
// Defaults applied so existing entries lacking these fields parse cleanly:
|
|
76
|
+
// relevance_scope → 'broad' (always-surface, safe default)
|
|
77
|
+
// relevance_paths → [] (no path anchors)
|
|
78
|
+
relevance_scope: z.enum(["narrow", "broad"]).default("broad"),
|
|
79
|
+
relevance_paths: z.array(z.string()).default([])
|
|
46
80
|
}).strict();
|
|
47
81
|
var ruleDescriptionIndexItemSchema = z.object({
|
|
48
82
|
stable_id: z.string(),
|
|
@@ -55,11 +89,6 @@ var agentsMetaNodeBaseSchema = z.object({
|
|
|
55
89
|
file: z.string(),
|
|
56
90
|
content_ref: z.string().optional(),
|
|
57
91
|
scope_glob: z.string(),
|
|
58
|
-
deps: z.array(z.string()),
|
|
59
|
-
priority: z.enum(["high", "medium", "low"]),
|
|
60
|
-
level: agentsLayerSchema.optional(),
|
|
61
|
-
layer: agentsLayerSchema,
|
|
62
|
-
topology_type: agentsTopologyTypeSchema,
|
|
63
92
|
hash: z.string(),
|
|
64
93
|
stable_id: z.string().optional(),
|
|
65
94
|
identity_source: agentsIdentitySourceSchema.optional(),
|
|
@@ -69,20 +98,40 @@ var agentsMetaNodeBaseSchema = z.object({
|
|
|
69
98
|
}).optional(),
|
|
70
99
|
description: ruleDescriptionSchema.optional(),
|
|
71
100
|
sections: z.array(z.string()).optional()
|
|
72
|
-
});
|
|
101
|
+
}).passthrough();
|
|
73
102
|
var agentsMetaNodeSchema = z.preprocess((value) => {
|
|
74
103
|
if (!isRecord(value) || typeof value.file !== "string") {
|
|
75
104
|
return value;
|
|
76
105
|
}
|
|
77
106
|
return withDerivedAgentsMetaNodeDefaults(value);
|
|
78
107
|
}, agentsMetaNodeBaseSchema);
|
|
108
|
+
var knowledgeTypeCountersSchema = z.object({
|
|
109
|
+
MOD: z.number().int().nonnegative().default(0),
|
|
110
|
+
DEC: z.number().int().nonnegative().default(0),
|
|
111
|
+
GLD: z.number().int().nonnegative().default(0),
|
|
112
|
+
PIT: z.number().int().nonnegative().default(0),
|
|
113
|
+
PRO: z.number().int().nonnegative().default(0)
|
|
114
|
+
}).default({ MOD: 0, DEC: 0, GLD: 0, PIT: 0, PRO: 0 });
|
|
115
|
+
var AgentsMetaCountersSchema = z.object({
|
|
116
|
+
KP: knowledgeTypeCountersSchema,
|
|
117
|
+
KT: knowledgeTypeCountersSchema
|
|
118
|
+
}).default({
|
|
119
|
+
KP: { MOD: 0, DEC: 0, GLD: 0, PIT: 0, PRO: 0 },
|
|
120
|
+
KT: { MOD: 0, DEC: 0, GLD: 0, PIT: 0, PRO: 0 }
|
|
121
|
+
});
|
|
79
122
|
var agentsMetaSchema = z.object({
|
|
80
123
|
revision: z.string(),
|
|
81
|
-
nodes: z.record(agentsMetaNodeSchema)
|
|
124
|
+
nodes: z.record(agentsMetaNodeSchema),
|
|
125
|
+
counters: AgentsMetaCountersSchema.optional()
|
|
82
126
|
});
|
|
127
|
+
var KNOWLEDGE_STABLE_ID_PATTERN = /^K[PT]-(MOD|DEC|GLD|PIT|PRO)-\d{4,}$/u;
|
|
128
|
+
function isKnowledgeStableId(stableId) {
|
|
129
|
+
return stableId !== void 0 && KNOWLEDGE_STABLE_ID_PATTERN.test(stableId);
|
|
130
|
+
}
|
|
83
131
|
function withDerivedAgentsMetaNodeDefaults(node) {
|
|
132
|
+
const isKnowledgeEntry = isKnowledgeStableId(node.stable_id);
|
|
84
133
|
const stableId = node.stable_id ?? deriveAgentsMetaStableId(node.file);
|
|
85
|
-
const identitySource = deriveAgentsMetaIdentitySource(node);
|
|
134
|
+
const identitySource = isKnowledgeEntry ? "declared" : deriveAgentsMetaIdentitySource(node);
|
|
86
135
|
return {
|
|
87
136
|
...node,
|
|
88
137
|
layer: node.layer ?? node.level ?? deriveAgentsMetaLayer(node.file),
|
|
@@ -92,6 +141,27 @@ function withDerivedAgentsMetaNodeDefaults(node) {
|
|
|
92
141
|
identity_source: identitySource
|
|
93
142
|
};
|
|
94
143
|
}
|
|
144
|
+
function allocateKnowledgeId(layer, type, current) {
|
|
145
|
+
const layerKey = layer === "personal" ? "KP" : "KT";
|
|
146
|
+
const typeCode = KNOWLEDGE_TYPE_CODES[type];
|
|
147
|
+
const previousCount = current[layerKey][typeCode] ?? 0;
|
|
148
|
+
const nextCount = previousCount + 1;
|
|
149
|
+
const id = formatKnowledgeId(layer, type, nextCount);
|
|
150
|
+
const nextCounters = {
|
|
151
|
+
...current,
|
|
152
|
+
[layerKey]: {
|
|
153
|
+
...current[layerKey],
|
|
154
|
+
[typeCode]: nextCount
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
return { id, nextCounters };
|
|
158
|
+
}
|
|
159
|
+
function defaultAgentsMetaCounters() {
|
|
160
|
+
return {
|
|
161
|
+
KP: { MOD: 0, DEC: 0, GLD: 0, PIT: 0, PRO: 0 },
|
|
162
|
+
KT: { MOD: 0, DEC: 0, GLD: 0, PIT: 0, PRO: 0 }
|
|
163
|
+
};
|
|
164
|
+
}
|
|
95
165
|
function deriveAgentsMetaStableId(file) {
|
|
96
166
|
const normalized = normalizePath(file);
|
|
97
167
|
if (normalized === "AGENTS.md" || normalized === ".fabric/bootstrap/README.md") {
|
|
@@ -103,6 +173,9 @@ function deriveAgentsMetaIdentitySource(node) {
|
|
|
103
173
|
if (node.identity_source !== void 0) {
|
|
104
174
|
return node.identity_source;
|
|
105
175
|
}
|
|
176
|
+
if (isKnowledgeStableId(node.stable_id)) {
|
|
177
|
+
return "declared";
|
|
178
|
+
}
|
|
106
179
|
const derivedStableId = deriveAgentsMetaStableId(node.file);
|
|
107
180
|
return node.stable_id !== void 0 && node.stable_id !== derivedStableId ? "declared" : "derived";
|
|
108
181
|
}
|
|
@@ -144,11 +217,11 @@ function isRecord(value) {
|
|
|
144
217
|
return typeof value === "object" && value !== null;
|
|
145
218
|
}
|
|
146
219
|
|
|
147
|
-
// src/schemas/
|
|
220
|
+
// src/schemas/knowledge-test-index.ts
|
|
148
221
|
import { z as z2 } from "zod";
|
|
149
|
-
var
|
|
222
|
+
var KNOWLEDGE_TEST_INDEX_SCHEMA_VERSION = 1;
|
|
150
223
|
var hashSchema = z2.string().min(1);
|
|
151
|
-
var
|
|
224
|
+
var knowledgeTestLinkSchema = z2.object({
|
|
152
225
|
rule_stable_id: z2.string().min(1),
|
|
153
226
|
rule_file: z2.string().min(1),
|
|
154
227
|
rule_hash: hashSchema,
|
|
@@ -158,20 +231,20 @@ var ruleTestLinkSchema = z2.object({
|
|
|
158
231
|
previous_test_hash: hashSchema.optional(),
|
|
159
232
|
annotation_line: z2.number().int().positive()
|
|
160
233
|
}).strict();
|
|
161
|
-
var
|
|
234
|
+
var knowledgeTestOrphanAnnotationSchema = z2.object({
|
|
162
235
|
rule_stable_id: z2.string().min(1),
|
|
163
236
|
test_file: z2.string().min(1),
|
|
164
237
|
test_hash: hashSchema,
|
|
165
238
|
previous_test_hash: hashSchema.optional(),
|
|
166
239
|
annotation_line: z2.number().int().positive()
|
|
167
240
|
}).strict();
|
|
168
|
-
var
|
|
169
|
-
schema_version: z2.literal(
|
|
241
|
+
var knowledgeTestIndexSchema = z2.object({
|
|
242
|
+
schema_version: z2.literal(KNOWLEDGE_TEST_INDEX_SCHEMA_VERSION),
|
|
170
243
|
generated_at: z2.string().datetime({ offset: true }),
|
|
171
244
|
revision: z2.string().min(1).optional(),
|
|
172
245
|
previous_revision: z2.string().min(1).optional(),
|
|
173
|
-
links: z2.array(
|
|
174
|
-
orphan_annotations: z2.array(
|
|
246
|
+
links: z2.array(knowledgeTestLinkSchema),
|
|
247
|
+
orphan_annotations: z2.array(knowledgeTestOrphanAnnotationSchema)
|
|
175
248
|
}).strict();
|
|
176
249
|
|
|
177
250
|
// src/schemas/ledger-entry.ts
|
|
@@ -226,18 +299,79 @@ var clientPathsSchema = z5.object({
|
|
|
226
299
|
claudeCodeDesktop: z5.string().optional(),
|
|
227
300
|
cursor: z5.string().optional(),
|
|
228
301
|
codexCLI: z5.string().optional()
|
|
229
|
-
}).
|
|
302
|
+
}).strict();
|
|
230
303
|
var mcpPayloadLimitsSchema = z5.object({
|
|
231
304
|
warnBytes: z5.number().int().positive().optional(),
|
|
232
305
|
hardBytes: z5.number().int().positive().optional()
|
|
233
306
|
}).optional();
|
|
307
|
+
var knowledgeLanguageSchema = z5.enum(["match-existing", "zh-CN", "en"]);
|
|
308
|
+
var defaultLayerFilterSchema = z5.enum(["team", "personal", "both"]);
|
|
234
309
|
var fabricConfigSchema = z5.object({
|
|
235
310
|
clientPaths: clientPathsSchema.optional(),
|
|
236
311
|
externalFixturePath: z5.string().optional(),
|
|
237
312
|
scanIgnores: z5.array(z5.string()).optional(),
|
|
238
313
|
auditMode: auditModeSchema.optional(),
|
|
239
314
|
audit_mode: auditModeSchema.optional(),
|
|
240
|
-
mcpPayloadLimits: mcpPayloadLimitsSchema
|
|
315
|
+
mcpPayloadLimits: mcpPayloadLimitsSchema,
|
|
316
|
+
// Backward-compat: both fields are optional with defaults so existing
|
|
317
|
+
// fabric-config.json files (pre-grill-followup) parse unchanged. The default
|
|
318
|
+
// values themselves are load-bearing — see docs/data-schema.md.
|
|
319
|
+
knowledge_language: knowledgeLanguageSchema.optional().default("match-existing"),
|
|
320
|
+
default_layer_filter: defaultLayerFilterSchema.optional().default("both"),
|
|
321
|
+
// Cooldown for the fabric-hint Stop hook (formerly archive-hint, renamed in
|
|
322
|
+
// rc.5 TASK-010). After ANY of the three signals (archive / review / import)
|
|
323
|
+
// fires, that signal stays silent for this many hours regardless of state
|
|
324
|
+
// drift — purely a reminder throttle. Default 12 means "at most twice per
|
|
325
|
+
// day if the user keeps ignoring it." Set to 24 to align with the archive
|
|
326
|
+
// trigger threshold. The legacy `archive_hint_` key is retained for backward
|
|
327
|
+
// compat with existing user fabric-config.json files.
|
|
328
|
+
archive_hint_cooldown_hours: z5.number().int().positive().optional().default(12),
|
|
329
|
+
// Underseed-node threshold for the fabric-hint Stop hook's import signal
|
|
330
|
+
// (rc.5 TASK-010). When the canonical knowledge node count is strictly less
|
|
331
|
+
// than this value AND a successful `init_scan_completed` event happened at
|
|
332
|
+
// least 24h ago AND no `knowledge_proposed` event has fired in the last 24h,
|
|
333
|
+
// the hook recommends running the fabric-import skill. Default 10 reflects
|
|
334
|
+
// the rule-of-thumb that a workspace with fewer than ten knowledge entries
|
|
335
|
+
// is below the floor for plan_context retrieval to be meaningful. Also
|
|
336
|
+
// consumed by `doctor` lint #22 (knowledge_underseeded).
|
|
337
|
+
underseed_node_threshold: z5.number().int().positive().optional().default(10),
|
|
338
|
+
// Edit-count threshold for the fabric-hint Stop hook's Signal A
|
|
339
|
+
// (rc.6 TASK-022 / E5). Signal A fires when EITHER (a) >=24h have elapsed
|
|
340
|
+
// since the last `knowledge_proposed` event, OR (b) >=archive_edit_threshold
|
|
341
|
+
// PreToolUse fires have been recorded in `.fabric/.cache/edit-counter` since
|
|
342
|
+
// the last `knowledge_proposed` event. The edit-counter sidecar is populated
|
|
343
|
+
// by the rc.6 PreToolUse hook (TASK-020 / E4) — one ISO-8601 line per fire.
|
|
344
|
+
// Default 20 reflects the rule-of-thumb "after ~20 Edit/Write operations
|
|
345
|
+
// there is probably something worth archiving"; lowered values nag more
|
|
346
|
+
// aggressively, higher values rely on the 24h fallback. Missing or absent
|
|
347
|
+
// edit-counter file degrades safely to the 24h-only path.
|
|
348
|
+
archive_edit_threshold: z5.number().int().positive().optional().default(20),
|
|
349
|
+
// rc.7 T7: hours-since-last-knowledge_proposed cutoff for Signal A's
|
|
350
|
+
// time branch. Was hardcoded as 24 in fabric-hint.cjs's THRESHOLD_HOURS;
|
|
351
|
+
// externalized so chatty workspaces can lower the bar and quiet ones can
|
|
352
|
+
// raise it. Default 24 preserves rc.6 behavior. See docs/configuration.md.
|
|
353
|
+
archive_hint_hours: z5.number().int().positive().optional().default(24),
|
|
354
|
+
// rc.7 T7: pending-count cutoff for Signal B (review skill). Was
|
|
355
|
+
// hardcoded as 10 in fabric-hint.cjs's THRESHOLD_PENDING_COUNT.
|
|
356
|
+
// Default 10 preserves rc.6 behavior. See docs/configuration.md for
|
|
357
|
+
// small/medium/large repo recommendations.
|
|
358
|
+
review_hint_pending_count: z5.number().int().positive().optional().default(10),
|
|
359
|
+
// rc.7 T7: pending-age cutoff (in days) for Signal B (review skill).
|
|
360
|
+
// Was hardcoded as 7 in fabric-hint.cjs's THRESHOLD_PENDING_AGE_DAYS.
|
|
361
|
+
// Default 7 preserves rc.6 behavior. See docs/configuration.md.
|
|
362
|
+
review_hint_pending_age_days: z5.number().int().positive().optional().default(7),
|
|
363
|
+
// rc.7 T7 + T10 pre-wiring: days-since-last-doctor cutoff for the future
|
|
364
|
+
// Signal D (maintenance hint). T10 will consume this to decide when the
|
|
365
|
+
// fabric-hint Stop hook surfaces a "run `fabric doctor`" reminder.
|
|
366
|
+
// Default 14 reflects a fortnightly cadence — long enough to avoid nag,
|
|
367
|
+
// short enough to catch index drift before it compounds.
|
|
368
|
+
maintenance_hint_days: z5.number().int().positive().optional().default(14),
|
|
369
|
+
// rc.7 T7 + T10 pre-wiring: cooldown between Signal D reminders, in
|
|
370
|
+
// days. Once Signal D fires, it stays silent for this many days even if
|
|
371
|
+
// the user doesn't run doctor. Default 7 keeps the reminder weekly at
|
|
372
|
+
// worst — pairing 14d trigger + 7d cooldown means at most ~2 reminders
|
|
373
|
+
// per month for a workspace that ignores them.
|
|
374
|
+
maintenance_hint_cooldown_days: z5.number().int().positive().optional().default(7)
|
|
241
375
|
});
|
|
242
376
|
|
|
243
377
|
// src/schemas/forensic-report.ts
|
|
@@ -408,9 +542,9 @@ var eventLedgerEnvelopeSchema = {
|
|
|
408
542
|
session_id: z9.string().optional()
|
|
409
543
|
};
|
|
410
544
|
var stringRecordSchema = z9.record(z9.string());
|
|
411
|
-
var
|
|
545
|
+
var knowledgeContextPlannedEventSchema = z9.object({
|
|
412
546
|
...eventLedgerEnvelopeSchema,
|
|
413
|
-
event_type: z9.literal("
|
|
547
|
+
event_type: z9.literal("knowledge_context_planned"),
|
|
414
548
|
target_paths: z9.array(z9.string()),
|
|
415
549
|
required_stable_ids: z9.array(z9.string()),
|
|
416
550
|
ai_selectable_stable_ids: z9.array(z9.string()),
|
|
@@ -421,9 +555,9 @@ var ruleContextPlannedEventSchema = z9.object({
|
|
|
421
555
|
known_tech: z9.array(z9.string()).optional(),
|
|
422
556
|
diagnostics: z9.array(z9.unknown()).optional()
|
|
423
557
|
});
|
|
424
|
-
var
|
|
558
|
+
var knowledgeSelectionEventSchema = z9.object({
|
|
425
559
|
...eventLedgerEnvelopeSchema,
|
|
426
|
-
event_type: z9.literal("
|
|
560
|
+
event_type: z9.literal("knowledge_selection"),
|
|
427
561
|
selection_token: z9.string(),
|
|
428
562
|
target_paths: z9.array(z9.string()),
|
|
429
563
|
required_stable_ids: z9.array(z9.string()),
|
|
@@ -434,9 +568,9 @@ var ruleSelectionEventSchema = z9.object({
|
|
|
434
568
|
rejected_stable_ids: z9.array(z9.string()),
|
|
435
569
|
ignored_stable_ids: z9.array(z9.string())
|
|
436
570
|
});
|
|
437
|
-
var
|
|
571
|
+
var knowledgeSectionsFetchedEventSchema = z9.object({
|
|
438
572
|
...eventLedgerEnvelopeSchema,
|
|
439
|
-
event_type: z9.literal("
|
|
573
|
+
event_type: z9.literal("knowledge_sections_fetched"),
|
|
440
574
|
selection_token: z9.string(),
|
|
441
575
|
target_paths: z9.array(z9.string()).optional(),
|
|
442
576
|
requested_sections: z9.array(z9.string()),
|
|
@@ -460,9 +594,9 @@ var editIntentCheckedEventSchema = z9.object({
|
|
|
460
594
|
matched_rule_context_ts: z9.number().int().nonnegative().nullable(),
|
|
461
595
|
window_ms: z9.number().int().nonnegative()
|
|
462
596
|
});
|
|
463
|
-
var
|
|
597
|
+
var knowledgeDriftDetectedEventSchema = z9.object({
|
|
464
598
|
...eventLedgerEnvelopeSchema,
|
|
465
|
-
event_type: z9.literal("
|
|
599
|
+
event_type: z9.literal("knowledge_drift_detected"),
|
|
466
600
|
revision: z9.string().optional(),
|
|
467
601
|
drifted_stable_ids: z9.array(z9.string()),
|
|
468
602
|
missing_files: z9.array(z9.string()),
|
|
@@ -476,23 +610,6 @@ var ruleDriftDetectedEventSchema = z9.object({
|
|
|
476
610
|
})
|
|
477
611
|
).optional()
|
|
478
612
|
});
|
|
479
|
-
var ruleBaselineAcceptedEventSchema = z9.object({
|
|
480
|
-
...eventLedgerEnvelopeSchema,
|
|
481
|
-
event_type: z9.literal("rule_baseline_accepted"),
|
|
482
|
-
revision: z9.string(),
|
|
483
|
-
previous_revision: z9.string().optional(),
|
|
484
|
-
accepted_stable_ids: z9.array(z9.string()),
|
|
485
|
-
source: z9.enum(["doctor_fix", "sync_meta"]).optional()
|
|
486
|
-
});
|
|
487
|
-
var baselineSyncedEventSchema = z9.object({
|
|
488
|
-
...eventLedgerEnvelopeSchema,
|
|
489
|
-
event_type: z9.literal("baseline_synced"),
|
|
490
|
-
revision: z9.string(),
|
|
491
|
-
previous_revision: z9.string().optional(),
|
|
492
|
-
synced_files: z9.array(z9.string()),
|
|
493
|
-
accepted_stable_ids: z9.array(z9.string()),
|
|
494
|
-
source: z9.enum(["doctor_fix", "sync_meta"])
|
|
495
|
-
});
|
|
496
613
|
var mcpEventLedgerEventSchema = z9.object({
|
|
497
614
|
...eventLedgerEnvelopeSchema,
|
|
498
615
|
event_type: z9.literal("mcp_event"),
|
|
@@ -525,7 +642,7 @@ var metaReconciledOnStartupEventSchema = z9.object({
|
|
|
525
642
|
event_type: z9.literal("meta_reconciled_on_startup"),
|
|
526
643
|
reconciled_files: z9.array(z9.string()),
|
|
527
644
|
duration_ms: z9.number().int().nonnegative(),
|
|
528
|
-
source: z9.literal("
|
|
645
|
+
source: z9.literal("reconcileKnowledge")
|
|
529
646
|
});
|
|
530
647
|
var metaReconciledEventSchema = z9.object({
|
|
531
648
|
...eventLedgerEnvelopeSchema,
|
|
@@ -533,7 +650,7 @@ var metaReconciledEventSchema = z9.object({
|
|
|
533
650
|
reconciled_files: z9.array(z9.string()),
|
|
534
651
|
duration_ms: z9.number().int().nonnegative(),
|
|
535
652
|
trigger: z9.enum(["doctor", "manual"]),
|
|
536
|
-
source: z9.literal("
|
|
653
|
+
source: z9.literal("reconcileKnowledge")
|
|
537
654
|
});
|
|
538
655
|
var claudeSkillPathMigratedEventSchema = z9.object({
|
|
539
656
|
...eventLedgerEnvelopeSchema,
|
|
@@ -553,19 +670,138 @@ var codexSkillPathMigratedEventSchema = z9.object({
|
|
|
553
670
|
from: z9.string(),
|
|
554
671
|
to: z9.string()
|
|
555
672
|
});
|
|
556
|
-
var
|
|
673
|
+
var initScanCompletedEventSchema = z9.object({
|
|
674
|
+
...eventLedgerEnvelopeSchema,
|
|
675
|
+
event_type: z9.literal("init_scan_completed"),
|
|
676
|
+
written_stable_ids: z9.array(z9.string()),
|
|
677
|
+
duration_ms: z9.number().int().nonnegative(),
|
|
678
|
+
source: z9.enum(["init", "scan", "doctor_fix"]).optional()
|
|
679
|
+
});
|
|
680
|
+
var knowledgeProposedEventSchema = z9.object({
|
|
681
|
+
...eventLedgerEnvelopeSchema,
|
|
682
|
+
event_type: z9.literal("knowledge_proposed"),
|
|
683
|
+
stable_id: z9.string().optional(),
|
|
684
|
+
timestamp: z9.string().datetime(),
|
|
685
|
+
reason: z9.string().optional()
|
|
686
|
+
});
|
|
687
|
+
var knowledgePromoteStartedEventSchema = z9.object({
|
|
688
|
+
...eventLedgerEnvelopeSchema,
|
|
689
|
+
event_type: z9.literal("knowledge_promote_started"),
|
|
690
|
+
stable_id: z9.string().optional(),
|
|
691
|
+
timestamp: z9.string().datetime(),
|
|
692
|
+
reason: z9.string().optional()
|
|
693
|
+
});
|
|
694
|
+
var knowledgePromotedEventSchema = z9.object({
|
|
695
|
+
...eventLedgerEnvelopeSchema,
|
|
696
|
+
event_type: z9.literal("knowledge_promoted"),
|
|
697
|
+
stable_id: z9.string().optional(),
|
|
698
|
+
timestamp: z9.string().datetime(),
|
|
699
|
+
reason: z9.string().optional()
|
|
700
|
+
});
|
|
701
|
+
var knowledgePromoteFailedEventSchema = z9.object({
|
|
702
|
+
...eventLedgerEnvelopeSchema,
|
|
703
|
+
event_type: z9.literal("knowledge_promote_failed"),
|
|
704
|
+
stable_id: z9.string().optional(),
|
|
705
|
+
timestamp: z9.string().datetime(),
|
|
706
|
+
reason: z9.string()
|
|
707
|
+
});
|
|
708
|
+
var knowledgeLayerChangedEventSchema = z9.object({
|
|
709
|
+
...eventLedgerEnvelopeSchema,
|
|
710
|
+
event_type: z9.literal("knowledge_layer_changed"),
|
|
711
|
+
stable_id: z9.string().optional(),
|
|
712
|
+
timestamp: z9.string().datetime(),
|
|
713
|
+
reason: z9.string().optional(),
|
|
714
|
+
from_layer: z9.enum(["team", "personal"]),
|
|
715
|
+
to_layer: z9.enum(["team", "personal"])
|
|
716
|
+
});
|
|
717
|
+
var knowledgeSlugRenamedEventSchema = z9.object({
|
|
718
|
+
...eventLedgerEnvelopeSchema,
|
|
719
|
+
event_type: z9.literal("knowledge_slug_renamed"),
|
|
720
|
+
stable_id: z9.string().optional(),
|
|
721
|
+
timestamp: z9.string().datetime(),
|
|
722
|
+
reason: z9.string().optional(),
|
|
723
|
+
from_slug: z9.string(),
|
|
724
|
+
to_slug: z9.string()
|
|
725
|
+
});
|
|
726
|
+
var knowledgeDemotedEventSchema = z9.object({
|
|
727
|
+
...eventLedgerEnvelopeSchema,
|
|
728
|
+
event_type: z9.literal("knowledge_demoted"),
|
|
729
|
+
stable_id: z9.string().optional(),
|
|
730
|
+
timestamp: z9.string().datetime(),
|
|
731
|
+
reason: z9.string().optional()
|
|
732
|
+
});
|
|
733
|
+
var knowledgeArchivedEventSchema = z9.object({
|
|
734
|
+
...eventLedgerEnvelopeSchema,
|
|
735
|
+
event_type: z9.literal("knowledge_archived"),
|
|
736
|
+
stable_id: z9.string().optional(),
|
|
737
|
+
timestamp: z9.string().datetime(),
|
|
738
|
+
reason: z9.string().optional()
|
|
739
|
+
});
|
|
740
|
+
var knowledgeArchiveAttemptedEventSchema = z9.object({
|
|
741
|
+
...eventLedgerEnvelopeSchema,
|
|
742
|
+
event_type: z9.literal("knowledge_archive_attempted"),
|
|
743
|
+
stable_id: z9.string().optional(),
|
|
744
|
+
timestamp: z9.string().datetime(),
|
|
745
|
+
reason: z9.string().optional()
|
|
746
|
+
});
|
|
747
|
+
var knowledgeDeferredEventSchema = z9.object({
|
|
748
|
+
...eventLedgerEnvelopeSchema,
|
|
749
|
+
event_type: z9.literal("knowledge_deferred"),
|
|
750
|
+
stable_id: z9.string().optional(),
|
|
751
|
+
timestamp: z9.string().datetime(),
|
|
752
|
+
reason: z9.string().optional(),
|
|
753
|
+
until: z9.string().datetime().optional()
|
|
754
|
+
});
|
|
755
|
+
var knowledgeRejectedEventSchema = z9.object({
|
|
756
|
+
...eventLedgerEnvelopeSchema,
|
|
757
|
+
event_type: z9.literal("knowledge_rejected"),
|
|
758
|
+
stable_id: z9.string().optional(),
|
|
759
|
+
timestamp: z9.string().datetime(),
|
|
760
|
+
reason: z9.string()
|
|
761
|
+
});
|
|
762
|
+
var knowledgeConsumedEventSchema = z9.object({
|
|
763
|
+
...eventLedgerEnvelopeSchema,
|
|
764
|
+
event_type: z9.literal("knowledge_consumed"),
|
|
765
|
+
stable_id: z9.string(),
|
|
766
|
+
consumed_at: z9.string().datetime(),
|
|
767
|
+
client_hash: z9.string()
|
|
768
|
+
});
|
|
769
|
+
var knowledgeScopeDegradedEventSchema = z9.object({
|
|
770
|
+
...eventLedgerEnvelopeSchema,
|
|
771
|
+
event_type: z9.literal("knowledge_scope_degraded"),
|
|
772
|
+
stable_id: z9.string(),
|
|
773
|
+
timestamp: z9.string().datetime(),
|
|
774
|
+
from_scope: z9.enum(["narrow", "broad"]),
|
|
775
|
+
to_scope: z9.enum(["narrow", "broad"]),
|
|
776
|
+
reason: z9.string()
|
|
777
|
+
});
|
|
778
|
+
var doctorRunEventSchema = z9.object({
|
|
779
|
+
...eventLedgerEnvelopeSchema,
|
|
780
|
+
event_type: z9.literal("doctor_run"),
|
|
781
|
+
mode: z9.enum(["lint", "apply-lint"]),
|
|
782
|
+
issues: z9.number().int().nonnegative(),
|
|
783
|
+
mutations: z9.number().int().nonnegative().optional(),
|
|
784
|
+
timestamp: z9.string().datetime()
|
|
785
|
+
});
|
|
786
|
+
var knowledgePathDangledEventSchema = z9.object({
|
|
787
|
+
...eventLedgerEnvelopeSchema,
|
|
788
|
+
event_type: z9.literal("knowledge_path_dangled"),
|
|
789
|
+
stable_id: z9.string(),
|
|
790
|
+
removed_glob: z9.string()
|
|
791
|
+
});
|
|
792
|
+
var pendingAutoArchivedEventSchema = z9.object({
|
|
557
793
|
...eventLedgerEnvelopeSchema,
|
|
558
|
-
event_type: z9.literal("
|
|
559
|
-
|
|
794
|
+
event_type: z9.literal("pending_auto_archived"),
|
|
795
|
+
pending_path: z9.string(),
|
|
796
|
+
archived_to: z9.string(),
|
|
797
|
+
reason: z9.string()
|
|
560
798
|
});
|
|
561
799
|
var eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
800
|
+
knowledgeContextPlannedEventSchema,
|
|
801
|
+
knowledgeSelectionEventSchema,
|
|
802
|
+
knowledgeSectionsFetchedEventSchema,
|
|
565
803
|
editIntentCheckedEventSchema,
|
|
566
|
-
|
|
567
|
-
ruleBaselineAcceptedEventSchema,
|
|
568
|
-
baselineSyncedEventSchema,
|
|
804
|
+
knowledgeDriftDetectedEventSchema,
|
|
569
805
|
mcpEventLedgerEventSchema,
|
|
570
806
|
reapplyCompletedEventSchema,
|
|
571
807
|
eventLedgerTruncatedEventSchema,
|
|
@@ -575,40 +811,83 @@ var eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
|
|
|
575
811
|
claudeSkillPathMigratedEventSchema,
|
|
576
812
|
claudeHookPathMigratedEventSchema,
|
|
577
813
|
codexSkillPathMigratedEventSchema,
|
|
578
|
-
|
|
814
|
+
initScanCompletedEventSchema,
|
|
815
|
+
// v2.0 rc.2 grill-followup TASK-004: knowledge.* lifecycle pre-registration
|
|
816
|
+
knowledgeProposedEventSchema,
|
|
817
|
+
knowledgePromoteStartedEventSchema,
|
|
818
|
+
knowledgePromotedEventSchema,
|
|
819
|
+
knowledgePromoteFailedEventSchema,
|
|
820
|
+
knowledgeLayerChangedEventSchema,
|
|
821
|
+
knowledgeSlugRenamedEventSchema,
|
|
822
|
+
knowledgeDemotedEventSchema,
|
|
823
|
+
knowledgeArchivedEventSchema,
|
|
824
|
+
knowledgeArchiveAttemptedEventSchema,
|
|
825
|
+
knowledgeDeferredEventSchema,
|
|
826
|
+
knowledgeRejectedEventSchema,
|
|
827
|
+
// v2.0 rc.5 TASK-014: knowledge_consumed (consumption tracking)
|
|
828
|
+
knowledgeConsumedEventSchema,
|
|
829
|
+
// v2.0 rc.5 TASK-012 (C3): knowledge_scope_degraded — narrow→broad auto-degrade
|
|
830
|
+
knowledgeScopeDegradedEventSchema,
|
|
831
|
+
// v2.0 rc.5 TASK-009 (B2): pending_auto_archived — doctor --apply-lint moves
|
|
832
|
+
// pending entries >30d old into the .archive/pending/ subtree.
|
|
833
|
+
pendingAutoArchivedEventSchema,
|
|
834
|
+
// v2.0 rc.5 TASK-013 (C4): knowledge_path_dangled — emitted by doctor lint
|
|
835
|
+
// #24 when a glob in relevance_paths resolves to zero filesystem matches.
|
|
836
|
+
knowledgePathDangledEventSchema,
|
|
837
|
+
// v2.0.0-rc.7 T10: doctor_run — emitted by `fabric doctor` to drive Signal D.
|
|
838
|
+
doctorRunEventSchema
|
|
579
839
|
]);
|
|
580
840
|
export {
|
|
581
841
|
AGENTS_META_IDENTITY_SOURCES,
|
|
582
842
|
AGENTS_META_LAYERS,
|
|
583
843
|
AGENTS_META_TOPOLOGY_TYPES,
|
|
844
|
+
AgentsMetaCountersSchema,
|
|
845
|
+
FabExtractKnowledgeInputSchema,
|
|
846
|
+
FabExtractKnowledgeInputShape,
|
|
847
|
+
FabExtractKnowledgeOutputSchema,
|
|
848
|
+
FabReviewInputSchema,
|
|
849
|
+
FabReviewOutputSchema,
|
|
850
|
+
KNOWLEDGE_TEST_INDEX_SCHEMA_VERSION,
|
|
851
|
+
KNOWLEDGE_TYPE_CODES,
|
|
852
|
+
KnowledgeEntryFrontmatterSchema,
|
|
853
|
+
KnowledgeTypeSchema,
|
|
854
|
+
LayerSchema,
|
|
855
|
+
MaturitySchema,
|
|
856
|
+
PROPOSED_REASON_DESCRIPTIONS,
|
|
584
857
|
PROTECTED_TOKENS,
|
|
585
|
-
|
|
858
|
+
ProposedReasonSchema,
|
|
859
|
+
StableIdSchema,
|
|
586
860
|
agentsIdentitySourceSchema,
|
|
587
861
|
agentsLayerSchema,
|
|
588
862
|
agentsMetaNodeSchema,
|
|
589
863
|
agentsMetaSchema,
|
|
590
864
|
agentsTopologyTypeSchema,
|
|
591
865
|
aiLedgerEntrySchema,
|
|
866
|
+
allocateKnowledgeId,
|
|
592
867
|
annotateIntentRequestSchema,
|
|
593
868
|
auditModeSchema,
|
|
594
|
-
baselineSyncedEventSchema,
|
|
595
869
|
candidateFileEntrySchema,
|
|
596
870
|
claudeHookPathMigratedEventSchema,
|
|
597
871
|
claudeSkillPathMigratedEventSchema,
|
|
598
872
|
clientPathsSchema,
|
|
599
873
|
codexSkillPathMigratedEventSchema,
|
|
600
874
|
createTranslator,
|
|
875
|
+
defaultAgentsMetaCounters,
|
|
876
|
+
defaultLayerFilterSchema,
|
|
601
877
|
defaultMessages,
|
|
602
878
|
deriveAgentsMetaIdentitySource,
|
|
603
879
|
deriveAgentsMetaLayer,
|
|
604
880
|
deriveAgentsMetaStableId,
|
|
605
881
|
deriveAgentsMetaTopologyType,
|
|
606
882
|
detectNodeLocale,
|
|
883
|
+
doctorRunEventSchema,
|
|
607
884
|
driftDetectedEventSchema,
|
|
608
885
|
editIntentCheckedEventSchema,
|
|
609
886
|
enMessages,
|
|
610
887
|
eventLedgerEventSchema,
|
|
611
888
|
eventLedgerTruncatedEventSchema,
|
|
889
|
+
fabExtractKnowledgeAnnotations,
|
|
890
|
+
fabReviewAnnotations,
|
|
612
891
|
fabricConfigSchema,
|
|
613
892
|
fabricEventSchema,
|
|
614
893
|
forensicAssertionCoverageSchema,
|
|
@@ -621,9 +900,10 @@ export {
|
|
|
621
900
|
forensicReportSchema,
|
|
622
901
|
forensicSamplingBudgetSchema,
|
|
623
902
|
forensicTopologySchema,
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
903
|
+
formatKnowledgeId,
|
|
904
|
+
getKnowledgeAnnotations,
|
|
905
|
+
getKnowledgeInputSchema,
|
|
906
|
+
getKnowledgeOutputSchema,
|
|
627
907
|
historyStateQuerySchema,
|
|
628
908
|
humanLedgerEntrySchema,
|
|
629
909
|
humanLockApproveRequestSchema,
|
|
@@ -637,11 +917,37 @@ export {
|
|
|
637
917
|
initContextInvariantSchema,
|
|
638
918
|
initContextSchema,
|
|
639
919
|
initContextSourceEvidenceSchema,
|
|
920
|
+
initScanCompletedEventSchema,
|
|
921
|
+
isKnowledgeStableId,
|
|
922
|
+
knowledgeArchiveAttemptedEventSchema,
|
|
923
|
+
knowledgeArchivedEventSchema,
|
|
924
|
+
knowledgeConsumedEventSchema,
|
|
925
|
+
knowledgeContextPlannedEventSchema,
|
|
926
|
+
knowledgeDeferredEventSchema,
|
|
927
|
+
knowledgeDemotedEventSchema,
|
|
928
|
+
knowledgeDriftDetectedEventSchema,
|
|
929
|
+
knowledgeLanguageSchema,
|
|
930
|
+
knowledgeLayerChangedEventSchema,
|
|
931
|
+
knowledgePathDangledEventSchema,
|
|
932
|
+
knowledgePromoteFailedEventSchema,
|
|
933
|
+
knowledgePromoteStartedEventSchema,
|
|
934
|
+
knowledgePromotedEventSchema,
|
|
935
|
+
knowledgeProposedEventSchema,
|
|
936
|
+
knowledgeRejectedEventSchema,
|
|
937
|
+
knowledgeScopeDegradedEventSchema,
|
|
938
|
+
knowledgeSectionsAnnotations,
|
|
939
|
+
knowledgeSectionsFetchedEventSchema,
|
|
940
|
+
knowledgeSectionsInputSchema,
|
|
941
|
+
knowledgeSectionsOutputSchema,
|
|
942
|
+
knowledgeSelectionEventSchema,
|
|
943
|
+
knowledgeSlugRenamedEventSchema,
|
|
944
|
+
knowledgeTestIndexSchema,
|
|
945
|
+
knowledgeTestLinkSchema,
|
|
946
|
+
knowledgeTestOrphanAnnotationSchema,
|
|
640
947
|
ledgerAppendedEventSchema,
|
|
641
948
|
ledgerEntrySchema,
|
|
642
949
|
ledgerQuerySchema,
|
|
643
950
|
ledgerSourceSchema,
|
|
644
|
-
legacyClientPathPresentEventSchema,
|
|
645
951
|
lockApprovedEventSchema,
|
|
646
952
|
lockDriftEventSchema,
|
|
647
953
|
mcpConfigMigratedEventSchema,
|
|
@@ -651,23 +957,16 @@ export {
|
|
|
651
957
|
metaReconciledOnStartupEventSchema,
|
|
652
958
|
metaUpdatedEventSchema,
|
|
653
959
|
normalizeLocale,
|
|
960
|
+
parseKnowledgeId,
|
|
961
|
+
pendingAutoArchivedEventSchema,
|
|
654
962
|
planContextAnnotations,
|
|
963
|
+
planContextHintNarrowEntrySchema,
|
|
964
|
+
planContextHintOutputSchema,
|
|
655
965
|
planContextInputSchema,
|
|
656
966
|
planContextOutputSchema,
|
|
657
967
|
reapplyCompletedEventSchema,
|
|
658
|
-
ruleBaselineAcceptedEventSchema,
|
|
659
|
-
ruleContextPlannedEventSchema,
|
|
660
968
|
ruleDescriptionIndexItemSchema,
|
|
661
969
|
ruleDescriptionSchema,
|
|
662
|
-
ruleDriftDetectedEventSchema,
|
|
663
|
-
ruleSectionsAnnotations,
|
|
664
|
-
ruleSectionsFetchedEventSchema,
|
|
665
|
-
ruleSectionsInputSchema,
|
|
666
|
-
ruleSectionsOutputSchema,
|
|
667
|
-
ruleSelectionEventSchema,
|
|
668
|
-
ruleTestIndexSchema,
|
|
669
|
-
ruleTestLinkSchema,
|
|
670
|
-
ruleTestOrphanAnnotationSchema,
|
|
671
970
|
structuredWarningSchema,
|
|
672
971
|
withDerivedAgentsMetaNodeDefaults,
|
|
673
972
|
zhCNMessages
|