@pruddiman/hem 0.0.1-beta-5671db0
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 +21 -0
- package/dist/agents/arbiter-agent.d.ts +72 -0
- package/dist/agents/arbiter-agent.js +149 -0
- package/dist/agents/architecture-agent.d.ts +148 -0
- package/dist/agents/architecture-agent.js +459 -0
- package/dist/agents/base-agent.d.ts +44 -0
- package/dist/agents/base-agent.js +57 -0
- package/dist/agents/crossref-agent.d.ts +140 -0
- package/dist/agents/crossref-agent.js +560 -0
- package/dist/agents/crossref-arbiter-agent.d.ts +72 -0
- package/dist/agents/crossref-arbiter-agent.js +147 -0
- package/dist/agents/documentation-agent.d.ts +55 -0
- package/dist/agents/documentation-agent.js +159 -0
- package/dist/agents/exploration-agent.d.ts +58 -0
- package/dist/agents/exploration-agent.js +102 -0
- package/dist/agents/grouping-agent.d.ts +167 -0
- package/dist/agents/grouping-agent.js +557 -0
- package/dist/agents/index-agent.d.ts +86 -0
- package/dist/agents/index-agent.js +360 -0
- package/dist/agents/organization-agent.d.ts +144 -0
- package/dist/agents/organization-agent.js +607 -0
- package/dist/auth.d.ts +372 -0
- package/dist/auth.js +1072 -0
- package/dist/broadcast-mcp.d.ts +21 -0
- package/dist/broadcast-mcp.js +59 -0
- package/dist/changelog.d.ts +85 -0
- package/dist/changelog.js +223 -0
- package/dist/decision-queue.d.ts +173 -0
- package/dist/decision-queue.js +265 -0
- package/dist/diff-scope.d.ts +24 -0
- package/dist/diff-scope.js +28 -0
- package/dist/discovery.d.ts +54 -0
- package/dist/discovery.js +405 -0
- package/dist/grouping.d.ts +37 -0
- package/dist/grouping.js +343 -0
- package/dist/helpers/format.d.ts +5 -0
- package/dist/helpers/format.js +13 -0
- package/dist/helpers/index.d.ts +11 -0
- package/dist/helpers/index.js +11 -0
- package/dist/helpers/parsing.d.ts +52 -0
- package/dist/helpers/parsing.js +128 -0
- package/dist/helpers/paths.d.ts +41 -0
- package/dist/helpers/paths.js +67 -0
- package/dist/helpers/strings.d.ts +45 -0
- package/dist/helpers/strings.js +97 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +1087 -0
- package/dist/merge-utils.d.ts +22 -0
- package/dist/merge-utils.js +34 -0
- package/dist/orchestrator.d.ts +194 -0
- package/dist/orchestrator.js +1169 -0
- package/dist/output.d.ts +106 -0
- package/dist/output.js +243 -0
- package/dist/progress.d.ts +228 -0
- package/dist/progress.js +644 -0
- package/dist/providers/copilot.d.ts +247 -0
- package/dist/providers/copilot.js +598 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.js +12 -0
- package/dist/providers/opencode.d.ts +156 -0
- package/dist/providers/opencode.js +416 -0
- package/dist/providers/types.d.ts +156 -0
- package/dist/providers/types.js +16 -0
- package/dist/resources.d.ts +76 -0
- package/dist/resources.js +151 -0
- package/dist/search-index.d.ts +71 -0
- package/dist/search-index.js +187 -0
- package/dist/search-mcp.d.ts +25 -0
- package/dist/search-mcp.js +100 -0
- package/dist/server-utils.d.ts +56 -0
- package/dist/server-utils.js +135 -0
- package/dist/session.d.ts +227 -0
- package/dist/session.js +370 -0
- package/dist/types.d.ts +272 -0
- package/dist/types.js +5 -0
- package/dist/worktree.d.ts +82 -0
- package/dist/worktree.js +187 -0
- package/package.json +45 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM-assisted cross-reference agent for Hem.
|
|
3
|
+
*
|
|
4
|
+
* Post-processing agent that runs AFTER the organization agent.
|
|
5
|
+
* Reads all generated documentation files and adds inter-document links
|
|
6
|
+
* (cross-references) to improve navigation.
|
|
7
|
+
*
|
|
8
|
+
* Architecture (v2 — parallel workers with broadcast):
|
|
9
|
+
* - Reads all generated docs from disk.
|
|
10
|
+
* - Adds cross-reference links between related pages.
|
|
11
|
+
* - For large file sets (>8 files), splits work across N parallel workers.
|
|
12
|
+
* - Workers communicate via an MCP broadcast tool + prompt injection.
|
|
13
|
+
* - The orchestrator intercepts broadcast tool calls via SSE and relays
|
|
14
|
+
* messages to all peer workers + their active subagents.
|
|
15
|
+
* - For small file sets (≤8 files), falls back to the single-agent path.
|
|
16
|
+
* - The pipeline discovers the final file set by scanning disk afterward.
|
|
17
|
+
*/
|
|
18
|
+
import type { Provider } from "../providers/types.js";
|
|
19
|
+
import { BaseAgent } from "./base-agent.js";
|
|
20
|
+
/** File count threshold: use parallel workers above this, single agent below. */
|
|
21
|
+
export declare const XREF_PARALLEL_THRESHOLD = 8;
|
|
22
|
+
/**
|
|
23
|
+
* Hard ceiling on parallel cross-ref workers. The actual worker count is
|
|
24
|
+
* `min(XREF_MAX_WORKERS, computeMaxConcurrency(), fileCount)`.
|
|
25
|
+
* The arbiter is excluded from this cap (it is lightweight).
|
|
26
|
+
*/
|
|
27
|
+
export declare const XREF_MAX_WORKERS = 4;
|
|
28
|
+
/** Parameters for the cross-reference agent prompt. */
|
|
29
|
+
export interface CrossRefPromptParams {
|
|
30
|
+
/** Project name. */
|
|
31
|
+
projectName: string;
|
|
32
|
+
/** Absolute path to the destination directory. */
|
|
33
|
+
destinationPath: string;
|
|
34
|
+
/** Relative paths of all generated documentation files. */
|
|
35
|
+
allDocFiles: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Parameters for a parallel cross-ref worker prompt. */
|
|
38
|
+
export interface CrossRefWorkerPromptParams {
|
|
39
|
+
/** Project name. */
|
|
40
|
+
projectName: string;
|
|
41
|
+
/** Absolute path to the destination directory. */
|
|
42
|
+
destinationPath: string;
|
|
43
|
+
/** Files assigned to THIS worker (relative paths). */
|
|
44
|
+
assignedFiles: string[];
|
|
45
|
+
/** ALL documentation files across all workers (for cross-reference awareness). */
|
|
46
|
+
allDocFiles: string[];
|
|
47
|
+
/** Label for this worker, e.g. "xref-worker-1". */
|
|
48
|
+
workerLabel: string;
|
|
49
|
+
/** Total number of parallel workers. */
|
|
50
|
+
totalWorkers: number;
|
|
51
|
+
}
|
|
52
|
+
/** A single cross-ref worker assignment: label → file list. */
|
|
53
|
+
export interface XrefWorkerAssignment {
|
|
54
|
+
label: string;
|
|
55
|
+
files: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* An agent that reads all generated documentation and adds inter-document
|
|
59
|
+
* cross-reference links for improved navigation.
|
|
60
|
+
*
|
|
61
|
+
* Edits files directly via the edit tool. The pipeline discovers the
|
|
62
|
+
* final file set by scanning disk afterward.
|
|
63
|
+
*/
|
|
64
|
+
export declare class CrossRefAgent extends BaseAgent {
|
|
65
|
+
constructor(provider: Provider);
|
|
66
|
+
/**
|
|
67
|
+
* Run the cross-reference pass over all generated documentation.
|
|
68
|
+
* Automatically selects single-agent or parallel mode based on file count.
|
|
69
|
+
*
|
|
70
|
+
* @param params - Cross-reference parameters including file paths.
|
|
71
|
+
* @param verbose - Optional logging callback (writes to stderr).
|
|
72
|
+
* @throws If session creation or prompting fails.
|
|
73
|
+
*/
|
|
74
|
+
run(params: CrossRefPromptParams, verbose?: (msg: string) => void): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Single-agent cross-reference pass (original behavior).
|
|
77
|
+
* Used when file count is ≤ XREF_PARALLEL_THRESHOLD.
|
|
78
|
+
*/
|
|
79
|
+
runSingle(params: CrossRefPromptParams, verbose?: (msg: string) => void): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Parallel cross-reference pass using multiple workers with an arbiter.
|
|
82
|
+
*
|
|
83
|
+
* 1. Computes worker count from resource limits (arbiter excluded).
|
|
84
|
+
* 2. Assigns files to workers via round-robin.
|
|
85
|
+
* 3. Subscribes to SSE events for broadcast interception.
|
|
86
|
+
* 4. Creates an arbiter session (long-lived coordinator).
|
|
87
|
+
* 5. Creates N worker sessions in parallel.
|
|
88
|
+
* 6. Relays broadcasts with targeted routing:
|
|
89
|
+
* - Worker → arbiter only.
|
|
90
|
+
* - Arbiter → @tagged worker(s) only (or all if @all-workers / no tag).
|
|
91
|
+
* - Completed sessions are excluded from relay.
|
|
92
|
+
* 7. Kills worker sessions immediately on completion (abort + delete).
|
|
93
|
+
* 8. Intercepts RECALL: broadcasts to respawn a worker for fixes.
|
|
94
|
+
* 9. Sends a final prompt to the arbiter so it can wrap up.
|
|
95
|
+
* 10. Kills the arbiter session.
|
|
96
|
+
*/
|
|
97
|
+
runParallel(params: CrossRefPromptParams, verbose?: (msg: string) => void): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Kill a session: abort any running work, then delete the session.
|
|
100
|
+
* Best-effort — failures are logged but not thrown.
|
|
101
|
+
*/
|
|
102
|
+
private killSession;
|
|
103
|
+
/**
|
|
104
|
+
* Spawn a recalled worker session to apply specific fixes.
|
|
105
|
+
*
|
|
106
|
+
* Called when the arbiter broadcasts `RECALL: @xref-worker-N <instructions>`.
|
|
107
|
+
* Creates a new session with the worker's original file assignment and a
|
|
108
|
+
* focused prompt containing the fix instructions. The session is killed
|
|
109
|
+
* immediately after completion.
|
|
110
|
+
*/
|
|
111
|
+
private runRecalledWorker;
|
|
112
|
+
/**
|
|
113
|
+
* Builds the single-agent cross-reference prompt (original behavior).
|
|
114
|
+
*/
|
|
115
|
+
static buildPrompt(params: CrossRefPromptParams): string;
|
|
116
|
+
/**
|
|
117
|
+
* Builds the prompt for a parallel cross-ref worker.
|
|
118
|
+
*
|
|
119
|
+
* Each worker gets:
|
|
120
|
+
* - A scoped identity (e.g. "xref-worker-1 of 3")
|
|
121
|
+
* - Its assigned file subset
|
|
122
|
+
* - The full file list for cross-reference awareness
|
|
123
|
+
* - Instructions for using the broadcast tool
|
|
124
|
+
* - Scoped task list (only edit YOUR files)
|
|
125
|
+
*/
|
|
126
|
+
static buildWorkerPrompt(params: CrossRefWorkerPromptParams): string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Assigns documentation files to cross-ref workers using round-robin distribution.
|
|
130
|
+
*
|
|
131
|
+
* Files are sorted alphabetically first so that files in the same
|
|
132
|
+
* directory tend to land on adjacent workers, preserving some locality.
|
|
133
|
+
* Then they are dealt out in order: file 0 → worker 1, file 1 → worker 2,
|
|
134
|
+
* …, wrapping around. This guarantees perfectly balanced workloads (±1 file).
|
|
135
|
+
*
|
|
136
|
+
* @param files - Relative file paths (e.g. "auth/overview.md").
|
|
137
|
+
* @param maxWorkers - Maximum number of workers to create.
|
|
138
|
+
* @returns An array of worker assignments, each with a label and file list.
|
|
139
|
+
*/
|
|
140
|
+
export declare function assignXrefFilesToWorkers(files: string[], maxWorkers: number): XrefWorkerAssignment[];
|