@point-seven-studio/jq-deck-server 0.0.0-stage → 0.2.1
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +98 -2
- package/dist/index.mjs +447 -0
- package/dist/jq-deck-server.mjs +559 -0
- package/dist/types/cli.d.ts +9 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/page.d.ts +9 -0
- package/dist/types/report.d.ts +43 -0
- package/dist/types/send.d.ts +3 -0
- package/dist/types/server.d.ts +34 -0
- package/dist/types/store.d.ts +37 -0
- package/dist/types/team.d.ts +59 -0
- package/package.json +59 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP side. handle() is a plain function from a request to a reply, so
|
|
3
|
+
* every rule here is tested without a socket.
|
|
4
|
+
*
|
|
5
|
+
* POST /report a machine's report Bearer machine token
|
|
6
|
+
* GET / the team page viewer cookie
|
|
7
|
+
* GET /api/team the same, as JSON viewer cookie or Bearer viewer token
|
|
8
|
+
* GET /login, POST /login, POST /logout
|
|
9
|
+
* GET /healthz "ok", for a load balancer
|
|
10
|
+
*/
|
|
11
|
+
import { type Server } from 'http';
|
|
12
|
+
export interface Req {
|
|
13
|
+
method: string;
|
|
14
|
+
path: string;
|
|
15
|
+
authorization?: string;
|
|
16
|
+
cookie?: string;
|
|
17
|
+
body: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Res {
|
|
20
|
+
status: number;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
body: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ServerContext {
|
|
25
|
+
dir: string;
|
|
26
|
+
version: string;
|
|
27
|
+
/** False only when serving plain HTTP on this machine. */
|
|
28
|
+
secureCookie: boolean;
|
|
29
|
+
now?: () => number;
|
|
30
|
+
}
|
|
31
|
+
export declare function handle(req: Req, ctx: ServerContext): Res;
|
|
32
|
+
/** Headers on every reply: never cached, never framed, and the page may load nothing. */
|
|
33
|
+
export declare const SECURITY_HEADERS: Record<string, string>;
|
|
34
|
+
export declare function startServer(ctx: ServerContext, port: number, host: string, onListen?: (port: number) => void): Server;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TeamReport } from './report.js';
|
|
2
|
+
export interface Machine {
|
|
3
|
+
name: string;
|
|
4
|
+
/** The person at that machine, as the board should show them. */
|
|
5
|
+
who: string;
|
|
6
|
+
token_sha256: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Viewer {
|
|
9
|
+
name: string;
|
|
10
|
+
token_sha256: string;
|
|
11
|
+
/** When set, this viewer sees only these repositories (by name or remote). */
|
|
12
|
+
repos?: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface Config {
|
|
15
|
+
machines: Machine[];
|
|
16
|
+
viewers: Viewer[];
|
|
17
|
+
}
|
|
18
|
+
export interface StoredReport {
|
|
19
|
+
machine: string;
|
|
20
|
+
who: string;
|
|
21
|
+
/** The server's clock, never the sender's: it decides what is stale. */
|
|
22
|
+
received_at: string;
|
|
23
|
+
report: TeamReport;
|
|
24
|
+
}
|
|
25
|
+
export declare function checkName(name: string): string;
|
|
26
|
+
export declare function initStore(dir: string): void;
|
|
27
|
+
export declare function readConfig(dir: string): Config;
|
|
28
|
+
/** Returns the token. It is shown once and not kept. */
|
|
29
|
+
export declare function addMachine(dir: string, name: string, who: string): string;
|
|
30
|
+
export declare function addViewer(dir: string, name: string, repos?: string[]): string;
|
|
31
|
+
/** Removes a machine (and its report) or a viewer. False when the name is unknown. */
|
|
32
|
+
export declare function remove(dir: string, name: string): boolean;
|
|
33
|
+
export declare const machineFor: (config: Config, token: string | null | undefined) => Machine | null;
|
|
34
|
+
export declare const viewerFor: (config: Config, token: string | null | undefined) => Viewer | null;
|
|
35
|
+
export declare function saveReport(dir: string, machine: Machine, report: TeamReport, now: number): void;
|
|
36
|
+
/** Reports from machines still in the config. A file that cannot be read is skipped. */
|
|
37
|
+
export declare function readReports(dir: string, config: Config): StoredReport[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The team board, as a pure function of the stored reports, the clock and who
|
|
3
|
+
* is looking. A report that has gone quiet never counts as current: a machine
|
|
4
|
+
* that last spoke hours ago may have closed every session since.
|
|
5
|
+
*/
|
|
6
|
+
import type { RepoReport } from './report.js';
|
|
7
|
+
import type { StoredReport, Viewer } from './store.js';
|
|
8
|
+
/** Heard from within this long: its numbers count. Five missed one-minute reports. */
|
|
9
|
+
export declare const FRESH_MS: number;
|
|
10
|
+
/** Not heard from for this long: its rows are dropped and it is listed as silent. */
|
|
11
|
+
export declare const SILENT_MS: number;
|
|
12
|
+
export type Freshness = 'fresh' | 'quiet' | 'silent';
|
|
13
|
+
export interface MachineState {
|
|
14
|
+
machine: string;
|
|
15
|
+
who: string;
|
|
16
|
+
received_at: string;
|
|
17
|
+
freshness: Freshness;
|
|
18
|
+
/** Whole minutes since the server last heard from it. */
|
|
19
|
+
minutes_ago: number;
|
|
20
|
+
}
|
|
21
|
+
export interface TeamRow extends RepoReport {
|
|
22
|
+
machine: string;
|
|
23
|
+
who: string;
|
|
24
|
+
freshness: Freshness;
|
|
25
|
+
minutes_ago: number;
|
|
26
|
+
/** Whole minutes the longest-waiting session has waited. null when none waits, or the report is not fresh. */
|
|
27
|
+
waiting_minutes: number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface TeamGroup {
|
|
30
|
+
/** The remote when there is one, else the folder name. */
|
|
31
|
+
key: string;
|
|
32
|
+
name: string;
|
|
33
|
+
remote: string | null;
|
|
34
|
+
needs_you: number;
|
|
35
|
+
rows: TeamRow[];
|
|
36
|
+
}
|
|
37
|
+
export interface Team {
|
|
38
|
+
generated_at: string;
|
|
39
|
+
headline: string;
|
|
40
|
+
totals: {
|
|
41
|
+
needs_you: number;
|
|
42
|
+
sessions: number;
|
|
43
|
+
machines_fresh: number;
|
|
44
|
+
machines_quiet: number;
|
|
45
|
+
machines_silent: number;
|
|
46
|
+
};
|
|
47
|
+
groups: TeamGroup[];
|
|
48
|
+
machines: MachineState[];
|
|
49
|
+
/** True when this viewer sees only some repositories. */
|
|
50
|
+
scoped: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function freshness(receivedAt: string, now: number): {
|
|
53
|
+
freshness: Freshness;
|
|
54
|
+
minutes_ago: number;
|
|
55
|
+
};
|
|
56
|
+
/** May this viewer see this repository? No list means every repository. */
|
|
57
|
+
export declare function visible(viewer: Pick<Viewer, 'repos'> | null, repo: Pick<RepoReport, 'name' | 'remote'>): boolean;
|
|
58
|
+
export declare function duration(minutes: number): string;
|
|
59
|
+
export declare function buildTeam(reports: StoredReport[], now: number, viewer?: Pick<Viewer, 'repos'> | null): Team;
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@point-seven-studio/jq-deck-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "A small server for a team's JQ Deck: each machine reports counts and scores per repository, and one page shows what is waiting on a person across the team. Self-hosted; stores files in one folder; no dependency. Unofficial; not affiliated with or endorsed by Anthropic.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"jq-deck-server": "dist/jq-deck-server.mjs"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/jq-deck-server.mjs",
|
|
18
|
+
"dist/index.mjs",
|
|
19
|
+
"dist/types",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"NOTICE"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"claude-code",
|
|
29
|
+
"coding-agents",
|
|
30
|
+
"multi-agent",
|
|
31
|
+
"developer-tools",
|
|
32
|
+
"team"
|
|
33
|
+
],
|
|
34
|
+
"author": "Point Seven Studio",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/point-seven-studio/jq-tools.git",
|
|
39
|
+
"directory": "packages/deck-server"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/point-seven-studio/jq-tools/tree/main/packages/deck-server#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/point-seven-studio/jq-tools/issues"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"build": "./build.sh",
|
|
49
|
+
"check": "npm run typecheck && npm test && ./build.sh --check",
|
|
50
|
+
"prepublishOnly": "npm run check"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^20.14.0",
|
|
54
|
+
"esbuild": "^0.21.5",
|
|
55
|
+
"typescript": "^5.4.5",
|
|
56
|
+
"vitest": "^1.6.0"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
}
|
|
61
|
+
}
|