anymous 1.0.1 → 1.0.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.
- package/package.json +1 -1
- package/script/postinstall.mjs +189 -0
- package/src/agent/prompt/web-designer.txt +23 -0
- package/src/cli/cmd/upgrade.ts +43 -4
- package/src/cli/upgrade.ts +26 -0
package/package.json
CHANGED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import childProcess from "child_process"
|
|
4
|
+
import fs from "fs"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import path from "path"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
import { fileURLToPath } from "url"
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
|
|
13
|
+
|
|
14
|
+
const platformMap = {
|
|
15
|
+
darwin: "darwin",
|
|
16
|
+
linux: "linux",
|
|
17
|
+
win32: "windows",
|
|
18
|
+
}
|
|
19
|
+
const archMap = {
|
|
20
|
+
x64: "x64",
|
|
21
|
+
arm64: "arm64",
|
|
22
|
+
arm: "arm",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const platform = platformMap[os.platform()] ?? os.platform()
|
|
26
|
+
const arch = archMap[os.arch()] ?? os.arch()
|
|
27
|
+
const base = `opencode-${platform}-${arch}`
|
|
28
|
+
const sourceBinary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
29
|
+
const targetBinary = path.join(__dirname, "bin", "opencode.exe")
|
|
30
|
+
|
|
31
|
+
function supportsAvx2() {
|
|
32
|
+
if (arch !== "x64") return false
|
|
33
|
+
|
|
34
|
+
if (platform === "linux") {
|
|
35
|
+
try {
|
|
36
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
37
|
+
} catch {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (platform === "darwin") {
|
|
43
|
+
try {
|
|
44
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
45
|
+
encoding: "utf8",
|
|
46
|
+
timeout: 1500,
|
|
47
|
+
})
|
|
48
|
+
if (result.status !== 0) return false
|
|
49
|
+
return (result.stdout || "").trim() === "1"
|
|
50
|
+
} catch {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (platform === "windows") {
|
|
56
|
+
const command =
|
|
57
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
58
|
+
|
|
59
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
60
|
+
try {
|
|
61
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
62
|
+
encoding: "utf8",
|
|
63
|
+
timeout: 3000,
|
|
64
|
+
windowsHide: true,
|
|
65
|
+
})
|
|
66
|
+
if (result.status !== 0) continue
|
|
67
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
68
|
+
if (output === "true" || output === "1") return true
|
|
69
|
+
if (output === "false" || output === "0") return false
|
|
70
|
+
} catch {
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function isMusl() {
|
|
80
|
+
if (platform !== "linux") return false
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
84
|
+
} catch {
|
|
85
|
+
// Ignore filesystem probes that are blocked by the host.
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
90
|
+
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
91
|
+
} catch {
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function packageNames() {
|
|
97
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
98
|
+
|
|
99
|
+
if (platform === "linux") {
|
|
100
|
+
if (isMusl()) {
|
|
101
|
+
if (arch === "x64")
|
|
102
|
+
return baseline
|
|
103
|
+
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
104
|
+
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
105
|
+
return [`${base}-musl`, base]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (arch === "x64")
|
|
109
|
+
return baseline
|
|
110
|
+
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
111
|
+
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
112
|
+
return [base, `${base}-musl`]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
|
|
116
|
+
return [base]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function resolveBinary(name) {
|
|
120
|
+
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
121
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
|
|
122
|
+
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
|
|
123
|
+
return binaryPath
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function installPackage(name) {
|
|
127
|
+
const version = packageJson.optionalDependencies?.[name]
|
|
128
|
+
if (!version) return
|
|
129
|
+
|
|
130
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-install-"))
|
|
131
|
+
try {
|
|
132
|
+
const result = childProcess.spawnSync(
|
|
133
|
+
"npm",
|
|
134
|
+
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
135
|
+
{ stdio: "inherit", windowsHide: true },
|
|
136
|
+
)
|
|
137
|
+
if (result.status !== 0) return
|
|
138
|
+
const packageDir = path.join(temp, "node_modules", name)
|
|
139
|
+
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
|
|
140
|
+
return true
|
|
141
|
+
} finally {
|
|
142
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function copyBinary(source, target) {
|
|
147
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
148
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
149
|
+
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
150
|
+
try {
|
|
151
|
+
fs.linkSync(source, target)
|
|
152
|
+
} catch {
|
|
153
|
+
fs.copyFileSync(source, target)
|
|
154
|
+
}
|
|
155
|
+
fs.chmodSync(target, 0o755)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function verifyBinary() {
|
|
159
|
+
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
160
|
+
encoding: "utf8",
|
|
161
|
+
stdio: "ignore",
|
|
162
|
+
windowsHide: true,
|
|
163
|
+
})
|
|
164
|
+
return result.status === 0
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function main() {
|
|
168
|
+
for (const name of packageNames()) {
|
|
169
|
+
try {
|
|
170
|
+
copyBinary(resolveBinary(name), targetBinary)
|
|
171
|
+
if (verifyBinary()) return
|
|
172
|
+
} catch {
|
|
173
|
+
if (installPackage(name) && verifyBinary()) return
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
throw new Error(
|
|
178
|
+
`It seems your package manager failed to install the right opencode CLI package. Try manually installing ${packageNames()
|
|
179
|
+
.map((name) => JSON.stringify(name))
|
|
180
|
+
.join(" or ")}.`,
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
main()
|
|
186
|
+
} catch (error) {
|
|
187
|
+
console.error(error.message)
|
|
188
|
+
process.exit(1)
|
|
189
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Expert Web Designer
|
|
2
|
+
|
|
3
|
+
## Expertise
|
|
4
|
+
- Frontend development: HTML, CSS, JavaScript, Tailwind, Three.js, WebGL
|
|
5
|
+
- UI/UX design: glassmorphism, neumorphism, dark/light themes, responsive layouts
|
|
6
|
+
- Visual effects: blur, glow, animations, 3D objects, particle systems
|
|
7
|
+
- Color theory: palettes, gradients, contrast, accessibility
|
|
8
|
+
- Vercel deployment, npm publishing, performance optimization
|
|
9
|
+
|
|
10
|
+
## Protocol
|
|
11
|
+
1. Ask user for the visual direction (dark/light, colors, effects)
|
|
12
|
+
2. Design the layout structure first, then visual details
|
|
13
|
+
3. Test responsiveness and performance
|
|
14
|
+
4. Deploy and verify
|
|
15
|
+
|
|
16
|
+
## Output Format
|
|
17
|
+
- Clean, minimal code with only what's needed
|
|
18
|
+
- Inline CSS for single-page sites
|
|
19
|
+
- CDN imports for libraries (Three.js, Tailwind)
|
|
20
|
+
|
|
21
|
+
## Cross-Agent Handoff
|
|
22
|
+
- **reverser-source**: generates site content about RE
|
|
23
|
+
- **reverser-automator**: generates HTML/JS automation tools for the site
|
package/src/cli/cmd/upgrade.ts
CHANGED
|
@@ -4,6 +4,19 @@ import * as prompts from "@clack/prompts"
|
|
|
4
4
|
import { Installation } from "../../installation"
|
|
5
5
|
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
|
6
6
|
|
|
7
|
+
const OPENCODE_RELEASES = "https://api.github.com/repos/anomalyco/opencode/releases/latest"
|
|
8
|
+
|
|
9
|
+
async function checkOpenCodeUpdate(): Promise<string | null> {
|
|
10
|
+
try {
|
|
11
|
+
const resp = await fetch(OPENCODE_RELEASES, { headers: { "User-Agent": "anymous" } })
|
|
12
|
+
if (!resp.ok) return null
|
|
13
|
+
const data: any = await resp.json()
|
|
14
|
+
return (data.tag_name as string).replace(/^v/, "")
|
|
15
|
+
} catch {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
export const UpgradeCommand = {
|
|
8
21
|
command: "upgrade [target]",
|
|
9
22
|
describe: "upgrade Anymous to the latest or a specific version",
|
|
@@ -19,16 +32,43 @@ export const UpgradeCommand = {
|
|
|
19
32
|
type: "string",
|
|
20
33
|
choices: ["curl", "npm", "pnpm", "bun", "brew", "choco", "scoop"],
|
|
21
34
|
})
|
|
35
|
+
.option("sync", {
|
|
36
|
+
alias: "s",
|
|
37
|
+
describe: "sync with latest opencode release before upgrading",
|
|
38
|
+
type: "boolean",
|
|
39
|
+
default: false,
|
|
40
|
+
})
|
|
22
41
|
},
|
|
23
|
-
handler: async (args: { target?: string; method?: string }) => {
|
|
42
|
+
handler: async (args: { target?: string; method?: string; sync?: boolean }) => {
|
|
24
43
|
UI.empty()
|
|
25
44
|
UI.println(UI.logo(" "))
|
|
26
45
|
UI.empty()
|
|
27
46
|
prompts.intro("Upgrade")
|
|
47
|
+
|
|
48
|
+
// Check for opencode updates
|
|
49
|
+
const opencodeLatest = await checkOpenCodeUpdate()
|
|
50
|
+
if (opencodeLatest && opencodeLatest !== InstallationVersion) {
|
|
51
|
+
prompts.log.info(`OpenCode v${opencodeLatest} disponível (atual: v${InstallationVersion})`)
|
|
52
|
+
if (args.sync) {
|
|
53
|
+
prompts.log.info("Sincronizando com opencode...")
|
|
54
|
+
prompts.log.info(`Execute: bun run script/sync-opencode.ts --version=${opencodeLatest}`)
|
|
55
|
+
} else {
|
|
56
|
+
const sync = await prompts.confirm({
|
|
57
|
+
message: `Sincronizar com opencode v${opencodeLatest}?`,
|
|
58
|
+
initialValue: false,
|
|
59
|
+
})
|
|
60
|
+
if (sync) {
|
|
61
|
+
prompts.log.info(`Execute para sincronizar:`)
|
|
62
|
+
prompts.log.info(` bun run script/sync-opencode.ts --version=${opencodeLatest}`)
|
|
63
|
+
prompts.log.info(`Depois: cd packages/opencode/dist-npm && npm publish --access public`)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
28
68
|
const detectedMethod = await Installation.method()
|
|
29
69
|
const method = (args.method as Installation.Method) ?? detectedMethod
|
|
30
70
|
if (method === "unknown") {
|
|
31
|
-
prompts.log.error(`
|
|
71
|
+
prompts.log.error(`anymous is installed to ${process.execPath} and may be managed by a package manager`)
|
|
32
72
|
const install = await prompts.select({
|
|
33
73
|
message: "Install anyways?",
|
|
34
74
|
options: [
|
|
@@ -46,7 +86,7 @@ export const UpgradeCommand = {
|
|
|
46
86
|
const target = args.target ? args.target.replace(/^v/, "") : await Installation.latest()
|
|
47
87
|
|
|
48
88
|
if (InstallationVersion === target) {
|
|
49
|
-
prompts.log.warn(`
|
|
89
|
+
prompts.log.warn(`anymous upgrade skipped: ${target} is already installed`)
|
|
50
90
|
prompts.outro("Done")
|
|
51
91
|
return
|
|
52
92
|
}
|
|
@@ -58,7 +98,6 @@ export const UpgradeCommand = {
|
|
|
58
98
|
if (err) {
|
|
59
99
|
spinner.stop("Upgrade failed", 1)
|
|
60
100
|
if (err instanceof Installation.UpgradeFailedError) {
|
|
61
|
-
// necessary because choco only allows install/upgrade in elevated terminals
|
|
62
101
|
if (method === "choco" && err.stderr.includes("not running from an elevated command shell")) {
|
|
63
102
|
prompts.log.error("Please run the terminal as Administrator and try again")
|
|
64
103
|
} else {
|
package/src/cli/upgrade.ts
CHANGED
|
@@ -5,9 +5,35 @@ import { Installation } from "@/installation"
|
|
|
5
5
|
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
|
6
6
|
import { GlobalBus } from "@/bus/global"
|
|
7
7
|
|
|
8
|
+
const OPENCODE_RELEASES = "https://api.github.com/repos/anomalyco/opencode/releases/latest"
|
|
9
|
+
|
|
10
|
+
async function checkOpenCodeUpdate(): Promise<string | null> {
|
|
11
|
+
try {
|
|
12
|
+
const resp = await fetch(OPENCODE_RELEASES, { headers: { "User-Agent": "anymous" } })
|
|
13
|
+
if (!resp.ok) return null
|
|
14
|
+
const data: any = await resp.json()
|
|
15
|
+
return (data.tag_name as string).replace(/^v/, "")
|
|
16
|
+
} catch {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
export async function upgrade() {
|
|
9
22
|
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
|
|
10
23
|
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
|
|
24
|
+
|
|
25
|
+
// Check if opencode has a newer release (sync needed)
|
|
26
|
+
const opencodeLatest = await checkOpenCodeUpdate()
|
|
27
|
+
if (opencodeLatest && opencodeLatest !== InstallationVersion) {
|
|
28
|
+
GlobalBus.emit("event", {
|
|
29
|
+
directory: "global",
|
|
30
|
+
payload: {
|
|
31
|
+
type: Installation.Event.UpdateAvailable.type,
|
|
32
|
+
properties: { version: `opencode v${opencodeLatest} — run 'bun run script/sync-opencode.ts' to sync` },
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
11
37
|
const method = await Installation.method()
|
|
12
38
|
const latest = await Installation.latest(method).catch(() => {})
|
|
13
39
|
if (!latest) return
|