@fenglimg/fabric-shared 2.0.0-rc.22 → 2.0.0-rc.25

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.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  LEGACY_KB_MARKER_BEGIN,
7
7
  LEGACY_KB_MARKER_END,
8
8
  LEGACY_KB_REGEX
9
- } from "./chunk-BEABJYVL.js";
9
+ } from "./chunk-4OQXR6JW.js";
10
10
  import {
11
11
  PROTECTED_TOKENS,
12
12
  createTranslator,
@@ -15,7 +15,7 @@ import {
15
15
  enMessages,
16
16
  normalizeLocale,
17
17
  zhCNMessages
18
- } from "./chunk-VKCXD6CI.js";
18
+ } from "./chunk-AFUQKKGR.js";
19
19
  import {
20
20
  FabExtractKnowledgeInputSchema,
21
21
  FabExtractKnowledgeInputShape,
@@ -29,16 +29,18 @@ import {
29
29
  KnowledgeTypeSchema,
30
30
  LayerSchema,
31
31
  MaturitySchema,
32
+ ONBOARD_SLOT_NAMES,
33
+ ONBOARD_SLOT_TOTAL,
32
34
  PROPOSED_REASON_DESCRIPTIONS,
33
35
  ProposedReasonSchema,
34
36
  StableIdSchema,
35
37
  annotateIntentRequestSchema,
38
+ citeContractMetricsSchema,
39
+ citeCoverageReportSchema,
40
+ citeLayerTypeBreakdownSchema,
36
41
  fabExtractKnowledgeAnnotations,
37
42
  fabReviewAnnotations,
38
43
  formatKnowledgeId,
39
- getKnowledgeAnnotations,
40
- getKnowledgeInputSchema,
41
- getKnowledgeOutputSchema,
42
44
  historyStateQuerySchema,
43
45
  humanLockApproveRequestSchema,
44
46
  humanLockFileParamsSchema,
@@ -47,6 +49,7 @@ import {
47
49
  knowledgeSectionsOutputSchema,
48
50
  ledgerQuerySchema,
49
51
  ledgerSourceSchema,
52
+ onboardSlotSchema,
50
53
  parseKnowledgeId,
51
54
  planContextAnnotations,
52
55
  planContextHintNarrowEntrySchema,
@@ -54,7 +57,7 @@ import {
54
57
  planContextInputSchema,
55
58
  planContextOutputSchema,
56
59
  structuredWarningSchema
57
- } from "./chunk-WK4WINAZ.js";
60
+ } from "./chunk-3RSYWMQU.js";
58
61
  import "./chunk-LXNCAKJZ.js";
59
62
 
60
63
  // src/schemas/agents-meta.ts
@@ -463,7 +466,24 @@ var fabricConfigSchema = z5.object({
463
466
  // Mirrors cite-policy precedent of locking enum-style numeric tunables
464
467
  // to a small literal set (vs free `.positive()`) to prevent fat-finger
465
468
  // misconfig.
466
- fabric_event_retention_days: z5.union([z5.literal(7), z5.literal(30), z5.literal(90)]).optional()
469
+ fabric_event_retention_days: z5.union([z5.literal(7), z5.literal(30), z5.literal(90)]).optional(),
470
+ // v2.0.0-rc.23 TASK-014 (F8c): onboard slot opt-out list. Tracks slot
471
+ // names the user explicitly dismissed during fabric-archive's first-run
472
+ // onboard phase (or via `fab config dismiss-slot <slot>`). Dismissed
473
+ // slots are excluded from `fab onboard-coverage`'s `missing` set and the
474
+ // doctor `Onboard coverage` advisory's recompute, so the user is never
475
+ // re-prompted for slots they consciously declined.
476
+ //
477
+ // Re-opening a dismissed slot requires `fab config onboard-reset <slot>`
478
+ // — a deliberate two-command UX to keep the dismiss intent reversible
479
+ // but never silently undone. Schema is intentionally `z.array(z.string())`
480
+ // rather than `z.array(onboardSlotSchema)` so historical configs survive
481
+ // a slot rename without a Zod parse error; downstream consumers
482
+ // intersect against ONBOARD_SLOT_NAMES at read time.
483
+ //
484
+ // Default `[]` keeps the field optional on existing configs — fresh
485
+ // installs land with no opt-outs.
486
+ onboard_slots_opted_out: z5.array(z5.string()).optional().default([])
467
487
  });
468
488
 
469
489
  // src/schemas/fabric-config-introspect.ts
@@ -888,7 +908,13 @@ var metaReconciledEventSchema = z10.object({
888
908
  event_type: z10.literal("meta_reconciled"),
889
909
  reconciled_files: z10.array(z10.string()),
890
910
  duration_ms: z10.number().int().nonnegative(),
891
- trigger: z10.enum(["doctor", "manual"]),
911
+ // v2.0.0-rc.23 TASK-005 (a-B): added `auto-heal-description` trigger so the
912
+ // read-path plan_context handler can drive a full reconcile when it detects
913
+ // any node carrying `description === undefined` (legacy meta drift that the
914
+ // revision-hash gate cannot catch — a missing description doesn't move the
915
+ // revision). Symmetric to rc.22 D2 read-side auto-heal but covers the
916
+ // description-undefined case which the revision drift gate misses.
917
+ trigger: z10.enum(["doctor", "manual", "auto-heal-description"]),
892
918
  source: z10.literal("reconcileKnowledge"),
893
919
  // v2.0.0-rc.22 TASK-014 (Scope E): set when reconcileKnowledge forced a
894
920
  // writeKnowledgeMeta on revision drift alone (no per-file content drift).
@@ -1053,6 +1079,24 @@ var assistantTurnObservedEventSchema = z10.object({
1053
1079
  kb_line_raw: z10.string().nullable(),
1054
1080
  cite_ids: z10.array(z10.string()).default([]),
1055
1081
  cite_tags: z10.array(z10.enum(["planned", "recalled", "chained-from", "dismissed", "none"])).default([]),
1082
+ // v2.0.0-rc.24 TASK-01: per-cite contract commitments. Index-aligned with
1083
+ // cite_ids/cite_tags (commitments[i] belongs to cite_ids[i]). Each slot
1084
+ // carries `operators[]` (kind + glob target) or `skip_reason` when the cite
1085
+ // cannot be operator-ized. Old rc.20-rc.23 events naturally parse with an
1086
+ // empty array via `.default([])` and are excluded from contract-policy
1087
+ // audits by the marker-gate (see cite_contract_policy_activated below).
1088
+ // Mirrors the rc.20 cite_tags parallel-array evolution exactly.
1089
+ cite_commitments: z10.array(
1090
+ z10.object({
1091
+ operators: z10.array(
1092
+ z10.object({
1093
+ kind: z10.enum(["edit", "not_edit", "require", "forbid"]),
1094
+ target: z10.string()
1095
+ })
1096
+ ),
1097
+ skip_reason: z10.string().nullable()
1098
+ })
1099
+ ).default([]),
1056
1100
  client: z10.enum(["cc", "codex", "cursor"]).optional(),
1057
1101
  turn_id: z10.string(),
1058
1102
  envelope_index: z10.number().int().nonnegative().optional(),
@@ -1064,6 +1108,10 @@ var citePolicyActivatedEventSchema = z10.object({
1064
1108
  policy_version: z10.string(),
1065
1109
  timestamp: z10.string().datetime()
1066
1110
  });
1111
+ var citeContractPolicyActivatedEventSchema = z10.object({
1112
+ ...eventLedgerEnvelopeSchema,
1113
+ event_type: z10.literal("cite_contract_policy_activated")
1114
+ });
1067
1115
  var eventsRotatedEventSchema = z10.object({
1068
1116
  ...eventLedgerEnvelopeSchema,
1069
1117
  event_type: z10.literal("events_rotated"),
@@ -1080,6 +1128,29 @@ var knowledgeMetaAutoHealedEventSchema = z10.object({
1080
1128
  trigger: z10.literal("read"),
1081
1129
  caller: z10.enum(["planContext", "getKnowledgeSections", "getKnowledge", "extractKnowledge"]).optional()
1082
1130
  });
1131
+ var serveLockClearedEventSchema = z10.object({
1132
+ ...eventLedgerEnvelopeSchema,
1133
+ event_type: z10.literal("serve_lock_cleared"),
1134
+ pid: z10.number().int().nonnegative(),
1135
+ age_ms: z10.number().int().nonnegative(),
1136
+ timestamp: z10.string().datetime()
1137
+ });
1138
+ var knowledgeEnrichedEventSchema = z10.object({
1139
+ ...eventLedgerEnvelopeSchema,
1140
+ event_type: z10.literal("knowledge_enriched"),
1141
+ path: z10.string(),
1142
+ added_fields: z10.array(z10.enum(["intent_clues", "tech_stack", "impact", "must_read_if"])),
1143
+ mode: z10.enum(["auto", "interactive"]),
1144
+ timestamp: z10.string().datetime()
1145
+ });
1146
+ var sessionArchiveAttemptedEventSchema = z10.object({
1147
+ ...eventLedgerEnvelopeSchema,
1148
+ event_type: z10.literal("session_archive_attempted"),
1149
+ outcome: z10.enum(["proposed", "viability_failed", "user_dismissed", "skipped_no_signal"]),
1150
+ covered_through_ts: z10.number().int().nonnegative(),
1151
+ candidates_proposed: z10.number().int().nonnegative().default(0),
1152
+ knowledge_proposed_ids: z10.array(z10.string()).default([])
1153
+ });
1083
1154
  var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
1084
1155
  knowledgeContextPlannedEventSchema,
1085
1156
  knowledgeSelectionEventSchema,
@@ -1132,14 +1203,110 @@ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
1132
1203
  // v2.0.0-rc.20 TASK-02: cite_policy_activated — session/policy-bump
1133
1204
  // marker recording when a given policy_version became active.
1134
1205
  citePolicyActivatedEventSchema,
1206
+ // v2.0.0-rc.24 TASK-01: cite_contract_policy_activated — drift-gated
1207
+ // idempotent marker opening the contract-policy audit window. Distinct
1208
+ // from cite_policy_activated so contract metrics get their own window.
1209
+ citeContractPolicyActivatedEventSchema,
1135
1210
  // v2.0.0-rc.22 Scope D T-D1: knowledge_meta_auto_healed — emitted by
1136
1211
  // loadActiveMeta when read-path drift triggers an in-place meta rebuild.
1137
1212
  knowledgeMetaAutoHealedEventSchema,
1138
1213
  // v2.0.0-rc.22 Scope A T3: events_rotated — emitted as the first line of
1139
1214
  // the post-rotation events.jsonl when sliding-window-by-age rotation moves
1140
1215
  // stale entries to events.archive/events-rotated-YYYY-MM-DD.jsonl.
1141
- eventsRotatedEventSchema
1216
+ eventsRotatedEventSchema,
1217
+ // v2.0.0-rc.23 TASK-010 (e): serve_lock_cleared — emitted by
1218
+ // `fab doctor --fix` when a stale `.fabric/.serve.lock` with a dead PID is
1219
+ // unlinked.
1220
+ serveLockClearedEventSchema,
1221
+ // v2.0.0-rc.23 TASK-007 (a-C2): knowledge_enriched — emitted by
1222
+ // `fab doctor --enrich-descriptions` once per modified canonical knowledge
1223
+ // file when one or more of the four rc.23 description-grade frontmatter
1224
+ // fields is back-filled.
1225
+ knowledgeEnrichedEventSchema,
1226
+ // v2.0.0-rc.25 TASK-01: session_archive_attempted — emitted by the
1227
+ // fabric-archive skill at the end of every invocation. Drives Phase 0.0
1228
+ // cross-session digest, outcome-based rescan filter (skips user_dismissed),
1229
+ // covered_through_ts watermark, and `fab doctor --archive-history`.
1230
+ sessionArchiveAttemptedEventSchema
1231
+ ]);
1232
+
1233
+ // src/cite-line-parser.ts
1234
+ var ID_RE = /^K[TP]-[A-Z]+-\d+$/;
1235
+ var SENTINEL_RE = /^KB:\s*none\b\s*(?:\[[^\]]*\])?\s*$/i;
1236
+ var FULL_RE = /^KB:\s+(K[TP]-[A-Z]+-\d+)(?:\s+\(([^)]*)\))?(?:\s+\[([^\]]+)\])?(?:\s+→\s*(.+))?\s*$/;
1237
+ var ALLOWED_TAGS = /* @__PURE__ */ new Set([
1238
+ "planned",
1239
+ "recalled",
1240
+ "chained-from",
1241
+ "dismissed",
1242
+ "none"
1142
1243
  ]);
1244
+ function parseTag(rawTag) {
1245
+ if (!rawTag) return "none";
1246
+ const head = rawTag.trim().split(/[\s:]+/)[0].toLowerCase();
1247
+ return ALLOWED_TAGS.has(head) ? head : "none";
1248
+ }
1249
+ function parseContractTail(tail) {
1250
+ const result = { operators: [], skip_reason: null };
1251
+ if (!tail) return result;
1252
+ const tokens = tail.trim().split(/\s+/).filter((t) => t.length > 0);
1253
+ for (const token of tokens) {
1254
+ const skipMatch = token.match(/^skip:(.+)$/i);
1255
+ if (skipMatch) {
1256
+ if (result.skip_reason === null) result.skip_reason = skipMatch[1];
1257
+ continue;
1258
+ }
1259
+ const notEditMatch = token.match(/^!edit:(.+)$/i);
1260
+ if (notEditMatch) {
1261
+ result.operators.push({ kind: "not_edit", target: notEditMatch[1] });
1262
+ continue;
1263
+ }
1264
+ const opMatch = token.match(/^(edit|require|forbid):(.+)$/i);
1265
+ if (opMatch) {
1266
+ result.operators.push({
1267
+ kind: opMatch[1].toLowerCase(),
1268
+ target: opMatch[2]
1269
+ });
1270
+ }
1271
+ }
1272
+ return result;
1273
+ }
1274
+ function parseLine(line) {
1275
+ const trimmed = line.trim();
1276
+ if (trimmed.length === 0) return null;
1277
+ if (SENTINEL_RE.test(trimmed)) {
1278
+ return { id: null, tag: "none", commitment: null };
1279
+ }
1280
+ const fullMatch = trimmed.match(FULL_RE);
1281
+ if (fullMatch) {
1282
+ const id = fullMatch[1];
1283
+ if (!ID_RE.test(id)) return null;
1284
+ return {
1285
+ id,
1286
+ tag: parseTag(fullMatch[3]),
1287
+ commitment: parseContractTail(fullMatch[4])
1288
+ };
1289
+ }
1290
+ return null;
1291
+ }
1292
+ function parseCiteLine(raw) {
1293
+ const result = {
1294
+ cite_ids: [],
1295
+ cite_tags: [],
1296
+ cite_commitments: []
1297
+ };
1298
+ if (typeof raw !== "string") return result;
1299
+ for (const line of raw.split(/\r?\n/)) {
1300
+ const parsed = parseLine(line);
1301
+ if (!parsed) continue;
1302
+ result.cite_tags.push(parsed.tag);
1303
+ if (parsed.id !== null) result.cite_ids.push(parsed.id);
1304
+ if (parsed.commitment !== null) {
1305
+ result.cite_commitments.push(parsed.commitment);
1306
+ }
1307
+ }
1308
+ return result;
1309
+ }
1143
1310
  export {
1144
1311
  AGENTS_META_IDENTITY_SOURCES,
1145
1312
  AGENTS_META_LAYERS,
@@ -1165,6 +1332,8 @@ export {
1165
1332
  LEGACY_KB_REGEX,
1166
1333
  LayerSchema,
1167
1334
  MaturitySchema,
1335
+ ONBOARD_SLOT_NAMES,
1336
+ ONBOARD_SLOT_TOTAL,
1168
1337
  PROPOSED_REASON_DESCRIPTIONS,
1169
1338
  PROTECTED_TOKENS,
1170
1339
  ProposedReasonSchema,
@@ -1181,6 +1350,10 @@ export {
1181
1350
  auditModeSchema,
1182
1351
  bootstrapMarkerMigratedEventSchema,
1183
1352
  candidateFileEntrySchema,
1353
+ citeContractMetricsSchema,
1354
+ citeContractPolicyActivatedEventSchema,
1355
+ citeCoverageReportSchema,
1356
+ citeLayerTypeBreakdownSchema,
1184
1357
  citePolicyActivatedEventSchema,
1185
1358
  claudeHookPathMigratedEventSchema,
1186
1359
  claudeSkillPathMigratedEventSchema,
@@ -1218,9 +1391,6 @@ export {
1218
1391
  forensicSamplingBudgetSchema,
1219
1392
  forensicTopologySchema,
1220
1393
  formatKnowledgeId,
1221
- getKnowledgeAnnotations,
1222
- getKnowledgeInputSchema,
1223
- getKnowledgeOutputSchema,
1224
1394
  getPanelFieldByKey,
1225
1395
  getPanelFields,
1226
1396
  historyStateQuerySchema,
@@ -1245,6 +1415,7 @@ export {
1245
1415
  knowledgeDeferredEventSchema,
1246
1416
  knowledgeDemotedEventSchema,
1247
1417
  knowledgeDriftDetectedEventSchema,
1418
+ knowledgeEnrichedEventSchema,
1248
1419
  knowledgeLayerChangedEventSchema,
1249
1420
  knowledgeMetaAutoHealedEventSchema,
1250
1421
  knowledgePathDangledEventSchema,
@@ -1276,6 +1447,8 @@ export {
1276
1447
  metaReconciledOnStartupEventSchema,
1277
1448
  metaUpdatedEventSchema,
1278
1449
  normalizeLocale,
1450
+ onboardSlotSchema,
1451
+ parseCiteLine,
1279
1452
  parseKnowledgeId,
1280
1453
  pendingAutoArchivedEventSchema,
1281
1454
  planContextAnnotations,
@@ -1287,6 +1460,8 @@ export {
1287
1460
  relevanceMigrationRunEventSchema,
1288
1461
  ruleDescriptionIndexItemSchema,
1289
1462
  ruleDescriptionSchema,
1463
+ serveLockClearedEventSchema,
1464
+ sessionArchiveAttemptedEventSchema,
1290
1465
  structuredWarningSchema,
1291
1466
  withDerivedAgentsMetaNodeDefaults,
1292
1467
  zhCNMessages