fwinit 1.5.2 → 1.5.3

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 (2) hide show
  1. package/dist/index.js +46 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
  import ora from "ora";
6
6
  import chalk from "chalk";
7
7
  import { readFileSync } from "fs";
8
- import { mkdir as mkdir3, cp as cp3, readFile as readFile2 } from "fs/promises";
8
+ import { mkdir as mkdir3, cp as cp3, readFile as readFile3 } from "fs/promises";
9
9
  import { join as join3, basename } from "path";
10
10
 
11
11
  // src/templates.ts
@@ -463,7 +463,7 @@ async function askGlobalSkillsToo() {
463
463
  }
464
464
 
465
465
  // src/global-skills.ts
466
- import { mkdir as mkdir2, cp as cp2, rm as rm2, readdir as readdir2 } from "fs/promises";
466
+ import { mkdir as mkdir2, cp as cp2, rm as rm2, readdir as readdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
467
467
  import { join as join2 } from "path";
468
468
  function resolveGlobalTargets() {
469
469
  const home = process.env.HOME;
@@ -497,6 +497,37 @@ function filterBundleByNames(only) {
497
497
  const known = new Set(AGENT_BUNDLE.map((e) => e.dir));
498
498
  return { bundle, unknown: only.filter((n) => !known.has(n)) };
499
499
  }
500
+ async function ensureGlobalOpencodeConfig() {
501
+ const home = process.env.HOME;
502
+ if (!home) return;
503
+ const configPath = join2(home, ".config", "opencode", "opencode.json");
504
+ try {
505
+ let data;
506
+ try {
507
+ const content = await readFile2(configPath, "utf-8");
508
+ data = JSON.parse(content);
509
+ } catch {
510
+ data = { agent: {} };
511
+ }
512
+ const agent = data.agent ?? {};
513
+ const dangerousGentleman = agent["dangerous-gentleman"] ?? {};
514
+ let changed = false;
515
+ if (dangerousGentleman.parallel_tool_calls !== true) {
516
+ dangerousGentleman.parallel_tool_calls = true;
517
+ changed = true;
518
+ }
519
+ if (dangerousGentleman.max_parallel_calls !== 10) {
520
+ dangerousGentleman.max_parallel_calls = 10;
521
+ changed = true;
522
+ }
523
+ if (changed) {
524
+ agent["dangerous-gentleman"] = dangerousGentleman;
525
+ data.agent = agent;
526
+ await writeFile2(configPath, JSON.stringify(data, null, 2), "utf-8");
527
+ }
528
+ } catch {
529
+ }
530
+ }
500
531
  function mapPlanToTarget(plan, target) {
501
532
  const mapped = [];
502
533
  for (const item of plan.installs) {
@@ -690,10 +721,10 @@ function adaptScriptToNode(script) {
690
721
  return s;
691
722
  }
692
723
  async function adaptToNodeRuntime(projectPath) {
693
- const { readFile: readFile3, writeFile: writeFile2, readdir: readdir3 } = await import("fs/promises");
724
+ const { readFile: readFile4, writeFile: writeFile3, readdir: readdir3 } = await import("fs/promises");
694
725
  const { join: join4 } = await import("path");
695
726
  const pkgPath = join4(projectPath, "package.json");
696
- const pkg = JSON.parse(await readFile3(pkgPath, "utf-8"));
727
+ const pkg = JSON.parse(await readFile4(pkgPath, "utf-8"));
697
728
  for (const key of Object.keys(pkg.scripts ?? {})) {
698
729
  pkg.scripts[key] = adaptScriptToNode(pkg.scripts[key]);
699
730
  }
@@ -701,7 +732,7 @@ async function adaptToNodeRuntime(projectPath) {
701
732
  pkg.devDependencies.tsx = "^4.0.0";
702
733
  pkg.devDependencies.vitest = "^3.0.0";
703
734
  delete pkg.devDependencies["bun-types"];
704
- await writeFile2(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
735
+ await writeFile3(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
705
736
  async function walk(dir) {
706
737
  const entries = await readdir3(dir, { withFileTypes: true });
707
738
  for (const entry of entries) {
@@ -709,9 +740,9 @@ async function adaptToNodeRuntime(projectPath) {
709
740
  if (entry.isDirectory()) {
710
741
  if (entry.name !== "node_modules") await walk(full);
711
742
  } else if (entry.name.endsWith(".test.ts")) {
712
- const content = await readFile3(full, "utf-8");
743
+ const content = await readFile4(full, "utf-8");
713
744
  if (content.includes("bun:test")) {
714
- await writeFile2(full, content.replaceAll('from "bun:test"', 'from "vitest"'));
745
+ await writeFile3(full, content.replaceAll('from "bun:test"', 'from "vitest"'));
715
746
  }
716
747
  }
717
748
  }
@@ -723,22 +754,22 @@ async function adaptToNodeRuntime(projectPath) {
723
754
  }
724
755
  const tsconfigPath = join4(projectPath, "tsconfig.json");
725
756
  try {
726
- const tsconfig = JSON.parse(await readFile3(tsconfigPath, "utf-8"));
757
+ const tsconfig = JSON.parse(await readFile4(tsconfigPath, "utf-8"));
727
758
  if (tsconfig.compilerOptions?.types?.includes("bun-types")) {
728
759
  delete tsconfig.compilerOptions.types;
729
- await writeFile2(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
760
+ await writeFile3(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n");
730
761
  }
731
762
  } catch {
732
763
  }
733
764
  }
734
765
  async function writeRootGitignore(projectPath) {
735
- const { writeFile: writeFile2, access } = await import("fs/promises");
766
+ const { writeFile: writeFile3, access } = await import("fs/promises");
736
767
  const { join: join4 } = await import("path");
737
768
  const gitignorePath = join4(projectPath, ".gitignore");
738
769
  try {
739
770
  await access(gitignorePath);
740
771
  } catch {
741
- await writeFile2(
772
+ await writeFile3(
742
773
  gitignorePath,
743
774
  "# Local AI runtime state\n.atl/\nodd\n"
744
775
  );
@@ -761,7 +792,7 @@ async function gitInit(projectPath) {
761
792
  }
762
793
  }
763
794
  async function writeRootFiles(info) {
764
- const { writeFile: writeFile2 } = await import("fs/promises");
795
+ const { writeFile: writeFile3 } = await import("fs/promises");
765
796
  const { join: join4 } = await import("path");
766
797
  const projectPath = resolve(process.cwd(), info.projectName);
767
798
  await writeRootGitignore(projectPath);
@@ -798,7 +829,7 @@ async function writeRootFiles(info) {
798
829
  "```",
799
830
  ""
800
831
  ].join("\n");
801
- await writeFile2(join4(projectPath, "README.md"), readme);
832
+ await writeFile3(join4(projectPath, "README.md"), readme);
802
833
  }
803
834
 
804
835
  // src/index.ts
@@ -853,6 +884,7 @@ async function installGlobalSkillsWithSpinner(targets, bundle) {
853
884
  console.log(chalk.dim(` \u2714 ${r.target.label} \u2014 ${r.copied} archivos`));
854
885
  }
855
886
  }
887
+ await ensureGlobalOpencodeConfig();
856
888
  console.log();
857
889
  } finally {
858
890
  await cleanup(tempDir);
@@ -861,7 +893,7 @@ async function installGlobalSkillsWithSpinner(targets, bundle) {
861
893
  async function readTemplatePostInit(dir) {
862
894
  try {
863
895
  const tj = JSON.parse(
864
- await readFile2(join3(dir, "template.json"), "utf-8")
896
+ await readFile3(join3(dir, "template.json"), "utf-8")
865
897
  );
866
898
  return tj.postInit;
867
899
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fwinit",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "CLI para crear proyectos desde templates",
5
5
  "type": "module",
6
6
  "bin": {