@sanqianx/ai-coding-event-bridge-console 0.7.3 → 0.7.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bin.js +80 -80
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanqianx/ai-coding-event-bridge-console",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Durable AI coding event bridge, all in one: capture connectors and installers (Claude Code, Codex, OpenCode, ZCode), journal with commit boundaries and per-commit conversation sealing, headless query, and a local conversation explorer console.",
5
5
  "license": "MIT",
6
6
  "private": false,
package/src/bin.js CHANGED
@@ -1,80 +1,80 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const http = require('http');
5
- const { bridgeHome } = require('./bridge');
6
- const { createConsoleServer } = require('./server');
7
- const { warmFolderPicker } = require('./pick-folder');
8
-
9
- /**
10
- * ai-coding-event-bridge-console CLI — the single package of this project.
11
- *
12
- * serve [--port 8790] [--host 127.0.0.1] [--home DIR]
13
- * Start the local console (explorer page + JSON API).
14
- *
15
- * commit-boundary [--cwd <repo>] [--home DIR] [--sha] [--branch]
16
- * [--committed-at ISO] [--subject TEXT]
17
- * Append one commit boundary event — the call a managed git
18
- * post-commit hook makes.
19
- *
20
- * The server binds to localhost by default: journals contain full
21
- * conversation bodies, so they stay on this machine unless --host says
22
- * otherwise.
23
- */
24
- async function main(argv = process.argv.slice(2)) {
25
- const command = argv[0];
26
- const get = (name) => {
27
- const i = argv.indexOf('--' + name);
28
- return i >= 0 ? argv[i + 1] : undefined;
29
- };
30
-
31
- if (command === 'commit-boundary') {
32
- // The boundary entry reads its own flags from process.argv; the extra
33
- // positional is ignored by its --flag lookup. The contract is one JSON
34
- // line (ok:true/false) on stdout, preserved even when required from here.
35
- await require('./bridge/bin/commit-boundary').main().catch((err) => {
36
- process.stderr.write(`${JSON.stringify({ ok: false, error: err && err.message ? err.message : String(err) })}\n`);
37
- process.exitCode = 1;
38
- });
39
- return;
40
- }
41
-
42
- if (command !== 'serve') {
43
- console.log('Usage: ai-coding-event-bridge-console <command> [options]');
44
- console.log(' serve Start the local console (explorer page + JSON API)');
45
- console.log(' --port 8790 --host 127.0.0.1 --home DIR');
46
- console.log(' commit-boundary Append one commit boundary event (git post-commit hooks)');
47
- console.log(' --cwd <repo> --home DIR --sha --branch');
48
- process.exitCode = command ? 1 : 0;
49
- return;
50
- }
51
-
52
- const home = bridgeHome(get('home'));
53
- const port = Number(get('port') || 8790);
54
- const host = get('host') || '127.0.0.1';
55
- const server = http.createServer(createConsoleServer({ home, runtimeToken: process.env.KB_EVENT_BRIDGE_RUNTIME_TOKEN }));
56
- await new Promise((resolve) => server.listen(port, host, resolve));
57
- let stopping = false;
58
- const stop = () => { if (stopping) return; stopping = true; server.closeAllConnections?.(); server.close(() => process.exit(0)); };
59
- for (const signal of ['SIGINT', 'SIGTERM']) process.once(signal, stop);
60
- process.on('message', message => { if (message?.type === 'kb:shutdown') stop(); });
61
- console.log(`ai-coding-event-bridge console serving on http://${host}:${port}`);
62
- console.log(` home: ${home}`);
63
- console.log(` import projects from the sidebar; conversations of imported`);
64
- console.log(` projects are stored per-project under their chosen store.`);
65
- // Compile the folder-picker helper up front so the first "browse…" click
66
- // pops the dialog in milliseconds instead of paying the powershell +
67
- // Add-Type startup. Never blocks or crashes the console.
68
- if (process.env.BRIDGE_CONSOLE_PICK_FOLDER !== '0') {
69
- warmFolderPicker({ title: '选择项目文件夹' }).catch(() => {});
70
- }
71
- }
72
-
73
- module.exports = { main };
74
-
75
- if (require.main === module) {
76
- main().catch((err) => {
77
- console.error(err && err.stack ? err.stack : err);
78
- process.exit(1);
79
- });
80
- }
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const http = require('http');
5
+ const { bridgeHome } = require('./bridge');
6
+ const { createConsoleServer } = require('./server');
7
+ const { warmFolderPicker } = require('./pick-folder');
8
+
9
+ /**
10
+ * ai-coding-event-bridge-console CLI — the single package of this project.
11
+ *
12
+ * serve [--port 8790] [--host 127.0.0.1] [--home DIR]
13
+ * Start the local console (explorer page + JSON API).
14
+ *
15
+ * commit-boundary [--cwd <repo>] [--home DIR] [--sha] [--branch]
16
+ * [--committed-at ISO] [--subject TEXT]
17
+ * Append one commit boundary event — the call a managed git
18
+ * post-commit hook makes.
19
+ *
20
+ * The server binds to localhost by default: journals contain full
21
+ * conversation bodies, so they stay on this machine unless --host says
22
+ * otherwise.
23
+ */
24
+ async function main(argv = process.argv.slice(2)) {
25
+ const command = argv[0];
26
+ const get = (name) => {
27
+ const i = argv.indexOf('--' + name);
28
+ return i >= 0 ? argv[i + 1] : undefined;
29
+ };
30
+
31
+ if (command === 'commit-boundary') {
32
+ // The boundary entry reads its own flags from process.argv; the extra
33
+ // positional is ignored by its --flag lookup. The contract is one JSON
34
+ // line (ok:true/false) on stdout, preserved even when required from here.
35
+ await require('./bridge/bin/commit-boundary').main().catch((err) => {
36
+ process.stderr.write(`${JSON.stringify({ ok: false, error: err && err.message ? err.message : String(err) })}\n`);
37
+ process.exitCode = 1;
38
+ });
39
+ return;
40
+ }
41
+
42
+ if (command !== 'serve') {
43
+ console.log('Usage: ai-coding-event-bridge-console <command> [options]');
44
+ console.log(' serve Start the local console (explorer page + JSON API)');
45
+ console.log(' --port 8790 --host 127.0.0.1 --home DIR');
46
+ console.log(' commit-boundary Append one commit boundary event (git post-commit hooks)');
47
+ console.log(' --cwd <repo> --home DIR --sha --branch');
48
+ process.exitCode = command ? 1 : 0;
49
+ return;
50
+ }
51
+
52
+ const home = bridgeHome(get('home'));
53
+ const port = Number(get('port') || 8790);
54
+ const host = get('host') || '127.0.0.1';
55
+ const server = http.createServer(createConsoleServer({ home, runtimeToken: process.env.KB_EVENT_BRIDGE_RUNTIME_TOKEN }));
56
+ await new Promise((resolve) => server.listen(port, host, resolve));
57
+ let stopping = false;
58
+ const stop = () => { if (stopping) return; stopping = true; server.closeAllConnections?.(); server.close(() => process.exit(0)); };
59
+ for (const signal of ['SIGINT', 'SIGTERM']) process.once(signal, stop);
60
+ process.on('message', message => { if (message?.type === 'kb:shutdown') stop(); });
61
+ console.log(`ai-coding-event-bridge console serving on http://${host}:${port}`);
62
+ console.log(` home: ${home}`);
63
+ console.log(` import projects from the sidebar; conversations of imported`);
64
+ console.log(` projects are stored per-project under their chosen store.`);
65
+ // Compile the folder-picker helper up front so the first "browse…" click
66
+ // pops the dialog in milliseconds instead of paying the powershell +
67
+ // Add-Type startup. Never blocks or crashes the console.
68
+ if (process.env.BRIDGE_CONSOLE_PICK_FOLDER !== '0') {
69
+ warmFolderPicker({ title: '选择项目文件夹' }).catch(() => {});
70
+ }
71
+ }
72
+
73
+ module.exports = { main };
74
+
75
+ if (require.main === module) {
76
+ main().catch((err) => {
77
+ console.error(err && err.stack ? err.stack : err);
78
+ process.exit(1);
79
+ });
80
+ }