@fenglimg/fabric-shared 2.0.0-rc.15 → 2.0.0-rc.22
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-BEABJYVL.js +39 -0
- package/dist/{chunk-BKTCBFXZ.js → chunk-VKCXD6CI.js} +178 -36
- package/dist/{chunk-NNDFOOBO.js → chunk-WK4WINAZ.js} +8 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +434 -5
- package/dist/index.js +582 -339
- package/dist/node/atomic-write.d.ts +16 -0
- package/dist/node/atomic-write.js +19 -10
- package/dist/schemas/api-contracts.d.ts +6 -0
- package/dist/schemas/api-contracts.js +1 -1
- package/dist/templates/bootstrap-canonical.d.ts +56 -0
- package/dist/templates/bootstrap-canonical.js +18 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +7 -3
|
@@ -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
|
}
|
|
@@ -467,6 +467,8 @@ declare const planContextOutputSchema: z.ZodObject<{
|
|
|
467
467
|
action_hint: string;
|
|
468
468
|
line?: number | undefined;
|
|
469
469
|
}>, "many">>;
|
|
470
|
+
auto_healed: z.ZodOptional<z.ZodBoolean>;
|
|
471
|
+
previous_revision_hash: z.ZodOptional<z.ZodString>;
|
|
470
472
|
}, "strip", z.ZodTypeAny, {
|
|
471
473
|
stale: boolean;
|
|
472
474
|
entries: {
|
|
@@ -551,6 +553,8 @@ declare const planContextOutputSchema: z.ZodObject<{
|
|
|
551
553
|
action_hint: string;
|
|
552
554
|
line?: number | undefined;
|
|
553
555
|
}[] | undefined;
|
|
556
|
+
auto_healed?: boolean | undefined;
|
|
557
|
+
previous_revision_hash?: string | undefined;
|
|
554
558
|
}, {
|
|
555
559
|
stale: boolean;
|
|
556
560
|
entries: {
|
|
@@ -635,6 +639,8 @@ declare const planContextOutputSchema: z.ZodObject<{
|
|
|
635
639
|
action_hint: string;
|
|
636
640
|
line?: number | undefined;
|
|
637
641
|
}[] | undefined;
|
|
642
|
+
auto_healed?: boolean | undefined;
|
|
643
|
+
previous_revision_hash?: string | undefined;
|
|
638
644
|
}>;
|
|
639
645
|
declare const planContextAnnotations: {
|
|
640
646
|
readonly readOnlyHint: true;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Fabric bootstrap content + marker constants — single source of truth
|
|
3
|
+
* consumed by both `fab install` (writer) and the server-side doctor (drift
|
|
4
|
+
* comparator). Mirrors the rc.18 banner-i18n shared-module pattern: shared
|
|
5
|
+
* constants in `packages/shared` so the cross-package boundary stays clean
|
|
6
|
+
* (server has zero dep on cli).
|
|
7
|
+
*
|
|
8
|
+
* rc.19 bootstrap-consolidation TASK-001: hoisted from per-writer ad-hoc
|
|
9
|
+
* strings. The canonical body is fixed for all projects — no interpolation —
|
|
10
|
+
* and intentionally zh-CN-hybrid per locked clarification 3.
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: the {@link BOOTSTRAP_CANONICAL} body is byte-locked. Do not edit
|
|
13
|
+
* casually — downstream drift detection asserts byte-identical equality, and
|
|
14
|
+
* the published-package version becomes the contract between Fabric CLI and
|
|
15
|
+
* any Fabric server.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* HTML-comment marker pair delimiting the managed Fabric bootstrap section.
|
|
19
|
+
* Both writer (idempotent in-place replace) and uninstall helper match these
|
|
20
|
+
* as plain substrings — keep byte-identical.
|
|
21
|
+
*/
|
|
22
|
+
declare const BOOTSTRAP_MARKER_BEGIN = "<!-- fabric:bootstrap:begin -->";
|
|
23
|
+
declare const BOOTSTRAP_MARKER_END = "<!-- fabric:bootstrap:end -->";
|
|
24
|
+
/**
|
|
25
|
+
* Legacy marker pair from rc.12-rc.18 era (when the managed section was
|
|
26
|
+
* branded "Fabric Knowledge Base"). Retained here for one-time migration
|
|
27
|
+
* detection only: rc.19 install path scans for legacy markers, strips the
|
|
28
|
+
* legacy region, and rewrites with the new bootstrap markers.
|
|
29
|
+
*/
|
|
30
|
+
declare const LEGACY_KB_MARKER_BEGIN = "<!-- fabric:knowledge-base:begin -->";
|
|
31
|
+
declare const LEGACY_KB_MARKER_END = "<!-- fabric:knowledge-base:end -->";
|
|
32
|
+
/**
|
|
33
|
+
* Regex matching the entire managed bootstrap section, markers inclusive,
|
|
34
|
+
* with an optional preceding blank-line separator (so re-install / uninstall
|
|
35
|
+
* don't leave orphan blank lines). Non-greedy body matches any content
|
|
36
|
+
* between the begin/end markers, including newlines. Mirrors the shape of
|
|
37
|
+
* the existing `FABRIC_SECTION_REGEX` in `packages/cli/src/install/skills-and-hooks.ts`.
|
|
38
|
+
*/
|
|
39
|
+
declare const BOOTSTRAP_REGEX: RegExp;
|
|
40
|
+
/**
|
|
41
|
+
* Legacy-marker variant used for one-time migration detection during rc.19
|
|
42
|
+
* install — same shape as {@link BOOTSTRAP_REGEX} but targets the older
|
|
43
|
+
* `knowledge-base` marker pair.
|
|
44
|
+
*/
|
|
45
|
+
declare const LEGACY_KB_REGEX: RegExp;
|
|
46
|
+
/**
|
|
47
|
+
* Canonical bootstrap body — byte-locked per rc.19 locked clarification 3.
|
|
48
|
+
* Rendered into the managed block between {@link BOOTSTRAP_MARKER_BEGIN} and
|
|
49
|
+
* {@link BOOTSTRAP_MARKER_END} by `fab install` across all three supported
|
|
50
|
+
* clients (Claude Code, Cursor, Codex CLI).
|
|
51
|
+
*
|
|
52
|
+
* Length guarantee: ≥ 400 bytes.
|
|
53
|
+
*/
|
|
54
|
+
declare const BOOTSTRAP_CANONICAL = "# Fabric Bootstrap\n\n\u672C\u9879\u76EE\u4F7F\u7528 Fabric \u7BA1\u7406\u8DE8\u5BA2\u6237\u7AEF AI \u77E5\u8BC6\u4E0E\u884C\u4E3A\u89C4\u5219\u3002\u672C\u6587\u4EF6\u7531 `fab install` \u540C\u6B65\u5230\u4E09\u7AEF managed block,**\u4E0D\u8981\u624B\u52A8\u7F16\u8F91\u4E09\u7AEF\u7684 block**,\u53EA\u6539\u8FD9\u91CC + \u91CD\u8DD1 `fab install`\u3002\n\n## \u884C\u4E3A\u89C4\u5219\n- **\u4FEE\u6539\u4EFB\u4F55\u6587\u4EF6\u524D**:\u5FC5\u987B\u5148\u8C03 `fab_plan_context(paths=[<\u88AB\u6539\u6587\u4EF6>])`,\u518D\u8C03 `fab_get_knowledge_sections` \u53D6\u76F8\u5173\u89C4\u5219\u6BB5\u843D\u3002\n- **`.fabric/agents.meta.json` \u4E25\u7981\u624B\u52A8\u7F16\u8F91**;engine \u4F1A\u81EA\u52A8\u540C\u6B65\u6D3E\u751F\u72B6\u6001,\u663E\u5F0F reconcile \u8DD1 `fab doctor --fix`\u3002\n\n## \u77E5\u8BC6\u5E93(KB)\n- **Discovery**:SessionStart hook \u5217 broad-scoped \u6761\u76EE;edit \u6587\u4EF6\u65F6 PreToolUse hook \u53EF\u80FD\u89E6\u53D1 narrow hint\u3002\n- **Usage**:\u7528 `fab_get_knowledge_sections(id=...)` \u6309 id \u53D6\u6761\u76EE\u5168\u6587\u3002\n- **Write flows**:`fabric-archive` / `fabric-review` / `fabric-import` \u4E09\u4E2A Skills\u3002\n- **Language**:\u6E32\u67D3\u6309 `.fabric/fabric-config.json` \u7684 `fabric_language` \u5B57\u6BB5\u3002\n\n## Cite policy\n\n- **\u89E6\u53D1**: \u505A edit / decide / propose plan \u4E4B\u524D,**\u56DE\u590D\u9996\u884C**\u5FC5\u987B\u5199 `KB: <id> (<\u22648\u5B57 \u7528\u6CD5>) [planned|recalled|chained-from <id>|dismissed:<reason>]` \u6216 `KB: none`\u3002\n- **`[recalled]` \u9A8C\u8BC1**: \u5FC5\u987B\u7D27\u8DDF\u4E00\u6B21 `fab_get_knowledge_sections(id=...)`,\u9632\u6B62\u7F16\u9020 id\u3002\n- **\u7528\u6237\u53E3\u5934\u63D0\u89C4\u5219\u6CA1\u7ED9 id**: \u5148\u8C03 `fab_extract_knowledge` \u6216 `search_context` \u53CD\u67E5\u3002\n- **dismissed reason**: \u679A\u4E3E `scope-mismatch | outdated | not-applicable | other:<text>`\u3002\n- **\u7A3D\u6838**: `fab doctor --cite-coverage [--since=7d] [--client=cc|codex|all]` \u8F93\u51FA cite \u8986\u76D6\u7387\u3002\u672C\u89C4\u5219\u4E0D\u963B\u65AD\u4F60\u5DE5\u4F5C,\u53EA\u8BB0\u5F55\u3002\n";
|
|
55
|
+
|
|
56
|
+
export { BOOTSTRAP_CANONICAL, BOOTSTRAP_MARKER_BEGIN, BOOTSTRAP_MARKER_END, BOOTSTRAP_REGEX, LEGACY_KB_MARKER_BEGIN, LEGACY_KB_MARKER_END, LEGACY_KB_REGEX };
|
|
@@ -0,0 +1,18 @@
|
|
|
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-BEABJYVL.js";
|
|
10
|
+
export {
|
|
11
|
+
BOOTSTRAP_CANONICAL,
|
|
12
|
+
BOOTSTRAP_MARKER_BEGIN,
|
|
13
|
+
BOOTSTRAP_MARKER_END,
|
|
14
|
+
BOOTSTRAP_REGEX,
|
|
15
|
+
LEGACY_KB_MARKER_BEGIN,
|
|
16
|
+
LEGACY_KB_MARKER_END,
|
|
17
|
+
LEGACY_KB_REGEX
|
|
18
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -111,7 +111,6 @@ type FabricLanguage = "match-existing" | "zh-CN" | "en" | "zh-CN-hybrid";
|
|
|
111
111
|
type DefaultLayerFilter = "team" | "personal" | "both";
|
|
112
112
|
interface FabricConfig {
|
|
113
113
|
clientPaths?: ClientPaths;
|
|
114
|
-
externalFixturePath?: string;
|
|
115
114
|
scanIgnores?: string[];
|
|
116
115
|
audit_mode?: AuditMode;
|
|
117
116
|
mcpPayloadLimits?: McpPayloadLimits;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-shared",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"./schemas/api-contracts": {
|
|
37
37
|
"types": "./dist/schemas/api-contracts.d.ts",
|
|
38
38
|
"import": "./dist/schemas/api-contracts.js"
|
|
39
|
+
},
|
|
40
|
+
"./templates/bootstrap-canonical": {
|
|
41
|
+
"types": "./dist/templates/bootstrap-canonical.d.ts",
|
|
42
|
+
"import": "./dist/templates/bootstrap-canonical.js"
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
"files": [
|
|
@@ -52,8 +56,8 @@
|
|
|
52
56
|
"vitest": "^3.2.4"
|
|
53
57
|
},
|
|
54
58
|
"scripts": {
|
|
55
|
-
"build": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts --format esm --dts --clean",
|
|
56
|
-
"dev": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts --format esm --dts --watch",
|
|
59
|
+
"build": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts src/templates/bootstrap-canonical.ts --format esm --dts --clean",
|
|
60
|
+
"dev": "tsup src/index.ts src/i18n/index.ts src/types/index.ts src/node.ts src/node/atomic-write.ts src/node/mcp-payload-guard.ts src/errors/index.ts src/schemas/api-contracts.ts src/templates/bootstrap-canonical.ts --format esm --dts --watch",
|
|
57
61
|
"test": "vitest run",
|
|
58
62
|
"test:coverage": "vitest run --coverage"
|
|
59
63
|
}
|