@neikyun/ciel 5.2.10 → 5.2.12

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/bin/ciel.js CHANGED
@@ -3,8 +3,7 @@
3
3
  // Vérifie si l'initialisation est nécessaire et détecte les nouvelles plateformes.
4
4
 
5
5
  const { existsSync, mkdirSync, writeFileSync, readFileSync, copyFileSync, readdirSync, chmodSync, unlinkSync } = require("fs");
6
- const { join } = require("path");
7
- const { execSync } = require("child_process");
6
+ const { join, delimiter } = require("path");
8
7
 
9
8
  const PKG_DIR = join(__dirname, "..");
10
9
  const PKG = JSON.parse(readFileSync(join(PKG_DIR, "package.json"), "utf-8"));
@@ -17,6 +16,19 @@ const c = (code, s) => process.stderr.isTTY ? `\x1b[${code}m${s}\x1b[0m` : s;
17
16
  const green = (s) => c(32, s);
18
17
  const cyan = (s) => c(36, s);
19
18
 
19
+ // Cherche un exécutable dans le PATH (fiable cross-platform, pas besoin de shell)
20
+ function searchPath(name) {
21
+ const pathExt = (process.env.PATHEXT || "").split(";");
22
+ if (!pathExt[0]) pathExt.push("", ".exe", ".cmd", ".bat", ".com");
23
+ const pathDirs = (process.env.PATH || "").split(delimiter);
24
+ for (const dir of pathDirs) {
25
+ for (const ext of pathExt) {
26
+ if (existsSync(join(dir, name + ext))) return true;
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+
20
32
  // ---- Helpers ----
21
33
  function copyDir(src, dest) {
22
34
  if (!existsSync(src)) return 0;
@@ -52,8 +64,8 @@ function detectPlatforms() {
52
64
  const hasClaude = existsSync(join(targetDir, ".claude/settings.json")) || existsSync(join(targetDir, ".claude"));
53
65
 
54
66
  // Détection CLI
55
- const hasOC_CLI = (() => { try { const r = execSync("opencode --version 2>&1", { stdio: "pipe", timeout: 5000 }); return r.toString().length > 0; } catch { return false; } })();
56
- const hasClaude_CLI = (() => { try { const r = execSync("claude --version 2>&1", { stdio: "pipe", timeout: 5000 }); return r.toString().length > 0; } catch { return false; } })();
67
+ const hasOC_CLI = searchPath("opencode");
68
+ const hasClaude_CLI = searchPath("claude");
57
69
 
58
70
  if (hasOC || hasOC_CLI) platforms.push("OpenCode");
59
71
  if (hasClaude || hasClaude_CLI) platforms.push("Claude Code");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neikyun/ciel",
3
- "version": "5.2.10",
3
+ "version": "5.2.12",
4
4
  "description": "Ciel — Deep-reasoning pipeline for LLM-assisted development. OpenCode plugin + multi-platform CLI (OpenCode, Claude Code, more).",
5
5
  "main": "./dist/plugin/index.js",
6
6
  "types": "./dist/plugin/index.d.ts",
@@ -34,11 +34,16 @@ function resolveAssets() {
34
34
  }
35
35
 
36
36
  function detectCLI(name) {
37
- try {
38
- const { execSync } = require("child_process");
39
- const r = execSync(name + " --version 2>&1", { stdio: "pipe", timeout: 3000, encoding: "utf8" });
40
- return r.length > 0 && !r.includes("not found");
41
- } catch { return false; }
37
+ // Cherche l'exécutable dans le PATH directement (fiable cross-platform)
38
+ const pathExt = process.env.PATHEXT ? process.env.PATHEXT.split(";") : ["", ".exe", ".cmd", ".bat", ".com"];
39
+ const pathDirs = (process.env.PATH || "").split(require("path").delimiter);
40
+ for (const dir of pathDirs) {
41
+ for (const ext of pathExt) {
42
+ const fullPath = require("path").join(dir, name + ext);
43
+ if (existsSync(fullPath)) return true;
44
+ }
45
+ }
46
+ return false;
42
47
  }
43
48
 
44
49
  // ---- Installation ----
@@ -108,6 +113,12 @@ async function main() {
108
113
  const platforms = detectPlatforms(targetDir);
109
114
  const assetsDir = resolveAssets();
110
115
 
116
+ // TOUJOURS chercher les CLI, même si des plateformes sont déjà détectées
117
+ const hasClaudeCLI = detectCLI("claude");
118
+ const hasOpenCodeCLI = detectCLI("opencode");
119
+ if (hasClaudeCLI && !platforms.includes("Claude Code")) platforms.push("Claude Code");
120
+ if (hasOpenCodeCLI && !platforms.includes("OpenCode")) platforms.push("OpenCode");
121
+
111
122
  // Toujours afficher le message Ciel (sur stderr pour être visible via npm)
112
123
  console.error(`\n ${bold("✦ Ciel v" + CIEL_VERSION)}`);
113
124
 
@@ -117,56 +128,11 @@ async function main() {
117
128
  }
118
129
 
119
130
  if (platforms.length === 0) {
120
- // Aucune plateforme détectée chercher les CLIs installées
121
- const hasOpenCode = detectCLI("opencode");
122
- const hasClaude = detectCLI("claude");
123
-
124
- if (!hasOpenCode && !hasClaude) {
125
- console.error(` ${yellow("~")} Aucune plateforme détectée.`);
126
- console.error(` Installez ${cyan("opencode")} ou ${cyan("claude")} puis relancez.`);
127
- console.error(` Ou: ${green("npx ciel init")}\n`);
128
- return;
129
- }
130
-
131
- // Proposer de configurer les CLIs détectées
132
- let creer = !process.stdin.isTTY;
133
- if (process.stdin.isTTY) {
134
- const detected = [hasOpenCode && "OpenCode", hasClaude && "Claude Code"].filter(Boolean).join(" + ");
135
- try {
136
- const readline = require("readline");
137
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
138
- creer = await new Promise(r => rl.question(` ${yellow("?")} Configurer Ciel pour ${cyan(detected)} ? ${green("(Y/n)")} `, a => { rl.close(); r(a.trim().toLowerCase() !== "n"); }));
139
- } catch { creer = true; }
140
- }
141
-
142
- if (!creer) {
143
- console.error(` ${cyan("→")} Annulé. Utilisez ${green("npx ciel init")} plus tard.\n`);
144
- return;
145
- }
146
-
147
- // Configurer les plateformes détectées
148
- if (hasOpenCode) {
149
- const cfgPath = join(targetDir, "opencode.json");
150
- if (!existsSync(cfgPath)) {
151
- const cfg = { $schema: "https://opencode.ai/config.json", plugin: ["@neikyun/ciel"] };
152
- writeFileSync(cfgPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
153
- console.error(` ${green("✓")} opencode.json créé`);
154
- }
155
- platforms.push("OpenCode");
156
- }
157
-
158
- if (hasClaude) {
159
- const claudeDir = join(targetDir, ".claude");
160
- if (!existsSync(claudeDir)) {
161
- mkdirSync(claudeDir, { recursive: true });
162
- }
163
- const settingsPath = join(claudeDir, "settings.json");
164
- if (!existsSync(settingsPath)) {
165
- writeFileSync(settingsPath, JSON.stringify({}, null, 2) + "\n", "utf-8");
166
- console.error(` ${green("✓")} .claude/settings.json créé`);
167
- }
168
- platforms.push("Claude Code");
169
- }
131
+ // Aucune plateforme détectée (ni config, ni CLI)
132
+ console.error(` ${yellow("~")} Aucune plateforme détectée.`);
133
+ console.error(` Installez ${cyan("opencode")} ou ${cyan("claude")} puis relancez.`);
134
+ console.error(` Ou: ${green("npx ciel init")}\n`);
135
+ return;
170
136
  }
171
137
 
172
138
  // Demander confirmation (sauter si non-TTY)