@logicseek/hello-cc 0.1.5 → 0.1.6
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/CHANGELOG.md +75 -0
- package/bin/hcc.mjs +1541 -3430
- package/docs/README.md +2 -0
- package/docs/README.zh-CN.md +3 -1
- package/docs/architecture-split-review.md +217 -0
- package/docs/architecture.md +385 -0
- package/docs/architecture.zh-CN.md +364 -0
- package/docs/layout-split-stack-audit.md +298 -0
- package/lib/automation.mjs +8 -0
- package/lib/cli-args.mjs +1 -1
- package/lib/cli-runtime.mjs +44 -0
- package/lib/coordination-state.mjs +218 -0
- package/lib/core/coordination/automation.mjs +222 -0
- package/lib/core/coordination/locks.mjs +46 -0
- package/lib/core/coordination/messages.mjs +116 -0
- package/lib/core/coordination/tasks.mjs +224 -0
- package/lib/core/coordination/teams.mjs +73 -0
- package/lib/core/coordination/timeline.mjs +187 -0
- package/lib/core/peers/bindings.mjs +83 -0
- package/lib/core/peers/format.mjs +13 -0
- package/lib/core/peers/identity.mjs +53 -0
- package/lib/core/peers/liveness.mjs +90 -0
- package/lib/core/peers/reconcile.mjs +238 -0
- package/lib/core/peers/session.mjs +14 -0
- package/lib/core/sessions/launch.mjs +89 -0
- package/lib/db/schema.mjs +324 -0
- package/lib/db/stores/peers.mjs +231 -0
- package/lib/db-schema.mjs +7 -324
- package/lib/errors.mjs +1 -7
- package/lib/handoff.mjs +26 -0
- package/lib/help.mjs +3 -0
- package/lib/integrations/hooks.mjs +171 -0
- package/lib/integrations/peers/identity.mjs +208 -0
- package/lib/integrations/peers/processes.mjs +151 -0
- package/lib/integrations/providers.mjs +282 -0
- package/lib/integrations/shims/script.mjs +384 -0
- package/lib/integrations/shims.mjs +106 -0
- package/lib/json-file.mjs +1 -14
- package/lib/locks.mjs +10 -0
- package/lib/messages.mjs +3 -0
- package/lib/package-meta.mjs +6 -24
- package/lib/peer-bindings.mjs +14 -0
- package/lib/peer-format.mjs +4 -0
- package/lib/peer-identity.mjs +15 -0
- package/lib/project-context.mjs +6 -0
- package/lib/project-registry.mjs +7 -0
- package/lib/provider-commands.mjs +13 -0
- package/lib/release/package-meta.mjs +31 -0
- package/lib/release/release-notes.mjs +40 -0
- package/lib/release-notes.mjs +6 -40
- package/lib/runtime/client.mjs +42 -0
- package/lib/runtime/paths.mjs +45 -0
- package/lib/runtime/project-context.mjs +32 -0
- package/lib/runtime/projects.mjs +76 -0
- package/lib/runtime/state.mjs +128 -0
- package/lib/runtime-client.mjs +3 -0
- package/lib/runtime-paths.mjs +11 -45
- package/lib/runtime-state.mjs +11 -0
- package/lib/session-launch.mjs +17 -0
- package/lib/setup.mjs +17 -293
- package/lib/shared/errors.mjs +7 -0
- package/lib/shared/json-file.mjs +14 -0
- package/lib/shim-script.mjs +1 -384
- package/lib/state-render.mjs +5 -0
- package/lib/task-cli.mjs +45 -0
- package/lib/task-liveness.mjs +8 -0
- package/lib/task-store.mjs +3 -0
- package/lib/team-planning.mjs +7 -0
- package/lib/terminal/tmux.mjs +372 -0
- package/lib/timeline.mjs +12 -0
- package/lib/tmux.mjs +18 -0
- package/lib/ui/help.mjs +419 -0
- package/lib/ui/state-render.mjs +61 -0
- package/lib/web/http.mjs +55 -0
- package/lib/web/peer-actions.mjs +270 -0
- package/lib/web/runtime.mjs +154 -0
- package/lib/web/ui-template.mjs +2055 -0
- package/lib/web-http.mjs +7 -55
- package/lib/web-peer-actions.mjs +3 -0
- package/lib/web-runtime.mjs +17 -108
- package/lib/web-ui-template.mjs +3 -1909
- package/package.json +1 -1
- package/scripts/github-release.mjs +2 -2
- package/scripts/regression.mjs +2468 -17
- package/scripts/release-notes.mjs +2 -2
package/lib/web-http.mjs
CHANGED
|
@@ -1,55 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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';
|
package/lib/web-runtime.mjs
CHANGED
|
@@ -1,108 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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';
|