@roarpeng/graphflow 1.15.1 → 1.15.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [1.15.3] - 2026-09-05
6
+
7
+ ### Changed
8
+
9
+ - **R4 context packaging 去重**:`buildLayeredContextPackage` / `buildEnhancedContextPackage` 抽出共享 `context-package-core`(keyword/vector 召回、L1–L3 配额打包、dialogue 与 neighbor expansion)。两条公开函数的签名与 MCP/CLI context preview 行为保持不变;enhanced 仍独占 adaptive budget、RepoMap、symbol boost、graph compression 与 same-file/import 扩展。
10
+
11
+ ### Tests
12
+
13
+ - **m74/m75 测试隔离**:不再 `process.chdir()`,也不再向真实 `$HOME/.npm/_npx` 写文件。fake home 与项目根均落在 `os.tmpdir()`,通过 `fromDir` 注入与 `process.cwd` mock 覆盖 unsafe-cwd 路径。
14
+
15
+ ## [1.15.2] - 2026-09-05
16
+
17
+ ### Added
18
+
19
+ - **飞轮公开复现包(path A)**:`npm run proof:flywheel` 串起已有的检索 / skill A/B / memory A/B 离线基准,打印机器可读摘要 + 人类 checklist;`--dry-run` / `--help` 不重跑基准。冻结数字目录 [`benchmarks/flywheel-proof-claims.json`](benchmarks/flywheel-proof-claims.json);第三方入口 [`docs/flywheel-reproduction.md`](docs/flywheel-reproduction.md)。不发明新数字,只接线仓库里已提交的自测 RESULTS。
20
+ - **GraphFlow + Serena 联合方案独立指南**:把 `docs/comparison.md` 里的 "better together" 提升为一等文档 [`docs/graphflow-serena.md`](docs/graphflow-serena.md) / [中文](docs/graphflow-serena.zh.md)——并列安装两个 MCP、谁做什么(context/plan → Serena 编辑 → `report_outcome`)、常见坑。README(EN/中文)与 comparison 互链;配置示例 [`examples/graphflow-serena.mcp.json`](examples/graphflow-serena.mcp.json)(仅 MCP 片段,不把 Serena 写入 `package.json`)。无运行时代码改动。
21
+
5
22
  ## [1.15.1] - 2026-09-05
6
23
 
7
24
  ### Changed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  English | [中文](README.zh.md)
4
4
 
5
- [![npm version](https://img.shields.io/badge/npm-1.15.1-blue)](https://www.npmjs.com/package/@roarpeng/graphflow)
5
+ [![npm version](https://img.shields.io/badge/npm-1.15.3-blue)](https://www.npmjs.com/package/@roarpeng/graphflow)
6
6
 
7
7
  > **The memory & context harness for coding agents.** Local-first code knowledge graph · bounded context compression (~98% token savings) · cross-session learning flywheel.
8
8
 
@@ -29,14 +29,16 @@ It is also **local-first and portable**: everything runs offline with no API key
29
29
 
30
30
  ## Proof, not promises
31
31
 
32
- All headline numbers come from a **public, reproducible benchmark suite** ([benchmarks/README.md](benchmarks/README.md)) with published methodology ([docs/benchmark-standards.md](docs/benchmark-standards.md)) and machine-readable JSON dumps pinned to commits:
32
+ **Third-party reproduction entry:** `npm run proof:flywheel` — one command, offline, no API key. Guide: [docs/flywheel-reproduction.md](docs/flywheel-reproduction.md). Independent runs are welcome; open a GitHub issue titled `[benchmark] Independent reproduction — <commit>`.
33
+
34
+ All headline numbers come from a **public, reproducible benchmark suite** ([benchmarks/README.md](benchmarks/README.md)) with published methodology ([docs/benchmark-standards.md](docs/benchmark-standards.md)) and machine-readable JSON dumps pinned to commits. Authoritative percentages live in the tracked RESULTS markdown; this package does not invent new scores.
33
35
 
34
36
  - **~98% token savings** (8-query suite, 262,926 → 2,843 tokens; independently re-counted with `gpt-tokenizer`)
35
37
  - **132-query golden retrieval set** in CI (Hit@5 = 100%, MRR = 0.836, NDCG@5 = 0.601); downloadable open dataset: [`benchmarks/datasets/retrieval-golden-v1.json`](benchmarks/datasets/retrieval-golden-v1.json) — run `npm run bench:retrieval`
36
38
  - **Skill A/B: 100% vs 61.5%** task success with the flywheel on vs off (26 tasks)
37
39
  - **Memory ROI: 100% vs 56.5%** with episodic memory on vs off (62 tasks, with attribution chains)
38
40
 
39
- Results are commit-anchored so any number above can be checked out and re-run. Third-party reproduction is actively welcomed — see [ROADMAP.md](ROADMAP.md) for the open invitation.
41
+ Results are commit-anchored so any number above can be checked out and re-run. See [ROADMAP.md](ROADMAP.md) for the open invitation.
40
42
 
41
43
  ## Memory poisoning protection
42
44
 
@@ -67,7 +69,7 @@ Connect via MCP (Cursor / Claude Code / …):
67
69
  }
68
70
  ```
69
71
 
70
- The agent calls `graphflow_context` for compressed context, then `graphflow_plan` to plan; without a provider API key GraphFlow automatically bridges the ATP thinking protocol to the host agent (agent-delegated mode).
72
+ The agent calls `graphflow_context` for compressed context, then `graphflow_plan` to plan; without a provider API key GraphFlow automatically bridges the ATP thinking protocol to the host agent (agent-delegated mode). For symbol-precise edits, compose Serena as a second MCP server — [GraphFlow + Serena](docs/graphflow-serena.md) (`examples/graphflow-serena.mcp.json`).
71
73
 
72
74
  ## Why GraphFlow
73
75
 
@@ -82,7 +84,7 @@ Single-purpose tools each do one thing well; GraphFlow combines graph + compress
82
84
  | Local-first | ✅ | ✅ | ✅ | ✅ |
83
85
  | Open protocol | [ATP/IR public spec](docs/atp-ir-spec-v1.md) | — | — | — |
84
86
 
85
- > The differentiator is the **learning flywheel**: graph indexing and token compression are replicable; project-private experience (skills, lessons, decisions) accumulated across sessions is not — it compounds with use. Serena is a complement, not a competitor — see [GraphFlow + Serena: better together](docs/comparison.md#graphflow--serena-better-together联合方案).
87
+ > The differentiator is the **learning flywheel**: graph indexing and token compression are replicable; project-private experience (skills, lessons, decisions) accumulated across sessions is not — it compounds with use. Serena is a complement, not a competitor — see [GraphFlow + Serena: better together](docs/graphflow-serena.md) ([中文](docs/graphflow-serena.zh.md); [comparison](docs/comparison.md)).
86
88
 
87
89
  ## Core capabilities (v1.13+)
88
90
 
@@ -285,7 +287,7 @@ Supported: Cursor, VS Code, Trae (incl. CN), Claude Code, Windsurf, Cline, Roo C
285
287
 
286
288
  ## Protocol
287
289
 
288
- [ATP/IR — Agent Thinking Protocol public specification v1.0](docs/atp-ir-spec-v1.md): work-item registry, submit/merge contract, compatibility rules. Third-party tools can implement compatible producers / consumers. Minimal Producer example: [`examples/atp-minimal-producer/`](examples/atp-minimal-producer/).
290
+ [ATP/IR — Agent Thinking Protocol public specification v1.0](docs/atp-ir-spec-v1.md): work-item registry, submit/merge contract, compatibility rules. Third-party tools can implement compatible producers / consumers. Minimal Producer example: [`examples/atp-minimal-producer/`](examples/atp-minimal-producer/). Dual-MCP compose snippet (GraphFlow + Serena, config only): [`examples/graphflow-serena.mcp.json`](examples/graphflow-serena.mcp.json).
289
291
 
290
292
  ## Community
291
293
 
@@ -325,7 +327,8 @@ GraphFlow/
325
327
  │ └── mcp/ # MCP server (10 tools)
326
328
  ├── tests/ # 142 files / 961 tests (incl. governance foundation and MCP HTTP/stdio matrix)
327
329
  ├── benchmarks/ # comprehensive + independent + SWE-bench + token savings + skill A/B (reproducible)
328
- ├── docs/ # ATP spec + context contract + experience memory + comparisons
330
+ ├── docs/ # ATP spec + context contract + experience memory + flywheel reproduction + GraphFlow/Serena
331
+ ├── examples/ # ATP producer + team-memory config + GraphFlow/Serena dual-MCP snippet
329
332
  ├── vscode-extension/ # VS Code panel and commands
330
333
  └── CHANGELOG.md
331
334
  ```
package/README.zh.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- [![npm version](https://img.shields.io/badge/npm-1.15.1-blue)](https://www.npmjs.com/package/@roarpeng/graphflow)
5
+ [![npm version](https://img.shields.io/badge/npm-1.15.3-blue)](https://www.npmjs.com/package/@roarpeng/graphflow)
6
6
 
7
7
  > **给编程 Agent 用的记忆与上下文 harness。** 本地优先的代码知识图谱 · 有界上下文压缩(约 98% token 节省) · 跨会话学习飞轮。
8
8
 
@@ -31,7 +31,7 @@ MCP 入口:
31
31
  }
32
32
  ```
33
33
 
34
- Agent 应先调 `graphflow_context` 拿压缩上下文,再视需要调用 `graphflow_plan`。没有 LLM API Key 时会桥接到宿主 Agent(agent-delegated)。
34
+ Agent 应先调 `graphflow_context` 拿压缩上下文,再视需要调用 `graphflow_plan`。没有 LLM API Key 时会桥接到宿主 Agent(agent-delegated)。需要符号级精确编辑时,把 Serena 作为第二个 MCP server 并列挂载——见 [GraphFlow + Serena 联合方案](docs/graphflow-serena.zh.md)(配置示例:[`examples/graphflow-serena.mcp.json`](examples/graphflow-serena.mcp.json))。
35
35
 
36
36
  ## 工作台脉络(v1.9.14)
37
37
 
@@ -136,4 +136,6 @@ dsh plugin --profile web remove @roarpeng/graphflow
136
136
 
137
137
  ## 更多
138
138
 
139
- 完整英文文档、基准与协议:[README.md](README.md) · [ATP/IR](docs/atp-ir-spec-v1.md) · [上下文合同](docs/context-contract.md) · [经验记忆](docs/experience-memory.md)
139
+ 完整英文文档、基准与协议:[README.md](README.md) · [ATP/IR](docs/atp-ir-spec-v1.md) · [上下文合同](docs/context-contract.md) · [经验记忆](docs/experience-memory.md) · [GraphFlow + Serena](docs/graphflow-serena.zh.md) · [竞品对比](docs/comparison.md)
140
+
141
+ 第三方复现飞轮 / 记忆 A/B / 检索自测:`npm run proof:flywheel`(说明见 [docs/flywheel-reproduction.md](docs/flywheel-reproduction.md))。
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Shared context-packaging core.
3
+ *
4
+ * `buildLayeredContextPackage` and `buildEnhancedContextPackage` used to
5
+ * duplicate retrieval + L1/L2/L3 quota packing (~60% overlap). Both public
6
+ * functions keep their signatures and extras; this module owns the common
7
+ * recall/pack steps so behavior stays identical.
8
+ */
9
+ import type { GraphNode } from "../core/types.js";
10
+ import type { GraphClient } from "./client-factory.js";
11
+ import type { ContextAnchorItem, LayeredContextPackage, LayeredPackageOptions, SubgraphExpansionOptions } from "./context-slicer-types.js";
12
+ export type DuplicateModulePolicy = "continue" | "break";
13
+ export interface PackState {
14
+ summaryChannel: string[];
15
+ anchorChannel: ContextAnchorItem[];
16
+ added: Set<string>;
17
+ quota: {
18
+ l1: number;
19
+ l2: number;
20
+ l3: number;
21
+ };
22
+ used: {
23
+ l1: number;
24
+ l2: number;
25
+ l3: number;
26
+ };
27
+ maxTokens: number;
28
+ maxAnchors?: number;
29
+ }
30
+ export interface PackBudget {
31
+ tokens: number;
32
+ truncated: boolean;
33
+ }
34
+ /**
35
+ * Governance pins for L3: Decision/goal nodes that packing must prefer so
36
+ * budget truncation cannot drop alignment / deviation / goal constraints.
37
+ */
38
+ export declare function isPinnedL3Node(node: GraphNode): boolean;
39
+ export declare function createPackState(maxTokens: number, options?: LayeredPackageOptions, maxAnchors?: number): PackState;
40
+ export declare function toLayeredPackage(state: PackState, budget: PackBudget): LayeredContextPackage;
41
+ export declare function expandSubgraph(client: GraphClient, seedIds: string[], options?: SubgraphExpansionOptions): Promise<GraphNode[]>;
42
+ export declare function vectorRecall(nodes: GraphNode[], queryEmbedding: number[], topK: number, minSimilarity: number): GraphNode[];
43
+ export declare function collectKeywordHits(client: GraphClient, query: string, options?: LayeredPackageOptions): Promise<GraphNode[]>;
44
+ /**
45
+ * Fuse keyword hits with vector recall when enabled.
46
+ * Returns `null` when vector recall is off so callers keep their current hit list
47
+ * (enhanced may have already applied symbol boosting).
48
+ * On failure, returns the original keyword hits (same reset both builders used).
49
+ */
50
+ export declare function fuseVectorRecallIfEnabled(client: GraphClient, query: string, keywordHits: GraphNode[], options: LayeredPackageOptions | undefined, logLabel: string): Promise<GraphNode[] | null>;
51
+ export declare function preparePackageHits(hits: GraphNode[], query: string, options: LayeredPackageOptions | undefined, snapshotNodes: GraphNode[] | undefined): GraphNode[];
52
+ export declare function tryAppendL3Node(node: GraphNode, state: PackState, budget: PackBudget): "packed" | "budget" | "skip";
53
+ export declare function packPrimaryHits(hits: GraphNode[], state: PackState, budget: PackBudget): void;
54
+ export declare function injectL2Modules(client: GraphClient, hits: GraphNode[], state: PackState, budget: PackBudget, duplicatePolicy: DuplicateModulePolicy): Promise<void>;
55
+ export declare function injectL3SkillsAndPins(client: GraphClient, query: string, options: LayeredPackageOptions | undefined, snapshotNodes: GraphNode[] | undefined, state: PackState, budget: PackBudget): Promise<void>;
56
+ export declare function injectDialogueTurns(client: GraphClient, query: string, options: LayeredPackageOptions | undefined, state: PackState, budget: PackBudget): Promise<void>;
57
+ export declare function injectSameFileAndImportExpansion(client: GraphClient, snapshotNodes: GraphNode[] | undefined, state: PackState, budget: PackBudget): Promise<void>;
58
+ export declare function injectNeighborExpansion(client: GraphClient, options: LayeredPackageOptions | undefined, state: PackState, budget: PackBudget): Promise<void>;
59
+ //# sourceMappingURL=context-package-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-package-core.d.ts","sourceRoot":"","sources":["../../src/graph/context-package-core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMlD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAavD,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AAQnC,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,OAAO,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACnC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,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