dfcode 3.0.0-beta.1 → 3.0.1-beta.2

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/bin/dfcode.js +105 -0
  2. package/package.json +9 -8
package/bin/dfcode.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ import childProcess from "child_process"
4
+ import fs from "fs"
5
+ import path from "path"
6
+ import os from "os"
7
+ import { fileURLToPath } from "url"
8
+
9
+ function run(target) {
10
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
11
+ stdio: "inherit",
12
+ })
13
+ if (result.error) {
14
+ console.error(result.error.message)
15
+ process.exit(1)
16
+ }
17
+ const code = typeof result.status === "number" ? result.status : result.signal ? 1 : 0
18
+ if (code !== 0) resetTerminal()
19
+ process.exit(code)
20
+ }
21
+
22
+ function resetTerminal() {
23
+ if (!process.stdout.isTTY && process.env.DFCODE_FORCE_TERMINAL_RESET !== "1") return
24
+ process.stdout.write(
25
+ [
26
+ "\x1b[0m",
27
+ "\x1b[?25h",
28
+ "\x1b[?1000l",
29
+ "\x1b[?1002l",
30
+ "\x1b[?1003l",
31
+ "\x1b[?1004l",
32
+ "\x1b[?1005l",
33
+ "\x1b[?1006l",
34
+ "\x1b[?1015l",
35
+ "\x1b[?2004l",
36
+ "\x1b[?1049l",
37
+ ].join(""),
38
+ )
39
+ }
40
+
41
+ const envPath = process.env.DFCODE_BIN_PATH
42
+ if (envPath) {
43
+ run(envPath)
44
+ }
45
+
46
+ const scriptPath = fs.realpathSync(fileURLToPath(import.meta.url))
47
+ const scriptDir = path.dirname(scriptPath)
48
+
49
+ const platformMap = {
50
+ darwin: "darwin",
51
+ linux: "linux",
52
+ win32: "windows",
53
+ }
54
+ const archMap = {
55
+ x64: "x64",
56
+ arm64: "arm64",
57
+ arm: "arm",
58
+ }
59
+
60
+ let platform = platformMap[os.platform()]
61
+ if (!platform) {
62
+ platform = os.platform()
63
+ }
64
+ let arch = archMap[os.arch()]
65
+ if (!arch) {
66
+ arch = os.arch()
67
+ }
68
+ const base = "dfcode-" + platform + "-" + arch
69
+ const binary = platform === "windows" ? "dfcode.exe" : "dfcode"
70
+
71
+ function findBinary(startDir) {
72
+ let current = startDir
73
+ for (;;) {
74
+ const modules = path.join(current, "node_modules")
75
+ if (fs.existsSync(modules)) {
76
+ const entries = fs.readdirSync(modules)
77
+ for (const entry of entries) {
78
+ if (!entry.startsWith(base)) {
79
+ continue
80
+ }
81
+ const candidate = path.join(modules, entry, "bin", binary)
82
+ if (fs.existsSync(candidate)) {
83
+ return candidate
84
+ }
85
+ }
86
+ }
87
+ const parent = path.dirname(current)
88
+ if (parent === current) {
89
+ return
90
+ }
91
+ current = parent
92
+ }
93
+ }
94
+
95
+ const resolved = findBinary(scriptDir)
96
+ if (!resolved) {
97
+ console.error(
98
+ 'It seems that your package manager failed to install the right version of the dfcode CLI for your platform. You can try manually installing the "' +
99
+ base +
100
+ '" package',
101
+ )
102
+ process.exit(1)
103
+ }
104
+
105
+ run(resolved)
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "dfcode",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.1-beta.2",
4
+ "type": "module",
4
5
  "description": "AI-powered coding assistant - TUI interface",
5
6
  "bin": {
6
- "dfcode": "./bin/dfcode"
7
+ "dfcode": "bin/dfcode.js"
7
8
  },
8
9
  "scripts": {
9
10
  "postinstall": "node ./postinstall.mjs"
10
11
  },
11
12
  "optionalDependencies": {
12
- "dfcode-darwin-arm64": "3.0.0-beta.1",
13
- "dfcode-darwin-x64": "3.0.0-beta.1",
14
- "dfcode-linux-x64": "3.0.0-beta.1",
15
- "dfcode-linux-arm64": "3.0.0-beta.1",
16
- "dfcode-windows-x64": "3.0.0-beta.1"
13
+ "dfcode-darwin-arm64": "3.0.1-beta.2",
14
+ "dfcode-darwin-x64": "3.0.1-beta.2",
15
+ "dfcode-linux-x64": "3.0.1-beta.2",
16
+ "dfcode-linux-arm64": "3.0.1-beta.2",
17
+ "dfcode-windows-x64": "3.0.1-beta.2"
17
18
  },
18
19
  "license": "MIT",
19
- "keywords": ["ai", "coding", "assistant", "cli", "tui", "llm", "claude", "openai", "gpt"]
20
+ "keywords": ["ai","coding","assistant","cli","tui","llm","claude","openai","gpt"]
20
21
  }