@roarpeng/graphflow 1.9.15 → 1.9.16

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.
@@ -9,6 +9,6 @@ export { getSettingsPanelStatus, indexGraphFromSettings, testRoutingAndIndexGrap
9
9
  export { assertGraphFlowRuntime, type GraphFlowRuntime, type GraphFlowRuntimeModule } from "./runtime/facade.js";
10
10
  export { runLearningNightly, runLearningNightlyResult, runSkillDecay, runSkillReset, runSkillPrune, runSkillConsolidatePlan, runSkillConsolidate, runLearnForget, } from "./runtime/learning.js";
11
11
  export { listEpisodes, searchEpisodes, forgetEpisode, type MemoryOutcome, type MemoryEpisodeItem, type MemorySearchHit, type MemoryForgetResult, } from "./runtime/memory.js";
12
- export { listDialogueTurnsRuntime, recordDialogueTurnRuntime, type DialogueListItem, } from "./runtime/dialogue.js";
12
+ export { listDialogueTurnsRuntime, recordDialogueTurnRuntime, resolveDialogueRecordInput, distillDialogueTurnsRuntime, type DialogueListItem, type DistillDialogueResult, } from "./runtime/dialogue.js";
13
13
  export { detectInstalledAgents, formatModelConfigGuide, installMcpToDetectedAgents, repairUnsafeWindowsMcpCommands, repairStaleGraphFlowMcpLaunchers, } from "../../integrations/agent-mcp-installer";
14
14
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/surfaces/cli/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,uBAAuB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACnG,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,OAAO,EACP,aAAa,EACb,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/surfaces/cli/runt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ClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,wCAAwC,CAAC"}
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.runSkillPrune = exports.runSkillReset = exports.runSkillDecay = exports.runLearningNightlyResult = exports.runLearningNightly = exports.assertGraphFlowRuntime = exports.testRoutingAndIndexGraph = exports.indexGraphFromSettings = exports.getSettingsPanelStatus = exports.mergeAgentInsightResult = exports.submitAgentInsightResult = exports.planInsight = exports.planInsightResult = exports.planAndBrainstormResult = exports.planAndBrainstorm = exports.diagnoseRoutingResult = exports.diagnoseRouting = exports.reportOutcome = exports.runTaskResult = exports.runTask = exports.startFileWatcherIfEnabled = exports.resetTokenSavingsStats = exports.getTokenSavingsStats = exports.getFlywheelReport = exports.syncSkillPackageRuntime = exports.importSkillPackageRuntime = exports.exportSkillPackageRuntime = exports.importArtifact = exports.exportExperienceMemory = exports.exportArtifact = exports.getSkillInsights = exports.inspectGraph = exports.rebuildGraph = exports.indexFile = exports.indexGraph = exports.listWorkbenchOutline = exports.captureAssistantReply = exports.expandAnchor = exports.previewContext = exports.validateSettingsForRouting = exports.validateSettingsForGraphIndex = exports.saveGraphFlowSettings = exports.getGraphFlowSettings = exports.resolveWritableConfigPath = exports.resolveConfigPath = exports.resolveConfig = exports.resolveGlobalConfigPath = exports.ensureWorkspaceGraphFlowConfig = exports.ensureGlobalGraphFlowConfig = exports.getDefaultConfig = void 0;
18
- exports.repairStaleGraphFlowMcpLaunchers = exports.repairUnsafeWindowsMcpCommands = exports.installMcpToDetectedAgents = exports.formatModelConfigGuide = exports.detectInstalledAgents = exports.recordDialogueTurnRuntime = exports.listDialogueTurnsRuntime = exports.forgetEpisode = exports.searchEpisodes = exports.listEpisodes = exports.runLearnForget = exports.runSkillConsolidate = exports.runSkillConsolidatePlan = void 0;
18
+ exports.repairStaleGraphFlowMcpLaunchers = exports.repairUnsafeWindowsMcpCommands = exports.installMcpToDetectedAgents = exports.formatModelConfigGuide = exports.detectInstalledAgents = exports.distillDialogueTurnsRuntime = exports.resolveDialogueRecordInput = exports.recordDialogueTurnRuntime = exports.listDialogueTurnsRuntime = exports.forgetEpisode = exports.searchEpisodes = exports.listEpisodes = exports.runLearnForget = exports.runSkillConsolidate = exports.runSkillConsolidatePlan = void 0;
19
19
  var defaults_1 = require("../../config/defaults");
20
20
  Object.defineProperty(exports, "getDefaultConfig", { enumerable: true, get: function () { return defaults_1.getDefaultConfig; } });
21
21
  var scaffold_1 = require("../../config/scaffold");
@@ -86,6 +86,8 @@ Object.defineProperty(exports, "forgetEpisode", { enumerable: true, get: functio
86
86
  var dialogue_js_1 = require("./runtime/dialogue.js");
87
87
  Object.defineProperty(exports, "listDialogueTurnsRuntime", { enumerable: true, get: function () { return dialogue_js_1.listDialogueTurnsRuntime; } });
88
88
  Object.defineProperty(exports, "recordDialogueTurnRuntime", { enumerable: true, get: function () { return dialogue_js_1.recordDialogueTurnRuntime; } });
89
+ Object.defineProperty(exports, "resolveDialogueRecordInput", { enumerable: true, get: function () { return dialogue_js_1.resolveDialogueRecordInput; } });
90
+ Object.defineProperty(exports, "distillDialogueTurnsRuntime", { enumerable: true, get: function () { return dialogue_js_1.distillDialogueTurnsRuntime; } });
89
91
  var agent_mcp_installer_1 = require("../../integrations/agent-mcp-installer");
90
92
  Object.defineProperty(exports, "detectInstalledAgents", { enumerable: true, get: function () { return agent_mcp_installer_1.detectInstalledAgents; } });
91
93
  Object.defineProperty(exports, "formatModelConfigGuide", { enumerable: true, get: function () { return agent_mcp_installer_1.formatModelConfigGuide; } });
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/surfaces/cli/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AAAhD,4GAAA,gBAAgB,OAAA;AACzB,kDAK+B;AAJ7B,uHAAA,2BAA2B,OAAA;AAC3B,0HAAA,8BAA8B,OAAA;AAC9B,mHAAA,uBAAuB,OAAA;AAGzB,gDAAmG;AAA1F,wGAAA,aAAa,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAAE,oHAAA,yBAAyB,OAAA;AACpE,qDAAmC;AACnC,qDAK+B;AAJ7B,mHAAA,oBAAoB,OAAA;AACpB,oHAAA,qBAAqB,OAAA;AACrB,4HAAA,6BAA6B,OAAA;AAC7B,yHAAA,0BAA0B,OAAA;AAE5B,+CAoB4B;AAnB1B,0GAAA,cAAc,OAAA;AACd,wGAAA,YAAY,OAAA;AACZ,iHAAA,qBAAqB,OAAA;AACrB,gHAAA,oBAAoB,OAAA;AACpB,sGAAA,UAAU,OAAA;AACV,qGAAA,SAAS,OAAA;AACT,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAChB,0GAAA,cAAc,OAAA;AACd,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA;AACd,qHAAA,yBAAyB,OAAA;AACzB,qHAAA,yBAAyB,OAAA;AACzB,mHAAA,uBAAuB,OAAA;AACvB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AACpB,kHAAA,sBAAsB,OAAA;AACtB,qHAAA,yBAAyB,OAAA;AAE3B,mDAY8B;AAX5B,qGAAA,OAAO,OAAA;AACP,2GAAA,aAAa,OAAA;AACb,2GAAA,aAAa,OAAA;AACb,6GAAA,eAAe,OAAA;AACf,mHAAA,qBAAqB,OAAA;AACrB,+GA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OAAA;AACvB,kHAAA,mBAAmB,OAAA;AACnB,6GAAA,cAAc,OAAA;AAEhB,iDAQ6B;AAP3B,yGAAA,YAAY,OAAA;AACZ,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AAMf,qDAO+B;AAN7B,uHAAA,wBAAwB,OAAA;AACxB,wHAAA,yBAAyB,OAAA;AACzB,yHAAA,0BAA0B,OAAA;AAC1B,0HAAA,2BAA2B,OAAA;AAI7B,8EAMgD;AAL9C,4HAAA,qBAAqB,OAAA;AACrB,6HAAA,sBAAsB,OAAA;AACtB,iIAAA,0BAA0B,OAAA;AAC1B,qIAAA,8BAA8B,OAAA;AAC9B,uIAAA,gCAAgC,OAAA"}
package/dsh/plugin.mjs CHANGED
@@ -80,6 +80,152 @@ export function buildContextHint(cwd = process.cwd()) {
80
80
  return `GraphFlow: before large code reads, call mcp__graphflow__graphflow_context with rootDir=${cwd}. Do not dump SKILL.md.`;
81
81
  }
82
82
 
83
+ /**
84
+ * Extract the plain text of a user message (its text ContentBlocks joined).
85
+ * Returns "" when the message carries no text. Never throws.
86
+ * @param {object|undefined} message - a UserMessage (agent/inbox/inserted payload).
87
+ * @returns {string}
88
+ */
89
+ export function extractMessageText(message) {
90
+ if (!message || typeof message !== "object") return "";
91
+ const content = message.content;
92
+ if (!Array.isArray(content)) return "";
93
+ const parts = [];
94
+ for (const block of content) {
95
+ if (block && typeof block === "object" && block.type === "text" && typeof block.text === "string") {
96
+ parts.push(block.text);
97
+ }
98
+ }
99
+ return parts.join("\n").trim();
100
+ }
101
+
102
+ /**
103
+ * The local GraphFlow CLI entry (this package's own dist build). Falls back to
104
+ * `graphflow` from PATH when dist is absent (source checkout without build).
105
+ * @returns {string}
106
+ */
107
+ export function resolveCliCommand(packageRoot = PACKAGE_ROOT) {
108
+ const distCli = join(packageRoot, "dist", "surfaces", "cli", "index.js");
109
+ return existsSync(distCli) ? distCli : "graphflow";
110
+ }
111
+
112
+ /**
113
+ * Whether a message originates from the human user rather than the harness.
114
+ * Only `source.kind === "user"` qualifies; harness/system injections
115
+ * (`plugin`/`tool`/`model`) must not become dialogue turns (job finished
116
+ * notices, subagent reports, tool results, …). Unknown/missing source falls
117
+ * back to the role check so nothing legitimate is dropped.
118
+ * @param {object|undefined} message
119
+ * @returns {boolean}
120
+ */
121
+ export function isUserOriginatedMessage(message) {
122
+ if (!message || typeof message !== "object") return false;
123
+ const kind =
124
+ message.source && typeof message.source === "object" ? message.source.kind : undefined;
125
+ if (kind === "user") return true;
126
+ if (kind === "plugin" || kind === "tool" || kind === "model") return false;
127
+ return message.role !== "system";
128
+ }
129
+
130
+ /**
131
+ * Best-effort auto-record of one user turn as a dialogue node.
132
+ * Spawns `graphflow dialogue record --query "<text>" [--session <sessionId>]`
133
+ * in the agent's workspace (cwd = session header cwd) so every web/agent
134
+ * question becomes a dialogue-turn graph node without relying on the agent
135
+ * calling graphflow_context itself. Only human-originated messages are
136
+ * recorded (see isUserOriginatedMessage) — harness/system injections must not
137
+ * pollute the dialogue graph. `sessionId` scopes the turn to one dsh session
138
+ * (omitted → default "main" dialogue session) so question recording and reply
139
+ * filling land in the same dialogue session. Never throws; the spawned child
140
+ * is detached.
141
+ * @param {object|undefined} message - a UserMessage (agent/inbox/inserted payload).
142
+ * @param {string} [cwd]
143
+ * @param {GraphFlowDshPluginConfig} [config]
144
+ * @param {string} [sessionId] - dialogue session name/id; omitted → "main".
145
+ * @returns {{attempted: boolean, reason?: string, workspace?: string}}
146
+ */
147
+ export function recordDialogueFromInbox(message, cwd, config = {}, sessionId) {
148
+ try {
149
+ if (!isUserOriginatedMessage(message)) {
150
+ return { attempted: false, reason: "not-user-message" };
151
+ }
152
+ const env = envOf(config);
153
+ if (!isAutoCaptureEnabled(env)) {
154
+ return { attempted: false, reason: "auto-capture-off" };
155
+ }
156
+ const text = extractMessageText(message);
157
+ if (text.length < 4) {
158
+ return { attempted: false, reason: "query-too-short" };
159
+ }
160
+ const workspace = typeof cwd === "string" && cwd.trim() ? cwd : process.cwd();
161
+ const spawnFn = typeof config.spawn === "function" ? config.spawn : spawn;
162
+ const cli = resolveCliCommand(config.packageRoot);
163
+ const args = [cli, "dialogue", "record", "--query", text];
164
+ if (typeof sessionId === "string" && sessionId.trim()) {
165
+ args.push("--session", sessionId);
166
+ }
167
+ const bin = cli === "graphflow" ? (env.GRAPHFLOW_HOOK_BIN?.trim() || "npx") : process.execPath;
168
+ const fullArgs = cli === "graphflow" ? ["-y", "--package=@roarpeng/graphflow", ...args] : args;
169
+ spawnFn(bin, fullArgs, {
170
+ cwd: workspace,
171
+ env,
172
+ stdio: "ignore",
173
+ detached: true,
174
+ windowsHide: true,
175
+ })?.unref?.();
176
+ return { attempted: true, workspace };
177
+ } catch {
178
+ return { attempted: false, reason: "error" };
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Best-effort fill of one assistant reply into the latest pending dialogue
184
+ * turn for `sessionId`. Spawns `graphflow dialogue record --reply "<text>"
185
+ * [--session <sessionId>]` (reply-only mode) in the workspace; the runtime
186
+ * fills the latest pending turn's assistantReply and safely skips when none is
187
+ * pending. Half-written (interrupted) replies are not filled. Never throws.
188
+ * @param {object|undefined} event - an `assistant/message` session event.
189
+ * @param {string} [sessionId] - dialogue session name/id.
190
+ * @param {string} [cwd]
191
+ * @param {GraphFlowDshPluginConfig} [config]
192
+ * @returns {{attempted: boolean, reason?: string, workspace?: string}}
193
+ */
194
+ export function recordReplyFromTurn(event, sessionId, cwd, config = {}) {
195
+ try {
196
+ const text = extractMessageText(event?.message);
197
+ if (!text) {
198
+ return { attempted: false, reason: "no-text" };
199
+ }
200
+ if (event?.interrupted) {
201
+ return { attempted: false, reason: "interrupted" };
202
+ }
203
+ const env = envOf(config);
204
+ if (!isAutoCaptureEnabled(env)) {
205
+ return { attempted: false, reason: "auto-capture-off" };
206
+ }
207
+ const workspace = typeof cwd === "string" && cwd.trim() ? cwd : process.cwd();
208
+ const spawnFn = typeof config.spawn === "function" ? config.spawn : spawn;
209
+ const cli = resolveCliCommand(config.packageRoot);
210
+ const args = [cli, "dialogue", "record", "--reply", text];
211
+ if (typeof sessionId === "string" && sessionId.trim()) {
212
+ args.push("--session", sessionId);
213
+ }
214
+ const bin = cli === "graphflow" ? (env.GRAPHFLOW_HOOK_BIN?.trim() || "npx") : process.execPath;
215
+ const fullArgs = cli === "graphflow" ? ["-y", "--package=@roarpeng/graphflow", ...args] : args;
216
+ spawnFn(bin, fullArgs, {
217
+ cwd: workspace,
218
+ env,
219
+ stdio: "ignore",
220
+ detached: true,
221
+ windowsHide: true,
222
+ })?.unref?.();
223
+ return { attempted: true, workspace };
224
+ } catch {
225
+ return { attempted: false, reason: "error" };
226
+ }
227
+ }
228
+
83
229
  export function loadGraphFlowSkillRegistration(packageRoot = PACKAGE_ROOT) {
84
230
  const skillPath = join(packageRoot, "skills", "graphflow", "SKILL.md");
85
231
  let content = "";
@@ -233,6 +379,59 @@ export function apply(ctx, config = {}) {
233
379
  // event bus missing
234
380
  }
235
381
 
382
+ const recordedInboxMessages = new WeakSet();
383
+
384
+ try {
385
+ // Auto record every user question as a dialogue-turn node (the dsh analog
386
+ // of Claude Code's PostToolUse capture): each web/agent question becomes a
387
+ // graph node with session/workspace lineage, without relying on the agent
388
+ // calling graphflow_context itself. Turns are scoped to the dsh session id
389
+ // so question recording and reply filling stay in the same dialogue
390
+ // session (never crossing same-workspace sessions).
391
+ listen(ctx, "agent/inbox/inserted", (payload) => {
392
+ try {
393
+ const message = payload?.message;
394
+ if (!message || typeof message !== "object") return;
395
+ if (recordedInboxMessages.has(message)) return;
396
+ recordedInboxMessages.add(message);
397
+ const agent = payloadAgent(payload);
398
+ const cwd =
399
+ agent?.session?.header?.cwd ??
400
+ resolveWorkspaceCwd(payload, config.cwd);
401
+ recordDialogueFromInbox(message, cwd, config, agent?.session?.id);
402
+ } catch {
403
+ // recording is optional
404
+ }
405
+ });
406
+ } catch {
407
+ // event bus missing
408
+ }
409
+
410
+ const recordedReplies = new WeakSet();
411
+
412
+ try {
413
+ // Auto fill every assistant reply into the latest pending dialogue turn of
414
+ // the same dsh session: closes the question→answer loop so dialogue-turn
415
+ // nodes record a complete exchange without the agent calling
416
+ // graphflow_context({ assistantReply }) itself. Deduped per message object;
417
+ // interrupted (half-written) replies are skipped.
418
+ listen(ctx, "session/event", (session, event) => {
419
+ try {
420
+ if (event?.type !== "assistant/message") return;
421
+ if (event.interrupted) return;
422
+ const message = event.message;
423
+ if (!message || typeof message !== "object") return;
424
+ if (recordedReplies.has(message)) return;
425
+ recordedReplies.add(message);
426
+ recordReplyFromTurn(event, session?.id, session?.header?.cwd, config);
427
+ } catch {
428
+ // reply fill is optional
429
+ }
430
+ });
431
+ } catch {
432
+ // event bus missing
433
+ }
434
+
236
435
  try {
237
436
  listen(ctx, "agent/pre-step", (payload, next) => {
238
437
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roarpeng/graphflow",
3
- "version": "1.9.15",
3
+ "version": "1.9.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,6 +12,7 @@
12
12
  "mcp.json",
13
13
  "cordis.patch.yml",
14
14
  "dsh",
15
+ "web",
15
16
  "skills",
16
17
  "src/surfaces/trae-skill",
17
18
  "src/surfaces/trae-rules",
@@ -39,6 +40,7 @@
39
40
  "default": "./dist/index.js"
40
41
  },
41
42
  "./dsh": "./dsh/plugin.mjs",
43
+ "./web": "./web/plugin.mjs",
42
44
  "./package.json": "./package.json"
43
45
  },
44
46
  "bin": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "graphflow",
4
- "version": "1.9.15",
4
+ "version": "1.9.16",
5
5
  "description": "图谱上下文压缩与任务规划插件(10 个 MCP 工具)。能力:压缩上下文、DAG 规划、增量建图、技能飞轮、诊断与产物导入导出。DeepSeek Harness:dsh plugin --profile web add @roarpeng/graphflow;工具名为 mcp__graphflow__graphflow_*。先调 graphflow_context(传 rootDir),复杂任务再 plan,改完代码后 index。",
6
6
  "author": {
7
7
  "name": "Roarpeng",
package/web/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # GraphFlow Web 知识节点栏
2
+
3
+ DeepSeek Harness web 右侧"知识节点"面板的源码种子。
4
+
5
+ ## 现状
6
+
7
+ - **自动按轮记录**(持久、随包生效):`dsh/plugin.mjs`(glue)监听 `agent/inbox/inserted`,
8
+ 自动把每一轮用户提问写成 `dialogue-turn` 图节点(写入 agent 会话工作区的 `.graphflow/`)。
9
+ 回复补全沿用既有机制:agent 调用 `graphflow_context({ assistantReply })` 时填充(与
10
+ Claude Code SessionEnd 同一契约)。可用 `GRAPHFLOW_AUTO_CAPTURE=0` 关闭。
11
+ - **右侧知识节点栏**(本会话生效):以动态 Cordis 插件(Host + Client 双半部)挂载:
12
+ - `conversation.session.header.utilities`:会话头部"知识节点"开关按钮
13
+ - `shell.overlay`:右缘浮动面板(additive,不替换任何出厂 UI),展示
14
+ Workbench 主题(主线/旁支、活跃、待回复、消息数)+ 对话轮次(Q/A、跳转标记)
15
+ - 点击节点:通过会话 binding 的 `prompt('queue')` 通道提交续聊指令,agent 自动调用
16
+ `graphflow_context({ topicId | resumeFromTurnId })` 恢复上下文继续
17
+
18
+ ## 数据来源
19
+
20
+ 面板数据由动态插件的 host 半部经 `harness.handle("gf.nodes.list")` 提供,
21
+ 内部调用(当前工作区下):
22
+ - `graphflow workbench tree --json`
23
+ - `graphflow dialogue list --json --limit 50`
24
+
25
+ ## 打包为静态客户端插件(未来)
26
+
27
+ dsh web 的静态客户端包必须预编译为 `window.__ModuleLoader__.load({id, factory})`
28
+ 工厂格式并经 `/plugins/<id>/client.js` 提供;纯 ESM 文件无法直接加载。
29
+ `plugin.mjs` 中的 `hostHalf()` / `clientHalf()` 即未来 `code.host` / `code.client`
30
+ 的源码。届时需:
31
+ 1. 在 `package.json` 增加 `dsh.client` 声明(`platform: "web"` + `inject` 列表)
32
+ 2. 用 dsh monorepo 的 rolldown 管线把 `./web` 编译为客户端 bundle
33
+ 3. 在 `cordis.patch.yml` 增加第三行(客户端插件行)
34
+
35
+ 在完成上述打包前,**不要**在 `cordis.patch.yml` 添加该行(client-modules 扫描到
36
+ 缺失 bundle 会使 profile 组合失败)。