flavor-code 1.2.9 → 1.2.11

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.js CHANGED
@@ -3,12 +3,13 @@ import { createRequire } from "node:module"; const require = createRequire(impor
3
3
  import {
4
4
  FlavorRpcServer,
5
5
  TraceRecorder
6
- } from "./chunk-G32MCAZA.js";
6
+ } from "./chunk-EY6KE7L2.js";
7
7
  import {
8
8
  staticTaskLines
9
9
  } from "./chunk-KKIBYDJI.js";
10
10
  import {
11
11
  DEFAULT_MAX_OUTPUT_BYTES,
12
+ MAX_ALIAS_LENGTH,
12
13
  MEMORY_TYPES,
13
14
  MemoryStore,
14
15
  PluginManifestSchema,
@@ -19,8 +20,9 @@ import {
19
20
  initializeFlavor,
20
21
  message,
21
22
  packageVersion,
22
- redactErrorText
23
- } from "./chunk-WGYNTR4Q.js";
23
+ redactErrorText,
24
+ runPalBroker
25
+ } from "./chunk-OT5XIN6G.js";
24
26
  import {
25
27
  McpServerConfigSchema,
26
28
  McpServerNameSchema,
@@ -34,11 +36,12 @@ import "./chunk-RQTYHUMK.js";
34
36
  import "./chunk-S32JRDZK.js";
35
37
 
36
38
  // src/cli.tsx
39
+ import { randomUUID as randomUUID2 } from "crypto";
37
40
  import { realpathSync } from "fs";
38
41
  import { homedir as homedir3 } from "os";
39
- import { resolve as resolve3 } from "path";
42
+ import { posix, resolve as resolve3 } from "path";
40
43
  import { fileURLToPath } from "url";
41
- import { Command } from "commander";
44
+ import { Command, Option } from "commander";
42
45
 
43
46
  // src/skills/manager.ts
44
47
  import { lstat, mkdir, readFile, readdir, realpath, rm, writeFile } from "fs/promises";
@@ -693,8 +696,8 @@ async function runEvaluationFile(path, outputPath) {
693
696
  }
694
697
 
695
698
  // src/cli.tsx
696
- function createProgram() {
697
- 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");
699
+ function createProgram(dependencies = {}) {
700
+ 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());
698
701
  program.command("init [directory]").description("Initialize Flavor project files in a directory (defaults to cwd)").action(async (directory) => {
699
702
  const cwd = directory ? resolve3(directory) : process.cwd();
700
703
  try {
@@ -742,6 +745,14 @@ function createProgram() {
742
745
  process.exitCode = await runEvaluationFile(spec, command.output);
743
746
  });
744
747
  program.action(async (options) => {
748
+ if (options.palsBroker !== void 0) {
749
+ if (!isLocalPalBrokerAddress(options.palsBroker, process.platform)) {
750
+ throw new Error("Invalid local pals broker address");
751
+ }
752
+ const broker = await (dependencies.runBroker ?? runPalBroker)({ address: options.palsBroker });
753
+ await broker.closed;
754
+ return;
755
+ }
745
756
  const resumeSession = options.resume === true ? true : typeof options.resume === "string" ? options.resume : void 0;
746
757
  if (options.mode === "rpc") {
747
758
  process.exitCode = await runRpcMode({
@@ -763,30 +774,57 @@ function createProgram() {
763
774
  process.exitCode = await runPrint(options.print, {}, resumeSession);
764
775
  return;
765
776
  }
766
- if (!process.stdin.isTTY) {
777
+ if (!(dependencies.isTTY?.() ?? process.stdin.isTTY)) {
767
778
  process.stderr.write("Interactive mode needs a TTY. Use --print <prompt> for scripts.\n");
768
779
  process.exitCode = 2;
769
780
  return;
770
781
  }
782
+ const palAlias = options.palName === void 0 ? void 0 : parsePalAlias(options.palName);
771
783
  setInteractiveProcessTitle();
772
- const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
773
- import("./claude-ink-ORUA7GWG.js"),
774
- import("react"),
775
- import("./app-USAFQVSX.js")
776
- ]);
777
- const instance = await render(createElement(
778
- AlternateScreen,
779
- { mouseTracking: true },
780
- createElement(App, {
781
- workspace: process.cwd(),
782
- home: homedir3(),
783
- ...resumeSession === void 0 ? {} : { resumeSession }
784
- })
785
- ), { exitOnCtrlC: false });
786
- await instance.waitUntilExit();
784
+ const props = {
785
+ workspace: process.cwd(),
786
+ home: homedir3(),
787
+ ...resumeSession === void 0 ? {} : { resumeSession },
788
+ instanceId: (dependencies.randomUUID ?? randomUUID2)(),
789
+ ...palAlias === void 0 ? {} : { palAlias }
790
+ };
791
+ if (dependencies.runInteractive !== void 0) {
792
+ await dependencies.runInteractive(props);
793
+ return;
794
+ }
795
+ await runInteractiveCli(props);
787
796
  });
788
797
  return program;
789
798
  }
799
+ async function runInteractiveCli(props) {
800
+ const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
801
+ import("./claude-ink-ORUA7GWG.js"),
802
+ import("react"),
803
+ import("./app-MXWPZBEU.js")
804
+ ]);
805
+ const instance = await render(createElement(
806
+ AlternateScreen,
807
+ { mouseTracking: true },
808
+ createElement(App, props)
809
+ ), { exitOnCtrlC: false });
810
+ await instance.waitUntilExit();
811
+ }
812
+ function parsePalAlias(value) {
813
+ const alias = value.trim();
814
+ if (alias.length < 1 || alias.length > MAX_ALIAS_LENGTH) {
815
+ throw new Error(`Pal name must be between 1 and ${MAX_ALIAS_LENGTH} characters`);
816
+ }
817
+ return alias;
818
+ }
819
+ function isLocalPalBrokerAddress(address, platform) {
820
+ if (platform === "win32") {
821
+ const prefix = "\\\\.\\pipe\\flavor-code-pals-u-";
822
+ if (!address.startsWith(prefix) || !address.endsWith("-v1")) return false;
823
+ return /^[a-f0-9]{16}$/u.test(address.slice(prefix.length, -3));
824
+ }
825
+ if (!address.startsWith("/") || address.startsWith("//") || address.includes("\0")) return false;
826
+ return posix.normalize(address) === address && posix.basename(address) === "pals-v1.sock" && posix.dirname(address) !== "/";
827
+ }
790
828
  async function runRpcMode(options) {
791
829
  let recorder;
792
830
  try {
@@ -909,6 +947,7 @@ if (process.argv[1]) {
909
947
  }
910
948
  export {
911
949
  createProgram,
950
+ isLocalPalBrokerAddress,
912
951
  runPrint,
913
952
  runRpcMode,
914
953
  setInteractiveProcessTitle