flavor-code 1.3.19 → 1.3.20

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/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-6LDYDQ3P.js";
6
+ } from "./chunk-VEUSROUQ.js";
7
7
  import {
8
8
  NPM_PACKAGE_NAME,
9
9
  fetchLatestVersion,
@@ -21,11 +21,13 @@ import {
21
21
  createProductionRuntime,
22
22
  executeShell,
23
23
  initializeFlavor,
24
+ installCrashGuard,
24
25
  message,
25
26
  packageVersion,
27
+ prepareSpawnInvocation,
26
28
  redactErrorText,
27
29
  runPalBroker
28
- } from "./chunk-PF457XCH.js";
30
+ } from "./chunk-Z62P4LL7.js";
29
31
  import "./chunk-CIVPKHF4.js";
30
32
  import {
31
33
  McpServerConfigSchema,
@@ -35,7 +37,7 @@ import {
35
37
  readRecoverableFile,
36
38
  setProjectSkillDisabled,
37
39
  updateProtectedFile
38
- } from "./chunk-HJOCNKPN.js";
40
+ } from "./chunk-RPFWB45Y.js";
39
41
  import {
40
42
  gt,
41
43
  isValidVersion
@@ -57,7 +59,11 @@ function npmExecutable(platform = process.platform) {
57
59
  return platform === "win32" ? "npm.cmd" : "npm";
58
60
  }
59
61
  var defaultInstall = (command, args) => new Promise((resolve4, reject) => {
60
- const child = spawn(command, args, { stdio: "inherit" });
62
+ const invocation = prepareSpawnInvocation(command, args);
63
+ const child = spawn(invocation.command, invocation.args, {
64
+ stdio: "inherit",
65
+ ...invocation.windowsVerbatimArguments === void 0 ? {} : { windowsVerbatimArguments: invocation.windowsVerbatimArguments }
66
+ });
61
67
  child.on("error", reject);
62
68
  child.on("close", (code) => resolve4(code));
63
69
  });
@@ -76,71 +82,10 @@ async function runUpdate(options = {}) {
76
82
  return exitCode === 0 ? { status: "updated", current, latest } : { status: "install-failed", current, latest, exitCode };
77
83
  }
78
84
 
79
- // src/utils/crash-guard.ts
80
- import { mkdirSync, writeFileSync } from "fs";
81
- import { join } from "path";
82
- var installed = false;
83
- function installCrashGuard(options = {}) {
84
- if (installed) return;
85
- installed = true;
86
- const crashLogDir = () => {
87
- try {
88
- return join((options.workspace ?? process.cwd)(), ".flavor");
89
- } catch {
90
- return process.cwd();
91
- }
92
- };
93
- const writeCrashLog = (kind, detail) => {
94
- try {
95
- const dir = crashLogDir();
96
- mkdirSync(dir, { recursive: true });
97
- const path = join(dir, `crash-${(/* @__PURE__ */ new Date()).toISOString().replace(/[^0-9]/g, "")}-${process.pid}.log`);
98
- writeFileSync(path, [
99
- `kind: ${kind}`,
100
- `version: ${process.version}`,
101
- `platform: ${process.platform}`,
102
- `time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
103
- "",
104
- detail
105
- ].join("\n"), { encoding: "utf8", mode: 384 });
106
- return path;
107
- } catch {
108
- return void 0;
109
- }
110
- };
111
- const restoreTerminal = () => {
112
- try {
113
- if (process.stdout.isTTY === true) process.stdout.write("\x1B[?25h\x1B[?1049l");
114
- } catch {
115
- }
116
- };
117
- const describe = (reason) => {
118
- if (reason instanceof Error) return `${reason.name}: ${reason.message}
119
- ${reason.stack ?? ""}`;
120
- return String(reason);
121
- };
122
- const crash = (kind, reason) => {
123
- const detail = describe(reason);
124
- const logPath = writeCrashLog(kind, detail);
125
- restoreTerminal();
126
- try {
127
- const safe = redactErrorText(detail.split("\n").slice(0, 3).join("\n"));
128
- process.stderr.write(`flavor crashed (${kind}): ${safe}
129
- `);
130
- if (logPath !== void 0) process.stderr.write(`crash log: ${logPath}
131
- `);
132
- } catch {
133
- }
134
- process.exit(1);
135
- };
136
- process.on("unhandledRejection", (reason) => crash("unhandledRejection", reason));
137
- process.on("uncaughtException", (error) => crash("uncaughtException", error));
138
- }
139
-
140
85
  // src/skills/manager.ts
141
86
  import { lstat, mkdir, readFile, readdir, realpath, rm, writeFile } from "fs/promises";
142
87
  import { homedir } from "os";
143
- import { isAbsolute, join as join2, relative, resolve, sep } from "path";
88
+ import { isAbsolute, join, relative, resolve, sep } from "path";
144
89
  import { stringify } from "yaml";
145
90
  var SkillManager = class {
146
91
  #workspace;
@@ -163,7 +108,7 @@ var SkillManager = class {
163
108
  async create(draft) {
164
109
  const value = parseDraft(draft);
165
110
  const projectRoot = this.#projectRoot();
166
- const directory = join2(projectRoot, value.name);
111
+ const directory = join(projectRoot, value.name);
167
112
  await mkdir(projectRoot, { recursive: true, mode: 448 });
168
113
  try {
169
114
  await mkdir(directory, { mode: 448 });
@@ -172,7 +117,7 @@ var SkillManager = class {
172
117
  throw error;
173
118
  }
174
119
  try {
175
- await writeFile(join2(directory, "SKILL.md"), renderSkill(value), { encoding: "utf8", flag: "wx", mode: 384 });
120
+ await writeFile(join(directory, "SKILL.md"), renderSkill(value), { encoding: "utf8", flag: "wx", mode: 384 });
176
121
  await this.#persistEnabled(value.name, true);
177
122
  return this.get(value.name);
178
123
  } catch (error) {
@@ -190,7 +135,7 @@ var SkillManager = class {
190
135
  throw error;
191
136
  });
192
137
  if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`Project skill path is not a real directory: ${validName}`);
193
- const skillFile = join2(directory, "SKILL.md");
138
+ const skillFile = join(directory, "SKILL.md");
194
139
  const fileInfo = await lstat(skillFile);
195
140
  if (!fileInfo.isFile() || fileInfo.isSymbolicLink()) throw new Error(`Project skill file is not a real file: ${validName}`);
196
141
  await writeFile(skillFile, renderSkill(value), { encoding: "utf8", mode: 384 });
@@ -222,12 +167,12 @@ var SkillManager = class {
222
167
  async #registry() {
223
168
  const loaded = await loadConfig({ cwd: this.#workspace, home: this.#home });
224
169
  const [globalPluginRoots, projectPluginRoots] = await Promise.all([
225
- discoverPluginSkillRoots(join2(this.#home, ".flavor-code", "plugins")),
226
- discoverPluginSkillRoots(join2(this.#workspace, ".flavor", "plugins"))
170
+ discoverPluginSkillRoots(join(this.#home, ".flavor-code", "plugins")),
171
+ discoverPluginSkillRoots(join(this.#workspace, ".flavor", "plugins"))
227
172
  ]);
228
173
  return {
229
174
  registry: new SkillRegistry({
230
- globalRoots: [join2(this.#home, ".flavor-code", "skills"), ...globalPluginRoots],
175
+ globalRoots: [join(this.#home, ".flavor-code", "skills"), ...globalPluginRoots],
231
176
  projectRoots: [this.#projectRoot(), ...projectPluginRoots]
232
177
  }),
233
178
  disabled: new Set(loaded.config.skills.disabled)
@@ -243,10 +188,10 @@ var SkillManager = class {
243
188
  };
244
189
  }
245
190
  #projectRoot() {
246
- return join2(this.#workspace, ".flavor", "skills");
191
+ return join(this.#workspace, ".flavor", "skills");
247
192
  }
248
193
  #projectSkillDirectory(name) {
249
- return join2(this.#projectRoot(), name);
194
+ return join(this.#projectRoot(), name);
250
195
  }
251
196
  };
252
197
  function parseName(value) {
@@ -287,9 +232,9 @@ async function discoverPluginSkillRoots(directory) {
287
232
  const roots = [];
288
233
  for (const entry of entries) {
289
234
  if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
290
- const pluginRoot = await realpath(join2(directory, entry.name));
235
+ const pluginRoot = await realpath(join(directory, entry.name));
291
236
  try {
292
- const manifest = PluginManifestSchema.parse(JSON.parse(await readFile(join2(pluginRoot, "flavor-plugin.json"), "utf8")));
237
+ const manifest = PluginManifestSchema.parse(JSON.parse(await readFile(join(pluginRoot, "flavor-plugin.json"), "utf8")));
293
238
  for (const contribution of manifest.contributes.skillRoots) {
294
239
  const candidate = resolve(pluginRoot, contribution.path);
295
240
  const info = await lstat(candidate);
@@ -421,11 +366,11 @@ function parseMemoryType(value) {
421
366
  }
422
367
 
423
368
  // src/mcp/config-manager.ts
424
- import { join as join3 } from "path";
369
+ import { join as join2 } from "path";
425
370
  var ProjectMcpConfigManager = class {
426
371
  path;
427
372
  constructor(workspace) {
428
- this.path = join3(workspace, ".flavor", "flavor.json");
373
+ this.path = join2(workspace, ".flavor", "flavor.json");
429
374
  }
430
375
  async list() {
431
376
  const document = await readRecoverableFile(this.path, (raw) => parseDocument(this.path, raw));
@@ -782,7 +727,7 @@ async function runEvaluationFile(path, outputPath) {
782
727
  })),
783
728
  ...parsed.maxTokens === void 0 ? {} : { maxTokens: parsed.maxTokens }
784
729
  };
785
- const configured = await import("./load-DELQW42K.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
730
+ const configured = await import("./load-4FWNXE6F.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
786
731
  const environment = createExecutionEnvironment(workspace, configured.config.execution) ?? new LocalExecutionEnvironment();
787
732
  let report;
788
733
  try {
@@ -937,7 +882,7 @@ async function runInteractiveCli(props) {
937
882
  const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
938
883
  import("./claude-ink-3K3NG7BF.js"),
939
884
  import("react"),
940
- import("./app-EVMUBQRE.js")
885
+ import("./app-EGG3BYQQ.js")
941
886
  ]);
942
887
  const instance = await render(createElement(
943
888
  AlternateScreen,
@@ -124,7 +124,7 @@ export declare const FlavorConfigSchema: z.ZodObject<{
124
124
  autoStoreThreshold: z.ZodDefault<z.ZodNumber>;
125
125
  ignoreStreakLimit: z.ZodDefault<z.ZodNumber>;
126
126
  reviewAutoDismissSeconds: z.ZodDefault<z.ZodNumber>;
127
- maxCandidatesPerTask: z.ZodDefault<z.ZodNumber>;
127
+ maxCandidatesPerTask: z.ZodDefault<z.ZodLiteral<1>>;
128
128
  retrievalTopK: z.ZodDefault<z.ZodNumber>;
129
129
  maxEntries: z.ZodDefault<z.ZodNumber>;
130
130
  maxEntryChars: z.ZodDefault<z.ZodNumber>;