codelark 0.1.0

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -0
  3. package/SECURITY.md +34 -0
  4. package/SKILL.md +67 -0
  5. package/agents/openai.yaml +4 -0
  6. package/dist/cli.mjs +8794 -0
  7. package/dist/daemon.mjs +47172 -0
  8. package/dist/ui-server.mjs +22165 -0
  9. package/package.json +73 -0
  10. package/schemas/config.v1.schema.json +259 -0
  11. package/schemas/data/audit.v1.schema.json +44 -0
  12. package/schemas/data/auto-tasks.v1.schema.json +94 -0
  13. package/schemas/data/channel-chats.v1.schema.json +159 -0
  14. package/schemas/data/channel-default-targets.v1.schema.json +43 -0
  15. package/schemas/data/messages.v1.schema.json +23 -0
  16. package/schemas/data/number-map.v1.schema.json +9 -0
  17. package/schemas/data/permissions.v1.schema.json +35 -0
  18. package/schemas/data/sessions.v1.schema.json +330 -0
  19. package/schemas/data/string-map.v1.schema.json +9 -0
  20. package/schemas/manifest.json +121 -0
  21. package/scripts/analyze-bridge-log.js +838 -0
  22. package/scripts/build-preflight.d.ts +21 -0
  23. package/scripts/build-preflight.js +70 -0
  24. package/scripts/build.js +53 -0
  25. package/scripts/check-npm-pack.js +46 -0
  26. package/scripts/daemon.ps1 +16 -0
  27. package/scripts/daemon.sh +206 -0
  28. package/scripts/doctor.ps1 +27 -0
  29. package/scripts/doctor.sh +185 -0
  30. package/scripts/hot-update-bridge.sh +298 -0
  31. package/scripts/install-codex-skills.sh +127 -0
  32. package/scripts/install-codex.sh +10 -0
  33. package/scripts/migrate-bindings-to-channel-chats.js +228 -0
  34. package/scripts/patch-codex-sdk-windows-hide.js +96 -0
  35. package/scripts/real-feishu-e2e.ts +5804 -0
  36. package/scripts/run-tests.js +83 -0
  37. package/scripts/setup-wizard-real-e2e.ts +195 -0
  38. package/scripts/supervisor-linux.sh +49 -0
  39. package/scripts/supervisor-macos.sh +167 -0
  40. package/scripts/supervisor-windows.ps1 +481 -0
  41. package/skills/codelark/SKILL.md +67 -0
  42. package/skills/codelark-auto/SKILL.md +80 -0
  43. package/skills/codelark-question/SKILL.md +54 -0
@@ -0,0 +1,96 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ /**
5
+ * Windows note:
6
+ * `@openai/codex-sdk` spawns the bundled Codex CLI without `windowsHide`,
7
+ * which causes a black console window to flash for each IM-triggered run.
8
+ *
9
+ * We patch the installed SDK after `npm install` so the bridge can keep using
10
+ * the upstream package while avoiding the extra console window on Windows.
11
+ *
12
+ * Maintenance rule:
13
+ * - Keep this patch conservative and version-gated.
14
+ * - When upgrading `@openai/codex-sdk`, verify the spawn block still matches.
15
+ * - If upstream adds `windowsHide` natively, remove this script.
16
+ */
17
+ const PATCH_MARKER = 'windowsHide: process.platform === "win32"';
18
+ const SUPPORTED_SDK_VERSION = /^0\.(11\d|12\d)\.\d+$/;
19
+
20
+ function logSkip(message) {
21
+ console.warn(`[postinstall] ${message}`);
22
+ }
23
+
24
+ function resolveSdkPaths() {
25
+ const packageRoot = path.join(process.cwd(), 'node_modules', '@openai', 'codex-sdk');
26
+ const packageJsonPath = path.join(packageRoot, 'package.json');
27
+ const entryPath = path.join(packageRoot, 'dist', 'index.js');
28
+ if (!fs.existsSync(packageJsonPath) || !fs.existsSync(entryPath)) {
29
+ return null;
30
+ }
31
+ return { packageJsonPath, entryPath };
32
+ }
33
+
34
+ function readSdkVersion(packageJsonPath) {
35
+ try {
36
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
37
+ return typeof pkg.version === 'string' ? pkg.version : null;
38
+ } catch {
39
+ return null;
40
+ }
41
+ }
42
+
43
+ function applyPatch(filePath) {
44
+ const source = fs.readFileSync(filePath, 'utf-8');
45
+ if (source.includes(PATCH_MARKER)) {
46
+ console.log('[postinstall] codex-sdk windowsHide patch already applied');
47
+ return false;
48
+ }
49
+
50
+ const patched = source.replace(
51
+ /const child = spawn\(this\.executablePath, commandArgs, \{\s*env,\s*signal: args\.signal\s*\}\);/,
52
+ `const child = spawn(this.executablePath, commandArgs, {
53
+ env,
54
+ windowsHide: process.platform === "win32",
55
+ signal: args.signal
56
+ });`,
57
+ );
58
+
59
+ if (patched === source) {
60
+ throw new Error(`Unable to locate Codex SDK spawn block in ${filePath}`);
61
+ }
62
+
63
+ fs.writeFileSync(filePath, patched, 'utf-8');
64
+ console.log(`[postinstall] patched codex-sdk windowsHide in ${path.relative(process.cwd(), filePath)}`);
65
+ return true;
66
+ }
67
+
68
+ if (process.platform !== 'win32') {
69
+ console.log('[postinstall] non-Windows platform detected, skipping codex-sdk windowsHide patch');
70
+ process.exit(0);
71
+ }
72
+
73
+ const sdkPaths = resolveSdkPaths();
74
+ if (!sdkPaths) {
75
+ console.log('[postinstall] @openai/codex-sdk not installed, skipping windowsHide patch');
76
+ process.exit(0);
77
+ }
78
+
79
+ const sdkVersion = readSdkVersion(sdkPaths.packageJsonPath);
80
+ if (!sdkVersion) {
81
+ logSkip('unable to read @openai/codex-sdk version, skipping windowsHide patch');
82
+ process.exit(0);
83
+ }
84
+
85
+ if (!SUPPORTED_SDK_VERSION.test(sdkVersion)) {
86
+ logSkip(`unsupported @openai/codex-sdk version ${sdkVersion}; skipping windowsHide patch`);
87
+ process.exit(0);
88
+ }
89
+
90
+ try {
91
+ applyPatch(sdkPaths.entryPath);
92
+ } catch (error) {
93
+ const message = error instanceof Error ? error.message : String(error);
94
+ logSkip(`failed to patch codex-sdk windowsHide (${message}); install will continue and the Windows console may still appear`);
95
+ process.exit(0);
96
+ }