@fenglimg/fabric-shared 2.0.0-rc.21 → 2.0.0-rc.23
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-GDYPVGWT.js +671 -0
- package/dist/{chunk-VKCXD6CI.js → chunk-GYIALPMW.js} +21 -2
- package/dist/{chunk-QZNUUIL3.js → chunk-IP6VWOVE.js} +7 -6
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +316 -9
- package/dist/index.js +105 -13
- package/dist/node/atomic-write.d.ts +16 -0
- package/dist/node/atomic-write.js +19 -10
- package/dist/schemas/api-contracts.d.ts +276 -238
- package/dist/schemas/api-contracts.js +1 -7
- package/dist/templates/bootstrap-canonical.d.ts +1 -1
- package/dist/templates/bootstrap-canonical.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NNDFOOBO.js +0 -626
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
enMessages,
|
|
8
8
|
normalizeLocale,
|
|
9
9
|
zhCNMessages
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GYIALPMW.js";
|
|
11
11
|
import {
|
|
12
12
|
FabExtractKnowledgeInputSchema,
|
|
13
13
|
FabExtractKnowledgeInputShape,
|
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
KnowledgeTypeSchema,
|
|
22
22
|
LayerSchema,
|
|
23
23
|
MaturitySchema,
|
|
24
|
+
ONBOARD_SLOT_NAMES,
|
|
25
|
+
ONBOARD_SLOT_TOTAL,
|
|
24
26
|
PROPOSED_REASON_DESCRIPTIONS,
|
|
25
27
|
ProposedReasonSchema,
|
|
26
28
|
StableIdSchema,
|
|
@@ -28,9 +30,6 @@ import {
|
|
|
28
30
|
fabExtractKnowledgeAnnotations,
|
|
29
31
|
fabReviewAnnotations,
|
|
30
32
|
formatKnowledgeId,
|
|
31
|
-
getKnowledgeAnnotations,
|
|
32
|
-
getKnowledgeInputSchema,
|
|
33
|
-
getKnowledgeOutputSchema,
|
|
34
33
|
historyStateQuerySchema,
|
|
35
34
|
humanLockApproveRequestSchema,
|
|
36
35
|
humanLockFileParamsSchema,
|
|
@@ -39,6 +38,7 @@ import {
|
|
|
39
38
|
knowledgeSectionsOutputSchema,
|
|
40
39
|
ledgerQuerySchema,
|
|
41
40
|
ledgerSourceSchema,
|
|
41
|
+
onboardSlotSchema,
|
|
42
42
|
parseKnowledgeId,
|
|
43
43
|
planContextAnnotations,
|
|
44
44
|
planContextHintNarrowEntrySchema,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
planContextInputSchema,
|
|
47
47
|
planContextOutputSchema,
|
|
48
48
|
structuredWarningSchema
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-GDYPVGWT.js";
|
|
50
50
|
import {
|
|
51
51
|
BOOTSTRAP_CANONICAL,
|
|
52
52
|
BOOTSTRAP_MARKER_BEGIN,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
LEGACY_KB_MARKER_BEGIN,
|
|
56
56
|
LEGACY_KB_MARKER_END,
|
|
57
57
|
LEGACY_KB_REGEX
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-IP6VWOVE.js";
|
|
59
59
|
|
|
60
60
|
// src/schemas/agents-meta.ts
|
|
61
61
|
import { z } from "zod";
|
|
@@ -450,7 +450,37 @@ var fabricConfigSchema = z5.object({
|
|
|
450
450
|
// for explicit resolve-or-drop decision. Default 14; tighter than the
|
|
451
451
|
// 7d Signal-B trigger because review specifically targets the long
|
|
452
452
|
// tail. Large repos with slower cadence can raise to 30.
|
|
453
|
-
review_stale_pending_days: z5.number().int().positive().optional().default(14)
|
|
453
|
+
review_stale_pending_days: z5.number().int().positive().optional().default(14),
|
|
454
|
+
// v2.0.0-rc.22 Scope A T3: sliding-window retention (in days) for the
|
|
455
|
+
// event ledger rotation primitive (`rotateEventLedgerIfNeeded`). Lines
|
|
456
|
+
// whose `ts` is older than `now - fabric_event_retention_days * 86_400_000`
|
|
457
|
+
// are partitioned into `.fabric/events.archive/events-rotated-YYYY-MM-DD.jsonl`.
|
|
458
|
+
// Locked to 7/30/90 — three operator-friendly preset windows. Default 30
|
|
459
|
+
// is applied at the consumer site (rotateEventLedgerIfNeeded), so this
|
|
460
|
+
// field stays `.optional()` without a `.default()` to keep the schema
|
|
461
|
+
// surface honest: absence means "use the library default", not "schema
|
|
462
|
+
// default of 30 was injected." 7 = ~tight, 30 = balanced, 90 = forensic.
|
|
463
|
+
// Mirrors cite-policy precedent of locking enum-style numeric tunables
|
|
464
|
+
// to a small literal set (vs free `.positive()`) to prevent fat-finger
|
|
465
|
+
// misconfig.
|
|
466
|
+
fabric_event_retention_days: z5.union([z5.literal(7), z5.literal(30), z5.literal(90)]).optional(),
|
|
467
|
+
// v2.0.0-rc.23 TASK-014 (F8c): onboard slot opt-out list. Tracks slot
|
|
468
|
+
// names the user explicitly dismissed during fabric-archive's first-run
|
|
469
|
+
// onboard phase (or via `fab config dismiss-slot <slot>`). Dismissed
|
|
470
|
+
// slots are excluded from `fab onboard-coverage`'s `missing` set and the
|
|
471
|
+
// doctor `Onboard coverage` advisory's recompute, so the user is never
|
|
472
|
+
// re-prompted for slots they consciously declined.
|
|
473
|
+
//
|
|
474
|
+
// Re-opening a dismissed slot requires `fab config onboard-reset <slot>`
|
|
475
|
+
// — a deliberate two-command UX to keep the dismiss intent reversible
|
|
476
|
+
// but never silently undone. Schema is intentionally `z.array(z.string())`
|
|
477
|
+
// rather than `z.array(onboardSlotSchema)` so historical configs survive
|
|
478
|
+
// a slot rename without a Zod parse error; downstream consumers
|
|
479
|
+
// intersect against ONBOARD_SLOT_NAMES at read time.
|
|
480
|
+
//
|
|
481
|
+
// Default `[]` keeps the field optional on existing configs — fresh
|
|
482
|
+
// installs land with no opt-outs.
|
|
483
|
+
onboard_slots_opted_out: z5.array(z5.string()).optional().default([])
|
|
454
484
|
});
|
|
455
485
|
|
|
456
486
|
// src/schemas/fabric-config-introspect.ts
|
|
@@ -875,8 +905,19 @@ var metaReconciledEventSchema = z10.object({
|
|
|
875
905
|
event_type: z10.literal("meta_reconciled"),
|
|
876
906
|
reconciled_files: z10.array(z10.string()),
|
|
877
907
|
duration_ms: z10.number().int().nonnegative(),
|
|
878
|
-
|
|
879
|
-
|
|
908
|
+
// v2.0.0-rc.23 TASK-005 (a-B): added `auto-heal-description` trigger so the
|
|
909
|
+
// read-path plan_context handler can drive a full reconcile when it detects
|
|
910
|
+
// any node carrying `description === undefined` (legacy meta drift that the
|
|
911
|
+
// revision-hash gate cannot catch — a missing description doesn't move the
|
|
912
|
+
// revision). Symmetric to rc.22 D2 read-side auto-heal but covers the
|
|
913
|
+
// description-undefined case which the revision drift gate misses.
|
|
914
|
+
trigger: z10.enum(["doctor", "manual", "auto-heal-description"]),
|
|
915
|
+
source: z10.literal("reconcileKnowledge"),
|
|
916
|
+
// v2.0.0-rc.22 TASK-014 (Scope E): set when reconcileKnowledge forced a
|
|
917
|
+
// writeKnowledgeMeta on revision drift alone (no per-file content drift).
|
|
918
|
+
// Distinguishes top-level schema/revision repair from the standard per-file
|
|
919
|
+
// drift path. Optional so existing emitters stay unchanged.
|
|
920
|
+
force_write_reason: z10.enum(["revision_drift"]).optional()
|
|
880
921
|
});
|
|
881
922
|
var claudeSkillPathMigratedEventSchema = z10.object({
|
|
882
923
|
...eventLedgerEnvelopeSchema,
|
|
@@ -1046,6 +1087,37 @@ var citePolicyActivatedEventSchema = z10.object({
|
|
|
1046
1087
|
policy_version: z10.string(),
|
|
1047
1088
|
timestamp: z10.string().datetime()
|
|
1048
1089
|
});
|
|
1090
|
+
var eventsRotatedEventSchema = z10.object({
|
|
1091
|
+
...eventLedgerEnvelopeSchema,
|
|
1092
|
+
event_type: z10.literal("events_rotated"),
|
|
1093
|
+
cutoff_ts: z10.string().datetime(),
|
|
1094
|
+
archived_count: z10.number().int().nonnegative(),
|
|
1095
|
+
kept_count: z10.number().int().nonnegative(),
|
|
1096
|
+
archive_path: z10.string()
|
|
1097
|
+
});
|
|
1098
|
+
var knowledgeMetaAutoHealedEventSchema = z10.object({
|
|
1099
|
+
...eventLedgerEnvelopeSchema,
|
|
1100
|
+
event_type: z10.literal("knowledge_meta_auto_healed"),
|
|
1101
|
+
previous_revision_hash: z10.string(),
|
|
1102
|
+
revision_hash: z10.string(),
|
|
1103
|
+
trigger: z10.literal("read"),
|
|
1104
|
+
caller: z10.enum(["planContext", "getKnowledgeSections", "getKnowledge", "extractKnowledge"]).optional()
|
|
1105
|
+
});
|
|
1106
|
+
var serveLockClearedEventSchema = z10.object({
|
|
1107
|
+
...eventLedgerEnvelopeSchema,
|
|
1108
|
+
event_type: z10.literal("serve_lock_cleared"),
|
|
1109
|
+
pid: z10.number().int().nonnegative(),
|
|
1110
|
+
age_ms: z10.number().int().nonnegative(),
|
|
1111
|
+
timestamp: z10.string().datetime()
|
|
1112
|
+
});
|
|
1113
|
+
var knowledgeEnrichedEventSchema = z10.object({
|
|
1114
|
+
...eventLedgerEnvelopeSchema,
|
|
1115
|
+
event_type: z10.literal("knowledge_enriched"),
|
|
1116
|
+
path: z10.string(),
|
|
1117
|
+
added_fields: z10.array(z10.enum(["intent_clues", "tech_stack", "impact", "must_read_if"])),
|
|
1118
|
+
mode: z10.enum(["auto", "interactive"]),
|
|
1119
|
+
timestamp: z10.string().datetime()
|
|
1120
|
+
});
|
|
1049
1121
|
var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
|
|
1050
1122
|
knowledgeContextPlannedEventSchema,
|
|
1051
1123
|
knowledgeSelectionEventSchema,
|
|
@@ -1097,7 +1169,23 @@ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
|
|
|
1097
1169
|
assistantTurnObservedEventSchema,
|
|
1098
1170
|
// v2.0.0-rc.20 TASK-02: cite_policy_activated — session/policy-bump
|
|
1099
1171
|
// marker recording when a given policy_version became active.
|
|
1100
|
-
citePolicyActivatedEventSchema
|
|
1172
|
+
citePolicyActivatedEventSchema,
|
|
1173
|
+
// v2.0.0-rc.22 Scope D T-D1: knowledge_meta_auto_healed — emitted by
|
|
1174
|
+
// loadActiveMeta when read-path drift triggers an in-place meta rebuild.
|
|
1175
|
+
knowledgeMetaAutoHealedEventSchema,
|
|
1176
|
+
// v2.0.0-rc.22 Scope A T3: events_rotated — emitted as the first line of
|
|
1177
|
+
// the post-rotation events.jsonl when sliding-window-by-age rotation moves
|
|
1178
|
+
// stale entries to events.archive/events-rotated-YYYY-MM-DD.jsonl.
|
|
1179
|
+
eventsRotatedEventSchema,
|
|
1180
|
+
// v2.0.0-rc.23 TASK-010 (e): serve_lock_cleared — emitted by
|
|
1181
|
+
// `fab doctor --fix` when a stale `.fabric/.serve.lock` with a dead PID is
|
|
1182
|
+
// unlinked.
|
|
1183
|
+
serveLockClearedEventSchema,
|
|
1184
|
+
// v2.0.0-rc.23 TASK-007 (a-C2): knowledge_enriched — emitted by
|
|
1185
|
+
// `fab doctor --enrich-descriptions` once per modified canonical knowledge
|
|
1186
|
+
// file when one or more of the four rc.23 description-grade frontmatter
|
|
1187
|
+
// fields is back-filled.
|
|
1188
|
+
knowledgeEnrichedEventSchema
|
|
1101
1189
|
]);
|
|
1102
1190
|
export {
|
|
1103
1191
|
AGENTS_META_IDENTITY_SOURCES,
|
|
@@ -1124,6 +1212,8 @@ export {
|
|
|
1124
1212
|
LEGACY_KB_REGEX,
|
|
1125
1213
|
LayerSchema,
|
|
1126
1214
|
MaturitySchema,
|
|
1215
|
+
ONBOARD_SLOT_NAMES,
|
|
1216
|
+
ONBOARD_SLOT_TOTAL,
|
|
1127
1217
|
PROPOSED_REASON_DESCRIPTIONS,
|
|
1128
1218
|
PROTECTED_TOKENS,
|
|
1129
1219
|
ProposedReasonSchema,
|
|
@@ -1160,6 +1250,7 @@ export {
|
|
|
1160
1250
|
enMessages,
|
|
1161
1251
|
eventLedgerEventSchema,
|
|
1162
1252
|
eventLedgerTruncatedEventSchema,
|
|
1253
|
+
eventsRotatedEventSchema,
|
|
1163
1254
|
fabExtractKnowledgeAnnotations,
|
|
1164
1255
|
fabReviewAnnotations,
|
|
1165
1256
|
fabricConfigSchema,
|
|
@@ -1176,9 +1267,6 @@ export {
|
|
|
1176
1267
|
forensicSamplingBudgetSchema,
|
|
1177
1268
|
forensicTopologySchema,
|
|
1178
1269
|
formatKnowledgeId,
|
|
1179
|
-
getKnowledgeAnnotations,
|
|
1180
|
-
getKnowledgeInputSchema,
|
|
1181
|
-
getKnowledgeOutputSchema,
|
|
1182
1270
|
getPanelFieldByKey,
|
|
1183
1271
|
getPanelFields,
|
|
1184
1272
|
historyStateQuerySchema,
|
|
@@ -1203,7 +1291,9 @@ export {
|
|
|
1203
1291
|
knowledgeDeferredEventSchema,
|
|
1204
1292
|
knowledgeDemotedEventSchema,
|
|
1205
1293
|
knowledgeDriftDetectedEventSchema,
|
|
1294
|
+
knowledgeEnrichedEventSchema,
|
|
1206
1295
|
knowledgeLayerChangedEventSchema,
|
|
1296
|
+
knowledgeMetaAutoHealedEventSchema,
|
|
1207
1297
|
knowledgePathDangledEventSchema,
|
|
1208
1298
|
knowledgePromoteFailedEventSchema,
|
|
1209
1299
|
knowledgePromoteStartedEventSchema,
|
|
@@ -1233,6 +1323,7 @@ export {
|
|
|
1233
1323
|
metaReconciledOnStartupEventSchema,
|
|
1234
1324
|
metaUpdatedEventSchema,
|
|
1235
1325
|
normalizeLocale,
|
|
1326
|
+
onboardSlotSchema,
|
|
1236
1327
|
parseKnowledgeId,
|
|
1237
1328
|
pendingAutoArchivedEventSchema,
|
|
1238
1329
|
planContextAnnotations,
|
|
@@ -1244,6 +1335,7 @@ export {
|
|
|
1244
1335
|
relevanceMigrationRunEventSchema,
|
|
1245
1336
|
ruleDescriptionIndexItemSchema,
|
|
1246
1337
|
ruleDescriptionSchema,
|
|
1338
|
+
serveLockClearedEventSchema,
|
|
1247
1339
|
structuredWarningSchema,
|
|
1248
1340
|
withDerivedAgentsMetaNodeDefaults,
|
|
1249
1341
|
zhCNMessages
|
|
@@ -8,6 +8,22 @@ declare function atomicWriteText(path: string, content: string, opts?: AtomicWri
|
|
|
8
8
|
declare function atomicWriteJson(path: string, value: unknown, opts?: AtomicWriteJsonOptions): Promise<void>;
|
|
9
9
|
interface LedgerWriteQueue {
|
|
10
10
|
append(path: string, line: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Run `fn` with exclusive access to `path` against all other queue operations
|
|
13
|
+
* (other `runExclusive` calls and `append` calls) on the same path within
|
|
14
|
+
* this LedgerWriteQueue instance.
|
|
15
|
+
*
|
|
16
|
+
* Scope: per-path, in-process (same Node process, same queue instance).
|
|
17
|
+
* Does NOT provide cross-process locking — separate concern.
|
|
18
|
+
*
|
|
19
|
+
* Error semantics: a rejection from `fn` is propagated to the returned
|
|
20
|
+
* Promise but does NOT poison the chain — subsequent `runExclusive` /
|
|
21
|
+
* `append` calls on the same path will still acquire and run.
|
|
22
|
+
*
|
|
23
|
+
* Ordering: submission-order FIFO. Calls on different paths run independently
|
|
24
|
+
* (in parallel where possible).
|
|
25
|
+
*/
|
|
26
|
+
runExclusive<T>(path: string, fn: () => Promise<T>): Promise<T>;
|
|
11
27
|
}
|
|
12
28
|
declare function createLedgerWriteQueue(): LedgerWriteQueue;
|
|
13
29
|
|
|
@@ -38,18 +38,27 @@ function createLedgerWriteQueue() {
|
|
|
38
38
|
const normalized = line.endsWith("\n") ? line : line + "\n";
|
|
39
39
|
await appendFile(path, normalized, "utf8");
|
|
40
40
|
}
|
|
41
|
+
function enqueue(path, work) {
|
|
42
|
+
const prev = chains.get(path) ?? Promise.resolve();
|
|
43
|
+
const result = prev.catch(() => void 0).then(() => work());
|
|
44
|
+
const chainSlot = result.then(
|
|
45
|
+
() => void 0,
|
|
46
|
+
() => void 0
|
|
47
|
+
);
|
|
48
|
+
chains.set(path, chainSlot);
|
|
49
|
+
chainSlot.finally(() => {
|
|
50
|
+
if (chains.get(path) === chainSlot) {
|
|
51
|
+
chains.delete(path);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
41
56
|
return {
|
|
42
57
|
append(path, line) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
guarded.finally(() => {
|
|
48
|
-
if (chains.get(path) === next) {
|
|
49
|
-
chains.delete(path);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return next;
|
|
58
|
+
return enqueue(path, () => doAppend(path, line));
|
|
59
|
+
},
|
|
60
|
+
runExclusive(path, fn) {
|
|
61
|
+
return enqueue(path, fn);
|
|
53
62
|
}
|
|
54
63
|
};
|
|
55
64
|
}
|