@fenglimg/fabric-shared 2.0.0-rc.30 → 2.0.0-rc.34

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
@@ -1,12 +1,4 @@
1
- import {
2
- BOOTSTRAP_CANONICAL,
3
- BOOTSTRAP_MARKER_BEGIN,
4
- BOOTSTRAP_MARKER_END,
5
- BOOTSTRAP_REGEX,
6
- LEGACY_KB_MARKER_BEGIN,
7
- LEGACY_KB_MARKER_END,
8
- LEGACY_KB_REGEX
9
- } from "./chunk-4OQXR6JW.js";
1
+ import "./chunk-LXNCAKJZ.js";
10
2
  import {
11
3
  PROTECTED_TOKENS,
12
4
  createTranslator,
@@ -16,7 +8,7 @@ import {
16
8
  normalizeLocale,
17
9
  resolveFabricLocale,
18
10
  zhCNMessages
19
- } from "./chunk-225L7D4T.js";
11
+ } from "./chunk-Z7UPW75I.js";
20
12
  import {
21
13
  FabExtractKnowledgeInputSchema,
22
14
  FabExtractKnowledgeInputShape,
@@ -59,11 +51,26 @@ import {
59
51
  planContextOutputSchema,
60
52
  structuredWarningSchema
61
53
  } from "./chunk-Y2YBFL2G.js";
62
- import "./chunk-LXNCAKJZ.js";
54
+ import {
55
+ BOOTSTRAP_CANONICAL,
56
+ BOOTSTRAP_MARKER_BEGIN,
57
+ BOOTSTRAP_MARKER_END,
58
+ BOOTSTRAP_REGEX,
59
+ LEGACY_KB_MARKER_BEGIN,
60
+ LEGACY_KB_MARKER_END,
61
+ LEGACY_KB_REGEX
62
+ } from "./chunk-4OQXR6JW.js";
63
63
 
64
64
  // src/schemas/agents-meta.ts
65
65
  import { z } from "zod";
66
66
  var FABRIC_AGENTS_PREFIX = ".fabric/agents/";
67
+ var KNOWLEDGE_TYPE_SINGULAR_TO_PLURAL = {
68
+ model: "models",
69
+ decision: "decisions",
70
+ guideline: "guidelines",
71
+ pitfall: "pitfalls",
72
+ process: "processes"
73
+ };
67
74
  var AGENTS_META_LAYERS = ["L0", "L1", "L2"];
68
75
  var AGENTS_META_TOPOLOGY_TYPES = ["mirror", "cross-cutting", "domain", "local", "global"];
69
76
  var AGENTS_META_IDENTITY_SOURCES = ["declared", "derived"];
@@ -79,7 +86,15 @@ var ruleDescriptionSchema = z.object({
79
86
  entities: z.array(z.string()).optional(),
80
87
  // v2.0 knowledge entry fields (TASK-002 schemas). All optional for backward compat.
81
88
  id: z.string().optional(),
82
- knowledge_type: z.enum(["models", "decisions", "guidelines", "pitfalls", "processes"]).optional(),
89
+ // rc.31 NEW-1: forward-compat for legacy on-disk agents.meta.json carrying
90
+ // singular knowledge_type values (model/decision/guideline/pitfall/process).
91
+ // Normalize to canonical plural form before enum validation so doctor and
92
+ // plan-context-hint can load pre-rc.28 meta files without aborting. Disk
93
+ // gets rewritten to plural on next reconcile (via knowledge-meta-builder).
94
+ knowledge_type: z.preprocess(
95
+ (value) => typeof value === "string" && value in KNOWLEDGE_TYPE_SINGULAR_TO_PLURAL ? KNOWLEDGE_TYPE_SINGULAR_TO_PLURAL[value] : value,
96
+ z.enum(["models", "decisions", "guidelines", "pitfalls", "processes"])
97
+ ).optional(),
83
98
  maturity: z.enum(["draft", "verified", "proven"]).optional(),
84
99
  knowledge_layer: z.enum(["personal", "team"]).optional(),
85
100
  layer_reason: z.string().optional(),
@@ -455,6 +470,25 @@ var fabricConfigSchema = z5.object({
455
470
  // 7d Signal-B trigger because review specifically targets the long
456
471
  // tail. Large repos with slower cadence can raise to 30.
457
472
  review_stale_pending_days: z5.number().int().positive().optional().default(14),
473
+ // v2.0.0-rc.34 TASK-05: reverse-unarchive opt-in. When true, callers of the
474
+ // `unarchiveKnowledge` primitive (and any future doctor auto-detect lint built
475
+ // on top) will execute the file move + ledger emit. When false (default),
476
+ // the same callers MUST short-circuit before any mutation — the primitive is
477
+ // shipped but inert until explicitly enabled. Opt-in posture mirrors the
478
+ // archive-flow precedent: destructive-ish file moves stay behind a flag.
479
+ reverse_unarchive_enabled: z5.boolean().optional().default(false),
480
+ // v2.0.0-rc.34 TASK-05: forces `unarchiveKnowledge` into dry-run mode even
481
+ // when called with `options.dryRun=false`. Lets operators preview a
482
+ // restoration pass before flipping `reverse_unarchive_enabled` to true.
483
+ reverse_unarchive_dry_run: z5.boolean().optional().default(false),
484
+ // v2.0.0-rc.34 TASK-06: long-session cite-policy evict window in user-prompt
485
+ // turns. UserPromptSubmit hook (Claude Code only) maintains a per-session
486
+ // counter and re-injects the cite contract reminder via
487
+ // hookSpecificOutput.additionalContext when `turn_count % interval === 0`.
488
+ // Default 0 = OFF (opt-in). Recommend 10-20 for active sessions; 5 for
489
+ // high-contract-criticality projects. Other strategies (time-based,
490
+ // token-budget) deferred to rc.35 per plan locked-decisions 2026-05-26.
491
+ cite_evict_interval: z5.number().int().min(0).optional().default(0),
458
492
  // v2.0.0-rc.22 Scope A T3: sliding-window retention (in days) for the
459
493
  // event ledger rotation primitive (`rotateEventLedgerIfNeeded`). Lines
460
494
  // whose `ts` is older than `now - fabric_event_retention_days * 86_400_000`
@@ -485,6 +519,76 @@ var fabricConfigSchema = z5.object({
485
519
  // Default `[]` keeps the field optional on existing configs — fresh
486
520
  // installs land with no opt-outs.
487
521
  onboard_slots_opted_out: z5.array(z5.string()).optional().default([]),
522
+ // v2.0.0-rc.33 W2-1 (P0-9): TopK upper bound for the broad SessionStart hint
523
+ // banner emitted by knowledge-hint-broad.cjs. After plan-context-hint returns
524
+ // its full broad-scoped index, the hook slices the entries to this many
525
+ // before grouping/truncation rendering — keeps the banner from scrolling off
526
+ // screen on well-seeded repos (Werewolf-class projects routinely surface 40+
527
+ // broad entries which buried the actually-relevant top hits). Default 8 is
528
+ // calibrated against the rc.32 eval baseline (cite-coverage 3.1%): the
529
+ // banner needs to fit in ~1 screenful so the agent actually reads it.
530
+ // Range 1..50; values above 20 effectively disable the cap because the
531
+ // TRUNCATION_THRESHOLD=12 grouped-render kicks in. Mirrors the rc.7 T7 +
532
+ // archive_max_* pattern of externalizing previously-hardcoded thresholds.
533
+ hint_broad_top_k: z5.number().int().min(1).max(50).optional().default(8),
534
+ // v2.0.0-rc.33 W2-1 (P0-9): TopK upper bound for the narrow PreToolUse hint
535
+ // emitted by knowledge-hint-narrow.cjs. After filtering to entries whose
536
+ // `relevance_scope === "narrow"` (rc.27 TASK-005 audit §2.5 fix), the hook
537
+ // slices to this many before the E3 emit-gate / renderSummary pipeline.
538
+ // Default 5 keeps each per-Edit hint terse — five lines max so the agent's
539
+ // working memory is not displaced by an unwieldy banner. Range 1..20.
540
+ hint_narrow_top_k: z5.number().int().min(1).max(20).optional().default(5),
541
+ // v2.0.0-rc.33 W2-1 (P0-9): per-file dedup window (in PreToolUse turns) for
542
+ // the narrow hint. Same (file_path, stable_id) tuple stays silent for this
543
+ // many turns even when the E3 cross-session cache would otherwise re-emit.
544
+ // Closes the rc.32 eval finding that a single hot file (e.g. werewolf
545
+ // GameRoom.tsx edited 30 times in a row) re-fired the same narrow hint
546
+ // each time, training the agent to ignore it. Default 5; range 1..50.
547
+ // Storage: .fabric/.cache/narrow-dedup-window.json — distinct from session-
548
+ // hints cache so a window-only suppression does not poison cross-session
549
+ // dedupe semantics.
550
+ hint_narrow_dedup_window_turns: z5.number().int().min(1).max(50).optional().default(5),
551
+ // v2.0.0-rc.33 W2-5 (P1-8): cooldown between broad SessionStart hint emits,
552
+ // in hours. Distinct from the archive_hint_cooldown_hours that gates the
553
+ // fabric-hint Stop hook — knowledge-hint-broad re-fires on every
554
+ // SessionStart by default (compact / clear / new-window), which on long
555
+ // sessions becomes redundant noise. Setting to 1 means "emit the broad
556
+ // menu at most once per hour"; 0 means "no cooldown, current behavior."
557
+ // Range 0..168 (one week). Stored alongside fabric-hint's cooldown cache
558
+ // under a distinct knowledge-hint-broad key.
559
+ hint_broad_cooldown_hours: z5.number().int().min(0).max(168).optional().default(0),
560
+ // v2.0.0-rc.33 W2-5 (P1-8): cooldown for the narrow PreToolUse hint.
561
+ // Same shape as hint_broad_cooldown_hours but applies to per-Edit hint
562
+ // re-emission across the cooldown window — independent of E3 session-
563
+ // hints dedupe. Default 0 preserves rc.32 behavior; set to e.g. 1 to
564
+ // throttle hint frequency during rapid-fire editing sprints. Range
565
+ // 0..168 (one week).
566
+ hint_narrow_cooldown_hours: z5.number().int().min(0).max(168).optional().default(0),
567
+ // v2.0.0-rc.33 W4-B3 (T5 P2): per-maturity inactivity thresholds (days)
568
+ // driving orphan_demote. Hardcoded at stable=90/endorsed=30/draft=14 in
569
+ // rc.32; chatty workspaces want them tighter, slow ones want them looser.
570
+ // Each field optional; absent → defaults inside doctor.ts apply. Ranges
571
+ // chosen so a typo can't accidentally disable the lint (min 1).
572
+ orphan_demote_stable_days: z5.number().int().min(1).max(3650).optional(),
573
+ orphan_demote_endorsed_days: z5.number().int().min(1).max(3650).optional(),
574
+ orphan_demote_draft_days: z5.number().int().min(1).max(3650).optional(),
575
+ // v2.0.0-rc.33 W4-A3 (T4 P2): per-entry summary truncation length used by
576
+ // knowledge-hint-{broad,narrow}.cjs. Hard-coded at 80 chars in rc.32 — too
577
+ // short for entries with parameterized summaries (e.g. "Use bcrypt with
578
+ // cost=12 for password hashing"), too long for terse pitfalls. Range 40..240;
579
+ // default 80 preserves rc.32 behavior. Both hooks read the same key so the
580
+ // banner styling stays consistent across SessionStart + PreToolUse.
581
+ hint_summary_max_len: z5.number().int().min(40).max(240).optional().default(80),
582
+ // v2.0.0-rc.33 W2-6 (P0-7 + P0-8): when true, knowledge-hint hooks emit
583
+ // their banners as `hookSpecificOutput.additionalContext` JSON on stdout
584
+ // (per Claude Code PreToolUse hook contract — see
585
+ // https://docs.claude.com/en/docs/claude-code/hooks#preToolUse), so the
586
+ // agent receives them in-context instead of as stderr breadcrumbs the
587
+ // user may not surface to the model. Default true reflects the rc.33 cite-
588
+ // coverage focus (rc.32 baseline 3.1% → primary cause: reminders never
589
+ // entered model context). Set false to revert to legacy stderr-only mode
590
+ // for hosts that don't honor the JSON contract.
591
+ hint_reminder_to_context: z5.boolean().optional().default(true),
488
592
  // v2.0.0-rc.29 TASK-008 (BUG-F3): selection-token TTL override. The
489
593
  // `fab_plan_context` MCP tool hands clients a `selection_token` whose default
490
594
  // 5-minute lifetime (`SELECTION_TOKEN_TTL_MS` at
@@ -1052,6 +1156,17 @@ var knowledgeArchiveAttemptedEventSchema = z10.object({
1052
1156
  timestamp: z10.string().datetime(),
1053
1157
  reason: z10.string().optional()
1054
1158
  });
1159
+ var knowledgeUnarchivedEventSchema = z10.object({
1160
+ ...eventLedgerEnvelopeSchema,
1161
+ event_type: z10.literal("knowledge_unarchived"),
1162
+ stable_id: z10.string().optional(),
1163
+ timestamp: z10.string().datetime(),
1164
+ reason: z10.string().optional(),
1165
+ // Pre-move archive path (e.g. ".fabric/.archive/decisions/KT-D-0007--single-cjs-hook.md").
1166
+ archive_path: z10.string().optional(),
1167
+ // Post-move canonical path (e.g. ".fabric/knowledge/team/decisions/KT-D-0007--single-cjs-hook.md").
1168
+ restored_to: z10.string().optional()
1169
+ });
1055
1170
  var knowledgeDeferredEventSchema = z10.object({
1056
1171
  ...eventLedgerEnvelopeSchema,
1057
1172
  event_type: z10.literal("knowledge_deferred"),
@@ -1219,6 +1334,8 @@ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
1219
1334
  knowledgeDemotedEventSchema,
1220
1335
  knowledgeArchivedEventSchema,
1221
1336
  knowledgeArchiveAttemptedEventSchema,
1337
+ // v2.0.0-rc.34 TASK-05: reverse of knowledge_archived
1338
+ knowledgeUnarchivedEventSchema,
1222
1339
  knowledgeDeferredEventSchema,
1223
1340
  knowledgeRejectedEventSchema,
1224
1341
  // v2.0 rc.5 TASK-014: knowledge_consumed (consumption tracking)
@@ -1488,6 +1605,7 @@ export {
1488
1605
  knowledgeTestIndexSchema,
1489
1606
  knowledgeTestLinkSchema,
1490
1607
  knowledgeTestOrphanAnnotationSchema,
1608
+ knowledgeUnarchivedEventSchema,
1491
1609
  ledgerAppendedEventSchema,
1492
1610
  ledgerEntrySchema,
1493
1611
  ledgerQuerySchema,
@@ -1,2 +1,2 @@
1
- export { e as AgentsActivationTier, a as AgentsIdentitySource, b as AgentsLayer, d as AgentsMeta, g as AgentsMetaCountersEnvelope, h as AgentsMetaKnowledgeTypeCounters, A as AgentsMetaNode, i as AgentsMetaNodeActivation, c as AgentsTopologyType, j as AiLedgerEntry, k as AuditMode, C as ClientPaths, D as DefaultLayerFilter, F as FabricConfig, l as FabricLanguage, m as HumanLedgerEntry, H as HumanLockEntry, L as LedgerEntry, M as McpPayloadLimits, R as RuleDescription, n as RuleDescriptionIndexItem } from '../index-DkXJGQCD.js';
1
+ export { e as AgentsActivationTier, a as AgentsIdentitySource, b as AgentsLayer, d as AgentsMeta, g as AgentsMetaCountersEnvelope, h as AgentsMetaKnowledgeTypeCounters, A as AgentsMetaNode, i as AgentsMetaNodeActivation, c as AgentsTopologyType, j as AiLedgerEntry, k as AuditMode, C as ClientPaths, D as DefaultLayerFilter, F as FabricConfig, l as FabricLanguage, m as HumanLedgerEntry, H as HumanLockEntry, L as LedgerEntry, M as McpPayloadLimits, R as RuleDescription, n as RuleDescriptionIndexItem } from '../index-BjssYQb3.js';
2
2
  import 'zod';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fenglimg/fabric-shared",
3
- "version": "2.0.0-rc.30",
3
+ "version": "2.0.0-rc.34",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",