flavor-code 1.4.0-beta.5 → 1.4.0-beta.7

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/README.md CHANGED
@@ -178,6 +178,8 @@ Common commands:
178
178
 
179
179
  You can submit steering or queue follow-ups while a run is in progress; once the current model response finishes, the task picks up new instructions at safe boundaries.
180
180
 
181
+ During planned work, a wide CLI shows the main task plan and sub-agent exploration side by side; if only one track exists it uses the full row, and narrow terminals stack both tracks. Long streamed responses keep a live `Writing response` activity below the latest output. LSP tools locate the nearest nested project configuration for each target file, so monorepos and sandbox/worktree projects do not need a `tsconfig.json` or `jsconfig.json` at the Flavor workspace root; JavaScript and CommonJS files are supported by the bundled TypeScript server as well.
182
+
181
183
  `/commit` and `/review` use the cheap sub-agent model and degrade gracefully when it is unavailable. Session checkpoints are tagged with the current git state (`branch@sha`), so `/tree` shows what the workspace looked like at each node. `/explain <symbol>` runs on the same cheap model: it assembles call relations from the code graph, the symbol's real source slice, and recent commits touching the file, then generates a five-part newcomer walkthrough (what it does / key implementation points / call flow / why it is written this way / gotchas); an interactive picker disambiguates multiple matches, and a missing graph degrades to a `/ast init` hint instead of an error.
182
184
 
183
185
  #### CLI pals and cross-project work
package/README.zh-CN.md CHANGED
@@ -178,6 +178,8 @@ OAuth PKCE 的运行时行为与配置约定见 [PKCE 规范](./docs/specs/pkce-
178
178
 
179
179
  运行中可以提交 steering 或排队 follow-up;当前模型响应结束后,任务会在安全边界处接收新指令。
180
180
 
181
+ 有任务规划时,宽终端会把主任务计划与子 Agent 探索左右并排展示;只有一类工作时占满整行,窄终端则自动纵向排列。长内容流式输出期间,最新内容下方会持续显示 `Writing response` 动作。LSP 工具会从目标文件向上寻找最近的嵌套项目配置,因此 monorepo、sandbox 或 worktree 项目无需在 Flavor 工作区根部额外放置 `tsconfig.json` / `jsconfig.json`;内置 TypeScript 服务也支持 JavaScript 与 CommonJS 文件。
182
+
181
183
  `/commit` 与 `/review` 使用廉价子 Agent 模型,模型不可用时优雅降级。会话 checkpoint 会标记当前 git 状态(`branch@sha`),`/tree` 可以看到每个节点对应的工作区现场。`/explain <符号>` 同样走廉价模型:它把代码图中的调用关系、符号的真实源码切片和该文件的近期提交历史组装成证据,生成面向新人的五段式讲解(做什么 / 关键实现点 / 调用关系 / 为什么这样写 / 注意事项);多个符号命中时弹出选择卡片,可方向键选择或直接输入更精确的名字;代码图未建立时提示 `/ast init`,不会抛错。
182
184
 
183
185
  #### CLI Pals 与跨项目协作
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
3
3
  import {
4
4
  statusPresentation
5
- } from "./chunk-2BF7CVWZ.js";
5
+ } from "./chunk-RAYH6K2H.js";
6
6
  import {
7
7
  COMMAND_DESCRIPTIONS,
8
8
  MVP_COMMANDS,
@@ -19,7 +19,7 @@ import {
19
19
  thinkingWindow,
20
20
  transcriptReducer,
21
21
  withTimeout
22
- } from "./chunk-J7TLT6LR.js";
22
+ } from "./chunk-ITKOMJD6.js";
23
23
  import "./chunk-N5MXHJKD.js";
24
24
  import "./chunk-KQMKY7C5.js";
25
25
  import {
@@ -38,7 +38,7 @@ import {
38
38
  useStdout,
39
39
  use_app_default,
40
40
  use_input_default
41
- } from "./chunk-IQAZ42TM.js";
41
+ } from "./chunk-XMRKRPNC.js";
42
42
  import {
43
43
  execFileNoThrow
44
44
  } from "./chunk-ZJCAQXA7.js";
@@ -1007,7 +1007,7 @@ function TaskStatusLine({ block, interactive }) {
1007
1007
  thinkingScroll.current = { start: state.start, lastTime: time };
1008
1008
  return state.text;
1009
1009
  })() : void 0;
1010
- return /* @__PURE__ */ jsxs2(Box_default, { flexDirection: "column", children: [
1010
+ return /* @__PURE__ */ jsxs2(Box_default, { flexDirection: "column", width: "100%", children: [
1011
1011
  /* @__PURE__ */ jsxs2(Box_default, { ref, flexDirection: "row", children: [
1012
1012
  /* @__PURE__ */ jsxs2(Text, { ...presentation.color === void 0 ? {} : { color: presentation.color }, children: [
1013
1013
  presentation.glyph,
@@ -1039,38 +1039,70 @@ function ThinkingLineView({ text }) {
1039
1039
  /* @__PURE__ */ jsx3(Text, { color: THINKING_TEXT, wrap: "truncate-end", children: text })
1040
1040
  ] });
1041
1041
  }
1042
+ var SPLIT_TRACK_MIN_COLUMNS = 72;
1042
1043
  function TaskProgressPanel({
1043
1044
  blocks,
1044
1045
  interactive,
1045
1046
  maxHeight = 8,
1047
+ columns = 80,
1046
1048
  scrollRef,
1047
1049
  onHoverChange
1048
1050
  }) {
1049
1051
  if (blocks.length === 0 || maxHeight <= 0) return null;
1052
+ const taskBlocks = blocks.filter((block) => block.task?.role === "main");
1053
+ const subagentBlocks = blocks.filter((block) => block.task?.role === "subagent");
1054
+ const hasTasks = taskBlocks.length > 0;
1055
+ const hasSubagents = subagentBlocks.length > 0;
1056
+ const split = hasTasks && hasSubagents && columns >= SPLIT_TRACK_MIN_COLUMNS;
1050
1057
  return /* @__PURE__ */ jsxs2(
1051
1058
  Box_default,
1052
1059
  {
1053
1060
  flexDirection: "column",
1054
1061
  flexShrink: 0,
1062
+ width: "100%",
1055
1063
  maxHeight,
1056
1064
  onMouseEnter: () => onHoverChange?.(true),
1057
1065
  onMouseLeave: () => onHoverChange?.(false),
1058
1066
  children: [
1059
- /* @__PURE__ */ jsx3(Text, { dimColor: true, children: "\u2500\u2500 task progress \u2500\u2500" }),
1067
+ split ? /* @__PURE__ */ jsx3(SplitTrackHeaders, {}) : /* @__PURE__ */ jsx3(TrackHeader, { role: hasTasks ? "main" : "subagent" }),
1060
1068
  maxHeight > 1 ? /* @__PURE__ */ jsx3(
1061
1069
  ScrollBox_default,
1062
1070
  {
1063
1071
  ...scrollRef === void 0 ? {} : { ref: scrollRef },
1064
1072
  flexDirection: "column",
1065
1073
  flexShrink: 1,
1074
+ width: "100%",
1066
1075
  maxHeight: maxHeight - 1,
1067
- children: blocks.map((block) => /* @__PURE__ */ jsx3(TaskStatusLine, { block, interactive }, block.id))
1076
+ children: split ? pairedTrackRows(taskBlocks, subagentBlocks).map(([task, subagent], index) => /* @__PURE__ */ jsxs2(Box_default, { flexDirection: "row", width: "100%", columnGap: 2, children: [
1077
+ /* @__PURE__ */ jsx3(Box_default, { flexBasis: 0, flexGrow: 1, minWidth: 0, flexDirection: "column", children: task === void 0 ? null : /* @__PURE__ */ jsx3(TaskStatusLine, { block: task, interactive }) }),
1078
+ /* @__PURE__ */ jsx3(Box_default, { flexBasis: 0, flexGrow: 1, minWidth: 0, flexDirection: "column", children: subagent === void 0 ? null : /* @__PURE__ */ jsx3(TaskStatusLine, { block: subagent, interactive }) })
1079
+ ] }, `${task?.id ?? "task"}:${subagent?.id ?? "subagent"}:${index}`)) : hasTasks && hasSubagents ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
1080
+ taskBlocks.map((block) => /* @__PURE__ */ jsx3(TaskStatusLine, { block, interactive }, block.id)),
1081
+ /* @__PURE__ */ jsx3(TrackHeader, { role: "subagent" }),
1082
+ subagentBlocks.map((block) => /* @__PURE__ */ jsx3(TaskStatusLine, { block, interactive }, block.id))
1083
+ ] }) : (hasTasks ? taskBlocks : subagentBlocks).map((block) => /* @__PURE__ */ jsx3(TaskStatusLine, { block, interactive }, block.id))
1068
1084
  }
1069
1085
  ) : null
1070
1086
  ]
1071
1087
  }
1072
1088
  );
1073
1089
  }
1090
+ function TrackHeader({ role }) {
1091
+ return /* @__PURE__ */ jsxs2(Text, { dimColor: true, children: [
1092
+ "\u2500\u2500 ",
1093
+ role === "main" ? "task plan" : "subagent exploration",
1094
+ " \u2500\u2500"
1095
+ ] });
1096
+ }
1097
+ function SplitTrackHeaders() {
1098
+ return /* @__PURE__ */ jsxs2(Box_default, { flexDirection: "row", width: "100%", columnGap: 2, children: [
1099
+ /* @__PURE__ */ jsx3(Box_default, { flexBasis: 0, flexGrow: 1, minWidth: 0, children: /* @__PURE__ */ jsx3(TrackHeader, { role: "main" }) }),
1100
+ /* @__PURE__ */ jsx3(Box_default, { flexBasis: 0, flexGrow: 1, minWidth: 0, children: /* @__PURE__ */ jsx3(TrackHeader, { role: "subagent" }) })
1101
+ ] });
1102
+ }
1103
+ function pairedTrackRows(tasks, subagents) {
1104
+ return Array.from({ length: Math.max(tasks.length, subagents.length) }, (_, index) => [tasks[index], subagents[index]]);
1105
+ }
1074
1106
 
1075
1107
  // src/ui/file-diff-style.ts
1076
1108
  var CONTENT = "#f8f8f2";
@@ -2550,6 +2582,7 @@ function TerminalLayout({
2550
2582
  blocks: activeTaskBlocks,
2551
2583
  interactive: activeSession,
2552
2584
  maxHeight: taskPanelRows,
2585
+ columns,
2553
2586
  ...taskScrollRef === void 0 ? {} : { scrollRef: taskScrollRef },
2554
2587
  ...onTaskPanelHoverChange === void 0 ? {} : { onHoverChange: onTaskPanelHoverChange }
2555
2588
  }
@@ -1399,7 +1399,7 @@ function transcriptReducer(state, action) {
1399
1399
  return finishActive(withUsage);
1400
1400
  }
1401
1401
  if (event.type === "text") {
1402
- return { ...state, active: addText(withoutModelActivity(state.active), event.text) };
1402
+ return { ...state, active: addStreamingText(state.active, event.text) };
1403
1403
  }
1404
1404
  if (event.type === "thinking") {
1405
1405
  return { ...state, active: attachThinking(state.active, event.text) };
@@ -1857,6 +1857,17 @@ function addText(turn, text, onNewLine = false) {
1857
1857
  }
1858
1858
  return withBlocks({ ...turn, assistantText }, blocks);
1859
1859
  }
1860
+ function addStreamingText(turn, text) {
1861
+ const activity = turn.blocks.find((block) => block.kind === "status" && block.activity === "model" && block.state === "running");
1862
+ if (activity === void 0) return addText(turn, text);
1863
+ const withoutActivity = withBlocks(turn, turn.blocks.filter((block) => block !== activity));
1864
+ const withText = addText(withoutActivity, text);
1865
+ const { thinkingText: _thinkingText, ...writingActivity } = activity;
1866
+ return withBlocks(withText, [...withText.blocks, {
1867
+ ...writingActivity,
1868
+ text: "Writing response"
1869
+ }]);
1870
+ }
1860
1871
  function boundedTranscriptBlock(block) {
1861
1872
  const presentation = block.presentation === void 0 ? void 0 : boundedTranscriptPresentation(block.presentation);
1862
1873
  const tool = block.tool === void 0 ? void 0 : {
@@ -6856,6 +6867,7 @@ import { mkdirSync as mkdirSync4, readFileSync as readFileSync3, renameSync as r
6856
6867
  import { createHash as createHash18, randomUUID as randomUUID20 } from "crypto";
6857
6868
  import { homedir as homedir3, release as osRelease, tmpdir as tmpdir4, version as osVersion } from "os";
6858
6869
  import { basename as basename7, dirname as dirname17, join as join30, relative as relative22, resolve as resolve31, sep as sep22 } from "path";
6870
+ import { performance } from "perf_hooks";
6859
6871
 
6860
6872
  // src/agent/subagents.ts
6861
6873
  import { z as z9 } from "zod";
@@ -18826,10 +18838,12 @@ var LspConnection = class {
18826
18838
  this.#disposed = true;
18827
18839
  this.#rejectAll(new Error("LSP connection disposed"));
18828
18840
  this.#shutdownPromise = (async () => {
18841
+ const closed = waitForProcessClose(this.#process);
18829
18842
  await terminateProcessTree(this.#process.pid);
18830
18843
  this.#process.stdin.destroy();
18831
18844
  this.#process.stdout.destroy();
18832
18845
  this.#process.stderr.destroy();
18846
+ await closed;
18833
18847
  })();
18834
18848
  return this.#shutdownPromise;
18835
18849
  }
@@ -18948,6 +18962,18 @@ var LspConnection = class {
18948
18962
  this.#pending.clear();
18949
18963
  }
18950
18964
  };
18965
+ function waitForProcessClose(child) {
18966
+ if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();
18967
+ return new Promise((resolveClose) => {
18968
+ const finish = () => {
18969
+ clearTimeout(timer);
18970
+ resolveClose();
18971
+ };
18972
+ const timer = setTimeout(finish, 2e3);
18973
+ timer.unref();
18974
+ child.once("close", finish);
18975
+ });
18976
+ }
18951
18977
  var LspBuffer = class {
18952
18978
  #data = Buffer.alloc(0);
18953
18979
  feed(chunk, onMessage) {
@@ -18978,7 +19004,7 @@ var TYPESCRIPT_CLI = resolve23(
18978
19004
  var KNOWN_SERVERS = [
18979
19005
  {
18980
19006
  language: "typescript",
18981
- extensions: [".ts", ".tsx", ".mts", ".cts"],
19007
+ extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"],
18982
19008
  command: process.execPath,
18983
19009
  args: [TYPESCRIPT_CLI, "--lsp", "--stdio"],
18984
19010
  rootFiles: ["tsconfig.json", "jsconfig.json"]
@@ -19063,35 +19089,39 @@ var RealLspManager = class {
19063
19089
  if (this.#disposed) throw new Error("LSP manager is disposed");
19064
19090
  const language = this.#languageForUri(uri);
19065
19091
  if (language === void 0) throw new Error(`No language server configured for ${uri}; use Read/Grep or the project compiler`);
19066
- const existing = this.#connections.get(language);
19067
- if (existing !== void 0) return existing;
19068
- const pending = this.#pendingStarts.get(language);
19069
- if (pending !== void 0) return pending;
19070
19092
  const config = this.#serverConfigs.find((c) => c.language === language);
19071
19093
  if (config === void 0) throw new Error(`No language server configured for ${language}`);
19072
- const hasRoot = config.rootFiles.some((file) => existsSync5(resolve23(this.#workspace, file)));
19073
- if (!hasRoot) throw new Error(`Cannot start ${language} language server: workspace needs ${config.rootFiles.join(" or ")}`);
19074
- const startPromise = this.#startServer(config);
19075
- this.#pendingStarts.set(language, startPromise);
19094
+ const filePath = uriToPath(uri);
19095
+ const projectRoot = findLanguageServerRoot(filePath, this.#workspace, config.rootFiles);
19096
+ if (projectRoot === void 0) {
19097
+ throw new Error(`Cannot start ${language} language server: no ${config.rootFiles.join(" or ")} found from ${dirname15(filePath)} up to workspace ${this.#workspace}`);
19098
+ }
19099
+ const connectionKey = `${language}:${projectRoot}`;
19100
+ const existing = this.#connections.get(connectionKey);
19101
+ if (existing !== void 0) return existing;
19102
+ const pending = this.#pendingStarts.get(connectionKey);
19103
+ if (pending !== void 0) return pending;
19104
+ const startPromise = this.#startServer(config, projectRoot);
19105
+ this.#pendingStarts.set(connectionKey, startPromise);
19076
19106
  try {
19077
19107
  const connection = await startPromise;
19078
19108
  if (this.#disposed) {
19079
19109
  await connection.shutdown();
19080
19110
  throw new Error("LSP manager is disposed");
19081
19111
  }
19082
- this.#connections.set(language, connection);
19112
+ this.#connections.set(connectionKey, connection);
19083
19113
  return connection;
19084
19114
  } finally {
19085
- this.#pendingStarts.delete(language);
19115
+ this.#pendingStarts.delete(connectionKey);
19086
19116
  }
19087
19117
  }
19088
- async #startServer(config) {
19118
+ async #startServer(config, projectRoot) {
19089
19119
  try {
19090
19120
  await access2(config.command, constants10.X_OK);
19091
19121
  } catch {
19092
19122
  }
19093
- const connection = new LspConnection(config.command, config.args, this.#workspace);
19094
- const rootUri = pathToFileURL2(this.#workspace).href;
19123
+ const connection = new LspConnection(config.command, config.args, projectRoot);
19124
+ const rootUri = pathToFileURL2(projectRoot).href;
19095
19125
  try {
19096
19126
  await connection.initialize(rootUri);
19097
19127
  this.#onStatus?.(`${config.language} Language Server ready (${config.command})`);
@@ -19127,7 +19157,21 @@ function createLspTools(workspace, options = {}) {
19127
19157
  const toUri = (filePath) => pathToFileURL2(filePath).href;
19128
19158
  const langTag = (file) => {
19129
19159
  const ext = file.slice(file.lastIndexOf(".")).toLowerCase();
19130
- const map = { ".ts": "ts", ".tsx": "tsx", ".mts": "ts", ".cts": "ts", ".py": "py", ".pyi": "py", ".pyx": "py", ".rs": "rs", ".go": "go" };
19160
+ const map = {
19161
+ ".ts": "ts",
19162
+ ".tsx": "tsx",
19163
+ ".mts": "ts",
19164
+ ".cts": "ts",
19165
+ ".js": "js",
19166
+ ".jsx": "jsx",
19167
+ ".mjs": "js",
19168
+ ".cjs": "js",
19169
+ ".py": "py",
19170
+ ".pyi": "py",
19171
+ ".pyx": "py",
19172
+ ".rs": "rs",
19173
+ ".go": "go"
19174
+ };
19131
19175
  const tag = map[ext];
19132
19176
  return tag === void 0 ? "" : " [" + tag + "]";
19133
19177
  };
@@ -19195,6 +19239,12 @@ function languageIdForPath(filePath) {
19195
19239
  return "typescript";
19196
19240
  case ".cts":
19197
19241
  return "typescript";
19242
+ case ".jsx":
19243
+ return "javascriptreact";
19244
+ case ".js":
19245
+ case ".mjs":
19246
+ case ".cjs":
19247
+ return "javascript";
19198
19248
  case ".py":
19199
19249
  case ".pyi":
19200
19250
  case ".pyx":
@@ -19207,6 +19257,19 @@ function languageIdForPath(filePath) {
19207
19257
  return "typescript";
19208
19258
  }
19209
19259
  }
19260
+ function findLanguageServerRoot(filePath, workspace, rootFiles) {
19261
+ const root = resolve23(workspace);
19262
+ const target = resolve23(filePath);
19263
+ if (!isWithin7(root, target)) return void 0;
19264
+ let current = dirname15(target);
19265
+ while (true) {
19266
+ if (rootFiles.some((file) => existsSync5(resolve23(current, file)))) return current;
19267
+ if (current === root) return void 0;
19268
+ const parent = dirname15(current);
19269
+ if (parent === current || !isWithin7(root, parent)) return void 0;
19270
+ current = parent;
19271
+ }
19272
+ }
19210
19273
  function isWithin7(root, candidate) {
19211
19274
  const delta = relative17(root, candidate);
19212
19275
  return delta === "" || !delta.startsWith(`..${sep17}`) && delta !== ".." && !isAbsolute12(delta);
@@ -24238,6 +24301,12 @@ async function createProductionRuntime(options) {
24238
24301
  holders.transcriptTurns = { entries: transcript.turns };
24239
24302
  } catch {
24240
24303
  }
24304
+ try {
24305
+ holders.userTiming = {
24306
+ entries: performance.getEntriesByType("measure").length + performance.getEntriesByType("mark").length
24307
+ };
24308
+ } catch {
24309
+ }
24241
24310
  return holders;
24242
24311
  };
24243
24312
  const rotateForHeap = (continuation, reading) => {
@@ -4,7 +4,7 @@ import {
4
4
  message,
5
5
  redactErrorText,
6
6
  redactSecrets
7
- } from "./chunk-J7TLT6LR.js";
7
+ } from "./chunk-ITKOMJD6.js";
8
8
 
9
9
  // src/rpc/server.ts
10
10
  import { createInterface } from "readline";
@@ -28,13 +28,13 @@ function statusPresentation(block, elapsedMs, interactive) {
28
28
  if (block.state === "running" && block.activity === "model") {
29
29
  return interactive ? {
30
30
  glyph: activityFrame(elapsedMs),
31
- text: "Flavoring",
31
+ text: block.text,
32
32
  color: "#81c8f2",
33
33
  metaLabel: formatElapsed(elapsedMs),
34
34
  metaColor: "ansi:blackBright"
35
35
  } : {
36
36
  glyph: "\xB7",
37
- text: "Flavoring",
37
+ text: block.text,
38
38
  color: "#81c8f2"
39
39
  };
40
40
  }