@farcyse/cli 0.0.0-stage → 2.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/farcyse.cjs ADDED
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env bun
2
+
3
+ const { createHash } = require("node:crypto")
4
+ const { spawn } = require("node:child_process")
5
+ const { chmod, copyFile, mkdir, mkdtemp, rename, rm, stat, unlink } = require("node:fs/promises")
6
+ const { existsSync, realpathSync } = require("node:fs")
7
+ const os = require("node:os")
8
+ const path = require("node:path")
9
+
10
+ async function main() {
11
+ const root = path.dirname(realpathSync(__filename))
12
+ const args = process.argv.slice(2)
13
+ const platform = process.platform === "win32" ? "windows" : process.platform
14
+ const musl = platform === "linux" && isMusl() ? "-musl" : ""
15
+ const target = `${platform}-${process.arch}${musl}`
16
+ const manifest = require(path.join(root, "package.json"))
17
+ const assetName = manifest.name + "-" + target
18
+ if (!manifest.optionalDependencies?.[assetName]) throw new Error(`This FarCyse package does not include ${target}`)
19
+ let assetManifest
20
+ try {
21
+ assetManifest = require.resolve(assetName + "/package.json", { paths: [root] })
22
+ } catch (error) {
23
+ if (error.code !== "MODULE_NOT_FOUND") throw error
24
+ throw new Error(`Missing ${assetName}. Reinstall FarCyse with optional dependencies enabled.`)
25
+ }
26
+ const payload = path.join(path.dirname(assetManifest), "payload")
27
+ const assets = require(path.join(payload, "manifest.json"))
28
+ const asset = assets[target]
29
+ if (!asset) throw new Error(`This FarCyse package does not include ${target}`)
30
+ const cache = path.join(process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache"), "farcyse", "private-cli")
31
+ const filename = platform === "windows" ? "farcyse.exe" : "farcyse"
32
+ const executable = path.join(cache, asset.sha256, filename)
33
+ if (!existsSync(executable)) await unpack(payload, cache, filename, target, asset)
34
+
35
+ const env = { ...process.env }
36
+ delete env.FARCYSE_PRIVATE_UNINSTALL_BUN
37
+ delete env.FARCYSE_PRIVATE_UNINSTALL_NPM
38
+ env.FARCYSE_CONFIG ||= path.join(root, "farcyse.json")
39
+ const uninstall = args.find((arg) => !/^--(?:no-)?print-logs(?:=|$)/.test(arg)) === "uninstall"
40
+ const manager = uninstall ? locateGlobalPackage(root, manifest.name) : undefined
41
+ if (manager?.method === "bun") env.FARCYSE_PRIVATE_UNINSTALL_BUN = process.execPath
42
+ if (manager?.method === "npm") env.FARCYSE_PRIVATE_UNINSTALL_NPM = "1"
43
+
44
+ // Windows locks running executables. Run uninstall from a temporary copy so its own cache can be removed.
45
+ const temp = platform === "windows" && uninstall
46
+ ? await mkdtemp(path.join(os.tmpdir(), "farcyse-uninstall-"))
47
+ : undefined
48
+ try {
49
+ const binary = temp ? path.join(temp, filename) : executable
50
+ if (temp) await copyFile(executable, binary)
51
+ const proc = Bun.spawn([binary, ...args], { env, stdin: "inherit", stdout: "inherit", stderr: "inherit" })
52
+ const signals = platform === "windows" ? ["SIGINT", "SIGTERM"] : ["SIGINT", "SIGTERM", "SIGHUP", "SIGUSR1"]
53
+ const handlers = signals.map((signal) => [signal, () => {
54
+ if (proc.exitCode === null) proc.kill(signal)
55
+ }])
56
+ for (const [signal, handler] of handlers) process.on(signal, handler)
57
+ try {
58
+ process.exitCode = await proc.exited
59
+ if (platform === "windows" && process.exitCode === 0 && manager?.method === "bun" && !existsSync(manager.package)) {
60
+ await removeWindowsShim(manager)
61
+ }
62
+ } finally {
63
+ for (const [signal, handler] of handlers) process.off(signal, handler)
64
+ }
65
+ } finally {
66
+ if (temp) await rm(temp, { recursive: true, force: true })
67
+ }
68
+ }
69
+
70
+ function locateGlobalPackage(root, name) {
71
+ const query = (command) => {
72
+ if (!Bun.which(command[0])) return ""
73
+ const result = Bun.spawnSync(command, { stdout: "pipe", stderr: "pipe" })
74
+ return result.success ? result.stdout.toString().trim() : ""
75
+ }
76
+ const npmModules = query(["npm", "root", "--global"])
77
+ if (path.isAbsolute(npmModules)) {
78
+ const installed = path.join(npmModules, name)
79
+ if (existsSync(installed) && realpathSync(installed) === root) return { method: "npm", package: installed }
80
+ }
81
+ const directory = query([process.execPath, "pm", "ls", "--global"]).match(/^(.+) node_modules \(\d+ installed\)/m)?.[1]
82
+ if (!directory) return
83
+ const installed = path.join(directory, "node_modules", name)
84
+ if (!existsSync(installed) || realpathSync(installed) !== root) return
85
+ const bin = query([process.execPath, "pm", "bin", "--global"])
86
+ return { method: "bun", package: installed, bin: path.isAbsolute(bin) ? bin : undefined }
87
+ }
88
+
89
+ async function removeWindowsShim(manager) {
90
+ if (!manager.bin) return
91
+ const shim = path.join(manager.bin, "farcyse.exe")
92
+ const metadata = path.join(manager.bin, "farcyse.bunx")
93
+ if (existsSync(metadata) || !existsSync(shim)) return
94
+ try {
95
+ await unlink(shim)
96
+ } catch (error) {
97
+ if (error.code === "ENOENT") return
98
+ if (error.code !== "EPERM" && error.code !== "EBUSY" && error.code !== "EACCES") throw error
99
+ // Bun removes the package and shim metadata, but Windows may lock the shim until the caller exits.
100
+ spawn(process.execPath, ["--eval", `(${retryShimRemoval.toString()})()`], {
101
+ detached: true,
102
+ stdio: "ignore",
103
+ windowsHide: true,
104
+ env: {
105
+ ...process.env,
106
+ FARCYSE_STALE_SHIM: shim,
107
+ FARCYSE_STALE_SHIM_MARKER: metadata,
108
+ FARCYSE_STALE_SHIM_PACKAGE: manager.package,
109
+ },
110
+ }).unref()
111
+ }
112
+ }
113
+
114
+ async function retryShimRemoval() {
115
+ const { existsSync, unlinkSync } = require("node:fs")
116
+ for (let attempts = 0; attempts < 40; attempts++) {
117
+ if (existsSync(process.env.FARCYSE_STALE_SHIM_MARKER) || existsSync(process.env.FARCYSE_STALE_SHIM_PACKAGE)) return
118
+ try {
119
+ unlinkSync(process.env.FARCYSE_STALE_SHIM)
120
+ return
121
+ } catch (error) {
122
+ if (error.code === "ENOENT") return
123
+ if (error.code !== "EPERM" && error.code !== "EBUSY" && error.code !== "EACCES") throw error
124
+ }
125
+ await Bun.sleep(250)
126
+ }
127
+ }
128
+
129
+ function isMusl() {
130
+ if (existsSync("/etc/alpine-release")) return true
131
+ const ldd = Bun.which("ldd")
132
+ if (!ldd) return false
133
+ const result = Bun.spawnSync([ldd, "--version"], { stdout: "pipe", stderr: "pipe" })
134
+ return /musl/i.test(result.stdout.toString() + result.stderr.toString())
135
+ }
136
+
137
+ async function unpack(payload, cache, filename, target, asset) {
138
+ await mkdir(cache, { recursive: true })
139
+ const staging = await mkdtemp(path.join(cache, ".extract-"))
140
+ try {
141
+ const hash = createHash("sha256")
142
+ const uncompressed = path.join(staging, filename)
143
+ const writer = Bun.file(uncompressed).writer()
144
+ try {
145
+ for (let index = 0; index < asset.parts; index++) {
146
+ const bytes = Bun.gunzipSync(await Bun.file(path.join(payload, `${target}.${index}.gz`)).bytes())
147
+ hash.update(bytes)
148
+ await writer.write(bytes)
149
+ }
150
+ } finally {
151
+ await writer.end()
152
+ }
153
+ if (hash.digest("hex") !== asset.sha256) throw new Error(`Checksum mismatch for ${target}`)
154
+ await chmod(uncompressed, 0o755)
155
+ const destination = path.join(cache, asset.sha256)
156
+ await rename(staging, destination).catch(async (error) => {
157
+ if (!(await stat(path.join(destination, filename)).catch(() => undefined))?.isFile()) throw error
158
+ })
159
+ } finally {
160
+ await rm(staging, { recursive: true, force: true })
161
+ }
162
+ }
163
+
164
+ main().catch((error) => {
165
+ console.error(error.message)
166
+ process.exitCode = 1
167
+ })
package/farcyse.json ADDED
@@ -0,0 +1,206 @@
1
+ {
2
+ "model": "openai/gpt-5.4-mini",
3
+ "agents": {
4
+ "web": {
5
+ "mode": "subagent",
6
+ "description": "Review saved HTTP, HAR, and browser fixture evidence",
7
+ "model": "openai/gpt-5.5",
8
+ "system": "Work with local artifacts staged by the operator under .farcyse/artifacts. Cite the supporting file and distinguish observed facts from inferences.\n\nSummarize recorded requests, status codes, headers, and page behavior. Inspect operator-opened local fixtures through the read-only Playwright tools when available.",
9
+ "permissions": [
10
+ {
11
+ "action": "*",
12
+ "resource": "*",
13
+ "effect": "deny"
14
+ },
15
+ {
16
+ "action": "read",
17
+ "resource": "*",
18
+ "effect": "allow"
19
+ },
20
+ {
21
+ "action": "glob",
22
+ "resource": "*",
23
+ "effect": "allow"
24
+ },
25
+ {
26
+ "action": "grep",
27
+ "resource": "*",
28
+ "effect": "allow"
29
+ },
30
+ {
31
+ "action": "playwright_fixture_browser_snapshot",
32
+ "resource": "*",
33
+ "effect": "allow"
34
+ },
35
+ {
36
+ "action": "playwright_fixture_browser_network_requests",
37
+ "resource": "*",
38
+ "effect": "allow"
39
+ }
40
+ ]
41
+ },
42
+ "crypto": {
43
+ "mode": "subagent",
44
+ "description": "Identify formats and encodings in local puzzle artifacts",
45
+ "model": "openai/gpt-5.5",
46
+ "system": "Work with local artifacts staged by the operator under .farcyse/artifacts. Cite the supporting file and distinguish observed facts from inferences.\n\nIdentify encoding, container format, and cryptographic metadata from supplied samples. Explain what the evidence establishes and what extra artifact would resolve ambiguity.",
47
+ "permissions": [
48
+ {
49
+ "action": "*",
50
+ "resource": "*",
51
+ "effect": "deny"
52
+ },
53
+ {
54
+ "action": "read",
55
+ "resource": "*",
56
+ "effect": "allow"
57
+ },
58
+ {
59
+ "action": "glob",
60
+ "resource": "*",
61
+ "effect": "allow"
62
+ },
63
+ {
64
+ "action": "grep",
65
+ "resource": "*",
66
+ "effect": "allow"
67
+ }
68
+ ]
69
+ },
70
+ "pwn": {
71
+ "mode": "subagent",
72
+ "description": "Inventory executable formats and hardening evidence",
73
+ "model": "openai/gpt-5.5",
74
+ "system": "Work with local artifacts staged by the operator under .farcyse/artifacts. Cite the supporting file and distinguish observed facts from inferences.\n\nInspect supplied binary metadata, headers, and static reports. Record architecture, imports, and reported hardening properties. Use artifact evidence without executing binaries or generating exploits.",
75
+ "permissions": [
76
+ {
77
+ "action": "*",
78
+ "resource": "*",
79
+ "effect": "deny"
80
+ },
81
+ {
82
+ "action": "read",
83
+ "resource": "*",
84
+ "effect": "allow"
85
+ },
86
+ {
87
+ "action": "glob",
88
+ "resource": "*",
89
+ "effect": "allow"
90
+ },
91
+ {
92
+ "action": "grep",
93
+ "resource": "*",
94
+ "effect": "allow"
95
+ }
96
+ ]
97
+ },
98
+ "reverse": {
99
+ "mode": "subagent",
100
+ "description": "Summarize symbols and structure from static local evidence",
101
+ "model": "openai/gpt-5.5",
102
+ "system": "Work with local artifacts staged by the operator under .farcyse/artifacts. Cite the supporting file and distinguish observed facts from inferences.\n\nExplain program structure from supplied symbols, strings, disassembly, or decompiler exports. Reference offsets or symbol names and preserve uncertainty about inferred behavior.",
103
+ "permissions": [
104
+ {
105
+ "action": "*",
106
+ "resource": "*",
107
+ "effect": "deny"
108
+ },
109
+ {
110
+ "action": "read",
111
+ "resource": "*",
112
+ "effect": "allow"
113
+ },
114
+ {
115
+ "action": "glob",
116
+ "resource": "*",
117
+ "effect": "allow"
118
+ },
119
+ {
120
+ "action": "grep",
121
+ "resource": "*",
122
+ "effect": "allow"
123
+ }
124
+ ]
125
+ },
126
+ "forensics": {
127
+ "mode": "subagent",
128
+ "description": "Inventory offline evidence and build timelines",
129
+ "model": "openai/gpt-5.5",
130
+ "system": "Work with local artifacts staged by the operator under .farcyse/artifacts. Cite the supporting file and distinguish observed facts from inferences.\n\nCorrelate timestamps and hash values across local evidence. Keep original time zones, report gaps, and identify conflicting records.",
131
+ "permissions": [
132
+ {
133
+ "action": "*",
134
+ "resource": "*",
135
+ "effect": "deny"
136
+ },
137
+ {
138
+ "action": "read",
139
+ "resource": "*",
140
+ "effect": "allow"
141
+ },
142
+ {
143
+ "action": "glob",
144
+ "resource": "*",
145
+ "effect": "allow"
146
+ },
147
+ {
148
+ "action": "grep",
149
+ "resource": "*",
150
+ "effect": "allow"
151
+ }
152
+ ]
153
+ }
154
+ },
155
+ "permissions": [
156
+ {
157
+ "action": "playwright_fixture_*",
158
+ "resource": "*",
159
+ "effect": "deny"
160
+ },
161
+ {
162
+ "action": "playwright_fixture_browser_snapshot",
163
+ "resource": "*",
164
+ "effect": "allow"
165
+ },
166
+ {
167
+ "action": "playwright_fixture_browser_network_requests",
168
+ "resource": "*",
169
+ "effect": "allow"
170
+ }
171
+ ],
172
+ "policies": [
173
+ {
174
+ "action": "tool.use",
175
+ "resource": "playwright_fixture_*:*",
176
+ "effect": "deny"
177
+ },
178
+ {
179
+ "action": "tool.use",
180
+ "resource": "playwright_fixture_browser_snapshot:*",
181
+ "effect": "allow"
182
+ },
183
+ {
184
+ "action": "tool.use",
185
+ "resource": "playwright_fixture_browser_network_requests:*",
186
+ "effect": "allow"
187
+ }
188
+ ],
189
+ "mcp": {
190
+ "servers": {
191
+ "playwright_fixture": {
192
+ "type": "local",
193
+ "command": [
194
+ "npx",
195
+ "-y",
196
+ "@playwright/mcp@0.0.86",
197
+ "--cdp-endpoint",
198
+ "http://127.0.0.1:9222"
199
+ ],
200
+ "disabled": true,
201
+ "codemode": false,
202
+ "protocol": "legacy"
203
+ }
204
+ }
205
+ }
206
+ }
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
+ "version": "2.4.1",
3
+ "license": "MIT",
4
+ "publishConfig": {
5
+ "registry": "https://registry.npmjs.org/",
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/farcyse/farcyse.git"
11
+ },
2
12
  "name": "@farcyse/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
13
+ "description": "FarCyse CLI",
14
+ "bin": {
15
+ "farcyse": "./farcyse.cjs"
16
+ },
17
+ "files": [
18
+ "farcyse.cjs",
19
+ "farcyse.json",
20
+ "LICENSE"
21
+ ],
22
+ "optionalDependencies": {
23
+ "@farcyse/cli-windows-x64": "2.4.1",
24
+ "@farcyse/cli-darwin-arm64": "2.4.1",
25
+ "@farcyse/cli-darwin-x64": "2.4.1"
26
+ }
27
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.