alchemylab-opencode 1.0.3 → 1.0.4
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/build.mjs +153 -0
- package/dist/chunk-7JG6KCBC.js +78 -0
- package/dist/chunk-7JG6KCBC.js.map +7 -0
- package/dist/chunk-CMAI7CAJ.js +2270 -0
- package/dist/chunk-CMAI7CAJ.js.map +7 -0
- package/dist/chunk-FPPWDLO7.js +117 -0
- package/dist/chunk-FPPWDLO7.js.map +7 -0
- package/dist/chunk-K4ME3WTI.js +6525 -0
- package/dist/chunk-K4ME3WTI.js.map +7 -0
- package/dist/chunk-KMHCMDYS.js +309 -0
- package/dist/chunk-KMHCMDYS.js.map +7 -0
- package/dist/chunk-NBI23JB4.js +23721 -0
- package/dist/chunk-NBI23JB4.js.map +7 -0
- package/dist/chunk-P44FI4UK.js +21 -0
- package/dist/chunk-P44FI4UK.js.map +7 -0
- package/dist/chunk-SM4I7RU4.js +718 -0
- package/dist/chunk-SM4I7RU4.js.map +7 -0
- package/dist/chunk-WCK3PNT7.js +5015 -0
- package/dist/chunk-WCK3PNT7.js.map +7 -0
- package/dist/mcp-6ID7DRNS.js +12 -0
- package/dist/mcp-6ID7DRNS.js.map +7 -0
- package/dist/pty.node-IR7ZMJYY.js +30 -0
- package/dist/pty.node-IR7ZMJYY.js.map +7 -0
- package/dist/registry-O4THPVFS.js +13 -0
- package/dist/registry-O4THPVFS.js.map +7 -0
- package/dist/run-HRWKT4NL.js +4781 -0
- package/dist/run-HRWKT4NL.js.map +7 -0
- package/dist/run-service-23VXHTA6.js +12 -0
- package/dist/run-service-23VXHTA6.js.map +7 -0
- package/dist/run.js +12 -0
- package/dist/run.js.map +7 -0
- package/dist/schema-YARWYUAH.js +14 -0
- package/dist/schema-YARWYUAH.js.map +7 -0
- package/dist/serve.js +31 -0
- package/dist/serve.js.map +7 -0
- package/dist/server-MHSLBRNZ.js +16 -0
- package/dist/server-MHSLBRNZ.js.map +7 -0
- package/dist/session-3UEFY5NC.js +13 -0
- package/dist/session-3UEFY5NC.js.map +7 -0
- package/dist/share-next-Q5WQ2ELY.js +14 -0
- package/dist/share-next-Q5WQ2ELY.js.map +7 -0
- package/dist/worktree-E5I74P2A.js +53 -0
- package/dist/worktree-E5I74P2A.js.map +7 -0
- package/package.json +10 -3
package/build.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild'
|
|
2
|
+
import { readFileSync, existsSync } from 'fs'
|
|
3
|
+
import { join, resolve, extname } from 'path'
|
|
4
|
+
|
|
5
|
+
const ROOT = resolve(import.meta.dirname)
|
|
6
|
+
const SRC = join(ROOT, 'packages/opencode/src')
|
|
7
|
+
const PACKAGES = join(ROOT, 'packages')
|
|
8
|
+
|
|
9
|
+
const tsExtensions = ['.ts', '.tsx', '/index.ts', '/index.tsx']
|
|
10
|
+
|
|
11
|
+
function resolveWithExtensions(path) {
|
|
12
|
+
if (extname(path) && existsSync(path)) return path
|
|
13
|
+
for (const ext of tsExtensions) {
|
|
14
|
+
const candidate = path + ext
|
|
15
|
+
if (existsSync(candidate)) return candidate
|
|
16
|
+
}
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// .txt → string export
|
|
21
|
+
const txtPlugin = {
|
|
22
|
+
name: 'txt-loader',
|
|
23
|
+
setup(build) {
|
|
24
|
+
build.onLoad({ filter: /\.txt$/ }, async (args) => {
|
|
25
|
+
const text = readFileSync(args.path, 'utf8')
|
|
26
|
+
return { contents: `export default ${JSON.stringify(text)}`, loader: 'js' }
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// #db / #pty → node implementations
|
|
32
|
+
const conditionalImportsPlugin = {
|
|
33
|
+
name: 'conditional-imports',
|
|
34
|
+
setup(build) {
|
|
35
|
+
build.onResolve({ filter: /^#db$/ }, () => ({ path: join(SRC, 'storage/db.node.ts') }))
|
|
36
|
+
build.onResolve({ filter: /^#pty$/ }, () => ({ path: join(SRC, 'pty/pty.node.ts') }))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// @/ and @tui/ path aliases
|
|
41
|
+
const aliasPlugin = {
|
|
42
|
+
name: 'path-aliases',
|
|
43
|
+
setup(build) {
|
|
44
|
+
build.onResolve({ filter: /^@\// }, (args) => {
|
|
45
|
+
const resolved = resolveWithExtensions(join(SRC, args.path.slice(2)))
|
|
46
|
+
return resolved ? { path: resolved } : undefined
|
|
47
|
+
})
|
|
48
|
+
build.onResolve({ filter: /^@tui\// }, (args) => {
|
|
49
|
+
const resolved = resolveWithExtensions(join(SRC, 'cli/cmd/tui', args.path.slice(5)))
|
|
50
|
+
return resolved ? { path: resolved } : undefined
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// @opencode-ai/* → resolve to local packages source (bundle them)
|
|
56
|
+
const opencodePackagesPlugin = {
|
|
57
|
+
name: 'opencode-packages',
|
|
58
|
+
setup(build) {
|
|
59
|
+
build.onResolve({ filter: /^@opencode-ai\// }, (args) => {
|
|
60
|
+
// @opencode-ai/plugin → packages/plugin/src/index.ts
|
|
61
|
+
// @opencode-ai/sdk → packages/sdk/src/index.ts
|
|
62
|
+
// @opencode-ai/sdk/v2 → packages/sdk/src/v2/index.ts
|
|
63
|
+
// @opencode-ai/util/error → packages/util/src/error.ts
|
|
64
|
+
const parts = args.path.replace('@opencode-ai/', '').split('/')
|
|
65
|
+
const pkg = parts[0] // plugin, sdk, util, script
|
|
66
|
+
const subpath = parts.slice(1).join('/')
|
|
67
|
+
|
|
68
|
+
let target
|
|
69
|
+
if (subpath) {
|
|
70
|
+
target = join(PACKAGES, pkg, 'src', subpath)
|
|
71
|
+
} else {
|
|
72
|
+
target = join(PACKAGES, pkg, 'src', 'index')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const resolved = resolveWithExtensions(target)
|
|
76
|
+
return resolved ? { path: resolved } : undefined
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Stub bun:* and bun imports
|
|
82
|
+
const bunStubPlugin = {
|
|
83
|
+
name: 'bun-stub',
|
|
84
|
+
setup(build) {
|
|
85
|
+
build.onResolve({ filter: /^bun(:|$)/ }, (args) => ({
|
|
86
|
+
path: args.path, namespace: 'bun-stub',
|
|
87
|
+
}))
|
|
88
|
+
build.onLoad({ filter: /.*/, namespace: 'bun-stub' }, () => ({
|
|
89
|
+
contents: 'export default {}', loader: 'js',
|
|
90
|
+
}))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// Fix external imports that don't work in Node ESM without extensions
|
|
96
|
+
const fixExternalImportsPlugin = {
|
|
97
|
+
name: 'fix-external-imports',
|
|
98
|
+
setup(build) {
|
|
99
|
+
const fixes = {
|
|
100
|
+
'vscode-jsonrpc/node': 'vscode-jsonrpc/node.js',
|
|
101
|
+
'@parcel/watcher/wrapper': '@parcel/watcher/wrapper.js',
|
|
102
|
+
}
|
|
103
|
+
for (const [from, to] of Object.entries(fixes)) {
|
|
104
|
+
build.onResolve({ filter: new RegExp('^' + from.replace(/[/\\]/g, '[\\/]') + '$') }, () => ({
|
|
105
|
+
path: to,
|
|
106
|
+
external: true,
|
|
107
|
+
}))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// Rewrite migration dir path for built output
|
|
114
|
+
const migrationPathPlugin = {
|
|
115
|
+
name: 'migration-path',
|
|
116
|
+
setup(build) {
|
|
117
|
+
build.onLoad({ filter: /storage\/db\./ }, async (args) => {
|
|
118
|
+
const { readFileSync } = await import('fs')
|
|
119
|
+
let contents = readFileSync(args.path, 'utf8')
|
|
120
|
+
// Replace the hardcoded ../../migration with a path relative to the package root
|
|
121
|
+
// At runtime, import.meta.dirname in dist/ is the dist dir
|
|
122
|
+
// We want packages/opencode/migration relative to the package root
|
|
123
|
+
contents = contents.replace(
|
|
124
|
+
'path.join(import.meta.dirname, "../../migration")',
|
|
125
|
+
'path.join(import.meta.dirname, "../packages/opencode/migration")'
|
|
126
|
+
)
|
|
127
|
+
// Also handle the alternate form
|
|
128
|
+
contents = contents.replace(
|
|
129
|
+
"path.join(import.meta.dirname, '../../migration')",
|
|
130
|
+
"path.join(import.meta.dirname, '../packages/opencode/migration')"
|
|
131
|
+
)
|
|
132
|
+
return { contents, loader: 'ts' }
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const result = await esbuild.build({
|
|
138
|
+
entryPoints: [join(SRC, 'serve.ts'), join(SRC, 'run.ts')],
|
|
139
|
+
bundle: true,
|
|
140
|
+
platform: 'node',
|
|
141
|
+
target: 'node22',
|
|
142
|
+
format: 'esm',
|
|
143
|
+
outdir: join(ROOT, 'dist'),
|
|
144
|
+
splitting: true,
|
|
145
|
+
sourcemap: true,
|
|
146
|
+
plugins: [txtPlugin, conditionalImportsPlugin, aliasPlugin, opencodePackagesPlugin, bunStubPlugin, fixExternalImportsPlugin, migrationPathPlugin],
|
|
147
|
+
packages: 'external',
|
|
148
|
+
|
|
149
|
+
banner: { js: '// Built by esbuild from opencode-server source' },
|
|
150
|
+
logLevel: 'info',
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
if (result.errors.length > 0) process.exit(1)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Built by esbuild from opencode-server source
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __using = (stack, value, async) => {
|
|
30
|
+
if (value != null) {
|
|
31
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
32
|
+
var dispose, inner;
|
|
33
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
34
|
+
if (dispose === void 0) {
|
|
35
|
+
dispose = value[__knownSymbol("dispose")];
|
|
36
|
+
if (async) inner = dispose;
|
|
37
|
+
}
|
|
38
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
39
|
+
if (inner) dispose = function() {
|
|
40
|
+
try {
|
|
41
|
+
inner.call(this);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return Promise.reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
stack.push([async, dispose, value]);
|
|
47
|
+
} else if (async) {
|
|
48
|
+
stack.push([async]);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
var __callDispose = (stack, error, hasError) => {
|
|
53
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
54
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
55
|
+
};
|
|
56
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
57
|
+
var next = (it) => {
|
|
58
|
+
while (it = stack.pop()) {
|
|
59
|
+
try {
|
|
60
|
+
var result = it[1] && it[1].call(it[2]);
|
|
61
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
62
|
+
} catch (e) {
|
|
63
|
+
fail(e);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (hasError) throw error;
|
|
67
|
+
};
|
|
68
|
+
return next();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
__require,
|
|
73
|
+
__export,
|
|
74
|
+
__reExport,
|
|
75
|
+
__using,
|
|
76
|
+
__callDispose
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-7JG6KCBC.js.map
|