flavor-code 1.4.0-beta.1 → 1.4.0-beta.4

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.
Files changed (159) hide show
  1. package/dist/agent/loop.d.ts +7 -2
  2. package/dist/{app-C5ZQUOKJ.js → app-UWIEIWBQ.js} +7 -7
  3. package/dist/{chunk-FOTMP4ZS.js → chunk-4RR5VVX4.js} +8 -2
  4. package/dist/{chunk-6MNOZ2TX.js → chunk-DCNUBQCH.js} +1376 -641
  5. package/dist/{chunk-ODRWR4KK.js → chunk-IQAZ42TM.js} +1 -1
  6. package/dist/{chunk-URUVFECH.js → chunk-KQMKY7C5.js} +8 -4
  7. package/dist/chunk-LKQTBL3R.js +107 -0
  8. package/dist/{chunk-3WCDZ6ZL.js → chunk-ZJCAQXA7.js} +2 -1
  9. package/dist/{claude-ink-LP32NSX5.js → claude-ink-ECZ6QF3P.js} +2 -2
  10. package/dist/cli-main.js +22 -15
  11. package/dist/cli.js +24 -5
  12. package/dist/config/schema.d.ts +4 -0
  13. package/dist/context/manager.d.ts +9 -0
  14. package/dist/desktop/main.js +1770 -949
  15. package/dist/desktop-renderer/assets/{index-CqRIr-hz.js → index-C0t1nGih.js} +2 -2
  16. package/dist/desktop-renderer/assets/{interactive-terminal-C4o7MNPO.js → interactive-terminal-BJqe96mZ.js} +1 -1
  17. package/dist/desktop-renderer/index.html +1 -1
  18. package/dist/git/service.d.ts +3 -3
  19. package/dist/git/tools.d.ts +1 -1
  20. package/dist/goal/classifier.d.ts +2 -0
  21. package/dist/goal/orchestrator.d.ts +18 -0
  22. package/dist/goal/planner.d.ts +2 -0
  23. package/dist/goal/store.d.ts +2 -0
  24. package/dist/goal/types.d.ts +8 -0
  25. package/dist/harness/journal.d.ts +2 -0
  26. package/dist/harness/local.d.ts +2 -0
  27. package/dist/init/project.d.ts +0 -6
  28. package/dist/jobs/registry.d.ts +7 -1
  29. package/dist/{load-V2UIYYQI.js → load-F4AYLCF6.js} +1 -1
  30. package/dist/loop/orchestrator.d.ts +18 -0
  31. package/dist/loop/types.d.ts +7 -0
  32. package/dist/production.d.ts +17 -0
  33. package/dist/sdk/index.js +5 -5
  34. package/dist/session/tree.d.ts +2 -0
  35. package/dist/tools/lsp.d.ts +13 -10
  36. package/dist/tools/runtime.d.ts +2 -1
  37. package/dist/tools/search.d.ts +1 -0
  38. package/dist/tools/types.d.ts +1 -1
  39. package/dist/ui/session.d.ts +9 -0
  40. package/dist/utils/abort.d.ts +4 -0
  41. package/dist/utils/execFileNoThrow.d.ts +1 -0
  42. package/dist/utils/heap.d.ts +58 -0
  43. package/dist/utils/memory-restart.d.ts +38 -3
  44. package/dist/utils/process-tree.d.ts +2 -0
  45. package/dist/utils/rotation-census.d.ts +36 -0
  46. package/package.json +2 -2
  47. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +7 -7
  48. package/dist/astgraph/db.mjs +0 -237
  49. package/dist/astgraph/extract.mjs +0 -239
  50. package/dist/astgraph/flavor-plugin.json +0 -25
  51. package/dist/astgraph/grammars.mjs +0 -68
  52. package/dist/astgraph/index.js +0 -301
  53. package/dist/astgraph/indexer.mjs +0 -175
  54. package/dist/astgraph/query.mjs +0 -165
  55. package/dist/astgraph/resolve.mjs +0 -93
  56. package/dist/astgraph/vendor/tree-sitter-javascript.wasm +0 -0
  57. package/dist/astgraph/vendor/tree-sitter-tsx.wasm +0 -0
  58. package/dist/astgraph/vendor/tree-sitter-typescript.wasm +0 -0
  59. package/dist/astgraph/vendor/tree-sitter.js +0 -3980
  60. package/dist/astgraph/vendor/tree-sitter.wasm +0 -0
  61. package/dist/astgraph/vendor/zod/LICENSE +0 -21
  62. package/dist/astgraph/vendor/zod/index.js +0 -4
  63. package/dist/astgraph/vendor/zod/locales/index.js +0 -1
  64. package/dist/astgraph/vendor/zod/locales/package.json +0 -7
  65. package/dist/astgraph/vendor/zod/package.json +0 -135
  66. package/dist/astgraph/vendor/zod/v4/classic/checks.js +0 -1
  67. package/dist/astgraph/vendor/zod/v4/classic/coerce.js +0 -17
  68. package/dist/astgraph/vendor/zod/v4/classic/compat.js +0 -31
  69. package/dist/astgraph/vendor/zod/v4/classic/errors.js +0 -48
  70. package/dist/astgraph/vendor/zod/v4/classic/external.js +0 -20
  71. package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +0 -599
  72. package/dist/astgraph/vendor/zod/v4/classic/index.js +0 -4
  73. package/dist/astgraph/vendor/zod/v4/classic/iso.js +0 -30
  74. package/dist/astgraph/vendor/zod/v4/classic/package.json +0 -7
  75. package/dist/astgraph/vendor/zod/v4/classic/parse.js +0 -15
  76. package/dist/astgraph/vendor/zod/v4/classic/schemas.js +0 -1395
  77. package/dist/astgraph/vendor/zod/v4/core/api.js +0 -1087
  78. package/dist/astgraph/vendor/zod/v4/core/checks.js +0 -575
  79. package/dist/astgraph/vendor/zod/v4/core/core.js +0 -78
  80. package/dist/astgraph/vendor/zod/v4/core/doc.js +0 -35
  81. package/dist/astgraph/vendor/zod/v4/core/errors.js +0 -185
  82. package/dist/astgraph/vendor/zod/v4/core/index.js +0 -16
  83. package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +0 -95
  84. package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +0 -601
  85. package/dist/astgraph/vendor/zod/v4/core/json-schema.js +0 -1
  86. package/dist/astgraph/vendor/zod/v4/core/package.json +0 -7
  87. package/dist/astgraph/vendor/zod/v4/core/parse.js +0 -93
  88. package/dist/astgraph/vendor/zod/v4/core/regexes.js +0 -139
  89. package/dist/astgraph/vendor/zod/v4/core/registries.js +0 -51
  90. package/dist/astgraph/vendor/zod/v4/core/schemas.js +0 -2239
  91. package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +0 -1
  92. package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +0 -448
  93. package/dist/astgraph/vendor/zod/v4/core/util.js +0 -674
  94. package/dist/astgraph/vendor/zod/v4/core/versions.js +0 -5
  95. package/dist/astgraph/vendor/zod/v4/index.js +0 -3
  96. package/dist/astgraph/vendor/zod/v4/locales/ar.js +0 -106
  97. package/dist/astgraph/vendor/zod/v4/locales/az.js +0 -105
  98. package/dist/astgraph/vendor/zod/v4/locales/be.js +0 -156
  99. package/dist/astgraph/vendor/zod/v4/locales/bg.js +0 -120
  100. package/dist/astgraph/vendor/zod/v4/locales/ca.js +0 -107
  101. package/dist/astgraph/vendor/zod/v4/locales/cs.js +0 -111
  102. package/dist/astgraph/vendor/zod/v4/locales/da.js +0 -115
  103. package/dist/astgraph/vendor/zod/v4/locales/de.js +0 -108
  104. package/dist/astgraph/vendor/zod/v4/locales/el.js +0 -109
  105. package/dist/astgraph/vendor/zod/v4/locales/en.js +0 -113
  106. package/dist/astgraph/vendor/zod/v4/locales/eo.js +0 -109
  107. package/dist/astgraph/vendor/zod/v4/locales/es.js +0 -132
  108. package/dist/astgraph/vendor/zod/v4/locales/fa.js +0 -114
  109. package/dist/astgraph/vendor/zod/v4/locales/fi.js +0 -112
  110. package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +0 -107
  111. package/dist/astgraph/vendor/zod/v4/locales/fr.js +0 -125
  112. package/dist/astgraph/vendor/zod/v4/locales/he.js +0 -214
  113. package/dist/astgraph/vendor/zod/v4/locales/hr.js +0 -122
  114. package/dist/astgraph/vendor/zod/v4/locales/hu.js +0 -108
  115. package/dist/astgraph/vendor/zod/v4/locales/hy.js +0 -147
  116. package/dist/astgraph/vendor/zod/v4/locales/id.js +0 -106
  117. package/dist/astgraph/vendor/zod/v4/locales/index.js +0 -52
  118. package/dist/astgraph/vendor/zod/v4/locales/is.js +0 -109
  119. package/dist/astgraph/vendor/zod/v4/locales/it.js +0 -108
  120. package/dist/astgraph/vendor/zod/v4/locales/ja.js +0 -107
  121. package/dist/astgraph/vendor/zod/v4/locales/ka.js +0 -112
  122. package/dist/astgraph/vendor/zod/v4/locales/kh.js +0 -5
  123. package/dist/astgraph/vendor/zod/v4/locales/km.js +0 -110
  124. package/dist/astgraph/vendor/zod/v4/locales/ko.js +0 -111
  125. package/dist/astgraph/vendor/zod/v4/locales/lt.js +0 -203
  126. package/dist/astgraph/vendor/zod/v4/locales/mk.js +0 -109
  127. package/dist/astgraph/vendor/zod/v4/locales/ms.js +0 -107
  128. package/dist/astgraph/vendor/zod/v4/locales/nl.js +0 -110
  129. package/dist/astgraph/vendor/zod/v4/locales/no.js +0 -108
  130. package/dist/astgraph/vendor/zod/v4/locales/ota.js +0 -109
  131. package/dist/astgraph/vendor/zod/v4/locales/package.json +0 -7
  132. package/dist/astgraph/vendor/zod/v4/locales/pl.js +0 -109
  133. package/dist/astgraph/vendor/zod/v4/locales/ps.js +0 -114
  134. package/dist/astgraph/vendor/zod/v4/locales/pt.js +0 -108
  135. package/dist/astgraph/vendor/zod/v4/locales/ro.js +0 -119
  136. package/dist/astgraph/vendor/zod/v4/locales/ru.js +0 -156
  137. package/dist/astgraph/vendor/zod/v4/locales/sl.js +0 -109
  138. package/dist/astgraph/vendor/zod/v4/locales/sv.js +0 -110
  139. package/dist/astgraph/vendor/zod/v4/locales/ta.js +0 -110
  140. package/dist/astgraph/vendor/zod/v4/locales/th.js +0 -110
  141. package/dist/astgraph/vendor/zod/v4/locales/tr.js +0 -105
  142. package/dist/astgraph/vendor/zod/v4/locales/ua.js +0 -5
  143. package/dist/astgraph/vendor/zod/v4/locales/uk.js +0 -108
  144. package/dist/astgraph/vendor/zod/v4/locales/ur.js +0 -110
  145. package/dist/astgraph/vendor/zod/v4/locales/uz.js +0 -110
  146. package/dist/astgraph/vendor/zod/v4/locales/vi.js +0 -108
  147. package/dist/astgraph/vendor/zod/v4/locales/yo.js +0 -107
  148. package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +0 -109
  149. package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +0 -107
  150. package/dist/astgraph/vendor/zod/v4/mini/checks.js +0 -1
  151. package/dist/astgraph/vendor/zod/v4/mini/coerce.js +0 -22
  152. package/dist/astgraph/vendor/zod/v4/mini/external.js +0 -14
  153. package/dist/astgraph/vendor/zod/v4/mini/index.js +0 -3
  154. package/dist/astgraph/vendor/zod/v4/mini/iso.js +0 -34
  155. package/dist/astgraph/vendor/zod/v4/mini/package.json +0 -7
  156. package/dist/astgraph/vendor/zod/v4/mini/parse.js +0 -1
  157. package/dist/astgraph/vendor/zod/v4/mini/schemas.js +0 -961
  158. package/dist/astgraph/vendor/zod/v4/package.json +0 -7
  159. package/dist/chunk-CIVPKHF4.js +0 -53
@@ -5,7 +5,7 @@ import {
5
5
  getGraphemeSegmenter,
6
6
  isEnvTruthy,
7
7
  logError
8
- } from "./chunk-3WCDZ6ZL.js";
8
+ } from "./chunk-ZJCAQXA7.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __require,
@@ -117,16 +117,20 @@ var FlavorConfigSchema = z.object({
117
117
  evaluationTimeoutMs: z.number().int().min(100).max(3e4).default(2e3)
118
118
  }).prefault({}),
119
119
  maxIterations: z.object({
120
- main: z.number().int().min(10).max(500).default(80),
121
- subagent: z.number().int().min(10).max(200).default(40),
120
+ main: z.number().int().min(10).max(500).default(300),
121
+ subagent: z.number().int().min(10).max(200).default(100),
122
122
  softLimitFactor: z.number().min(0.5).max(1).default(0.8),
123
- extendBy: z.number().int().min(5).max(100).default(20)
123
+ extendBy: z.number().int().min(5).max(100).default(50)
124
124
  }).prefault({}),
125
125
  loop: z.object({
126
- maxCycles: z.number().int().positive().max(1e4).default(20),
126
+ maxCycles: z.number().int().positive().max(1e4).default(100),
127
127
  maxTokens: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).default(5e5),
128
128
  isolation: z.literal("auto").default("auto")
129
129
  }).prefault({}),
130
+ goal: z.object({
131
+ maxRounds: z.number().int().positive().max(1e4).default(100),
132
+ maxStallStreak: z.number().int().positive().max(100).default(3)
133
+ }).prefault({}),
130
134
  context: z.object({
131
135
  windowTokens: z.number().int().positive().default(2e5),
132
136
  reservedOutputTokens: z.number().int().nonnegative().default(2e4),
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
3
+
4
+ // src/utils/memory-restart.ts
5
+ import { join } from "path";
6
+ var MEMORY_RESTART_EXIT_CODE = 75;
7
+ var MEMORY_RESTART_MARKER_FILE = "memory-restart.json";
8
+ var MEMORY_RESTART_MAX_ATTEMPTS = 24;
9
+ var MEMORY_RESTART_WINDOW_MS = 60 * 60 * 1e3;
10
+ var MEMORY_RESTART_MIN_GAP_MS = 5 * 60 * 1e3;
11
+ var MEMORY_RESTART_CONTINUATION_TTL_MS = 10 * 60 * 1e3;
12
+ var SESSION_ID_PATTERN = /^session-[A-Za-z0-9_-]+$/u;
13
+ var rotationActive = false;
14
+ function markMemoryRotation() {
15
+ rotationActive = true;
16
+ }
17
+ function memoryRotationActive() {
18
+ return rotationActive;
19
+ }
20
+ function memoryRestartMarkerPath(workspace) {
21
+ return join(workspace, ".flavor", "tmp", MEMORY_RESTART_MARKER_FILE);
22
+ }
23
+ function nextMemoryRestartMarker(previous, sessionId, now, continuation) {
24
+ const previousWindowStart = previous?.windowStartedAt ?? previous?.requestedAt;
25
+ const reusable = previous !== void 0 && previous.sessionId === sessionId && previousWindowStart !== void 0 && now.getTime() - Date.parse(previousWindowStart) < MEMORY_RESTART_WINDOW_MS && Number.isInteger(previous.attempts) && previous.attempts > 0;
26
+ return {
27
+ sessionId,
28
+ windowStartedAt: reusable ? previousWindowStart : now.toISOString(),
29
+ requestedAt: now.toISOString(),
30
+ attempts: reusable ? previous.attempts + 1 : 1,
31
+ ...continuation === void 0 ? {} : { continuation }
32
+ };
33
+ }
34
+ function consumedMemoryRestartMarker(marker) {
35
+ return {
36
+ sessionId: marker.sessionId,
37
+ ...marker.windowStartedAt === void 0 ? {} : { windowStartedAt: marker.windowStartedAt },
38
+ requestedAt: marker.requestedAt,
39
+ attempts: marker.attempts
40
+ };
41
+ }
42
+ function rotationCooldownActive(marker, sessionId, now) {
43
+ return marker !== void 0 && marker.sessionId === sessionId && now.getTime() - Date.parse(marker.requestedAt) < MEMORY_RESTART_MIN_GAP_MS;
44
+ }
45
+ function pendingContinuation(marker, sessionId, now) {
46
+ if (marker === void 0 || marker.sessionId !== sessionId) return void 0;
47
+ if (now.getTime() - Date.parse(marker.requestedAt) > MEMORY_RESTART_CONTINUATION_TTL_MS) return void 0;
48
+ const continuation = marker.continuation;
49
+ if (continuation === void 0) return void 0;
50
+ if (continuation.kind !== "loop" && continuation.kind !== "goal") return void 0;
51
+ if (typeof continuation.id !== "string" || continuation.id.length === 0) return void 0;
52
+ return continuation;
53
+ }
54
+ function shouldRelaunchForMemoryRestart(marker) {
55
+ return marker !== void 0 && SESSION_ID_PATTERN.test(marker.sessionId) && Number.isInteger(marker.attempts) && marker.attempts >= 1 && marker.attempts <= MEMORY_RESTART_MAX_ATTEMPTS;
56
+ }
57
+ function memoryRestartArgs(argv, marker) {
58
+ if (!shouldRelaunchForMemoryRestart(marker)) return void 0;
59
+ const stripped = [];
60
+ for (let index = 0; index < argv.length; index += 1) {
61
+ const argument = argv[index];
62
+ if (argument === "--resume") {
63
+ if (index + 1 < argv.length && !argv[index + 1].startsWith("-")) index += 1;
64
+ continue;
65
+ }
66
+ if (argument.startsWith("--resume=")) continue;
67
+ if (argument === "--memory-restart") continue;
68
+ stripped.push(argument);
69
+ }
70
+ return [...stripped, "--resume", marker.sessionId, "--memory-restart"];
71
+ }
72
+ function parseMemoryRestartMarker(json) {
73
+ try {
74
+ const value = JSON.parse(json);
75
+ if (typeof value.sessionId !== "string" || typeof value.requestedAt !== "string" || typeof value.attempts !== "number") {
76
+ return void 0;
77
+ }
78
+ const continuation = value.continuation;
79
+ if (continuation !== void 0 && (typeof continuation !== "object" || continuation === null || continuation.kind !== "loop" && continuation.kind !== "goal" || typeof continuation.id !== "string")) {
80
+ return void 0;
81
+ }
82
+ const windowStartedAt = value.windowStartedAt;
83
+ if (windowStartedAt !== void 0 && typeof windowStartedAt !== "string") return void 0;
84
+ return {
85
+ sessionId: value.sessionId,
86
+ ...windowStartedAt === void 0 ? {} : { windowStartedAt },
87
+ requestedAt: value.requestedAt,
88
+ attempts: value.attempts,
89
+ ...continuation === void 0 ? {} : { continuation }
90
+ };
91
+ } catch {
92
+ return void 0;
93
+ }
94
+ }
95
+
96
+ export {
97
+ MEMORY_RESTART_EXIT_CODE,
98
+ markMemoryRotation,
99
+ memoryRotationActive,
100
+ memoryRestartMarkerPath,
101
+ nextMemoryRestartMarker,
102
+ consumedMemoryRestartMarker,
103
+ rotationCooldownActive,
104
+ pendingContinuation,
105
+ memoryRestartArgs,
106
+ parseMemoryRestartMarker
107
+ };
@@ -10,7 +10,8 @@ function execFileNoThrow(file, args, options = {}) {
10
10
  cwd: options.useCwd === false ? void 0 : process.cwd(),
11
11
  env: options.env,
12
12
  encoding: "utf8",
13
- windowsHide: true
13
+ windowsHide: true,
14
+ ...options.signal === void 0 ? {} : { signal: options.signal }
14
15
  }, (error, stdout, stderr) => {
15
16
  resolve2({
16
17
  stdout,
@@ -10,8 +10,8 @@ import {
10
10
  useStdout,
11
11
  use_app_default,
12
12
  use_input_default
13
- } from "./chunk-ODRWR4KK.js";
14
- import "./chunk-3WCDZ6ZL.js";
13
+ } from "./chunk-IQAZ42TM.js";
14
+ import "./chunk-ZJCAQXA7.js";
15
15
  import "./chunk-S32JRDZK.js";
16
16
  export {
17
17
  AlternateScreen,
package/dist/cli-main.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
3
3
  import {
4
4
  FlavorRpcServer,
5
5
  TraceRecorder
6
- } from "./chunk-FOTMP4ZS.js";
6
+ } from "./chunk-4RR5VVX4.js";
7
7
  import {
8
8
  staticTaskLines
9
9
  } from "./chunk-2BF7CVWZ.js";
@@ -29,8 +29,10 @@ import {
29
29
  redactErrorText,
30
30
  runDoctor,
31
31
  runPalBroker
32
- } from "./chunk-6MNOZ2TX.js";
33
- import "./chunk-CIVPKHF4.js";
32
+ } from "./chunk-DCNUBQCH.js";
33
+ import {
34
+ MEMORY_RESTART_EXIT_CODE
35
+ } from "./chunk-LKQTBL3R.js";
34
36
  import {
35
37
  McpServerConfigSchema,
36
38
  McpServerNameSchema,
@@ -39,11 +41,11 @@ import {
39
41
  readRecoverableFile,
40
42
  setProjectSkillDisabled,
41
43
  updateProtectedFile
42
- } from "./chunk-URUVFECH.js";
44
+ } from "./chunk-KQMKY7C5.js";
43
45
  import {
44
46
  gt,
45
47
  isValidVersion
46
- } from "./chunk-3WCDZ6ZL.js";
48
+ } from "./chunk-ZJCAQXA7.js";
47
49
  import "./chunk-S32JRDZK.js";
48
50
 
49
51
  // src/cli.tsx
@@ -728,7 +730,7 @@ async function runEvaluationFile(path, outputPath) {
728
730
  })),
729
731
  ...parsed.maxTokens === void 0 ? {} : { maxTokens: parsed.maxTokens }
730
732
  };
731
- const configured = await import("./load-V2UIYYQI.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
733
+ const configured = await import("./load-F4AYLCF6.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
732
734
  const environment = createExecutionEnvironment(workspace, configured.config.execution) ?? new LocalExecutionEnvironment();
733
735
  let report;
734
736
  try {
@@ -752,7 +754,7 @@ async function runEvaluationFile(path, outputPath) {
752
754
 
753
755
  // src/cli.tsx
754
756
  function createProgram(dependencies = {}) {
755
- const program = new Command().name("flavor").description("Interactive coding agent").version(packageVersion()).option("-p, --print <prompt>", "run one prompt without the interactive UI").option("--resume [session-id]", "resume a saved session (latest when id is omitted)").option("--mode <mode>", "runtime mode: interactive or rpc").option("--workspace <path>", "workspace path (RPC mode)").option("--rpc-approvals", "allow an RPC client to resolve interactive tool approvals").option("--rpc-streamed-writes", "stream proposed file writes to an RPC client before committing them").option("--trace <path>", "write a redacted JSONL execution trace").option("--pal-name <alias>", "name this interactive Flavor instance for /pals and /chat").addOption(new Option("--pals-broker <address>").hideHelp());
757
+ const program = new Command().name("flavor").description("Interactive coding agent").version(packageVersion()).option("-p, --print <prompt>", "run one prompt without the interactive UI").option("--resume [session-id]", "resume a saved session (latest when id is omitted)").option("--mode <mode>", "runtime mode: interactive or rpc").option("--workspace <path>", "workspace path (RPC mode)").option("--rpc-approvals", "allow an RPC client to resolve interactive tool approvals").option("--rpc-streamed-writes", "stream proposed file writes to an RPC client before committing them").option("--trace <path>", "write a redacted JSONL execution trace").option("--pal-name <alias>", "name this interactive Flavor instance for /pals and /chat").addOption(new Option("--memory-restart").hideHelp()).addOption(new Option("--pals-broker <address>").hideHelp());
756
758
  program.command("init [directory]").description("Initialize Flavor project files in a directory (defaults to cwd)").action(async (directory) => {
757
759
  const cwd = directory ? resolve3(directory) : process.cwd();
758
760
  try {
@@ -869,7 +871,7 @@ function createProgram(dependencies = {}) {
869
871
  return;
870
872
  }
871
873
  if (options.print !== void 0) {
872
- process.exitCode = await runPrint(options.print, {}, resumeSession);
874
+ process.exitCode = await runPrint(options.print, {}, resumeSession, options.memoryRestart === true);
873
875
  return;
874
876
  }
875
877
  if (!(dependencies.isTTY?.() ?? process.stdin.isTTY)) {
@@ -896,9 +898,9 @@ function createProgram(dependencies = {}) {
896
898
  }
897
899
  async function runInteractiveCli(props) {
898
900
  const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
899
- import("./claude-ink-LP32NSX5.js"),
901
+ import("./claude-ink-ECZ6QF3P.js"),
900
902
  import("react"),
901
- import("./app-C5ZQUOKJ.js")
903
+ import("./app-UWIEIWBQ.js")
902
904
  ]);
903
905
  const instance = await render(createElement(
904
906
  AlternateScreen,
@@ -961,7 +963,7 @@ async function runRpcMode(options) {
961
963
  });
962
964
  await server.start();
963
965
  await recorder?.close();
964
- return 0;
966
+ return process.exitCode === MEMORY_RESTART_EXIT_CODE ? MEMORY_RESTART_EXIT_CODE : 0;
965
967
  } catch (error) {
966
968
  await recorder?.close().catch(() => void 0);
967
969
  process.stderr.write(`rpc: ${safeError(error)}
@@ -972,7 +974,7 @@ async function runRpcMode(options) {
972
974
  function setInteractiveProcessTitle(target = process) {
973
975
  target.title = "Flavor Code";
974
976
  }
975
- async function runPrint(prompt, dependencies = {}, resumeSession) {
977
+ async function runPrint(prompt, dependencies = {}, resumeSession, memoryRestart = false) {
976
978
  let code = 0;
977
979
  let runtime;
978
980
  const stdout = dependencies.stdout ?? ((text) => process.stdout.write(text));
@@ -1004,7 +1006,11 @@ async function runPrint(prompt, dependencies = {}, resumeSession) {
1004
1006
  }
1005
1007
  try {
1006
1008
  await runtime.session.start();
1007
- await runtime.session.submit(prompt);
1009
+ if (runtime.session.rotationContinuationResumed) {
1010
+ await runtime.session.whenIdle();
1011
+ } else if (!memoryRestart) {
1012
+ await runtime.session.submit(prompt);
1013
+ }
1008
1014
  } catch (error) {
1009
1015
  stderr(`runtime: ${safeError(error)}
1010
1016
  `);
@@ -1025,8 +1031,9 @@ async function runPrint(prompt, dependencies = {}, resumeSession) {
1025
1031
  code = 1;
1026
1032
  }
1027
1033
  }
1028
- if (code === 0) stdout("\n");
1029
- return code;
1034
+ const restarting = process.exitCode === MEMORY_RESTART_EXIT_CODE;
1035
+ if (code === 0 && !restarting) stdout("\n");
1036
+ return restarting ? MEMORY_RESTART_EXIT_CODE : code;
1030
1037
  }
1031
1038
  function safeError(error) {
1032
1039
  return redactErrorText(message(error));
package/dist/cli.js CHANGED
@@ -5,19 +5,23 @@ import {
5
5
  memoryRestartArgs,
6
6
  memoryRestartMarkerPath,
7
7
  parseMemoryRestartMarker
8
- } from "./chunk-CIVPKHF4.js";
8
+ } from "./chunk-LKQTBL3R.js";
9
9
  import "./chunk-S32JRDZK.js";
10
10
 
11
11
  // src/launcher.ts
12
12
  import { spawn } from "child_process";
13
13
  import { realpathSync, readFileSync } from "fs";
14
+ import { totalmem } from "os";
14
15
  import { fileURLToPath } from "url";
15
16
  function needsRelaunch(runtime) {
16
17
  if (!runtime.execArgv.some((argument) => argument === "--report-on-fatalerror")) return true;
17
- return !runtime.execArgv.some((argument) => argument.startsWith("--heapsnapshot-near-heap-limit"));
18
+ if (!runtime.execArgv.some((argument) => argument.startsWith("--heapsnapshot-near-heap-limit"))) return true;
19
+ return !runtime.execArgv.some((argument) => argument === "--expose-gc");
18
20
  }
21
+ var HEAP_HEADROOM_MB = 8192;
22
+ var HEAP_HEADROOM_MIN_TOTALMEM = 12 * 1024 * 1024 * 1024;
19
23
  function cliMainArguments(mainPath, argv) {
20
- return [
24
+ const flags = [
21
25
  // Fatal V8 errors (heap OOM, native crashes) bypass crash-guard.ts and
22
26
  // leave only an unusable native stack. Ask Node to dump a diagnostic
23
27
  // report next to the working directory so the next crash has a scene.
@@ -27,9 +31,24 @@ function cliMainArguments(mainPath, argv) {
27
31
  // Capture one heap snapshot as the heap nears its limit so the next
28
32
  // crash leaves a .heapsnapshot retainer trail next to the report.
29
33
  "--heapsnapshot-near-heap-limit=1",
30
- mainPath,
31
- ...argv
34
+ // The heap watermarks are GC-verified: heapUsed counts uncollected
35
+ // garbage, and stopping turns or rotating on garbage alone would waste
36
+ // work. Exposing gc lets the watermark measure the live set instead.
37
+ "--expose-gc"
32
38
  ];
39
+ const processHeapFlag = process.execArgv.find((argument) => argument.startsWith("--max-old-space-size"));
40
+ const argvHeapFlag = argv.find((argument) => argument.startsWith("--max-old-space-size"));
41
+ const userHeapFlag = processHeapFlag ?? argvHeapFlag;
42
+ if (userHeapFlag !== void 0) {
43
+ flags.push(userHeapFlag);
44
+ } else {
45
+ const constrained = process.constrainedMemory?.() ?? 0;
46
+ const availableLimit = constrained > 0 ? Math.min(totalmem(), constrained) : totalmem();
47
+ if (availableLimit >= HEAP_HEADROOM_MIN_TOTALMEM) {
48
+ flags.push(`--max-old-space-size=${HEAP_HEADROOM_MB}`);
49
+ }
50
+ }
51
+ return [...flags, mainPath, ...argv.filter((argument) => argument !== argvHeapFlag)];
33
52
  }
34
53
  async function launchCli() {
35
54
  const mainUrl = new URL("./cli-main.js", import.meta.url);
@@ -164,6 +164,10 @@ export declare const FlavorConfigSchema: z.ZodObject<{
164
164
  maxTokens: z.ZodDefault<z.ZodNumber>;
165
165
  isolation: z.ZodDefault<z.ZodLiteral<"auto">>;
166
166
  }, z.core.$strip>>;
167
+ goal: z.ZodPrefault<z.ZodObject<{
168
+ maxRounds: z.ZodDefault<z.ZodNumber>;
169
+ maxStallStreak: z.ZodDefault<z.ZodNumber>;
170
+ }, z.core.$strip>>;
167
171
  context: z.ZodPrefault<z.ZodObject<{
168
172
  windowTokens: z.ZodDefault<z.ZodNumber>;
169
173
  reservedOutputTokens: z.ZodDefault<z.ZodNumber>;
@@ -97,6 +97,15 @@ export declare class ContextManager {
97
97
  restore(snapshot: ContextSnapshot): void;
98
98
  messagesForModel(): ModelMessage[];
99
99
  estimatedTokens(): number;
100
+ /** Retained sizes for the rotation census: what this context holds right now. */
101
+ census(): {
102
+ messages: number;
103
+ messageChars: number;
104
+ visibilityEntries: number;
105
+ visibilityChars: number;
106
+ transientEntries: number;
107
+ transientChars: number;
108
+ };
100
109
  needsCompaction(): boolean;
101
110
  get lastRecordedInputTokens(): number | undefined;
102
111
  get consecutiveAutoCompactFailures(): number;