@mmmbuto/qwen-code-termux 0.6.4-termux → 0.6.402

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.
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ //
8
+ // Licensed under the Apache License, Version 2.0 (the "License");
9
+ // you may not use this file except in compliance with the License.
10
+ // You may obtain a copy of the License at
11
+ //
12
+ // http://www.apache.org/licenses/LICENSE-2.0
13
+ //
14
+ // Unless required by applicable law or agreed to in writing, software
15
+ // distributed under the License is distributed on an "AS IS" BASIS,
16
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ // See the License for the specific language governing permissions and
18
+ // limitations under the License.
19
+
20
+ import { copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs';
21
+ import { dirname, join, basename } from 'node:path';
22
+ import { fileURLToPath } from 'node:url';
23
+ import { glob } from 'glob';
24
+ import fs from 'node:fs';
25
+
26
+ const __dirname = dirname(fileURLToPath(import.meta.url));
27
+ const root = join(__dirname, '..');
28
+ const distDir = join(root, 'dist');
29
+ const coreVendorDir = join(root, 'packages', 'core', 'vendor');
30
+
31
+ // Create the dist directory if it doesn't exist
32
+ if (!existsSync(distDir)) {
33
+ mkdirSync(distDir);
34
+ }
35
+
36
+ // Find and copy all .sb files from packages to the root of the dist directory
37
+ const sbFiles = glob.sync('packages/**/*.sb', { cwd: root });
38
+ for (const file of sbFiles) {
39
+ copyFileSync(join(root, file), join(distDir, basename(file)));
40
+ }
41
+
42
+ console.log('Copied sandbox profiles to dist/');
43
+
44
+ // Copy vendor directory (contains ripgrep binaries)
45
+ console.log('Copying vendor directory...');
46
+ if (existsSync(coreVendorDir)) {
47
+ const destVendorDir = join(distDir, 'vendor');
48
+ copyRecursiveSync(coreVendorDir, destVendorDir);
49
+ console.log('Copied vendor directory to dist/');
50
+ } else {
51
+ console.warn(`Warning: Vendor directory not found at ${coreVendorDir}`);
52
+ }
53
+
54
+ // Copy tiktoken wasm payload (required by bundled tokenizer)
55
+ const tiktokenWasmCandidates = [
56
+ join(root, 'node_modules', 'tiktoken', 'tiktoken_bg.wasm'),
57
+ join(
58
+ root,
59
+ 'packages',
60
+ 'core',
61
+ 'node_modules',
62
+ 'tiktoken',
63
+ 'tiktoken_bg.wasm',
64
+ ),
65
+ join(
66
+ root,
67
+ 'packages',
68
+ 'sdk-typescript',
69
+ 'node_modules',
70
+ 'tiktoken',
71
+ 'tiktoken_bg.wasm',
72
+ ),
73
+ ];
74
+ const tiktokenWasmDest = join(distDir, 'tiktoken_bg.wasm');
75
+ let tiktokenWasmCopied = false;
76
+
77
+ for (const candidate of tiktokenWasmCandidates) {
78
+ if (existsSync(candidate)) {
79
+ copyFileSync(candidate, tiktokenWasmDest);
80
+ tiktokenWasmCopied = true;
81
+ console.log('Copied tiktoken_bg.wasm to dist/');
82
+ break;
83
+ }
84
+ }
85
+
86
+ if (!tiktokenWasmCopied) {
87
+ console.warn(
88
+ 'Warning: tiktoken_bg.wasm not found; tokenization may fail at runtime.',
89
+ );
90
+ }
91
+
92
+ console.log('\n✅ All bundle assets copied to dist/');
93
+
94
+ /**
95
+ * Recursively copy directory
96
+ */
97
+ function copyRecursiveSync(src, dest) {
98
+ if (!existsSync(src)) {
99
+ return;
100
+ }
101
+
102
+ const stats = statSync(src);
103
+
104
+ if (stats.isDirectory()) {
105
+ if (!existsSync(dest)) {
106
+ mkdirSync(dest, { recursive: true });
107
+ }
108
+
109
+ const entries = fs.readdirSync(src);
110
+ for (const entry of entries) {
111
+ // Skip .DS_Store files
112
+ if (entry === '.DS_Store') {
113
+ continue;
114
+ }
115
+
116
+ const srcPath = join(src, entry);
117
+ const destPath = join(dest, entry);
118
+ copyRecursiveSync(srcPath, destPath);
119
+ }
120
+ } else {
121
+ copyFileSync(src, dest);
122
+ // Preserve execute permissions for binaries
123
+ const srcStats = statSync(src);
124
+ if (srcStats.mode & 0o111) {
125
+ fs.chmodSync(dest, srcStats.mode);
126
+ }
127
+ }
128
+ }
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @license
5
+ * Copyright 2025 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+
9
+ // Copyright 2025 Google LLC
10
+ //
11
+ // Licensed under the Apache License, Version 2.0 (the "License");
12
+ // you may not use this file except in compliance with the License.
13
+ // You may obtain a copy of the License at
14
+ //
15
+ // http://www.apache.org/licenses/LICENSE-2.0
16
+ //
17
+ // Unless required by applicable law or agreed to in writing, software
18
+ // distributed under the License is distributed on an "AS IS" BASIS,
19
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ // See the License for the specific language governing permissions and
21
+ // limitations under the License.
22
+
23
+ import fs from 'node:fs';
24
+ import path from 'node:path';
25
+
26
+ const sourceDir = path.join('src');
27
+ const targetDir = path.join('dist', 'src');
28
+
29
+ const extensionsToCopy = ['.md', '.json', '.sb'];
30
+
31
+ function copyFilesRecursive(source, target, rootSourceDir) {
32
+ if (!fs.existsSync(target)) {
33
+ fs.mkdirSync(target, { recursive: true });
34
+ }
35
+
36
+ const items = fs.readdirSync(source, { withFileTypes: true });
37
+
38
+ for (const item of items) {
39
+ const sourcePath = path.join(source, item.name);
40
+ const targetPath = path.join(target, item.name);
41
+
42
+ if (item.isDirectory()) {
43
+ copyFilesRecursive(sourcePath, targetPath, rootSourceDir);
44
+ } else {
45
+ const ext = path.extname(item.name);
46
+ // Copy standard extensions, or .js files in i18n/locales directory
47
+ // Use path.relative for precise matching to avoid false positives
48
+ const relativePath = path.relative(rootSourceDir, sourcePath);
49
+ const normalizedPath = relativePath.replace(/\\/g, '/');
50
+ const isLocaleJs =
51
+ ext === '.js' && normalizedPath.startsWith('i18n/locales/');
52
+ if (extensionsToCopy.includes(ext) || isLocaleJs) {
53
+ fs.copyFileSync(sourcePath, targetPath);
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ if (!fs.existsSync(sourceDir)) {
60
+ console.error(`Source directory ${sourceDir} not found.`);
61
+ process.exit(1);
62
+ }
63
+
64
+ copyFilesRecursive(sourceDir, targetDir, sourceDir);
65
+
66
+ // Copy example extensions into the bundle.
67
+ const packageName = path.basename(process.cwd());
68
+ if (packageName === 'cli') {
69
+ const examplesSource = path.join(
70
+ sourceDir,
71
+ 'commands',
72
+ 'extensions',
73
+ 'examples',
74
+ );
75
+ const examplesTarget = path.join(
76
+ targetDir,
77
+ 'commands',
78
+ 'extensions',
79
+ 'examples',
80
+ );
81
+ if (fs.existsSync(examplesSource)) {
82
+ fs.cpSync(examplesSource, examplesTarget, { recursive: true });
83
+ }
84
+ }
85
+
86
+ console.log('Successfully copied files.');
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # This script creates an alias for the Gemini CLI
5
+
6
+ # Determine the project directory
7
+ PROJECT_DIR=$(cd "$(dirname "$0")/.." && pwd)
8
+ ALIAS_COMMAND="alias qwen='node "${PROJECT_DIR}/scripts/start.js"'"
9
+
10
+ # Detect shell and set config file path
11
+ if [[ "${SHELL}" == *"/bash" ]]; then
12
+ CONFIG_FILE="${HOME}/.bashrc"
13
+ elif [[ "${SHELL}" == *"/zsh" ]]; then
14
+ CONFIG_FILE="${HOME}/.zshrc"
15
+ else
16
+ echo "Unsupported shell. Only bash and zsh are supported."
17
+ exit 1
18
+ fi
19
+
20
+ echo "This script will add the following alias to your shell configuration file (${CONFIG_FILE}):"
21
+ echo " ${ALIAS_COMMAND}"
22
+ echo ""
23
+
24
+ # Check if the alias already exists
25
+ if grep -q "alias qwen=" "${CONFIG_FILE}"; then
26
+ echo "A 'qwen' alias already exists in ${CONFIG_FILE}. No changes were made."
27
+ exit 0
28
+ fi
29
+
30
+ read -p "Do you want to proceed? (y/n) " -n 1 -r
31
+ echo ""
32
+ if [[ "${REPLY}" =~ ^[Yy]$ ]]; then
33
+ echo "${ALIAS_COMMAND}" >> "${CONFIG_FILE}"
34
+ echo ""
35
+ echo "Alias added to ${CONFIG_FILE}."
36
+ echo "Please run 'source ${CONFIG_FILE}' or open a new terminal to use the 'qwen' command."
37
+ else
38
+ echo "Aborted. No changes were made."
39
+ fi
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Qwen
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * Shims for esbuild ESM bundles to support require() calls
9
+ * This file is injected into the bundle via esbuild's inject option
10
+ */
11
+
12
+ import { createRequire } from 'node:module';
13
+ import { fileURLToPath } from 'node:url';
14
+ import { dirname } from 'node:path';
15
+
16
+ // Create require function for the current module and make it global
17
+ const _require = createRequire(import.meta.url);
18
+
19
+ // Make require available globally for dynamic requires
20
+ if (typeof globalThis.require === 'undefined') {
21
+ globalThis.require = _require;
22
+ }
23
+
24
+ // Export for esbuild injection
25
+ export const require = _require;
26
+
27
+ // Setup __filename and __dirname for compatibility
28
+ export const __filename = fileURLToPath(import.meta.url);
29
+ export const __dirname = dirname(__filename);
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ //
8
+ // Licensed under the Apache License, Version 2.0 (the "License");
9
+ // you may not use this file except in compliance with the License.
10
+ // You may obtain a copy of the License at
11
+ //
12
+ // http://www.apache.org/licenses/LICENSE-2.0
13
+ //
14
+ // Unless required by applicable law or agreed to in writing, software
15
+ // distributed under the License is distributed on an "AS IS" BASIS,
16
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ // See the License for the specific language governing permissions and
18
+ // limitations under the License.
19
+
20
+ import { execSync } from 'node:child_process';
21
+ import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
22
+ import { dirname, join, relative } from 'node:path';
23
+ import { fileURLToPath } from 'node:url';
24
+ import { readPackageUp } from 'read-package-up';
25
+
26
+ const __dirname = dirname(fileURLToPath(import.meta.url));
27
+ const root = join(__dirname, '..');
28
+ const scriptPath = relative(root, fileURLToPath(import.meta.url));
29
+ const generatedCliDir = join(root, 'packages/cli/src/generated');
30
+ const cliGitCommitFile = join(generatedCliDir, 'git-commit.ts');
31
+ const generatedCoreDir = join(root, 'packages/core/src/generated');
32
+ const coreGitCommitFile = join(generatedCoreDir, 'git-commit.ts');
33
+ let gitCommitInfo = 'N/A';
34
+ let cliVersion = 'UNKNOWN';
35
+
36
+ if (!existsSync(generatedCliDir)) {
37
+ mkdirSync(generatedCliDir, { recursive: true });
38
+ }
39
+
40
+ if (!existsSync(generatedCoreDir)) {
41
+ mkdirSync(generatedCoreDir, { recursive: true });
42
+ }
43
+
44
+ try {
45
+ const gitHash = execSync('git rev-parse --short HEAD', {
46
+ encoding: 'utf-8',
47
+ }).trim();
48
+ if (gitHash) {
49
+ gitCommitInfo = gitHash;
50
+ }
51
+
52
+ const result = await readPackageUp();
53
+ cliVersion = result?.packageJson?.version ?? 'UNKNOWN';
54
+ } catch {
55
+ // ignore
56
+ }
57
+
58
+ const fileContent = `/**
59
+ * @license
60
+ * Copyright ${new Date().getFullYear()} Google LLC
61
+ * SPDX-License-Identifier: Apache-2.0
62
+ */
63
+
64
+ // This file is auto-generated by the build script (${scriptPath})
65
+ // Do not edit this file manually.
66
+ export const GIT_COMMIT_INFO = '${gitCommitInfo}';
67
+ export const CLI_VERSION = '${cliVersion}';
68
+ `;
69
+
70
+ writeFileSync(cliGitCommitFile, fileContent);
71
+ writeFileSync(coreGitCommitFile, fileContent);