notex-companion 0.1.0
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/README.md +82 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +875 -0
- package/dist/context.d.ts +6 -0
- package/dist/cors.d.ts +9 -0
- package/dist/footer.d.ts +12 -0
- package/dist/graph.d.ts +39 -0
- package/dist/http.d.ts +21 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +769 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/net.d.ts +14 -0
- package/dist/ops.d.ts +75 -0
- package/dist/pairing.d.ts +6 -0
- package/dist/scoring.d.ts +17 -0
- package/dist/serve.d.ts +26 -0
- package/dist/traversal.d.ts +16 -0
- package/dist/types.d.ts +68 -0
- package/package.json +43 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Degraded, GraphEdge, GraphNode, GraphStamp, Truncated } from "./types.js";
|
|
2
|
+
export type BuildContextOptions = {
|
|
3
|
+
truncated?: Truncated;
|
|
4
|
+
degraded?: Degraded;
|
|
5
|
+
};
|
|
6
|
+
export declare function buildContext(question: string, stamp: GraphStamp, nodes: GraphNode[], edges: GraphEdge[], opts?: BuildContextOptions): string;
|
package/dist/cors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--origin` is repeatable, defaulting to the production Notex origin (companion-api.md §5);
|
|
3
|
+
* `http://localhost:3000` is added on top of that only outside production.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveOrigins(configured: string[], nodeEnv: string | undefined, productionOrigin?: string): string[];
|
|
6
|
+
/** Headers for a real (non-preflight) response. `{}` when the origin isn't an exact allowlist match. */
|
|
7
|
+
export declare function corsHeaders(origins: string[], requestOrigin: string | undefined): Record<string, string>;
|
|
8
|
+
/** Full preflight header set (companion-api.md §5). `{}` when the origin isn't an exact allowlist match. */
|
|
9
|
+
export declare function preflightHeaders(origins: string[], requestOrigin: string | undefined): Record<string, string>;
|
package/dist/footer.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Degraded, GraphStamp, Truncated } from "./types.js";
|
|
2
|
+
export type FooterSource = {
|
|
3
|
+
file: string;
|
|
4
|
+
location: string;
|
|
5
|
+
};
|
|
6
|
+
export type BuildFooterOptions = {
|
|
7
|
+
/** YYYY-MM-DD. Defaults to today. */
|
|
8
|
+
draftDate?: string;
|
|
9
|
+
truncated?: Truncated;
|
|
10
|
+
degraded?: Degraded;
|
|
11
|
+
};
|
|
12
|
+
export declare function buildFooter(stamp: GraphStamp, sources: FooterSource[], opts?: BuildFooterOptions): string;
|
package/dist/graph.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ScoreIndexEntry } from "./scoring.js";
|
|
2
|
+
import { type GraphEdge, type GraphNode, type GraphStamp } from "./types.js";
|
|
3
|
+
type RawNode = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
norm_label?: string;
|
|
7
|
+
source_file: string;
|
|
8
|
+
source_location: string;
|
|
9
|
+
file_type: string;
|
|
10
|
+
community: number | null;
|
|
11
|
+
community_name?: string;
|
|
12
|
+
};
|
|
13
|
+
type RawEdge = {
|
|
14
|
+
source: string;
|
|
15
|
+
target: string;
|
|
16
|
+
relation: string;
|
|
17
|
+
weight: number;
|
|
18
|
+
confidence: string;
|
|
19
|
+
source_file: string;
|
|
20
|
+
source_location: string;
|
|
21
|
+
};
|
|
22
|
+
export type AdjacencyEntry = {
|
|
23
|
+
other: string;
|
|
24
|
+
edge: RawEdge;
|
|
25
|
+
};
|
|
26
|
+
export type GraphIndex = {
|
|
27
|
+
stamp: GraphStamp;
|
|
28
|
+
nodesById: Map<string, RawNode>;
|
|
29
|
+
edges: RawEdge[];
|
|
30
|
+
/** Undirected — the graph is `"directed": false` (companion-api.md §2.2). */
|
|
31
|
+
adjacency: Map<string, AdjacencyEntry[]>;
|
|
32
|
+
scoreIndex: ScoreIndexEntry[];
|
|
33
|
+
project: (n: RawNode) => GraphNode;
|
|
34
|
+
projectEdge: (e: RawEdge) => GraphEdge;
|
|
35
|
+
};
|
|
36
|
+
/** `graphRoot` expressed relative to `checkoutPath`; "" when they are the same or graphRoot is outside it. */
|
|
37
|
+
export declare function rootPrefixFor(checkoutPath: string, graphRoot: string): string;
|
|
38
|
+
export declare function loadGraph(checkoutPath: string): GraphIndex;
|
|
39
|
+
export {};
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GraphIndex } from "./graph.js";
|
|
2
|
+
import { OpError } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The graph is loaded once into memory (companion-api.md §3); `loading` covers the window
|
|
5
|
+
* before that finishes, `error` covers a permanently unreadable graph.json (never a crash).
|
|
6
|
+
*/
|
|
7
|
+
export type GraphState = {
|
|
8
|
+
kind: "loading";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "ready";
|
|
11
|
+
index: GraphIndex;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "error";
|
|
14
|
+
error: OpError;
|
|
15
|
+
};
|
|
16
|
+
export type HandlerOptions = {
|
|
17
|
+
token: string;
|
|
18
|
+
origins: string[];
|
|
19
|
+
getGraphState: () => GraphState;
|
|
20
|
+
};
|
|
21
|
+
export declare function createHandler(opts: HandlerOptions): (req: Request) => Promise<Response>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./ops.js";
|
|
3
|
+
export { loadGraph, type GraphIndex } from "./graph.js";
|
|
4
|
+
export { serve, type ServeHandle, type ServeOptions } from "./serve.js";
|
|
5
|
+
export { createHandler, type GraphState, type HandlerOptions } from "./http.js";
|