anymous 1.0.1 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymous",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AI-powered reverse engineering platform",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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(`opencode is installed to ${process.execPath} and may be managed by a package manager`)
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(`opencode upgrade skipped: ${target} is already installed`)
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 {
@@ -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