@proletariat/cli 0.3.110 → 0.3.112
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/dist/commands/gateway/connect.d.ts +33 -0
- package/dist/commands/gateway/connect.js +130 -0
- package/dist/commands/gateway/connect.js.map +1 -0
- package/dist/commands/gateway/disconnect.d.ts +21 -0
- package/dist/commands/gateway/disconnect.js +69 -0
- package/dist/commands/gateway/disconnect.js.map +1 -0
- package/dist/commands/gateway/start.d.ts +23 -0
- package/dist/commands/gateway/start.js +133 -0
- package/dist/commands/gateway/start.js.map +1 -0
- package/dist/commands/gateway/status.d.ts +16 -0
- package/dist/commands/gateway/status.js +76 -0
- package/dist/commands/gateway/status.js.map +1 -0
- package/dist/commands/gateway/test.d.ts +22 -0
- package/dist/commands/gateway/test.js +83 -0
- package/dist/commands/gateway/test.js.map +1 -0
- package/dist/commands/orchestrator/attach.d.ts +2 -0
- package/dist/commands/orchestrator/attach.js +80 -118
- package/dist/commands/orchestrator/attach.js.map +1 -1
- package/dist/commands/orchestrator/start.js +21 -0
- package/dist/commands/orchestrator/start.js.map +1 -1
- package/dist/commands/orchestrator/status.d.ts +3 -0
- package/dist/commands/orchestrator/status.js +104 -130
- package/dist/commands/orchestrator/status.js.map +1 -1
- package/dist/commands/orchestrator/stop.d.ts +2 -0
- package/dist/commands/orchestrator/stop.js +105 -107
- package/dist/commands/orchestrator/stop.js.map +1 -1
- package/dist/commands/reconcile.d.ts +29 -0
- package/dist/commands/reconcile.js +140 -0
- package/dist/commands/reconcile.js.map +1 -0
- package/dist/commands/session/attach.d.ts +2 -6
- package/dist/commands/session/attach.js +68 -97
- package/dist/commands/session/attach.js.map +1 -1
- package/dist/commands/session/list.d.ts +4 -1
- package/dist/commands/session/list.js +160 -326
- package/dist/commands/session/list.js.map +1 -1
- package/dist/commands/work/ship.js +131 -61
- package/dist/commands/work/ship.js.map +1 -1
- package/dist/commands/work/start.js +104 -49
- package/dist/commands/work/start.js.map +1 -1
- package/dist/lib/execution/session-utils.d.ts +4 -1
- package/dist/lib/execution/session-utils.js +3 -0
- package/dist/lib/execution/session-utils.js.map +1 -1
- package/dist/lib/gateway/channel-factory.d.ts +13 -0
- package/dist/lib/gateway/channel-factory.js +37 -0
- package/dist/lib/gateway/channel-factory.js.map +1 -0
- package/dist/lib/gateway/channels/telegram.d.ts +115 -0
- package/dist/lib/gateway/channels/telegram.js +215 -0
- package/dist/lib/gateway/channels/telegram.js.map +1 -0
- package/dist/lib/gateway/router.d.ts +84 -0
- package/dist/lib/gateway/router.js +140 -0
- package/dist/lib/gateway/router.js.map +1 -0
- package/dist/lib/gateway/session-poker.d.ts +35 -0
- package/dist/lib/gateway/session-poker.js +85 -0
- package/dist/lib/gateway/session-poker.js.map +1 -0
- package/dist/lib/gateway/types.d.ts +124 -0
- package/dist/lib/gateway/types.js +17 -0
- package/dist/lib/gateway/types.js.map +1 -0
- package/dist/lib/machine-db-mirror.d.ts +64 -0
- package/dist/lib/machine-db-mirror.js +82 -0
- package/dist/lib/machine-db-mirror.js.map +1 -0
- package/dist/lib/machine-db.d.ts +98 -0
- package/dist/lib/machine-db.js +152 -0
- package/dist/lib/machine-db.js.map +1 -1
- package/dist/lib/orchestrate/prompt-chain.d.ts +19 -4
- package/dist/lib/orchestrate/prompt-chain.js +19 -4
- package/dist/lib/orchestrate/prompt-chain.js.map +1 -1
- package/dist/lib/pr/index.d.ts +34 -2
- package/dist/lib/pr/index.js +95 -4
- package/dist/lib/pr/index.js.map +1 -1
- package/dist/lib/reconcile/core.d.ts +62 -0
- package/dist/lib/reconcile/core.js +137 -0
- package/dist/lib/reconcile/core.js.map +1 -0
- package/dist/lib/reconcile/index.d.ts +54 -0
- package/dist/lib/reconcile/index.js +377 -0
- package/dist/lib/reconcile/index.js.map +1 -0
- package/dist/lib/reconcile/types.d.ts +133 -0
- package/dist/lib/reconcile/types.js +16 -0
- package/dist/lib/reconcile/types.js.map +1 -0
- package/dist/lib/session/renderer.d.ts +121 -0
- package/dist/lib/session/renderer.js +547 -0
- package/dist/lib/session/renderer.js.map +1 -0
- package/dist/lib/update-check.d.ts +64 -7
- package/dist/lib/update-check.js +164 -20
- package/dist/lib/update-check.js.map +1 -1
- package/oclif.manifest.json +1203 -750
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier 2 State Reconciler — Types (PRLT-1280)
|
|
3
|
+
*
|
|
4
|
+
* The reconciler is the safety net that fixes board drift when Tier 1
|
|
5
|
+
* (event-driven hooks) misses an event. It polls the provider (GitHub for
|
|
6
|
+
* PR state) and fires normal ticket transitions when it detects drift.
|
|
7
|
+
*
|
|
8
|
+
* Design constraints:
|
|
9
|
+
* - Provider-agnostic: the reconciler core does not branch on provider type.
|
|
10
|
+
* It routes every transition through the existing provider adapter layer.
|
|
11
|
+
* - Idempotent: running twice back-to-back must be safe. Every check asks
|
|
12
|
+
* "is current == expected?" and no-ops when they match.
|
|
13
|
+
* - No LLM, no supervision tree, no daemon rewrite. One function on a timer.
|
|
14
|
+
*/
|
|
15
|
+
import type { PRInfo } from '../pr/index.js';
|
|
16
|
+
import type { Ticket } from '../pmo/types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Source of a linked PR. Used for logging and to decide which PMO mapping
|
|
19
|
+
* to touch when the reconciler sees a transition is needed.
|
|
20
|
+
*/
|
|
21
|
+
export type LinkedPRSource = 'ticket_branch' | 'external_map';
|
|
22
|
+
/**
|
|
23
|
+
* A PR linked to a ticket, along with its provenance.
|
|
24
|
+
*/
|
|
25
|
+
export interface LinkedPR {
|
|
26
|
+
/** Live PR info as reported by GitHub at the time of the reconcile cycle */
|
|
27
|
+
pr: PRInfo;
|
|
28
|
+
/** How this PR was discovered for the ticket */
|
|
29
|
+
source: LinkedPRSource;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A single transition the reconciler is about to apply (or would apply in dry-run).
|
|
33
|
+
*/
|
|
34
|
+
export interface ReconcileTransition {
|
|
35
|
+
/** Ticket being moved */
|
|
36
|
+
ticketId: string;
|
|
37
|
+
/** Ticket display title (for logging) */
|
|
38
|
+
ticketTitle: string;
|
|
39
|
+
/** The project the ticket belongs to */
|
|
40
|
+
projectId: string;
|
|
41
|
+
/** Provider name that owns this ticket (from resolver) */
|
|
42
|
+
provider: string;
|
|
43
|
+
/** Ticket's state before the transition */
|
|
44
|
+
fromState: string | null;
|
|
45
|
+
/** Ticket's state after the transition (target column name) */
|
|
46
|
+
toState: string;
|
|
47
|
+
/** PR number that drove this transition, when available */
|
|
48
|
+
prNumber?: number;
|
|
49
|
+
/** PR state that drove this transition (MERGED, CLOSED, OPEN) */
|
|
50
|
+
prState?: PRInfo['state'];
|
|
51
|
+
/** Human-readable reason for the transition */
|
|
52
|
+
reason: string;
|
|
53
|
+
/** ISO timestamp the reconciler decided on this transition */
|
|
54
|
+
decidedAt: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for running a reconcile cycle.
|
|
58
|
+
*/
|
|
59
|
+
export interface ReconcileOptions {
|
|
60
|
+
/** If true, compute transitions but do not apply them */
|
|
61
|
+
dryRun?: boolean;
|
|
62
|
+
/** Working directory for GitHub CLI calls (git remote, gh pr view) */
|
|
63
|
+
cwd?: string;
|
|
64
|
+
/** Optional callback for human-readable logs */
|
|
65
|
+
log?: (msg: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Restrict reconciliation to a specific project. When omitted the
|
|
68
|
+
* reconciler runs workspace-wide across every project.
|
|
69
|
+
*/
|
|
70
|
+
projectId?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Injectable PR lookup. Tests use this to avoid the real gh CLI.
|
|
73
|
+
* Implementations must query live — the reconciler is not allowed to
|
|
74
|
+
* depend on a local PR cache.
|
|
75
|
+
*/
|
|
76
|
+
prLookup?: PRLookupFn;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Function signature for live PR lookup.
|
|
80
|
+
*
|
|
81
|
+
* The reconciler calls this once per PR reference. Implementations must
|
|
82
|
+
* hit the remote GitHub API (gh CLI or the REST client) — a stale local
|
|
83
|
+
* cache defeats the whole point of a Tier 2 reconciler.
|
|
84
|
+
*/
|
|
85
|
+
export type PRLookupFn = (ref: PRLookupRef, cwd?: string) => PRInfo | null;
|
|
86
|
+
/**
|
|
87
|
+
* A PR reference that can be resolved to a PRInfo.
|
|
88
|
+
*
|
|
89
|
+
* Tickets link to PRs via either their ticket branch (common for
|
|
90
|
+
* prlt-managed work) or via a stored URL in the external execution
|
|
91
|
+
* mapping table (common when the PR was opened outside prlt).
|
|
92
|
+
*/
|
|
93
|
+
export type PRLookupRef = {
|
|
94
|
+
kind: 'branch';
|
|
95
|
+
branch: string;
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'number';
|
|
98
|
+
number: number;
|
|
99
|
+
} | {
|
|
100
|
+
kind: 'url';
|
|
101
|
+
url: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Report returned after a reconcile cycle completes.
|
|
105
|
+
*/
|
|
106
|
+
export interface ReconcileReport {
|
|
107
|
+
/** Total number of tickets considered (across all scanned projects) */
|
|
108
|
+
checked: number;
|
|
109
|
+
/** Transitions that were applied (or would be applied in dry-run) */
|
|
110
|
+
applied: ReconcileTransition[];
|
|
111
|
+
/** Transitions that the reconciler decided on but did not execute because of --dry-run */
|
|
112
|
+
skipped: ReconcileTransition[];
|
|
113
|
+
/** Transitions that failed to apply */
|
|
114
|
+
failed: Array<{
|
|
115
|
+
transition: ReconcileTransition;
|
|
116
|
+
error: string;
|
|
117
|
+
}>;
|
|
118
|
+
/** Non-fatal errors encountered while gathering state */
|
|
119
|
+
errors: Array<{
|
|
120
|
+
ticketId: string;
|
|
121
|
+
error: string;
|
|
122
|
+
}>;
|
|
123
|
+
/** ISO timestamp when the cycle started */
|
|
124
|
+
startedAt: string;
|
|
125
|
+
/** ISO timestamp when the cycle finished */
|
|
126
|
+
finishedAt: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Minimal view of a ticket the reconciler actually reads. Narrow surface
|
|
130
|
+
* makes the reconciler easy to unit-test without fabricating full Ticket
|
|
131
|
+
* objects.
|
|
132
|
+
*/
|
|
133
|
+
export type ReconcileTicket = Pick<Ticket, 'id' | 'title' | 'projectId' | 'statusName' | 'statusCategory' | 'branch' | 'metadata'>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier 2 State Reconciler — Types (PRLT-1280)
|
|
3
|
+
*
|
|
4
|
+
* The reconciler is the safety net that fixes board drift when Tier 1
|
|
5
|
+
* (event-driven hooks) misses an event. It polls the provider (GitHub for
|
|
6
|
+
* PR state) and fires normal ticket transitions when it detects drift.
|
|
7
|
+
*
|
|
8
|
+
* Design constraints:
|
|
9
|
+
* - Provider-agnostic: the reconciler core does not branch on provider type.
|
|
10
|
+
* It routes every transition through the existing provider adapter layer.
|
|
11
|
+
* - Idempotent: running twice back-to-back must be safe. Every check asks
|
|
12
|
+
* "is current == expected?" and no-ops when they match.
|
|
13
|
+
* - No LLM, no supervision tree, no daemon rewrite. One function on a timer.
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/reconcile/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Renderer (PRLT-1272)
|
|
3
|
+
*
|
|
4
|
+
* Unified machine-wide session collection and grouped rendering.
|
|
5
|
+
*
|
|
6
|
+
* The principle: `prlt session list`, `prlt orchestrator status`, and related
|
|
7
|
+
* commands should ALWAYS query machine-wide for all sessions, regardless of
|
|
8
|
+
* whether the user is inside an HQ. Sessions are then visually grouped by
|
|
9
|
+
* their originating HQ — the current HQ bubbles to the top, other locations
|
|
10
|
+
* are still visible but de-emphasized.
|
|
11
|
+
*
|
|
12
|
+
* Sources collected:
|
|
13
|
+
* 1. machine.db `executions` table — cross-repo ticketless and ticketed work
|
|
14
|
+
* 2. Each registered HQ's workspace.db `agent_work` table — per-HQ workers
|
|
15
|
+
* 3. Discovered tmux/Docker orchestrator sessions — detected by name prefix
|
|
16
|
+
*
|
|
17
|
+
* Each entry is annotated with its hqPath/hqName/role so the renderer can
|
|
18
|
+
* group them.
|
|
19
|
+
*/
|
|
20
|
+
export type SessionRole = 'orchestrator' | 'worker' | 'headless';
|
|
21
|
+
export type SessionStatus = 'starting' | 'running' | 'idle' | 'died' | 'stale' | 'stopped' | 'completed' | 'failed';
|
|
22
|
+
/**
|
|
23
|
+
* Where a session record came from.
|
|
24
|
+
* - `db`: tracked in workspace.db or machine.db
|
|
25
|
+
* - `discovered`: found via tmux/Docker prefix scan (orphan)
|
|
26
|
+
*/
|
|
27
|
+
export type SessionSource = 'db' | 'discovered';
|
|
28
|
+
/**
|
|
29
|
+
* A unified session record representing one running agent on the machine.
|
|
30
|
+
*
|
|
31
|
+
* Sessions originate from three sources:
|
|
32
|
+
* - workspace.db (per-HQ agent_work table) → workers, ticketed
|
|
33
|
+
* - machine.db (cross-repo executions table) → ticketless
|
|
34
|
+
* - tmux/Docker discovery → orchestrators (named prlt-orchestrator-*)
|
|
35
|
+
*/
|
|
36
|
+
export interface UnifiedSession {
|
|
37
|
+
/** Stable identifier — sessionId where present, else execution id */
|
|
38
|
+
id: string;
|
|
39
|
+
/** tmux session name (or container synthetic id) */
|
|
40
|
+
sessionId: string;
|
|
41
|
+
/** Ticket id (e.g., 'PRLT-123', 'orchestrator', 'headless') */
|
|
42
|
+
ticketId: string;
|
|
43
|
+
/** Agent name (display) */
|
|
44
|
+
agentName: string;
|
|
45
|
+
/** Status — running/idle/stale/etc. */
|
|
46
|
+
status: SessionStatus;
|
|
47
|
+
/** Role — orchestrator vs worker vs headless */
|
|
48
|
+
role: SessionRole;
|
|
49
|
+
/** Execution environment */
|
|
50
|
+
environment: 'host' | 'container';
|
|
51
|
+
/** Container id (for container envs) */
|
|
52
|
+
containerId?: string;
|
|
53
|
+
/** Whether the runtime is verified alive */
|
|
54
|
+
exists: boolean;
|
|
55
|
+
/** Where the record was sourced from (backward compat field) */
|
|
56
|
+
source: SessionSource;
|
|
57
|
+
/** When this session started (best effort) */
|
|
58
|
+
startedAt?: Date;
|
|
59
|
+
/** Last heartbeat (workers only) */
|
|
60
|
+
lastHeartbeat?: Date;
|
|
61
|
+
/** Lifecycle state from DB (workers only) */
|
|
62
|
+
lifecycleState?: string;
|
|
63
|
+
/** HQ path this session originated from, if known */
|
|
64
|
+
hqPath?: string;
|
|
65
|
+
/** HQ name (display) */
|
|
66
|
+
hqName?: string;
|
|
67
|
+
/** Repo path the agent ran in (machine.db only, may differ from HQ) */
|
|
68
|
+
repoPath?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface CollectOptions {
|
|
71
|
+
/** Include only sessions in this HQ path */
|
|
72
|
+
hqPathFilter?: string;
|
|
73
|
+
/** Filter to specific role */
|
|
74
|
+
roleFilter?: SessionRole;
|
|
75
|
+
/** Include stopped/completed sessions (default: only active runtimes) */
|
|
76
|
+
includeAll?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface GroupedSessions {
|
|
79
|
+
/** Path of the HQ the user is currently in (resolved from cwd), if any */
|
|
80
|
+
currentHq?: string;
|
|
81
|
+
currentHqName?: string;
|
|
82
|
+
/** Sessions belonging to the current HQ */
|
|
83
|
+
here: UnifiedSession[];
|
|
84
|
+
/** Sessions in other HQs or headless */
|
|
85
|
+
elsewhere: UnifiedSession[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Replace the user's home directory in a path with `~` for display.
|
|
89
|
+
*/
|
|
90
|
+
export declare function tildifyPath(p: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Collect all sessions on the machine, regardless of cwd.
|
|
93
|
+
*
|
|
94
|
+
* Queries:
|
|
95
|
+
* 1. machine.db (cross-repo executions, source of truth for ticketless work)
|
|
96
|
+
* 2. Every registered HQ's workspace.db (workers per HQ)
|
|
97
|
+
* 3. tmux/Docker (orchestrators by name prefix)
|
|
98
|
+
*
|
|
99
|
+
* Filters are applied at the end so the underlying machine query path is
|
|
100
|
+
* the same in every command.
|
|
101
|
+
*/
|
|
102
|
+
export declare function collectAllSessions(options?: CollectOptions): UnifiedSession[];
|
|
103
|
+
/**
|
|
104
|
+
* Group sessions into "current HQ" vs "other locations" buckets.
|
|
105
|
+
*
|
|
106
|
+
* The current HQ is resolved from `process.cwd()` (or an explicit override).
|
|
107
|
+
* Sessions whose hqPath matches the current HQ go into `here`; everything
|
|
108
|
+
* else goes into `elsewhere`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function groupSessionsByHQ(sessions: UnifiedSession[], currentHqOverride?: string | null): GroupedSessions;
|
|
111
|
+
/** Format a Date into a compact relative duration like "~15m", "~3h", "~2d". */
|
|
112
|
+
export declare function formatRelativeAge(start?: Date, now?: Date): string;
|
|
113
|
+
/**
|
|
114
|
+
* Group elsewhere sessions by hqPath/hqName for nicer rendering.
|
|
115
|
+
* Sessions without an hqPath are bucketed under "(no HQ)".
|
|
116
|
+
*/
|
|
117
|
+
export declare function bucketElsewhereByHq(elsewhere: UnifiedSession[]): Array<{
|
|
118
|
+
hqPath: string | null;
|
|
119
|
+
hqName: string;
|
|
120
|
+
sessions: UnifiedSession[];
|
|
121
|
+
}>;
|