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