@peer2peer/ext-ix 0.0.0-stage → 0.1.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 +201 -0
- package/README.md +79 -2
- package/SPEC.md +785 -0
- package/dist/conflicts.d.ts +64 -0
- package/dist/conflicts.js +188 -0
- package/dist/extension.d.ts +45 -0
- package/dist/extension.js +615 -0
- package/dist/footprint-command.d.ts +57 -0
- package/dist/footprint-command.js +398 -0
- package/dist/footprint-compute.d.ts +106 -0
- package/dist/footprint-compute.js +559 -0
- package/dist/footprint.d.ts +162 -0
- package/dist/footprint.js +451 -0
- package/dist/hmac.d.ts +18 -0
- package/dist/hmac.js +42 -0
- package/dist/impact.d.ts +66 -0
- package/dist/impact.js +208 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +21 -0
- package/dist/ix.d.ts +158 -0
- package/dist/ix.js +420 -0
- package/dist/listener.d.ts +48 -0
- package/dist/listener.js +203 -0
- package/dist/memory.d.ts +50 -0
- package/dist/memory.js +315 -0
- package/dist/note.d.ts +40 -0
- package/dist/note.js +82 -0
- package/dist/overlap-command.d.ts +37 -0
- package/dist/overlap-command.js +81 -0
- package/dist/overlap.d.ts +83 -0
- package/dist/overlap.js +227 -0
- package/dist/repo.d.ts +36 -0
- package/dist/repo.js +116 -0
- package/dist/subgraph.d.ts +59 -0
- package/dist/subgraph.js +140 -0
- package/dist/text.d.ts +83 -0
- package/dist/text.js +187 -0
- package/dist/which.d.ts +1 -0
- package/dist/which.js +45 -0
- package/package.json +61 -4
package/dist/impact.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type RepoRef } from "./repo.js";
|
|
2
|
+
import { type Roots, type RiskLevel } from "./text.js";
|
|
3
|
+
export declare const IMPACT_KIND: "x:ix.impact";
|
|
4
|
+
export interface ImpactSymbol {
|
|
5
|
+
name: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
/** Callers Ix counted for it. */
|
|
9
|
+
callers?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ImpactComponent {
|
|
12
|
+
name: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
/** Dependents in it. */
|
|
15
|
+
count: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ImpactBody {
|
|
18
|
+
target: {
|
|
19
|
+
name: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
};
|
|
22
|
+
repo?: RepoRef;
|
|
23
|
+
riskLevel: RiskLevel;
|
|
24
|
+
riskSummary: string;
|
|
25
|
+
riskCategory?: string;
|
|
26
|
+
atRisk: string[];
|
|
27
|
+
/** Affected files (repo-relative). */
|
|
28
|
+
files: string[];
|
|
29
|
+
/** The sender's changed files (repo-relative), when they said. */
|
|
30
|
+
changed?: string[];
|
|
31
|
+
symbols: ImpactSymbol[];
|
|
32
|
+
components: ImpactComponent[];
|
|
33
|
+
counts?: {
|
|
34
|
+
callers?: number;
|
|
35
|
+
callees?: number;
|
|
36
|
+
members?: number;
|
|
37
|
+
importers?: number;
|
|
38
|
+
dependents?: number;
|
|
39
|
+
};
|
|
40
|
+
/** The sender's graph had lost edges: the counts are a floor. */
|
|
41
|
+
graphDegraded?: boolean;
|
|
42
|
+
nextStep?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function parseImpactBody(v: unknown): ImpactBody;
|
|
45
|
+
export declare function impactFallback(b: Pick<ImpactBody, "riskLevel" | "files" | "symbols">): string;
|
|
46
|
+
export interface ImpactInput {
|
|
47
|
+
/** `ix impact <target> --format json` output. */
|
|
48
|
+
ix: unknown;
|
|
49
|
+
repo?: RepoRef;
|
|
50
|
+
changed?: string[];
|
|
51
|
+
root?: Roots;
|
|
52
|
+
home?: string;
|
|
53
|
+
hostname?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sending: maps Ix's impact JSON (container or leaf shape) to a body. Paths
|
|
57
|
+
* are made repo-relative (others dropped), free text scrubbed of local
|
|
58
|
+
* paths, every list capped.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildImpact(i: ImpactInput): {
|
|
61
|
+
body: ImpactBody;
|
|
62
|
+
fallback: string;
|
|
63
|
+
};
|
|
64
|
+
export declare function renderImpact(b: ImpactBody, from: {
|
|
65
|
+
address: string;
|
|
66
|
+
}): Record<string, unknown>;
|
package/dist/impact.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// x:ix.impact: a blast-radius report for a change, made by the sender's Ix
|
|
4
|
+
// (`ix impact <target> --format json`, SPEC.md §5). The receiver only reads
|
|
5
|
+
// it: it lists files, symbols and components, and a risk summary.
|
|
6
|
+
import { parseRepo } from "./repo.js";
|
|
7
|
+
import { fail, frame, isObj, jsonBytes, LIMITS, line, list, MAX_BODY_BYTES, oneOf, optInt, optStr, relPath, RISK_LEVELS, scrubPaths, str, toRepoRelative, } from "./text.js";
|
|
8
|
+
export const IMPACT_KIND = "x:ix.impact";
|
|
9
|
+
const NAME_MAX = LIMITS.symbol;
|
|
10
|
+
function parseSymbol(x, i) {
|
|
11
|
+
if (!isObj(x))
|
|
12
|
+
return fail(`impact.symbols[${i}] must be an object`);
|
|
13
|
+
const name = str(x, "name", NAME_MAX, `impact.symbols[${i}]`);
|
|
14
|
+
const kind = str(x, "kind", LIMITS.kind, `impact.symbols[${i}]`);
|
|
15
|
+
const path = x.path === undefined ? undefined : relPath(x.path, `impact.symbols[${i}].path`);
|
|
16
|
+
const callers = optInt(x, "callers", `impact.symbols[${i}]`);
|
|
17
|
+
return { name, kind, ...(path ? { path } : {}), ...(callers !== undefined ? { callers } : {}) };
|
|
18
|
+
}
|
|
19
|
+
function parseComponent(x, i) {
|
|
20
|
+
if (!isObj(x))
|
|
21
|
+
return fail(`impact.components[${i}] must be an object`);
|
|
22
|
+
const name = str(x, "name", LIMITS.region, `impact.components[${i}]`);
|
|
23
|
+
const kind = optStr(x, "kind", LIMITS.kind, `impact.components[${i}]`);
|
|
24
|
+
const count = optInt(x, "count", `impact.components[${i}]`) ?? 0;
|
|
25
|
+
return { name, ...(kind ? { kind } : {}), count };
|
|
26
|
+
}
|
|
27
|
+
export function parseImpactBody(v) {
|
|
28
|
+
if (!isObj(v))
|
|
29
|
+
return fail("impact body must be an object");
|
|
30
|
+
const o = v;
|
|
31
|
+
if (jsonBytes(o) > MAX_BODY_BYTES)
|
|
32
|
+
fail(`impact body is larger than ${MAX_BODY_BYTES} bytes`);
|
|
33
|
+
if (!isObj(o.target))
|
|
34
|
+
fail("impact.target must be {name, kind}");
|
|
35
|
+
const t = o.target;
|
|
36
|
+
const target = { name: str(t, "name", NAME_MAX, "impact.target"), kind: str(t, "kind", LIMITS.kind, "impact.target") };
|
|
37
|
+
const repo = o.repo === undefined ? undefined : parseRepo(o.repo, "impact.repo");
|
|
38
|
+
const riskLevel = oneOf(o, "riskLevel", RISK_LEVELS, "impact");
|
|
39
|
+
const riskSummary = str(o, "riskSummary", LIMITS.riskSummary, "impact");
|
|
40
|
+
const riskCategory = optStr(o, "riskCategory", 40, "impact");
|
|
41
|
+
const atRisk = list(o, "atRisk", LIMITS.atRisk, "impact", (x, i) => {
|
|
42
|
+
if (typeof x !== "string" || x.trim() === "" || [...x].length > LIMITS.atRiskItem)
|
|
43
|
+
return fail(`impact.atRisk[${i}] must be a string of 1-${LIMITS.atRiskItem}`);
|
|
44
|
+
return x.trim();
|
|
45
|
+
});
|
|
46
|
+
const files = list(o, "files", LIMITS.files, "impact", (x, i) => relPath(x, `impact.files[${i}]`));
|
|
47
|
+
const changed = list(o, "changed", LIMITS.changed, "impact", (x, i) => relPath(x, `impact.changed[${i}]`));
|
|
48
|
+
const symbols = list(o, "symbols", LIMITS.symbols, "impact", parseSymbol);
|
|
49
|
+
const components = list(o, "components", LIMITS.components, "impact", parseComponent);
|
|
50
|
+
let counts;
|
|
51
|
+
if (o.counts !== undefined) {
|
|
52
|
+
if (!isObj(o.counts))
|
|
53
|
+
fail("impact.counts must be an object");
|
|
54
|
+
const c = o.counts;
|
|
55
|
+
counts = {};
|
|
56
|
+
for (const k of ["callers", "callees", "members", "importers", "dependents"]) {
|
|
57
|
+
const n = optInt(c, k, "impact.counts");
|
|
58
|
+
if (n !== undefined)
|
|
59
|
+
counts[k] = n;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (o.graphDegraded !== undefined && typeof o.graphDegraded !== "boolean")
|
|
63
|
+
fail("impact.graphDegraded must be a boolean");
|
|
64
|
+
const nextStep = optStr(o, "nextStep", LIMITS.nextStep, "impact");
|
|
65
|
+
return {
|
|
66
|
+
target,
|
|
67
|
+
...(repo ? { repo } : {}),
|
|
68
|
+
riskLevel,
|
|
69
|
+
riskSummary,
|
|
70
|
+
...(riskCategory ? { riskCategory } : {}),
|
|
71
|
+
atRisk,
|
|
72
|
+
files,
|
|
73
|
+
...(changed.length ? { changed } : {}),
|
|
74
|
+
symbols,
|
|
75
|
+
components,
|
|
76
|
+
...(counts && Object.keys(counts).length ? { counts } : {}),
|
|
77
|
+
...(o.graphDegraded === true ? { graphDegraded: true } : {}),
|
|
78
|
+
...(nextStep ? { nextStep } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function impactFallback(b) {
|
|
82
|
+
const n = b.files.length || b.symbols.length;
|
|
83
|
+
const what = b.riskLevel === "unknown" ? "" : `${b.riskLevel} risk, `;
|
|
84
|
+
return `shared an Ix blast-radius report (${what}${n} affected): install Ix to open it: https://github.com/ix-infrastructure/Ix`;
|
|
85
|
+
}
|
|
86
|
+
const num = (v) => (typeof v === "number" && Number.isSafeInteger(v) && v >= 0 ? v : undefined);
|
|
87
|
+
const s = (v, max) => (typeof v === "string" && v.trim() !== "" ? v.trim().slice(0, max) : undefined);
|
|
88
|
+
/**
|
|
89
|
+
* Sending: maps Ix's impact JSON (container or leaf shape) to a body. Paths
|
|
90
|
+
* are made repo-relative (others dropped), free text scrubbed of local
|
|
91
|
+
* paths, every list capped.
|
|
92
|
+
*/
|
|
93
|
+
export function buildImpact(i) {
|
|
94
|
+
if (!isObj(i.ix))
|
|
95
|
+
return fail("ix impact output must be a JSON object");
|
|
96
|
+
const x = i.ix;
|
|
97
|
+
if (typeof x.error === "string")
|
|
98
|
+
fail(`ix impact: ${String(x.message ?? x.error).slice(0, 200)}`);
|
|
99
|
+
// L3: every free-text field, names included (a target or symbol can be a path).
|
|
100
|
+
const scrub = (t) => scrubPaths(t, { root: i.root, home: i.home, hostname: i.hostname });
|
|
101
|
+
const rt = isObj(x.resolvedTarget) ? x.resolvedTarget : {};
|
|
102
|
+
const target = { name: scrub(s(rt.name, NAME_MAX) ?? "(unknown)"), kind: s(rt.kind, LIMITS.kind) ?? "unknown" };
|
|
103
|
+
const riskLevel = RISK_LEVELS.includes(String(x.riskLevel)) ? x.riskLevel : "unknown";
|
|
104
|
+
const rel = (p) => (typeof p === "string" ? toRepoRelative(p, i.root) : undefined);
|
|
105
|
+
const symbols = [];
|
|
106
|
+
const seen = new Set();
|
|
107
|
+
const addSym = (m) => {
|
|
108
|
+
if (!isObj(m) || symbols.length >= LIMITS.symbols)
|
|
109
|
+
return;
|
|
110
|
+
const raw = s(m.name, NAME_MAX);
|
|
111
|
+
if (!raw || raw === "(unnamed)")
|
|
112
|
+
return;
|
|
113
|
+
const name = scrub(raw);
|
|
114
|
+
const kind = s(m.kind, LIMITS.kind) ?? "unknown";
|
|
115
|
+
const path = rel(m.path);
|
|
116
|
+
const key = `${kind}|${name}|${path ?? ""}`;
|
|
117
|
+
if (seen.has(key))
|
|
118
|
+
return;
|
|
119
|
+
seen.add(key);
|
|
120
|
+
const callers = num(m.callerCount);
|
|
121
|
+
symbols.push({ name, kind, ...(path ? { path } : {}), ...(callers !== undefined ? { callers } : {}) });
|
|
122
|
+
};
|
|
123
|
+
for (const m of Array.isArray(x.topImpactedMembers) ? x.topImpactedMembers : [])
|
|
124
|
+
addSym(m);
|
|
125
|
+
for (const m of Array.isArray(x.callerList) ? x.callerList : [])
|
|
126
|
+
addSym(m);
|
|
127
|
+
const components = [];
|
|
128
|
+
for (const b of Array.isArray(x.propagationBuckets) ? x.propagationBuckets : []) {
|
|
129
|
+
if (!isObj(b) || components.length >= LIMITS.components)
|
|
130
|
+
continue;
|
|
131
|
+
const region = s(b.region, LIMITS.region);
|
|
132
|
+
if (!region)
|
|
133
|
+
continue;
|
|
134
|
+
const name = scrub(region);
|
|
135
|
+
const kind = s(b.regionKind, LIMITS.kind);
|
|
136
|
+
components.push({ name, ...(kind ? { kind } : {}), count: num(b.count) ?? 0 });
|
|
137
|
+
}
|
|
138
|
+
const files = [...new Set(symbols.map((m) => m.path).filter((p) => !!p))].slice(0, LIMITS.files);
|
|
139
|
+
const sum = isObj(x.summary) ? x.summary : {};
|
|
140
|
+
const counts = {};
|
|
141
|
+
const map = [
|
|
142
|
+
["callers", "callers"],
|
|
143
|
+
["callees", "callees"],
|
|
144
|
+
["members", "members"],
|
|
145
|
+
["importers", "directImporters"],
|
|
146
|
+
["dependents", "directDependents"],
|
|
147
|
+
];
|
|
148
|
+
for (const [k, from] of map) {
|
|
149
|
+
const n = num(sum[from]);
|
|
150
|
+
if (n !== undefined)
|
|
151
|
+
counts[k] = n;
|
|
152
|
+
}
|
|
153
|
+
const atRisk = (Array.isArray(x.atRiskBehavior) ? x.atRiskBehavior : [])
|
|
154
|
+
.map((b) => s(b, LIMITS.atRiskItem))
|
|
155
|
+
.filter((b) => !!b)
|
|
156
|
+
.map(scrub)
|
|
157
|
+
.slice(0, LIMITS.atRisk);
|
|
158
|
+
const changed = [...new Set((i.changed ?? []).map((p) => toRepoRelative(p, i.root)).filter((p) => !!p))].slice(0, LIMITS.changed);
|
|
159
|
+
const nextStep = s(x.nextStep, LIMITS.nextStep);
|
|
160
|
+
const rc = s(x.riskCategory, 40);
|
|
161
|
+
const riskCategory = rc ? scrub(rc) : undefined;
|
|
162
|
+
const raw = {
|
|
163
|
+
target,
|
|
164
|
+
...(i.repo ? { repo: i.repo } : {}),
|
|
165
|
+
riskLevel,
|
|
166
|
+
riskSummary: scrub(s(x.riskSummary, LIMITS.riskSummary) ?? "No risk summary."),
|
|
167
|
+
...(riskCategory ? { riskCategory } : {}),
|
|
168
|
+
atRisk,
|
|
169
|
+
files,
|
|
170
|
+
...(changed.length ? { changed } : {}),
|
|
171
|
+
symbols,
|
|
172
|
+
components,
|
|
173
|
+
...(Object.keys(counts).length ? { counts } : {}),
|
|
174
|
+
...(x.graph !== undefined ? { graphDegraded: true } : {}),
|
|
175
|
+
...(nextStep ? { nextStep: scrub(nextStep) } : {}),
|
|
176
|
+
};
|
|
177
|
+
const body = parseImpactBody(raw);
|
|
178
|
+
return { body, fallback: impactFallback(body) };
|
|
179
|
+
}
|
|
180
|
+
export function renderImpact(b, from) {
|
|
181
|
+
const files = b.files.slice(0, 15);
|
|
182
|
+
const comps = b.components.slice(0, 8).map((c) => `${line(c.name, LIMITS.region)} (${c.count})`);
|
|
183
|
+
const parts = [
|
|
184
|
+
`change to ${line(b.target.kind, LIMITS.kind)} ${line(b.target.name, NAME_MAX)}${b.repo ? ` in ${line(b.repo.remote, LIMITS.remote)}` : ""}`,
|
|
185
|
+
`risk ${b.riskLevel}: ${line(b.riskSummary, LIMITS.riskSummary)}`,
|
|
186
|
+
b.atRisk.length ? `at risk: ${b.atRisk.slice(0, 5).map((a) => line(a, LIMITS.atRiskItem)).join("; ")}` : undefined,
|
|
187
|
+
comps.length ? `components: ${comps.join(", ")}` : undefined,
|
|
188
|
+
files.length ? `files: ${files.join(", ")}${b.files.length > files.length ? `, +${b.files.length - files.length} more` : ""}` : undefined,
|
|
189
|
+
b.graphDegraded ? "the sender's graph is degraded, so counts are a floor" : undefined,
|
|
190
|
+
].filter(Boolean);
|
|
191
|
+
return {
|
|
192
|
+
type: "impact",
|
|
193
|
+
target: { name: line(b.target.name, NAME_MAX), kind: line(b.target.kind, LIMITS.kind) },
|
|
194
|
+
...(b.repo ? { repo: b.repo } : {}),
|
|
195
|
+
riskLevel: b.riskLevel,
|
|
196
|
+
riskSummary: line(b.riskSummary, LIMITS.riskSummary),
|
|
197
|
+
...(b.riskCategory ? { riskCategory: line(b.riskCategory, 40) } : {}),
|
|
198
|
+
atRisk: b.atRisk.map((a) => line(a, LIMITS.atRiskItem)),
|
|
199
|
+
files: b.files,
|
|
200
|
+
...(b.changed ? { changed: b.changed } : {}),
|
|
201
|
+
symbols: b.symbols.map((m) => ({ name: line(m.name, NAME_MAX), kind: line(m.kind, LIMITS.kind), ...(m.path ? { path: m.path } : {}), ...(m.callers !== undefined ? { callers: m.callers } : {}) })),
|
|
202
|
+
components: b.components.map((c) => ({ name: line(c.name, LIMITS.region), ...(c.kind ? { kind: line(c.kind, LIMITS.kind) } : {}), count: c.count })),
|
|
203
|
+
...(b.counts ? { counts: b.counts } : {}),
|
|
204
|
+
...(b.graphDegraded ? { graphDegraded: true } : {}),
|
|
205
|
+
...(b.nextStep ? { nextStep: line(b.nextStep, LIMITS.nextStep) } : {}),
|
|
206
|
+
digest: frame(from.address, "Ix blast-radius report", parts.join("; ")),
|
|
207
|
+
};
|
|
208
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { extension, createIxExtension, receiveIx, ixCommands, KINDS, VERSION, type Deps } from "./extension.js";
|
|
2
|
+
export { NOTE_KIND, parseNoteBody, buildNote, renderNote, noteFallback, type NoteBody, type NoteInput } from "./note.js";
|
|
3
|
+
export { SUBGRAPH_KIND, parseSubgraphBody, parseSelector, buildSubgraph, renderSubgraph, subgraphFallback, resolveArgv, describeSelector, splitPattern, type SubgraphBody, type Selector, type SubgraphInput, } from "./subgraph.js";
|
|
4
|
+
export { IMPACT_KIND, parseImpactBody, buildImpact, renderImpact, impactFallback, type ImpactBody, type ImpactInput, type ImpactSymbol, type ImpactComponent } from "./impact.js";
|
|
5
|
+
export { semanticConflicts, ixNeighbourhood, parseAround, type SemanticConflict, type PeerChanges, type Neighbourhood, type NeighbourhoodFn, type Relation, type ConflictOptions } from "./conflicts.js";
|
|
6
|
+
export { ixRunner, ixAvailable, ixJson, ixEnv, guardRunner, refuseForTarget, checkedTarget, localTarget, isLoopbackEndpoint, memoryCall, memorySupport, parseMemorySupport, confirmsLocalWrite, IX_ENV_ALLOW, LOCAL_IX_COMMANDS, DEFAULT_IX_ENDPOINT, type IxRunner, type IxResult, type IxTarget, type MemoryCall, type MemorySupport } from "./ix.js";
|
|
7
|
+
export { ixMemory, memoryText, memoryPurpose, memorySessionName, memoryActor, MEMORY_TTL_HOURS } from "./memory.js";
|
|
8
|
+
export { normalizeRemote, parseRepo, localRepo, compareRepo, type RepoRef, type LocalRepo } from "./repo.js";
|
|
9
|
+
export { SPEC_VERSION, MAX_BODY_BYTES, LIMITS, NOTE_TAGS, RISK_LEVELS, InvalidBody, IxExtError, toRepoRelative, scrubPaths, type NoteTag, type RiskLevel } from "./text.js";
|
|
10
|
+
export { FOOTPRINT_KIND, FOOTPRINT_TTL, MAX_FOOTPRINT_BYTES, FP_LIMITS, parseFootprintBody, assembleFootprint, footprintFallback, footprintDigest, symbolKey, wireQualifiedKey, type FootprintBody, type FpActor, type FpComponent, type RawActor, } from "./footprint.js";
|
|
11
|
+
export { computeFootprint, parseUnifiedDiff, groupRanges, parseWorktrees, declaredNames, type ComputeInput, type ComputeDeps, type ComputeResult } from "./footprint-compute.js";
|
|
12
|
+
export { footprintNames, FOOTPRINT_MIN_INTERVAL_MS, FOOTPRINT_KEEPALIVE_MS, type FootprintConfig } from "./footprint-command.js";
|
|
13
|
+
export { deriveNameKey, pickRootCommit, hashFile, hashSymbol, hashRegion, type NameKey } from "./hmac.js";
|
|
14
|
+
export { computeOverlaps, OVERLAP_TIERS, type Overlap, type OverlapPeer, type OverlapTier, type OverlapSeverity, type OverlapDirection } from "./overlap.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2026 Ix Infrastructure Inc.
|
|
2
|
+
//
|
|
3
|
+
// @peer2peer/ext-ix: the Ix extension for Peer2Peer v3 (SPEC.md). `p2p`
|
|
4
|
+
// loads `extension` when this package is installed; the rest is the library
|
|
5
|
+
// (send helpers that build bodies from Ix output, receive helpers that
|
|
6
|
+
// validate, sanitize and render, and semantic-conflict detection) for other
|
|
7
|
+
// clients such as the Claude Code mod.
|
|
8
|
+
export { extension, createIxExtension, receiveIx, ixCommands, KINDS, VERSION } from "./extension.js";
|
|
9
|
+
export { NOTE_KIND, parseNoteBody, buildNote, renderNote, noteFallback } from "./note.js";
|
|
10
|
+
export { SUBGRAPH_KIND, parseSubgraphBody, parseSelector, buildSubgraph, renderSubgraph, subgraphFallback, resolveArgv, describeSelector, splitPattern, } from "./subgraph.js";
|
|
11
|
+
export { IMPACT_KIND, parseImpactBody, buildImpact, renderImpact, impactFallback } from "./impact.js";
|
|
12
|
+
export { semanticConflicts, ixNeighbourhood, parseAround } from "./conflicts.js";
|
|
13
|
+
export { ixRunner, ixAvailable, ixJson, ixEnv, guardRunner, refuseForTarget, checkedTarget, localTarget, isLoopbackEndpoint, memoryCall, memorySupport, parseMemorySupport, confirmsLocalWrite, IX_ENV_ALLOW, LOCAL_IX_COMMANDS, DEFAULT_IX_ENDPOINT } from "./ix.js";
|
|
14
|
+
export { ixMemory, memoryText, memoryPurpose, memorySessionName, memoryActor, MEMORY_TTL_HOURS } from "./memory.js";
|
|
15
|
+
export { normalizeRemote, parseRepo, localRepo, compareRepo } from "./repo.js";
|
|
16
|
+
export { SPEC_VERSION, MAX_BODY_BYTES, LIMITS, NOTE_TAGS, RISK_LEVELS, InvalidBody, IxExtError, toRepoRelative, scrubPaths } from "./text.js";
|
|
17
|
+
export { FOOTPRINT_KIND, FOOTPRINT_TTL, MAX_FOOTPRINT_BYTES, FP_LIMITS, parseFootprintBody, assembleFootprint, footprintFallback, footprintDigest, symbolKey, wireQualifiedKey, } from "./footprint.js";
|
|
18
|
+
export { computeFootprint, parseUnifiedDiff, groupRanges, parseWorktrees, declaredNames } from "./footprint-compute.js";
|
|
19
|
+
export { footprintNames, FOOTPRINT_MIN_INTERVAL_MS, FOOTPRINT_KEEPALIVE_MS } from "./footprint-command.js";
|
|
20
|
+
export { deriveNameKey, pickRootCommit, hashFile, hashSymbol, hashRegion } from "./hmac.js";
|
|
21
|
+
export { computeOverlaps, OVERLAP_TIERS } from "./overlap.js";
|
package/dist/ix.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { IxExtError } from "./text.js";
|
|
2
|
+
import { type ListenerCheck } from "./listener.js";
|
|
3
|
+
export interface IxResult {
|
|
4
|
+
code: number;
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IxRunner {
|
|
9
|
+
run(argv: readonly string[], opts?: {
|
|
10
|
+
stdin?: string;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}): Promise<IxResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare const IX_TIMEOUT_MS = 30000;
|
|
16
|
+
/**
|
|
17
|
+
* Where an `ix` call may go: the graph target p2p's chokepoint gave (ExtContext.graphTarget,
|
|
18
|
+
* packages/p2p/src/projects.ts graphTarget). Never taken from the environment.
|
|
19
|
+
*/
|
|
20
|
+
export type IxTarget = {
|
|
21
|
+
kind: "local";
|
|
22
|
+
endpoint: string;
|
|
23
|
+
why?: string;
|
|
24
|
+
trustRootListener?: true;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "shared";
|
|
27
|
+
circle: string;
|
|
28
|
+
endpoint: string;
|
|
29
|
+
token?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Ix's own default backend (ix-cli DEFAULT_ENDPOINT). */
|
|
32
|
+
export declare const DEFAULT_IX_ENDPOINT = "http://localhost:8090";
|
|
33
|
+
/** http(s) to localhost, 127.0.0.0/8 or ::1, no credentials, query or fragment (as p2p's isLoopbackEndpoint). */
|
|
34
|
+
export declare function isLoopbackEndpoint(url: unknown): url is string;
|
|
35
|
+
/** A loopback endpoint as `origin + pathname`, trailing slashes dropped; undefined when it isn't one. */
|
|
36
|
+
export declare function normalizeLoopbackEndpoint(url: unknown): string | undefined;
|
|
37
|
+
/** A shared graph's endpoint as `origin + pathname`: https, off this machine, no credentials, query or fragment. */
|
|
38
|
+
export declare function normalizeSharedEndpoint(url: unknown): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The local target a library caller (or a p2p from before graph targets) gets: Ix's default
|
|
41
|
+
* backend. Never from the environment (IX_ENDPOINT is exactly what an agent or a Pro login sets):
|
|
42
|
+
* a person's other local port comes from p2p's config.json, through the host's target.
|
|
43
|
+
*/
|
|
44
|
+
export declare function localTarget(_env?: Record<string, string | undefined>): IxTarget;
|
|
45
|
+
/**
|
|
46
|
+
* A target as given, checked again here (a buggy or older host is not trusted with it): a local
|
|
47
|
+
* one must name a loopback endpoint, a shared one an https endpoint off this machine. Anything else
|
|
48
|
+
* is the default local target.
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkedTarget(t: unknown): IxTarget;
|
|
51
|
+
/**
|
|
52
|
+
* What an `ix` child sees of the environment: these names only (case-insensitively, as on
|
|
53
|
+
* Windows). No IX_ENDPOINT, IX_PAT, IX_ORG or any other IX_* cloud or login setting of the caller's
|
|
54
|
+
* (Ix Pro's PAT mode is driven by the environment alone), no P2P_* (the person token), no
|
|
55
|
+
* NODE_OPTIONS, proxies, LD_* or DYLD_*. IX_HOME (where Ix keeps its local state, the workspace
|
|
56
|
+
* registry) and IX_TOKEN (the local backend's token, which Ix sends to a loopback endpoint only)
|
|
57
|
+
* stay.
|
|
58
|
+
*/
|
|
59
|
+
export declare const IX_ENV_ALLOW: readonly string[];
|
|
60
|
+
/**
|
|
61
|
+
* The environment an `ix` call runs with: IX_ENV_ALLOW from `env`, then the target pinned:
|
|
62
|
+
* IX_ENDPOINT is the target's endpoint (Ix reads it before config.yaml's `endpoint`, which Ix Pro
|
|
63
|
+
* rewrites to the cloud cluster on `ix login`); a shared target's token, when it has one, goes as
|
|
64
|
+
* IX_PAT; readers never start a background `ix map` (Ix Pro routes a map to the cloud whenever an
|
|
65
|
+
* org session is active in config.yaml, whatever IX_ENDPOINT says); no update check.
|
|
66
|
+
*/
|
|
67
|
+
export declare function ixEnv(env: Record<string, string | undefined>, target: IxTarget): NodeJS.ProcessEnv;
|
|
68
|
+
/** PATH with its relative and empty entries dropped (they mean the current directory: a repository's own `node`). */
|
|
69
|
+
export declare function absolutePath(v: string, platform?: NodeJS.Platform): string;
|
|
70
|
+
/** What one `ix` call is for its graph target: its argv and the folder it runs in. */
|
|
71
|
+
export interface IxCall {
|
|
72
|
+
argv: readonly string[];
|
|
73
|
+
cwd: string;
|
|
74
|
+
}
|
|
75
|
+
/** Resolves the target of one call. */
|
|
76
|
+
export type TargetFn = (call: IxCall) => Promise<IxTarget>;
|
|
77
|
+
/**
|
|
78
|
+
* The paths an `ix` call names, absolute: the folder it runs in, its positional target (a file, a
|
|
79
|
+
* `file:start-end` range, a directory or a symbol, resolved against the cwd: a symbol only names
|
|
80
|
+
* the cwd's project again), and the values of `--path` and `--root`. Every one's project is
|
|
81
|
+
* intersected into the call's graph target, so a call can't reach past a private project it names.
|
|
82
|
+
*/
|
|
83
|
+
export declare function callPaths(call: IxCall): string[];
|
|
84
|
+
/**
|
|
85
|
+
* The `ix` subcommands ext-ix may run against a local target: reads of the local graph only. Ix
|
|
86
|
+
* Pro's own commands (`ix note` writes and reads Ix-memory in the cloud, whatever IX_ENDPOINT says)
|
|
87
|
+
* and `ix map` (routed to the cloud when an org session is active) are refused, so a private
|
|
88
|
+
* project's content never reaches the cloud through ext-ix. The exceptions are the memory calls
|
|
89
|
+
* (memoryCall): exact forms of `ix note` and `ix session`, allowed against a local target only and
|
|
90
|
+
* only when the `ix` that answers is the OSS one (guardRunner, memorySupport).
|
|
91
|
+
*/
|
|
92
|
+
export declare const LOCAL_IX_COMMANDS: readonly string[];
|
|
93
|
+
/** An Ix note id (`ix note show <id>`): what --ix-note accepts. */
|
|
94
|
+
export declare const IX_NOTE_ID_RE: RegExp;
|
|
95
|
+
/** An Ix session reference (`--session=`): a name or an id. */
|
|
96
|
+
export declare const IX_SESSION_REF_RE: RegExp;
|
|
97
|
+
/** The sessions ext-ix creates: `p2p-` and a session id (or its hash). */
|
|
98
|
+
export declare const IX_SESSION_NAME_RE: RegExp;
|
|
99
|
+
/** `--actor=`: `p2p`, or `p2p:` and a Peer2Peer address. A label on the OSS backend, never an identity. */
|
|
100
|
+
export declare const IX_ACTOR_RE: RegExp;
|
|
101
|
+
/** Longest `--purpose=` ext-ix sends. */
|
|
102
|
+
export declare const MAX_PURPOSE = 200;
|
|
103
|
+
/** Longest session TTL ext-ix asks for, in hours (a year). */
|
|
104
|
+
export declare const MAX_TTL_HOURS = 8760;
|
|
105
|
+
export type MemoryCall = "help" | "note-create" | "note-show" | "session-create" | "session-show";
|
|
106
|
+
/**
|
|
107
|
+
* Which memory call `argv` is, when it is exactly one of the forms ext-ix runs; undefined for
|
|
108
|
+
* anything else (another subcommand, an extra or repeated flag, a positional note text: the text
|
|
109
|
+
* only ever goes on stdin, never into argv where `ps` shows it):
|
|
110
|
+
* ix --help which commands answer (memorySupport)
|
|
111
|
+
* ix note --json show <id> read a note (--ix-note)
|
|
112
|
+
* ix session --json show <ref> is a remembered session still there
|
|
113
|
+
* ix note --tag=<t> [--session=<ref>] [--actor=<a>] --json write a note, text on stdin
|
|
114
|
+
* ix session --json create <p2p-name> --purpose=<p> --actor=<a> --ttl=<h> a session record
|
|
115
|
+
*/
|
|
116
|
+
export declare function memoryCall(argv: readonly string[]): MemoryCall | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Which `ix note` / `ix session` this Ix has, from `ix --help` (the capability, never a trial write):
|
|
119
|
+
* - "oss": the OSS commands against the local backend (Ix after 0.13.0, ix-infrastructure/Ix#916).
|
|
120
|
+
* Ix registers them only when Ix Pro did not load, and lists them in a "Memory:" section of the
|
|
121
|
+
* help only then.
|
|
122
|
+
* - "pro": Ix Pro loaded (its "Pro:" section). Its `ix note` and `ix session` always go to the
|
|
123
|
+
* active cloud org, whatever IX_ENDPOINT says.
|
|
124
|
+
* - "none": neither (an Ix from before #916 without Pro, or not Ix at all).
|
|
125
|
+
* Anything that isn't plainly the first is not it.
|
|
126
|
+
*/
|
|
127
|
+
export type MemorySupport = "oss" | "pro" | "none";
|
|
128
|
+
export declare function parseMemorySupport(help: string): MemorySupport;
|
|
129
|
+
/** Why a memory call can't run with this Ix, for a person: what to do about it. */
|
|
130
|
+
export declare function memoryRefusal(support: Exclude<MemorySupport, "oss">, target: IxTarget): IxExtError;
|
|
131
|
+
/** `ix --help` through `ix`, read as a MemorySupport; "none" when it fails. */
|
|
132
|
+
export declare function memorySupport(ix: IxRunner): Promise<MemorySupport>;
|
|
133
|
+
/** Whether a write's stderr says it went to `endpoint`, the local backend (OSS `ix note`/`ix session` print `→ local backend <origin+path>`). */
|
|
134
|
+
export declare function confirmsLocalWrite(stderr: string, endpoint: string): boolean;
|
|
135
|
+
/** The refusal for a command a target doesn't allow. */
|
|
136
|
+
export declare function refuseForTarget(argv: readonly string[], target: IxTarget): IxExtError | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Wraps a runner so every call is checked against its target first (refuseForTarget). `cwd`: the
|
|
139
|
+
* folder a call runs in when it names none. A memory call (`ix note`, `ix session`) also needs:
|
|
140
|
+
* - the target's port to be held by this user's process only (root's too only with the person's
|
|
141
|
+
* `ixTrustRootListener`, listener.ts), checked before every write and once per guard for a read,
|
|
142
|
+
* else `ix_listener`;
|
|
143
|
+
* - the OSS commands (memorySupport): asked once per guard, and again right before every
|
|
144
|
+
* `ix session create`;
|
|
145
|
+
* - for a write, stderr saying it went to the target's local endpoint, whatever the exit code:
|
|
146
|
+
* else `ix_unconfirmed` (whatever answered was not the OSS command against that backend).
|
|
147
|
+
*/
|
|
148
|
+
export declare function guardRunner(inner: IxRunner, target: TargetFn | (() => Promise<IxTarget>), cwd?: string, opts?: {
|
|
149
|
+
listener?: ListenerCheck;
|
|
150
|
+
}): IxRunner;
|
|
151
|
+
export declare function ixRunner(opts?: {
|
|
152
|
+
env?: Record<string, string | undefined>;
|
|
153
|
+
cwd?: string;
|
|
154
|
+
target?: IxTarget | TargetFn;
|
|
155
|
+
}): IxRunner;
|
|
156
|
+
export declare function ixAvailable(ix: IxRunner): Promise<boolean>;
|
|
157
|
+
/** Runs and parses JSON output; a failure is an IxExtError naming the command. */
|
|
158
|
+
export declare function ixJson(ix: IxRunner, argv: readonly string[]): Promise<unknown>;
|