@logicseek/hello-cc 0.1.5 → 0.1.7

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 (88) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/README.md +21 -3
  3. package/README.zh-CN.md +21 -3
  4. package/assets/screenshots/web-console.png +0 -0
  5. package/bin/hcc.mjs +1943 -3519
  6. package/docs/README.md +2 -0
  7. package/docs/README.zh-CN.md +3 -1
  8. package/docs/architecture-split-review.md +217 -0
  9. package/docs/architecture.md +385 -0
  10. package/docs/architecture.zh-CN.md +364 -0
  11. package/docs/layout-split-stack-audit.md +298 -0
  12. package/lib/automation.mjs +8 -0
  13. package/lib/cli-args.mjs +1 -1
  14. package/lib/cli-runtime.mjs +45 -0
  15. package/lib/coordination-state.mjs +218 -0
  16. package/lib/core/coordination/automation.mjs +222 -0
  17. package/lib/core/coordination/locks.mjs +46 -0
  18. package/lib/core/coordination/messages.mjs +116 -0
  19. package/lib/core/coordination/tasks.mjs +240 -0
  20. package/lib/core/coordination/teams.mjs +73 -0
  21. package/lib/core/coordination/timeline.mjs +196 -0
  22. package/lib/core/peers/bindings.mjs +83 -0
  23. package/lib/core/peers/format.mjs +13 -0
  24. package/lib/core/peers/identity.mjs +61 -0
  25. package/lib/core/peers/liveness.mjs +90 -0
  26. package/lib/core/peers/reconcile.mjs +238 -0
  27. package/lib/core/peers/session.mjs +14 -0
  28. package/lib/core/sessions/launch.mjs +89 -0
  29. package/lib/db/schema.mjs +324 -0
  30. package/lib/db/stores/peers.mjs +231 -0
  31. package/lib/db-schema.mjs +7 -324
  32. package/lib/errors.mjs +1 -7
  33. package/lib/handoff.mjs +26 -0
  34. package/lib/help.mjs +3 -0
  35. package/lib/integrations/hooks.mjs +171 -0
  36. package/lib/integrations/peers/identity.mjs +208 -0
  37. package/lib/integrations/peers/processes.mjs +151 -0
  38. package/lib/integrations/providers.mjs +282 -0
  39. package/lib/integrations/shims/script.mjs +384 -0
  40. package/lib/integrations/shims.mjs +106 -0
  41. package/lib/json-file.mjs +1 -14
  42. package/lib/locks.mjs +10 -0
  43. package/lib/messages.mjs +3 -0
  44. package/lib/package-meta.mjs +6 -24
  45. package/lib/peer-bindings.mjs +14 -0
  46. package/lib/peer-format.mjs +4 -0
  47. package/lib/peer-identity.mjs +15 -0
  48. package/lib/project-context.mjs +6 -0
  49. package/lib/project-registry.mjs +7 -0
  50. package/lib/provider-commands.mjs +13 -0
  51. package/lib/release/package-meta.mjs +31 -0
  52. package/lib/release/release-notes.mjs +40 -0
  53. package/lib/release-notes.mjs +6 -40
  54. package/lib/runtime/client.mjs +42 -0
  55. package/lib/runtime/paths.mjs +45 -0
  56. package/lib/runtime/project-context.mjs +32 -0
  57. package/lib/runtime/projects.mjs +76 -0
  58. package/lib/runtime/state.mjs +128 -0
  59. package/lib/runtime-client.mjs +3 -0
  60. package/lib/runtime-paths.mjs +11 -45
  61. package/lib/runtime-state.mjs +11 -0
  62. package/lib/session-launch.mjs +17 -0
  63. package/lib/setup.mjs +17 -293
  64. package/lib/shared/errors.mjs +7 -0
  65. package/lib/shared/json-file.mjs +14 -0
  66. package/lib/shim-script.mjs +1 -384
  67. package/lib/state-render.mjs +5 -0
  68. package/lib/task-cli.mjs +45 -0
  69. package/lib/task-liveness.mjs +8 -0
  70. package/lib/task-store.mjs +3 -0
  71. package/lib/team-planning.mjs +7 -0
  72. package/lib/terminal/tmux.mjs +372 -0
  73. package/lib/timeline.mjs +12 -0
  74. package/lib/tmux.mjs +18 -0
  75. package/lib/ui/help.mjs +419 -0
  76. package/lib/ui/state-render.mjs +61 -0
  77. package/lib/web/http.mjs +55 -0
  78. package/lib/web/peer-actions.mjs +306 -0
  79. package/lib/web/runtime.mjs +154 -0
  80. package/lib/web/ui-template.mjs +2057 -0
  81. package/lib/web-http.mjs +7 -55
  82. package/lib/web-peer-actions.mjs +3 -0
  83. package/lib/web-runtime.mjs +17 -108
  84. package/lib/web-ui-template.mjs +3 -1909
  85. package/package.json +1 -1
  86. package/scripts/github-release.mjs +2 -2
  87. package/scripts/regression.mjs +2901 -79
  88. package/scripts/release-notes.mjs +2 -2
package/lib/web-http.mjs CHANGED
@@ -1,55 +1,7 @@
1
- import fs from 'node:fs';
2
- import { CliError } from './errors.mjs';
3
-
4
- function readRequestBody(req, limit = 1024 * 1024) {
5
- return new Promise((resolve, reject) => {
6
- let body = '';
7
- req.on('data', (chunk) => {
8
- body += chunk;
9
- if (body.length > limit) {
10
- reject(new CliError('REQUEST_TOO_LARGE', 'Request body is too large'));
11
- req.destroy();
12
- }
13
- });
14
- req.on('end', () => resolve(body));
15
- req.on('error', reject);
16
- });
17
- }
18
-
19
- export async function readJsonRequest(req) {
20
- const body = await readRequestBody(req);
21
- if (!body.trim()) return {};
22
- return JSON.parse(body);
23
- }
24
-
25
- export function sendHttp(res, status, contentType, body) {
26
- res.writeHead(status, {
27
- 'Content-Type': contentType,
28
- 'Cache-Control': 'no-store'
29
- });
30
- res.end(body);
31
- }
32
-
33
- export function sendJson(res, status, body) {
34
- sendHttp(res, status, 'application/json; charset=utf-8', JSON.stringify(body, null, 2));
35
- }
36
-
37
- export function sendFile(res, filePath, contentType) {
38
- try {
39
- const body = fs.readFileSync(filePath);
40
- res.writeHead(200, {
41
- 'Content-Type': contentType,
42
- 'Cache-Control': 'no-store'
43
- });
44
- res.end(body);
45
- } catch {
46
- sendJson(res, 404, { ok: false, error: { code: 'NOT_FOUND', message: 'Asset not found' } });
47
- }
48
- }
49
-
50
- export function authOk(url, req, token) {
51
- if (!token) return true;
52
- const queryToken = url.searchParams.get('token');
53
- const auth = req.headers.authorization || '';
54
- return queryToken === token || auth === `Bearer ${token}`;
55
- }
1
+ export {
2
+ authOk,
3
+ readJsonRequest,
4
+ sendFile,
5
+ sendHttp,
6
+ sendJson
7
+ } from './web/http.mjs';
@@ -0,0 +1,3 @@
1
+ export {
2
+ createWebPeerActions
3
+ } from './web/peer-actions.mjs';
@@ -1,108 +1,17 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import process from 'node:process';
4
- import { randomBytes } from 'node:crypto';
5
- import { intOpt } from './cli-args.mjs';
6
- import { CliError } from './errors.mjs';
7
- import { globalWebTokenPath } from './runtime-paths.mjs';
8
-
9
- export function runtimeConnectHost(host) {
10
- if (host === '0.0.0.0' || host === '::') return '127.0.0.1';
11
- return host;
12
- }
13
-
14
- export function runtimeBaseUrl(host, port) {
15
- return `http://${runtimeConnectHost(host)}:${port}`;
16
- }
17
-
18
- export function runtimeApiUrl(runtime, route) {
19
- const baseUrl = typeof runtime === 'string' ? runtime : runtime?.base_url;
20
- return new URL(route, baseUrl);
21
- }
22
-
23
- export function requestUrl(req) {
24
- return new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
25
- }
26
-
27
- export function runtimeUrlQuery(runtime, projectRoot = null) {
28
- const parts = [];
29
- if (runtime.token) parts.push(`token=${encodeURIComponent(runtime.token)}`);
30
- if (projectRoot) parts.push(`project=${encodeURIComponent(projectRoot)}`);
31
- return parts.length ? `?${parts.join('&')}` : '';
32
- }
33
-
34
- export function publicRuntimeUrl(runtime, projectRoot = null) {
35
- const host = runtime.host === '0.0.0.0' || runtime.host === '::'
36
- ? '<machine-ip>'
37
- : runtime.host || runtimeConnectHost(runtime.host || '127.0.0.1');
38
- return `http://${host}:${runtime.port}/${runtimeUrlQuery(runtime, projectRoot)}`;
39
- }
40
-
41
- export function localRuntimeUrl(runtime, projectRoot = null) {
42
- const host = runtimeConnectHost(runtime.host || '127.0.0.1');
43
- return `http://${host}:${runtime.port}/${runtimeUrlQuery(runtime, projectRoot)}`;
44
- }
45
-
46
- export function readStoredWebToken() {
47
- const file = globalWebTokenPath();
48
- if (!fs.existsSync(file)) return '';
49
- try {
50
- return fs.readFileSync(file, 'utf8').trim();
51
- } catch {
52
- return '';
53
- }
54
- }
55
-
56
- export function writeStoredWebToken(token) {
57
- if (!token) return '';
58
- const file = globalWebTokenPath();
59
- fs.mkdirSync(path.dirname(file), { recursive: true });
60
- fs.writeFileSync(file, `${token}\n`, { mode: 0o600 });
61
- fs.chmodSync(file, 0o600);
62
- return file;
63
- }
64
-
65
- export function validateWebTokenOpts(opts) {
66
- if (opts['no-token'] && (opts.token || process.env.HCC_WEB_TOKEN)) {
67
- throw new CliError('BAD_ARGS', '--no-token cannot be combined with --token or HCC_WEB_TOKEN');
68
- }
69
- }
70
-
71
- export function makeWebToken(opts) {
72
- validateWebTokenOpts(opts);
73
- if (opts['no-token']) return '';
74
- const explicitToken = opts.token || process.env.HCC_WEB_TOKEN || '';
75
- if (explicitToken) {
76
- writeStoredWebToken(explicitToken);
77
- return explicitToken;
78
- }
79
- const stored = readStoredWebToken();
80
- if (stored) return stored;
81
- const generated = randomBytes(24).toString('base64url');
82
- writeStoredWebToken(generated);
83
- return generated;
84
- }
85
-
86
- export function expectedWebHost(opts) {
87
- return opts.host || (opts.local ? '127.0.0.1' : '0.0.0.0');
88
- }
89
-
90
- export function webRuntimeMatchesRequest(runtime, opts) {
91
- if (!runtime) return false;
92
- if (opts['no-token'] && (opts.token || process.env.HCC_WEB_TOKEN)) return false;
93
- const expectedHost = expectedWebHost(opts);
94
- if (runtime.host !== expectedHost) return false;
95
- const expectedPort = intOpt(opts, 'port', 8787);
96
- if (opts.port !== undefined && runtime.port !== expectedPort) return false;
97
- const explicitToken = opts.token || process.env.HCC_WEB_TOKEN || '';
98
- if (opts['no-token']) return !runtime.token;
99
- if (explicitToken) return runtime.token === explicitToken;
100
- return Boolean(runtime.token);
101
- }
102
-
103
- export function rememberRuntimeToken(runtime, opts) {
104
- if (!runtime?.token || opts['no-token']) return;
105
- const explicitToken = opts.token || process.env.HCC_WEB_TOKEN || '';
106
- if (explicitToken && runtime.token !== explicitToken) return;
107
- writeStoredWebToken(runtime.token);
108
- }
1
+ export {
2
+ expectedWebHost,
3
+ isLoopbackHost,
4
+ listenServer,
5
+ localRuntimeUrl,
6
+ makeWebToken,
7
+ nextSessionId,
8
+ publicRuntimeUrl,
9
+ rememberRuntimeToken,
10
+ requestUrl,
11
+ runtimeApiUrl,
12
+ runtimeBaseUrl,
13
+ runtimeConnectHost,
14
+ runtimeUrlQuery,
15
+ validateWebTokenOpts,
16
+ webRuntimeMatchesRequest
17
+ } from './web/runtime.mjs';