@nick848/fet 1.1.0 → 1.1.1

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/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from "../chunk-J5WB4KAL.js";
6
6
 
7
7
  // src/cli/index.ts
8
- import { createInterface } from "readline/promises";
8
+ import { createInterface as createInterface2 } from "readline/promises";
9
9
  import { Command } from "commander";
10
10
 
11
11
  // src/commands/doctor.ts
@@ -1575,6 +1575,7 @@ ${block}
1575
1575
 
1576
1576
  // src/commands/update-context.ts
1577
1577
  import { readFile as readFile7 } from "fs/promises";
1578
+ import { createInterface } from "readline/promises";
1578
1579
  import { join as join11 } from "path";
1579
1580
 
1580
1581
  // src/config/yaml.ts
@@ -1627,7 +1628,7 @@ async function updateContextFiles(ctx) {
1627
1628
  });
1628
1629
  }
1629
1630
  if (existingAgents && !hasManagedAutoRegion(existingAgents)) {
1630
- if (!ctx.yes) {
1631
+ if (!ctx.yes && !await confirmInitCanReplaceUnmanagedAgents(ctx)) {
1631
1632
  throw new FetError({
1632
1633
  code: "TOOL_ADAPTER_CONFLICT" /* ToolAdapterConflict */,
1633
1634
  message: ctx.language === "en" ? "AGENTS.md already exists and does not contain a FET-managed region." : "AGENTS.md \u5DF2\u5B58\u5728\uFF0C\u4E14\u4E0D\u5305\u542B FET \u6258\u7BA1\u533A\u57DF\u3002",
@@ -1664,6 +1665,27 @@ async function updateContextFiles(ctx) {
1664
1665
  await ctx.stateStore.writeGlobal(state);
1665
1666
  return { warnings };
1666
1667
  }
1668
+ async function confirmInitCanReplaceUnmanagedAgents(ctx) {
1669
+ if (ctx.command !== "init" || ctx.json || !process.stdin.isTTY || !process.stderr.isTTY) {
1670
+ return false;
1671
+ }
1672
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
1673
+ try {
1674
+ const question = ctx.language === "en" ? "AGENTS.md already exists and is not managed by FET. Continue now with the same effect as fet init --yes? [y/N] " : "AGENTS.md \u5DF2\u5B58\u5728\u4E14\u4E0D\u7531 FET \u6258\u7BA1\u3002\u662F\u5426\u7EE7\u7EED\u6267\u884C\uFF0C\u6548\u679C\u7B49\u540C\u4E8E fet init --yes\uFF1F[y/N] ";
1675
+ const answer = (await rl.question(question)).trim().toLowerCase();
1676
+ if (answer === "y" || answer === "yes") {
1677
+ return true;
1678
+ }
1679
+ } finally {
1680
+ rl.close();
1681
+ }
1682
+ throw new FetError({
1683
+ code: "USER_CANCELLED" /* UserCancelled */,
1684
+ message: ctx.language === "en" ? "fet init cancelled so you can handle AGENTS.md manually." : "\u5DF2\u53D6\u6D88 fet init\uFF0C\u4F60\u53EF\u4EE5\u5148\u624B\u52A8\u5904\u7406 AGENTS.md\u3002",
1685
+ details: { path: "AGENTS.md" },
1686
+ suggestedCommand: ctx.language === "en" ? "Review AGENTS.md, then rerun fet init or fet init --yes." : "\u68C0\u67E5 AGENTS.md \u540E\uFF0C\u624B\u52A8\u91CD\u65B0\u8FD0\u884C fet init \u6216 fet init --yes\u3002"
1687
+ });
1688
+ }
1667
1689
  async function readOptional2(path) {
1668
1690
  try {
1669
1691
  return await readFile7(path, "utf8");
@@ -4599,7 +4621,7 @@ async function handleModelPolicyRecommendation(ctx) {
4599
4621
  if (policyMode !== "confirm" || ctx.yes || ctx.json || !process.stdin.isTTY || !process.stderr.isTTY) {
4600
4622
  return;
4601
4623
  }
4602
- const rl = createInterface({ input: process.stdin, output: process.stderr });
4624
+ const rl = createInterface2({ input: process.stdin, output: process.stderr });
4603
4625
  try {
4604
4626
  const question = ctx.language === "en" ? "Continue anyway? [y/N] " : "\u4ECD\u7136\u7EE7\u7EED\uFF1F[y/N] ";
4605
4627
  const answer = (await rl.question(question)).trim().toLowerCase();