clew-code 0.3.3 → 0.3.5
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/README.md +22 -8
- package/dist/main.js +2073 -2166
- package/package.json +5 -5
- package/scripts/bun-run.mjs +33 -0
- package/scripts/postbuild-inject-macro.mjs +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clew-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "ClewCode — multi-provider AI coding agent CLI",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"homepage": "https://github.com/ClewCode/ClewCode#readme",
|
|
27
27
|
"scripts": {
|
|
28
28
|
"prebuild-version": "node scripts/prebuild-version.mjs",
|
|
29
|
-
"dev": "bun run prebuild-version && bun
|
|
30
|
-
"start": "bun run prebuild-version && bun
|
|
31
|
-
"dev:channels": "bun run prebuild-version && bun
|
|
32
|
-
"build": "bun run prebuild-version && NODE_ENV=production bun build --production --define.TRANSCRIPT_CLASSIFIER=true --define.CHICAGO_MCP=true --define.VOICE_MODE=true src/main.tsx --outdir ./dist --target bun --external electron --external 'chromium-bidi*' --external '@ant/claude-for-chrome-mcp' --external '@anthropic-ai/bedrock-sdk' --external '@anthropic-ai/foundry-sdk' --external '@anthropic-ai/vertex-sdk' --external '@anthropic-ai/mcpb' --external '@aws-sdk/client-bedrock-runtime' --external 'google-auth-library' --external 'sharp' --external 'asciichart' --external 'audio-capture-napi' --external 'modifiers-napi' --external '@xenova/transformers' --external 'onnxruntime-node' --external playwright --external 'playwright-core' --external 'node-pty' &&
|
|
29
|
+
"dev": "bun run prebuild-version && node scripts/bun-run.mjs --watch",
|
|
30
|
+
"start": "bun run prebuild-version && node scripts/bun-run.mjs",
|
|
31
|
+
"dev:channels": "bun run prebuild-version && node scripts/bun-run.mjs -- --dangerously-load-development-channels server:clew-orc",
|
|
32
|
+
"build": "bun run prebuild-version && NODE_ENV=production bun build --production --define.TRANSCRIPT_CLASSIFIER=true --define.CHICAGO_MCP=true --define.VOICE_MODE=true src/main.tsx --outdir ./dist --target bun --external electron --external 'chromium-bidi*' --external '@ant/claude-for-chrome-mcp' --external '@anthropic-ai/bedrock-sdk' --external '@anthropic-ai/foundry-sdk' --external '@anthropic-ai/vertex-sdk' --external '@anthropic-ai/mcpb' --external '@aws-sdk/client-bedrock-runtime' --external 'google-auth-library' --external 'sharp' --external 'asciichart' --external 'audio-capture-napi' --external 'modifiers-napi' --external '@xenova/transformers' --external 'onnxruntime-node' --external playwright --external 'playwright-core' --external 'node-pty' && node scripts/postbuild-inject-macro.mjs",
|
|
33
33
|
"prepublishOnly": "bun run build",
|
|
34
34
|
"test": "bun test",
|
|
35
35
|
"lint": "biome lint --write src/",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun runner — injects MACRO global via Bun's --define and runs main.tsx.
|
|
3
|
+
*
|
|
4
|
+
* Uses `--define MACRO:JSON_OBJECT` syntax where the value is parsed as JSON.
|
|
5
|
+
* This replaces bare `MACRO` identifier in all modules at transpile time,
|
|
6
|
+
* making MACRO.VERSION etc. work in dev mode without post-build injection.
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { dirname, join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const root = dirname(__dirname);
|
|
15
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
|
|
16
|
+
|
|
17
|
+
const extraArgs = process.argv.slice(2);
|
|
18
|
+
const isWatch = extraArgs[0] === '--watch';
|
|
19
|
+
if (isWatch) extraArgs.shift();
|
|
20
|
+
|
|
21
|
+
const macroJson = JSON.stringify({
|
|
22
|
+
VERSION: pkg.version,
|
|
23
|
+
PACKAGE_URL: 'clew-code',
|
|
24
|
+
FEEDBACK_CHANNEL: 'https://github.com/ClewCode/ClewCode/issues',
|
|
25
|
+
ISSUES_EXPLAINER: 'visit https://github.com/ClewCode/ClewCode/issues',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const args = ['run', '--define', `MACRO:${macroJson}`];
|
|
29
|
+
if (isWatch) args.push('--watch');
|
|
30
|
+
args.push(join(root, 'src/main.tsx'), ...extraArgs);
|
|
31
|
+
|
|
32
|
+
const child = spawn('bun', args, { stdio: 'inherit', cwd: root });
|
|
33
|
+
child.on('exit', (code) => process.exit(code ?? 1));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-build script: injects global `var MACRO` declaration into the bundled
|
|
3
|
+
* output so code that references the bare `MACRO` identifier works at runtime.
|
|
4
|
+
*
|
|
5
|
+
* main.tsx already sets `globalThis.MACRO` from generated/version.json, but
|
|
6
|
+
* bundled modules reference the bare `MACRO` identifier (intended for Bun's
|
|
7
|
+
* --define). Without --define, the identifier is undefined in module scope.
|
|
8
|
+
*
|
|
9
|
+
* This script prepends `var MACRO;` right before the bundle starts so the
|
|
10
|
+
* module scope finds `MACRO` on globalThis via the fallback chain.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { dirname, join } from 'node:path';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const root = dirname(__dirname);
|
|
19
|
+
|
|
20
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
|
|
21
|
+
const bundlePath = join(root, 'dist', 'main.js');
|
|
22
|
+
|
|
23
|
+
// Inject MACRO with actual values so bundled modules that reference the bare
|
|
24
|
+
// `MACRO` identifier (intended for Bun's --define) work at runtime without
|
|
25
|
+
// --define flags.
|
|
26
|
+
const preamble = `var MACRO={VERSION:"${pkg.version}",PACKAGE_URL:"clew-code",FEEDBACK_CHANNEL:"https://github.com/ClewCode/ClewCode/issues",ISSUES_EXPLAINER:"visit https://github.com/ClewCode/ClewCode/issues"};\n`;
|
|
27
|
+
|
|
28
|
+
const original = readFileSync(bundlePath, 'utf-8');
|
|
29
|
+
|
|
30
|
+
// Only inject if not already present
|
|
31
|
+
if (!original.startsWith('var MACRO=') && !original.startsWith('var MACRO;')) {
|
|
32
|
+
writeFileSync(bundlePath, preamble + original, 'utf-8');
|
|
33
|
+
console.log(`[postbuild] Injected var MACRO (version: ${pkg.version})`);
|
|
34
|
+
} else {
|
|
35
|
+
console.log('[postbuild] var MACRO already present, skipping');
|
|
36
|
+
}
|