@miadi/relational-git-repository-mapper 0.0.0-stage → 0.3.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Miadi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
1
+ # @miadi/relational-git-repository-mapper
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A git repository as Miadi sees it: the rows its owner's hub holds, beside the agent
4
+ sessions that worked in it.
5
+
6
+ **"Repository" in this package always means a git repository**: a project such as
7
+ `jgwill/Miadi`, cloned, committed to, pushed. It never means a database repository: not
8
+ the DDD Repository pattern, not a Data Mapper, not a persistence layer. Nothing here
9
+ stores records in a database. The name leaves out GitHub on purpose: today the owners
10
+ and names are GitHub's, and the mapping is meant to hold other git hosts too.
11
+
12
+ Formerly `@miadi/relational-repository-mapper` (0.1.x, deprecated on npm in favour of this
13
+ package). The CLI keeps its name, `miadi-repomap`.
14
+
15
+ - **The rows** come from a repository mapping hub, read with
16
+ [`@medicine-wheel/developer-repository-mapping`](https://www.npmjs.com/package/@medicine-wheel/developer-repository-mapping):
17
+ `<owner>/<owner>/.miadi/repository-mapping/`, and for a meta hub (`jgwill/jgwill`) every hub
18
+ it registers. Lifecycle, purpose, git drift, features, relations.
19
+ - **The sessions** come from the witness team's session inventory, read with
20
+ `@miadi/hooks-interpreter` (`readInventoryRecords`): one record per Claude session.
21
+ - **The join**: a record's `repo` (`owner/name`), case-folded, matched to
22
+ `repository:<owner>/<name>`. Records without a `repo` are counted, not shown.
23
+
24
+ Per session it carries `session_id`, `tmux_session_name`, `status`, the team
25
+ (`team_fit.team.id`, else `team`), `mission`, `date` (as YYYY-MM-DD), the titles of `work_completed`, the
26
+ ending (`disposition.proposed`, `disposition.decided`) and `links.evidence` refs. The
27
+ keeper's descriptions and file lists stay in the record.
28
+
29
+ When no hub is configured, or the hub clone holds no mapping folder yet, every repository
30
+ reads "no mapping yet" and still lists its sessions.
31
+
32
+ ## Lineage: which git repository learned from which
33
+
34
+ A lineage is not a dependency. `learned-from` says that one repository took what another
35
+ explored and carries it on its own, sometimes with another way of knowing, without
36
+ importing it. Dependencies (`consumes`) stay in the owner hubs.
37
+
38
+ ```bash
39
+ miadi-repomap lineage jgwill/medicine-wheel # what did the medicine wheel learn from?
40
+ miadi-repomap lineage # every lineage, the whole forest
41
+ ```
42
+
43
+ The rows this package ships come from William's word in Episode 297
44
+ (screenwalk 2610221013, 10:03–11:21): `jgwill/coaiajs` learned from
45
+ `avadisabelle/coaia-narrative`, and `jgwill/medicine-wheel` learned from both. None
46
+ depends on another. Every row is `pending` until William reads it. A host adds or corrects
47
+ rows with a JSONL file (`--lineage <file>` or `MIADI_REPOSITORY_LINEAGE`), read first: the
48
+ first file to name a pair speaks for it. Each row carries the attribution of
49
+ `@medicine-wheel/capabilities`, a `description` of at most 55 words, and
50
+ `"type": "learned-from"`.
51
+
52
+ In the app: `GET /api/repositories/lineage[?repository=owner/name]`, and the `lineage`
53
+ field of `GET /api/repositories/{owner}/{name}`, shown as a Lineage card on its page.
54
+
55
+ ## Configuration
56
+
57
+ | variable | default | |
58
+ |---|---|---|
59
+ | `MIADI_REPOSITORY_MAPPING_HUB` | none | a hub clone (`…/jgwill/jgwill`) or its mapping folder |
60
+ | `MIADI_SESSION_INVENTORY_DIR` | `~/workspace/.mino/session-inventory` | the inventory records |
61
+ | `MIADI_REPOSITORY_LINEAGE` | none | a lineage JSONL read before the shipped rows |
62
+
63
+ ## CLI
64
+
65
+ ```bash
66
+ miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
67
+ miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
68
+ miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
69
+ ```
70
+
71
+ Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage, 2 usage error.
72
+
73
+ ## Library
74
+
75
+ ```ts
76
+ import { repositoryListing, repositoryDetail, sessionsByRepository, repositoryView } from "@miadi/relational-git-repository-mapper"
77
+ ```
78
+
79
+ `sessionsByRepository`, `repositoryView` and `listRepositories` are pure;
80
+ `repositoryListing` and `repositoryDetail` read the hub and the inventory.
81
+
82
+ In the Miadi app: `GET /api/repositories`, `GET /api/repositories/{owner}/{name}` (write
83
+ access, as session missions are), and the pages `/repositories` and
84
+ `/repositories/{owner}/{name}`.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // miadi-repomap — a repository's mapping rows beside the sessions that worked in it.
4
+ //
5
+ // miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
6
+ // miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]
7
+ // miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]
8
+ //
9
+ // `lineage <owner/name>` answers "what did this repository learn from", and
10
+ // who learned from it; with no repository it prints every lineage. A lineage
11
+ // is not a dependency: `learned-from` names what a repository took from
12
+ // another that it carries on its own. --lineage adds a host's JSONL before
13
+ // the rows this package ships (default MIADI_REPOSITORY_LINEAGE).
14
+ // --hub defaults to MIADI_REPOSITORY_MAPPING_HUB (a jgwill/jgwill clone, or a
15
+ // mapping folder); --inventory to MIADI_SESSION_INVENTORY_DIR, else
16
+ // ~/workspace/.mino/session-inventory. Read-only.
17
+ //
18
+ // Exit codes: 0 done, 1 `show`: the repository is in no hub, no record and no lineage, 2 usage error.
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const read_1 = require("./read");
21
+ const USAGE = [
22
+ "usage: miadi-repomap list [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
23
+ " miadi-repomap show <owner/name> [--hub <path>] [--inventory <dir>] [--lineage <file>] [--json]",
24
+ " miadi-repomap lineage [<owner/name>] [--lineage <file>] [--json]",
25
+ ].join("\n");
26
+ const FLAGS = {
27
+ list: ["hub", "inventory", "lineage", "json"],
28
+ show: ["hub", "inventory", "lineage", "json"],
29
+ lineage: ["lineage", "json"],
30
+ };
31
+ class UsageError extends Error {
32
+ }
33
+ function parse(argv) {
34
+ const positional = [];
35
+ const flags = {};
36
+ for (let i = 0; i < argv.length; i++) {
37
+ const arg = argv[i];
38
+ if (!arg.startsWith("--")) {
39
+ positional.push(arg);
40
+ continue;
41
+ }
42
+ const key = arg.slice(2);
43
+ if (key === "json" || key === "help") {
44
+ flags[key] = true;
45
+ continue;
46
+ }
47
+ const value = argv[++i];
48
+ if (value === undefined || value.startsWith("--") || !value.trim())
49
+ throw new UsageError(`--${key} needs a value`);
50
+ flags[key] = value;
51
+ }
52
+ const allowed = FLAGS[positional[0]];
53
+ const unknown = allowed ? Object.keys(flags).filter((k) => !allowed.includes(k)) : [];
54
+ if (unknown.length)
55
+ throw new UsageError(`${positional[0]} does not take ${unknown.map((k) => `--${k}`).join(", ")}`);
56
+ return { positional, flags };
57
+ }
58
+ const value = (flags, key) => (typeof flags[key] === "string" ? flags[key] : undefined);
59
+ function hubLine(hub) {
60
+ switch (hub.state) {
61
+ case "no-hub":
62
+ return "no mapping yet: no hub configured (MIADI_REPOSITORY_MAPPING_HUB)";
63
+ case "no-mapping-yet":
64
+ return `no mapping yet: ${hub.path} holds no .miadi/repository-mapping/`;
65
+ case "unreadable":
66
+ return `the mapping at ${hub.path} does not read (${hub.errors} errors)`;
67
+ case "read":
68
+ return `mapping read from ${hub.hubs.length} hub(s): ${hub.errors} errors, ${hub.warnings} warnings`;
69
+ }
70
+ }
71
+ const short = (id) => id.replace(/^repository:/, "");
72
+ function linkLines(links) {
73
+ return links.map((l) => ` ${short(l.repository)}${l.description ? ` — ${l.description}` : ""} [${l.revision}]`);
74
+ }
75
+ function sessionLine(s) {
76
+ const ending = s.disposition ? ` ending ${s.disposition.decided ?? `${s.disposition.proposed} (proposed)`}` : "";
77
+ return ` ${s.date ?? "?"} ${(s.tmux_session_name ?? s.session_id).padEnd(36)} ${(s.team ?? "-").padEnd(10)} ${s.status ?? "-"}${ending} ${s.session_id}`;
78
+ }
79
+ async function main() {
80
+ const { positional, flags } = parse(process.argv.slice(2));
81
+ const command = positional[0];
82
+ if (command === "help" || (!command && flags.help)) {
83
+ console.log(USAGE);
84
+ return 0;
85
+ }
86
+ const options = { hub: value(flags, "hub"), inventory: value(flags, "inventory"), lineage: value(flags, "lineage") };
87
+ if (command === "lineage") {
88
+ const answer = (0, read_1.repositoryLineage)(positional[1], { lineage: options.lineage });
89
+ for (const i of answer.issues)
90
+ console.error(`${i.severity} ${i.file ?? ""}${i.line ? `:${i.line}` : ""} — ${i.message}`);
91
+ if (flags.json) {
92
+ console.log(JSON.stringify(answer, null, 2));
93
+ return 0;
94
+ }
95
+ if (answer.graph) {
96
+ for (const e of answer.graph.edges)
97
+ console.log(`${short(e.from)} learned from ${short(e.to)}${e.description ? ` — ${e.description}` : ""}`);
98
+ console.error(`${answer.graph.edges.length} lineages among ${answer.graph.nodes.length} repositories, read from ${answer.from.join(", ")}`);
99
+ return 0;
100
+ }
101
+ const l = answer.lineage;
102
+ const lines = [
103
+ `${short(answer.repository)} learned from (${l.learned_from.length}):`,
104
+ ...(l.learned_from.length ? linkLines(l.learned_from) : [" no lineage recorded"]),
105
+ `${short(answer.repository)} taught (${l.taught.length}):`,
106
+ ...(l.taught.length ? linkLines(l.taught) : [" no lineage recorded"]),
107
+ ];
108
+ console.log(lines.join("\n"));
109
+ return 0;
110
+ }
111
+ if (command === "list") {
112
+ const listing = await (0, read_1.repositoryListing)(options);
113
+ if (flags.json) {
114
+ console.log(JSON.stringify(listing, null, 2));
115
+ return 0;
116
+ }
117
+ console.error(hubLine(listing.hub));
118
+ for (const r of listing.repositories) {
119
+ const state = r.mapped ? `${r.lifecycle} · ${r.drift}` : "no mapping yet";
120
+ console.log(`${`${r.owner}/${r.name}`.padEnd(48)} ${String(r.sessions).padStart(4)} sessions ${(r.last_session ?? "").padEnd(10)} ${state.padEnd(24)} ${r.teams.join(",") || "-"}`);
121
+ }
122
+ console.error(`${listing.repositories.length} repositories; ${listing.inventory.records} records read from ${listing.inventory.from}, ${listing.inventory.without_repo} without a repo`);
123
+ return 0;
124
+ }
125
+ if (command === "show") {
126
+ if (!positional[1])
127
+ throw new UsageError("show needs a repository: owner/name");
128
+ const detail = await (0, read_1.repositoryDetail)(positional[1], options);
129
+ if (flags.json) {
130
+ console.log(JSON.stringify(detail, null, 2));
131
+ return detail.repository ? 0 : 1;
132
+ }
133
+ const r = detail.repository;
134
+ if (!r) {
135
+ console.error(`miadi-repomap: ${positional[1]} is in no hub and no inventory record`);
136
+ return 1;
137
+ }
138
+ const lines = [
139
+ `${r.owner}/${r.name} ${r.url}`,
140
+ r.repository
141
+ ? ` ${r.repository.lifecycle} · ${r.repository.origin} · ${r.repository.revision}${r.source ? ` · from ${r.source}` : ""}`
142
+ : ` ${hubLine(detail.hub)}`,
143
+ r.reading ? ` git: ${r.reading.reason} (${r.reading.drift})` : "",
144
+ r.repository?.purpose ? ` purpose: ${r.repository.purpose}` : "",
145
+ r.features.length ? ` features (${r.features.length}):` : "",
146
+ ...r.features.map((f) => ` ${f.nodeId} [${f.status}]${f.statement ? ` ${f.statement}` : ""}`),
147
+ r.relations.length ? ` relations (${r.relations.length}):` : "",
148
+ ...r.relations.map((x) => ` ${x.from} ${x.type} ${x.to}`),
149
+ r.lineage.learned_from.length ? ` learned from (${r.lineage.learned_from.length}):` : "",
150
+ ...linkLines(r.lineage.learned_from),
151
+ r.lineage.taught.length ? ` taught (${r.lineage.taught.length}):` : "",
152
+ ...linkLines(r.lineage.taught),
153
+ ` sessions (${r.sessions.length}):`,
154
+ ...r.sessions.map(sessionLine),
155
+ ];
156
+ console.log(lines.filter(Boolean).join("\n"));
157
+ return 0;
158
+ }
159
+ if (!command)
160
+ throw new UsageError("a command is needed");
161
+ throw new UsageError(`unknown command: ${command}`);
162
+ }
163
+ main().then((code) => {
164
+ process.exitCode = code;
165
+ }, (error) => {
166
+ console.error(`miadi-repomap: ${error.message}`);
167
+ if (error instanceof UsageError) {
168
+ console.error(USAGE);
169
+ process.exitCode = 2;
170
+ return;
171
+ }
172
+ process.exitCode = 1;
173
+ });
@@ -0,0 +1,5 @@
1
+ export type { RepositorySession, MappingState, HubState, RepositoryView, RepositorySummary, InventoryState, RepositoryListing, } from "./types";
2
+ export { dayOf, teamOf, dispositionOf, sessionOf, repositoryKey, sessionsByRepository, repositoryView, listRepositories, type SessionsByRepository, } from "./join";
3
+ export { LineageRowSchema, parseLineage, lineageOf, lineageGraph, type LineageRow, type LineageEdge, type LineageLink, type RepositoryLineage, type LineageGraph, } from "./lineage";
4
+ export { SHIPPED_LINEAGE_JSONL, SHIPPED_LINEAGE_SOURCE } from "./shipped-lineage";
5
+ export { inventoryDir, hubPath, readHubState, readMapper, repositoryListing, repositoryDetail, readLineage, repositoryLineage, type ReadOptions, type MapperRead, type LineageRead, type LineageAnswer, } from "./read";
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // @miadi/relational-git-repository-mapper — a git repository as Miadi sees it:
3
+ // the rows its owner hub holds beside the agent sessions that worked in it.
4
+ // "Repository" here is always a git repository, never the DDD Repository or a
5
+ // Data Mapper. Formerly @miadi/relational-repository-mapper (deprecated).
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.repositoryLineage = exports.readLineage = exports.repositoryDetail = exports.repositoryListing = exports.readMapper = exports.readHubState = exports.hubPath = exports.inventoryDir = exports.SHIPPED_LINEAGE_SOURCE = exports.SHIPPED_LINEAGE_JSONL = exports.lineageGraph = exports.lineageOf = exports.parseLineage = exports.LineageRowSchema = exports.listRepositories = exports.repositoryView = exports.sessionsByRepository = exports.repositoryKey = exports.sessionOf = exports.dispositionOf = exports.teamOf = exports.dayOf = void 0;
8
+ var join_1 = require("./join");
9
+ Object.defineProperty(exports, "dayOf", { enumerable: true, get: function () { return join_1.dayOf; } });
10
+ Object.defineProperty(exports, "teamOf", { enumerable: true, get: function () { return join_1.teamOf; } });
11
+ Object.defineProperty(exports, "dispositionOf", { enumerable: true, get: function () { return join_1.dispositionOf; } });
12
+ Object.defineProperty(exports, "sessionOf", { enumerable: true, get: function () { return join_1.sessionOf; } });
13
+ Object.defineProperty(exports, "repositoryKey", { enumerable: true, get: function () { return join_1.repositoryKey; } });
14
+ Object.defineProperty(exports, "sessionsByRepository", { enumerable: true, get: function () { return join_1.sessionsByRepository; } });
15
+ Object.defineProperty(exports, "repositoryView", { enumerable: true, get: function () { return join_1.repositoryView; } });
16
+ Object.defineProperty(exports, "listRepositories", { enumerable: true, get: function () { return join_1.listRepositories; } });
17
+ var lineage_1 = require("./lineage");
18
+ Object.defineProperty(exports, "LineageRowSchema", { enumerable: true, get: function () { return lineage_1.LineageRowSchema; } });
19
+ Object.defineProperty(exports, "parseLineage", { enumerable: true, get: function () { return lineage_1.parseLineage; } });
20
+ Object.defineProperty(exports, "lineageOf", { enumerable: true, get: function () { return lineage_1.lineageOf; } });
21
+ Object.defineProperty(exports, "lineageGraph", { enumerable: true, get: function () { return lineage_1.lineageGraph; } });
22
+ var shipped_lineage_1 = require("./shipped-lineage");
23
+ Object.defineProperty(exports, "SHIPPED_LINEAGE_JSONL", { enumerable: true, get: function () { return shipped_lineage_1.SHIPPED_LINEAGE_JSONL; } });
24
+ Object.defineProperty(exports, "SHIPPED_LINEAGE_SOURCE", { enumerable: true, get: function () { return shipped_lineage_1.SHIPPED_LINEAGE_SOURCE; } });
25
+ var read_1 = require("./read");
26
+ Object.defineProperty(exports, "inventoryDir", { enumerable: true, get: function () { return read_1.inventoryDir; } });
27
+ Object.defineProperty(exports, "hubPath", { enumerable: true, get: function () { return read_1.hubPath; } });
28
+ Object.defineProperty(exports, "readHubState", { enumerable: true, get: function () { return read_1.readHubState; } });
29
+ Object.defineProperty(exports, "readMapper", { enumerable: true, get: function () { return read_1.readMapper; } });
30
+ Object.defineProperty(exports, "repositoryListing", { enumerable: true, get: function () { return read_1.repositoryListing; } });
31
+ Object.defineProperty(exports, "repositoryDetail", { enumerable: true, get: function () { return read_1.repositoryDetail; } });
32
+ Object.defineProperty(exports, "readLineage", { enumerable: true, get: function () { return read_1.readLineage; } });
33
+ Object.defineProperty(exports, "repositoryLineage", { enumerable: true, get: function () { return read_1.repositoryLineage; } });
package/dist/join.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { type RepositoryMapping } from "@medicine-wheel/developer-repository-mapping";
2
+ import type { InventorySnapshot } from "@miadi/hooks-interpreter";
3
+ import { type LineageEdge } from "./lineage";
4
+ import type { RepositorySession, RepositorySummary, RepositoryView } from "./types";
5
+ /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
6
+ export declare function dayOf(date: string | undefined): string | undefined;
7
+ /** `team_fit.team.id` first: it is measured at inventory time and includes a team set later. Then `team`. */
8
+ export declare function teamOf(snapshot: InventorySnapshot): string | undefined;
9
+ export declare function dispositionOf(snapshot: InventorySnapshot): RepositorySession["disposition"];
10
+ export declare function sessionOf(sessionId: string, snapshot: InventorySnapshot): RepositorySession;
11
+ /** `owner/name`, case-folded, of a record's `repo`, or undefined when it names no repository. */
12
+ export declare function repositoryKey(repo: string | undefined): string | undefined;
13
+ export interface SessionsByRepository {
14
+ /** case-folded owner/name → its sessions, newest first */
15
+ sessions: Map<string, RepositorySession[]>;
16
+ /** case-folded owner/name → the repo as the first record (newest) wrote it */
17
+ spelled: Map<string, string>;
18
+ records: number;
19
+ withoutRepo: number;
20
+ }
21
+ export declare function sessionsByRepository(records: ReadonlyMap<string, InventorySnapshot>): SessionsByRepository;
22
+ /**
23
+ * One repository: its rows when a hub holds them, its sessions, and its
24
+ * lineage. Undefined when no hub, no record and no lineage names it.
25
+ */
26
+ export declare function repositoryView(repository: string, mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, sources?: Record<string, string>, lineageEdges?: readonly LineageEdge[]): RepositoryView | undefined;
27
+ /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
28
+ export declare function listRepositories(mapping: RepositoryMapping | undefined, bySessions: SessionsByRepository, lineageEdges?: readonly LineageEdge[]): RepositorySummary[];
package/dist/join.js ADDED
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ // The join, pure: inventory records grouped by the repository they name, and a
3
+ // repository's mapping rows beside its sessions. The key is the record's
4
+ // `repo` (owner/name), case-folded, matched to repository:<owner>/<name>:
5
+ // GitHub names are case-insensitive, and records write them as they found them.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.dayOf = dayOf;
8
+ exports.teamOf = teamOf;
9
+ exports.dispositionOf = dispositionOf;
10
+ exports.sessionOf = sessionOf;
11
+ exports.repositoryKey = repositoryKey;
12
+ exports.sessionsByRepository = sessionsByRepository;
13
+ exports.repositoryView = repositoryView;
14
+ exports.listRepositories = listRepositories;
15
+ const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
16
+ const lineage_1 = require("./lineage");
17
+ const text = (value) => (typeof value === "string" && value.trim() ? value : undefined);
18
+ /** A record's `date` as YYYY-MM-DD: older records write a full timestamp, newer ones the day. */
19
+ function dayOf(date) {
20
+ const m = date ? /^(\d{4}-\d{2}-\d{2})/.exec(date.trim()) : null;
21
+ return m ? m[1] : undefined;
22
+ }
23
+ /** `team_fit.team.id` first: it is measured at inventory time and includes a team set later. Then `team`. */
24
+ function teamOf(snapshot) {
25
+ const fit = snapshot.team_fit;
26
+ return text(fit?.team?.id) ?? snapshot.team;
27
+ }
28
+ function dispositionOf(snapshot) {
29
+ const d = snapshot.disposition;
30
+ const proposed = text(d?.proposed);
31
+ const decided = text(d?.decided);
32
+ return proposed || decided ? { ...(proposed ? { proposed } : {}), ...(decided ? { decided } : {}) } : undefined;
33
+ }
34
+ function sessionOf(sessionId, snapshot) {
35
+ const team = teamOf(snapshot);
36
+ const disposition = dispositionOf(snapshot);
37
+ const date = dayOf(snapshot.date);
38
+ return {
39
+ session_id: sessionId,
40
+ ...(snapshot.tmux_session_name ? { tmux_session_name: snapshot.tmux_session_name } : {}),
41
+ ...(snapshot.status ? { status: snapshot.status } : {}),
42
+ ...(team ? { team } : {}),
43
+ ...(snapshot.mission ? { mission: snapshot.mission } : {}),
44
+ ...(date ? { date } : {}),
45
+ work_completed: (snapshot.work_completed ?? []).map((item) => item.title),
46
+ ...(disposition ? { disposition } : {}),
47
+ ...(snapshot.evidence?.length ? { evidence: snapshot.evidence } : {}),
48
+ modified_at: snapshot.modified_at,
49
+ };
50
+ }
51
+ /** `owner/name`, case-folded, of a record's `repo`, or undefined when it names no repository. */
52
+ function repositoryKey(repo) {
53
+ const id = repo ? (0, developer_repository_mapping_1.toRepositoryNodeId)(repo.trim().replace(/\.git$/, "")) : undefined;
54
+ return id ? id.slice("repository:".length).toLowerCase() : undefined;
55
+ }
56
+ const newestFirst = (a, b) => (b.date ?? "").localeCompare(a.date ?? "") || b.modified_at.localeCompare(a.modified_at);
57
+ function sessionsByRepository(records) {
58
+ const sessions = new Map();
59
+ const spelled = new Map();
60
+ let withoutRepo = 0;
61
+ for (const [id, snapshot] of records) {
62
+ const key = repositoryKey(snapshot.repo);
63
+ if (!key) {
64
+ withoutRepo += 1;
65
+ continue;
66
+ }
67
+ const list = sessions.get(key) ?? [];
68
+ list.push(sessionOf(id, snapshot));
69
+ sessions.set(key, list);
70
+ if (!spelled.has(key))
71
+ spelled.set(key, snapshot.repo.trim().replace(/\.git$/, ""));
72
+ }
73
+ for (const list of sessions.values())
74
+ list.sort(newestFirst);
75
+ return { sessions, spelled, records: records.size, withoutRepo };
76
+ }
77
+ const keyOfNode = (nodeId) => nodeId.slice("repository:".length).toLowerCase();
78
+ /**
79
+ * One repository: its rows when a hub holds them, its sessions, and its
80
+ * lineage. Undefined when no hub, no record and no lineage names it.
81
+ */
82
+ function repositoryView(repository, mapping, bySessions, sources = {}, lineageEdges = []) {
83
+ const key = repositoryKey(repository);
84
+ if (!key)
85
+ return undefined;
86
+ const row = mapping?.repositories.find((r) => keyOfNode(r.nodeId) === key);
87
+ const sessions = bySessions.sessions.get(key) ?? [];
88
+ const lineage = (0, lineage_1.lineageOf)(key, lineageEdges);
89
+ const named = lineageEdges.flatMap((e) => [e.from, e.to]).find((id) => keyOfNode(id) === key);
90
+ if (!row && !sessions.length && !named)
91
+ return undefined;
92
+ const nodeId = row?.nodeId ?? named ?? `repository:${bySessions.spelled.get(key) ?? key}`;
93
+ const { owner, name } = (0, developer_repository_mapping_1.parseRepositoryNodeId)(nodeId);
94
+ return {
95
+ nodeId,
96
+ owner,
97
+ name,
98
+ url: (0, developer_repository_mapping_1.repositoryUrl)(nodeId),
99
+ mapped: Boolean(row),
100
+ ...(row ? { repository: row, reading: (0, developer_repository_mapping_1.reconcileLifecycle)(row) } : {}),
101
+ ...(row && sources[row.nodeId] ? { source: sources[row.nodeId] } : {}),
102
+ features: row ? mapping.features.filter((f) => f.repository === row.nodeId) : [],
103
+ relations: row ? mapping.relations.filter((r) => r.from === row.nodeId || r.to === row.nodeId) : [],
104
+ sessions,
105
+ lineage,
106
+ };
107
+ }
108
+ /** Every repository a hub holds, a record names or a lineage names, most sessions first. */
109
+ function listRepositories(mapping, bySessions, lineageEdges = []) {
110
+ const keys = new Set([
111
+ ...bySessions.sessions.keys(),
112
+ ...(mapping?.repositories ?? []).map((r) => keyOfNode(r.nodeId)),
113
+ ...lineageEdges.flatMap((e) => [keyOfNode(e.from), keyOfNode(e.to)]),
114
+ ]);
115
+ return [...keys]
116
+ .map((key) => {
117
+ const view = repositoryView(key, mapping, bySessions, {}, lineageEdges);
118
+ const teams = [...new Set(view.sessions.flatMap((s) => (s.team ? [s.team] : [])))].sort();
119
+ return {
120
+ nodeId: view.nodeId,
121
+ owner: view.owner,
122
+ name: view.name,
123
+ mapped: view.mapped,
124
+ ...(view.repository ? { lifecycle: view.repository.lifecycle } : {}),
125
+ ...(view.reading ? { drift: view.reading.drift } : {}),
126
+ sessions: view.sessions.length,
127
+ ...(view.sessions[0]?.date ? { last_session: view.sessions[0].date } : {}),
128
+ teams,
129
+ };
130
+ })
131
+ .sort((a, b) => b.sessions - a.sessions || a.nodeId.toLowerCase().localeCompare(b.nodeId.toLowerCase()));
132
+ }
@@ -0,0 +1,105 @@
1
+ import { z } from "zod";
2
+ import { type MappingIssue } from "@medicine-wheel/developer-repository-mapping";
3
+ export declare const LineageRowSchema: z.ZodEffects<z.ZodObject<{
4
+ statedBy: z.ZodString;
5
+ statedAt: z.ZodString;
6
+ grounding: z.ZodArray<z.ZodString, "many">;
7
+ revision: z.ZodEnum<["pending", "revised", "affirmed"]>;
8
+ revisedBy: z.ZodOptional<z.ZodString>;
9
+ revisedAt: z.ZodOptional<z.ZodString>;
10
+ /** the repository that learned */
11
+ from: z.ZodString;
12
+ /** the repository it learned from */
13
+ to: z.ZodString;
14
+ type: z.ZodLiteral<"learned-from">;
15
+ /** what was learned, at most 55 words */
16
+ description: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
17
+ }, "strict", z.ZodTypeAny, {
18
+ from: string;
19
+ to: string;
20
+ type: "learned-from";
21
+ statedBy: string;
22
+ statedAt: string;
23
+ grounding: string[];
24
+ revision: "pending" | "revised" | "affirmed";
25
+ description?: string | undefined;
26
+ revisedBy?: string | undefined;
27
+ revisedAt?: string | undefined;
28
+ }, {
29
+ from: string;
30
+ to: string;
31
+ type: "learned-from";
32
+ statedBy: string;
33
+ statedAt: string;
34
+ grounding: string[];
35
+ revision: "pending" | "revised" | "affirmed";
36
+ description?: string | undefined;
37
+ revisedBy?: string | undefined;
38
+ revisedAt?: string | undefined;
39
+ }>, {
40
+ from: string;
41
+ to: string;
42
+ type: "learned-from";
43
+ statedBy: string;
44
+ statedAt: string;
45
+ grounding: string[];
46
+ revision: "pending" | "revised" | "affirmed";
47
+ description?: string | undefined;
48
+ revisedBy?: string | undefined;
49
+ revisedAt?: string | undefined;
50
+ }, {
51
+ from: string;
52
+ to: string;
53
+ type: "learned-from";
54
+ statedBy: string;
55
+ statedAt: string;
56
+ grounding: string[];
57
+ revision: "pending" | "revised" | "affirmed";
58
+ description?: string | undefined;
59
+ revisedBy?: string | undefined;
60
+ revisedAt?: string | undefined;
61
+ }>;
62
+ /** One `learned-from` row: `from` learned from `to`. */
63
+ export type LineageRow = z.infer<typeof LineageRowSchema>;
64
+ /** A lineage row and the file it was read from. */
65
+ export interface LineageEdge extends LineageRow {
66
+ source: string;
67
+ }
68
+ /** One end of a lineage, seen from a repository. */
69
+ export interface LineageLink {
70
+ /** the other repository */
71
+ repository: string;
72
+ description?: string;
73
+ statedBy: string;
74
+ statedAt: string;
75
+ grounding: string[];
76
+ revision: LineageRow["revision"];
77
+ source: string;
78
+ }
79
+ export interface RepositoryLineage {
80
+ /** what this repository learned from */
81
+ learned_from: LineageLink[];
82
+ /** the repositories that learned from this one */
83
+ taught: LineageLink[];
84
+ }
85
+ export interface LineageGraph {
86
+ /** every repository a lineage names, sorted */
87
+ nodes: string[];
88
+ edges: LineageEdge[];
89
+ }
90
+ /**
91
+ * Lineage rows from several JSONL texts, in precedence order: the first text
92
+ * that names a pair speaks for it, and a later row on the same pair is
93
+ * reported and skipped. Never throws.
94
+ */
95
+ export declare function parseLineage(texts: readonly {
96
+ text: string;
97
+ source: string;
98
+ }[]): {
99
+ edges: LineageEdge[];
100
+ issues: MappingIssue[];
101
+ };
102
+ /** What a repository learned from, and who learned from it. Matched case-folded. */
103
+ export declare function lineageOf(repository: string, edges: readonly LineageEdge[]): RepositoryLineage;
104
+ /** The whole forest: every repository a lineage names, and every edge. */
105
+ export declare function lineageGraph(edges: readonly LineageEdge[]): LineageGraph;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // Lineage, pure: which git repository learned from which.
3
+ //
4
+ // A lineage is not a dependency. A repository that learned from another
5
+ // may import nothing from it: it took what the other explored and carries it
6
+ // on its own, sometimes with another way of knowing. A dependency is
7
+ // `consumes` in an owner hub's relations; a lineage is `learned-from`, here.
8
+ // William, screenwalk 2610221013 (Episode 297, V5 and V6): a forest of trees
9
+ // that grew independently of each other, influenced into their relationship,
10
+ // as a graph a model can navigate.
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LineageRowSchema = void 0;
13
+ exports.parseLineage = parseLineage;
14
+ exports.lineageOf = lineageOf;
15
+ exports.lineageGraph = lineageGraph;
16
+ const zod_1 = require("zod");
17
+ const capabilities_1 = require("@medicine-wheel/capabilities");
18
+ const developer_repository_mapping_1 = require("@medicine-wheel/developer-repository-mapping");
19
+ exports.LineageRowSchema = zod_1.z
20
+ .object({
21
+ /** the repository that learned */
22
+ from: developer_repository_mapping_1.RepositoryNodeIdSchema,
23
+ /** the repository it learned from */
24
+ to: developer_repository_mapping_1.RepositoryNodeIdSchema,
25
+ type: zod_1.z.literal("learned-from"),
26
+ /** what was learned, at most 55 words */
27
+ description: capabilities_1.StatementSchema.optional(),
28
+ ...capabilities_1.attributionShape,
29
+ })
30
+ .strict()
31
+ .superRefine((row, ctx) => {
32
+ (0, capabilities_1.refineAttribution)(row, ctx);
33
+ if (row.from.toLowerCase() === row.to.toLowerCase()) {
34
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ["to"], message: "a repository does not learn from itself" });
35
+ }
36
+ });
37
+ const fold = (id) => id.toLowerCase();
38
+ const edgeKey = (row) => `${fold(row.from)} ${fold(row.to)}`;
39
+ /**
40
+ * Lineage rows from several JSONL texts, in precedence order: the first text
41
+ * that names a pair speaks for it, and a later row on the same pair is
42
+ * reported and skipped. Never throws.
43
+ */
44
+ function parseLineage(texts) {
45
+ const edges = [];
46
+ const issues = [];
47
+ const seen = new Map();
48
+ for (const { text, source } of texts) {
49
+ const parsed = (0, developer_repository_mapping_1.parseJsonl)(text, exports.LineageRowSchema, source);
50
+ issues.push(...parsed.issues);
51
+ for (const row of parsed.rows) {
52
+ const key = edgeKey(row);
53
+ const earlier = seen.get(key);
54
+ if (earlier) {
55
+ issues.push({ severity: "warning", file: source, nodeId: row.from, message: `${row.from} learned-from ${row.to} is already read from ${earlier}; skipped` });
56
+ continue;
57
+ }
58
+ seen.set(key, source);
59
+ edges.push({ ...row, source });
60
+ }
61
+ }
62
+ return { edges, issues };
63
+ }
64
+ const linkOf = (edge, repository) => ({
65
+ repository,
66
+ ...(edge.description ? { description: edge.description } : {}),
67
+ statedBy: edge.statedBy,
68
+ statedAt: edge.statedAt,
69
+ grounding: edge.grounding,
70
+ revision: edge.revision,
71
+ source: edge.source,
72
+ });
73
+ /** What a repository learned from, and who learned from it. Matched case-folded. */
74
+ function lineageOf(repository, edges) {
75
+ const id = fold(repository.startsWith("repository:") ? repository : `repository:${repository}`);
76
+ const byRepository = (a, b) => a.repository.toLowerCase().localeCompare(b.repository.toLowerCase());
77
+ return {
78
+ learned_from: edges.filter((e) => fold(e.from) === id).map((e) => linkOf(e, e.to)).sort(byRepository),
79
+ taught: edges.filter((e) => fold(e.to) === id).map((e) => linkOf(e, e.from)).sort(byRepository),
80
+ };
81
+ }
82
+ /** The whole forest: every repository a lineage names, and every edge. */
83
+ function lineageGraph(edges) {
84
+ const nodes = new Map();
85
+ for (const e of edges) {
86
+ for (const id of [e.from, e.to])
87
+ if (!nodes.has(fold(id)))
88
+ nodes.set(fold(id), id);
89
+ }
90
+ return {
91
+ nodes: [...nodes.values()].sort((a, b) => fold(a).localeCompare(fold(b))),
92
+ edges: [...edges],
93
+ };
94
+ }
package/dist/read.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import type { MappingIssue, MergedMapping } from "@medicine-wheel/developer-repository-mapping";
2
+ import { type SessionsByRepository } from "./join";
3
+ import { type LineageEdge, type LineageGraph, type RepositoryLineage } from "./lineage";
4
+ import type { HubState, InventoryState, RepositoryListing, RepositoryView } from "./types";
5
+ type Env = Record<string, string | undefined>;
6
+ /** The witness team's inventory: `MIADI_SESSION_INVENTORY_DIR`, else `~/workspace/.mino/session-inventory`. */
7
+ export declare function inventoryDir(env?: Env): string;
8
+ /** The hub to read: `MIADI_REPOSITORY_MAPPING_HUB`, a hub clone or its mapping folder. Unset means none. */
9
+ export declare function hubPath(env?: Env): string | undefined;
10
+ export interface ReadOptions {
11
+ /** hub clone or mapping folder; default {@link hubPath} */
12
+ hub?: string;
13
+ /** inventory directory; default {@link inventoryDir} */
14
+ inventory?: string;
15
+ /** a lineage JSONL read before the shipped one; default `MIADI_REPOSITORY_LINEAGE` */
16
+ lineage?: string;
17
+ }
18
+ export interface LineageRead {
19
+ /** the files read, in precedence order */
20
+ from: string[];
21
+ edges: LineageEdge[];
22
+ issues: MappingIssue[];
23
+ }
24
+ /**
25
+ * The lineage: a host's own file first (`--lineage` or
26
+ * `MIADI_REPOSITORY_LINEAGE`), then the rows this package ships. The first
27
+ * to name a pair speaks for it. A file that cannot be read is reported.
28
+ */
29
+ export declare function readLineage(path?: string | undefined): LineageRead;
30
+ export declare function readHubState(path: string | undefined): Promise<{
31
+ hub: HubState;
32
+ mapping?: MergedMapping;
33
+ }>;
34
+ export interface MapperRead {
35
+ hub: HubState;
36
+ mapping?: MergedMapping;
37
+ inventory: InventoryState;
38
+ sessions: SessionsByRepository;
39
+ lineage: LineageRead;
40
+ }
41
+ export declare function readMapper(options?: ReadOptions): Promise<MapperRead>;
42
+ export declare function repositoryListing(options?: ReadOptions): Promise<RepositoryListing>;
43
+ export declare function repositoryDetail(repository: string, options?: ReadOptions): Promise<{
44
+ hub: HubState;
45
+ inventory: InventoryState;
46
+ repository?: RepositoryView;
47
+ }>;
48
+ export interface LineageAnswer {
49
+ /** the files the lineage was read from, in precedence order */
50
+ from: string[];
51
+ issues: MappingIssue[];
52
+ /** with a repository: what it learned from and who learned from it */
53
+ repository?: string;
54
+ lineage?: RepositoryLineage;
55
+ /** without one: the whole forest */
56
+ graph?: LineageGraph;
57
+ }
58
+ /** "What did this repository learn from?", or with no repository, every lineage. Reads no hub and no inventory. */
59
+ export declare function repositoryLineage(repository?: string, options?: Pick<ReadOptions, "lineage">): LineageAnswer;
60
+ export {};
package/dist/read.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ // Reading, on Node: the hub (a jgwill/jgwill clone, whose meta mapping reads
3
+ // the hubs it registers) and the session inventory. Read-only; nothing here
4
+ // writes a mapping or a record.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.inventoryDir = inventoryDir;
7
+ exports.hubPath = hubPath;
8
+ exports.readLineage = readLineage;
9
+ exports.readHubState = readHubState;
10
+ exports.readMapper = readMapper;
11
+ exports.repositoryListing = repositoryListing;
12
+ exports.repositoryDetail = repositoryDetail;
13
+ exports.repositoryLineage = repositoryLineage;
14
+ const node_fs_1 = require("node:fs");
15
+ const shipped_lineage_1 = require("./shipped-lineage");
16
+ const node_os_1 = require("node:os");
17
+ const node_path_1 = require("node:path");
18
+ const node_1 = require("@medicine-wheel/developer-repository-mapping/node");
19
+ const hooks_interpreter_1 = require("@miadi/hooks-interpreter");
20
+ const join_1 = require("./join");
21
+ const lineage_1 = require("./lineage");
22
+ /** The witness team's inventory: `MIADI_SESSION_INVENTORY_DIR`, else `~/workspace/.mino/session-inventory`. */
23
+ function inventoryDir(env = process.env) {
24
+ return env.MIADI_SESSION_INVENTORY_DIR?.trim() || (0, node_path_1.join)((0, node_os_1.homedir)(), "workspace", ".mino", "session-inventory");
25
+ }
26
+ /** The hub to read: `MIADI_REPOSITORY_MAPPING_HUB`, a hub clone or its mapping folder. Unset means none. */
27
+ function hubPath(env = process.env) {
28
+ return env.MIADI_REPOSITORY_MAPPING_HUB?.trim() || undefined;
29
+ }
30
+ /**
31
+ * The lineage: a host's own file first (`--lineage` or
32
+ * `MIADI_REPOSITORY_LINEAGE`), then the rows this package ships. The first
33
+ * to name a pair speaks for it. A file that cannot be read is reported.
34
+ */
35
+ function readLineage(path = process.env.MIADI_REPOSITORY_LINEAGE?.trim() || undefined) {
36
+ const texts = [];
37
+ const unread = [];
38
+ if (path) {
39
+ try {
40
+ texts.push({ text: (0, node_fs_1.readFileSync)(path, "utf8"), source: path });
41
+ }
42
+ catch (error) {
43
+ unread.push({ severity: "error", file: path, message: `lineage not read: ${error.message}` });
44
+ }
45
+ }
46
+ texts.push({ text: shipped_lineage_1.SHIPPED_LINEAGE_JSONL, source: shipped_lineage_1.SHIPPED_LINEAGE_SOURCE });
47
+ const parsed = (0, lineage_1.parseLineage)(texts);
48
+ return { from: [...(path ? [path] : []), shipped_lineage_1.SHIPPED_LINEAGE_SOURCE], edges: parsed.edges, issues: [...unread, ...parsed.issues] };
49
+ }
50
+ async function readHubState(path) {
51
+ if (!path)
52
+ return { hub: { state: "no-hub", hubs: [], errors: 0, warnings: 0 } };
53
+ const dir = await (0, node_1.findMappingDir)(path);
54
+ if (!dir)
55
+ return { hub: { state: "no-mapping-yet", path, hubs: [], errors: 0, warnings: 0 } };
56
+ const read = await (0, node_1.readHub)(dir);
57
+ const errors = read.issues.filter((i) => i.severity === "error").length;
58
+ return {
59
+ hub: { state: read.merged ? "read" : "unreadable", path, hubs: read.hubs, errors, warnings: read.issues.length - errors },
60
+ ...(read.merged ? { mapping: read.merged } : {}),
61
+ };
62
+ }
63
+ async function readMapper(options = {}) {
64
+ const { hub, mapping } = await readHubState(options.hub ?? hubPath());
65
+ const from = options.inventory ?? inventoryDir();
66
+ const sessions = (0, join_1.sessionsByRepository)((0, hooks_interpreter_1.readInventoryRecords)(from));
67
+ return {
68
+ hub,
69
+ ...(mapping ? { mapping } : {}),
70
+ inventory: { from, records: sessions.records, without_repo: sessions.withoutRepo },
71
+ sessions,
72
+ lineage: readLineage(options.lineage),
73
+ };
74
+ }
75
+ async function repositoryListing(options = {}) {
76
+ const read = await readMapper(options);
77
+ return { hub: read.hub, inventory: read.inventory, repositories: (0, join_1.listRepositories)(read.mapping, read.sessions, read.lineage.edges) };
78
+ }
79
+ async function repositoryDetail(repository, options = {}) {
80
+ const read = await readMapper(options);
81
+ const view = (0, join_1.repositoryView)(repository, read.mapping, read.sessions, read.mapping?.sources, read.lineage.edges);
82
+ return { hub: read.hub, inventory: read.inventory, ...(view ? { repository: view } : {}) };
83
+ }
84
+ /** "What did this repository learn from?", or with no repository, every lineage. Reads no hub and no inventory. */
85
+ function repositoryLineage(repository, options = {}) {
86
+ const read = readLineage(options.lineage);
87
+ const base = { from: read.from, issues: read.issues };
88
+ if (!repository)
89
+ return { ...base, graph: (0, lineage_1.lineageGraph)(read.edges) };
90
+ const id = repository.startsWith("repository:") ? repository : `repository:${repository}`;
91
+ return { ...base, repository: id, lineage: (0, lineage_1.lineageOf)(id, read.edges) };
92
+ }
@@ -0,0 +1,2 @@
1
+ export declare const SHIPPED_LINEAGE_SOURCE = "@miadi/relational-git-repository-mapper (shipped)";
2
+ export declare const SHIPPED_LINEAGE_JSONL = "{\"from\":\"repository:jgwill/coaiajs\",\"to\":\"repository:avadisabelle/coaia-narrative\",\"type\":\"learned-from\",\"description\":\"coaiajs holds what the coaia-narrative prototype explored, the narrative context protocol applied to structural tension charts, plus more, and works on its own. Neither depends on the other.\",\"statedBy\":\"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)\",\"statedAt\":\"2026-10-22T10:13:00-04:00\",\"grounding\":[\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 10:03-10:20, 10:49-11:10\",\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5\"],\"revision\":\"pending\"}\n{\"from\":\"repository:jgwill/medicine-wheel\",\"to\":\"repository:avadisabelle/coaia-narrative\",\"type\":\"learned-from\",\"description\":\"The medicine wheel learns from coaia-narrative's exploration of the narrative context protocol on structural tension charts, to implement the same thing with a different way of knowing. It does not depend on coaia-narrative.\",\"statedBy\":\"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)\",\"statedAt\":\"2026-10-22T10:13:00-04:00\",\"grounding\":[\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 10:49-11:21\",\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5\"],\"revision\":\"pending\"}\n{\"from\":\"repository:jgwill/medicine-wheel\",\"to\":\"repository:jgwill/coaiajs\",\"type\":\"learned-from\",\"description\":\"The medicine wheel learns from coaiajs, which holds coaia-narrative's work and more, to implement the same thing with a different way of knowing. It does not depend on coaiajs.\",\"statedBy\":\"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)\",\"statedAt\":\"2026-10-22T10:13:00-04:00\",\"grounding\":[\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 11:03-11:21\",\"miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5\"],\"revision\":\"pending\"}\n";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // The lineage this package ships: rows recorded from William's word, read
3
+ // after a host's own file (`--lineage`, `MIADI_REPOSITORY_LINEAGE`). Kept as a module, not a file beside dist/, so it
4
+ // travels with the code into a bundle. One JSON row per line, as in a hub.
5
+ //
6
+ // Source: Episode 297, screenwalk 2610221013 at 10:03-11:21, and the feedback
7
+ // map's V5 and V6. Three lineages applying one principle, none depending on
8
+ // another. Every row is pending until William reads it.
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SHIPPED_LINEAGE_JSONL = exports.SHIPPED_LINEAGE_SOURCE = void 0;
11
+ exports.SHIPPED_LINEAGE_SOURCE = "@miadi/relational-git-repository-mapper (shipped)";
12
+ exports.SHIPPED_LINEAGE_JSONL = `{"from":"repository:jgwill/coaiajs","to":"repository:avadisabelle/coaia-narrative","type":"learned-from","description":"coaiajs holds what the coaia-narrative prototype explored, the narrative context protocol applied to structural tension charts, plus more, and works on its own. Neither depends on the other.","statedBy":"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)","statedAt":"2026-10-22T10:13:00-04:00","grounding":["miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 10:03-10:20, 10:49-11:10","miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5"],"revision":"pending"}
13
+ {"from":"repository:jgwill/medicine-wheel","to":"repository:avadisabelle/coaia-narrative","type":"learned-from","description":"The medicine wheel learns from coaia-narrative's exploration of the narrative context protocol on structural tension charts, to implement the same thing with a different way of knowing. It does not depend on coaia-narrative.","statedBy":"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)","statedAt":"2026-10-22T10:13:00-04:00","grounding":["miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 10:49-11:21","miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5"],"revision":"pending"}
14
+ {"from":"repository:jgwill/medicine-wheel","to":"repository:jgwill/coaiajs","type":"learned-from","description":"The medicine wheel learns from coaiajs, which holds coaia-narrative's work and more, to implement the same thing with a different way of knowing. It does not depend on coaiajs.","statedBy":"William, screenwalk 2610221013, transcribed by mw-rwl-repo (claude-opus-5-5)","statedAt":"2026-10-22T10:13:00-04:00","grounding":["miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/transcription-gemini.txt 11:03-11:21","miadi-chronicle://297 captures/screenwalk-2610221013-DD-VideoExplainerFeedback-001/feedback-map.md V5"],"revision":"pending"}
15
+ `;
@@ -0,0 +1,86 @@
1
+ import type { FeatureFacet, LifecycleReading, RelationRow, RepositoryFacet } from "@medicine-wheel/developer-repository-mapping";
2
+ import type { HubStatus } from "@medicine-wheel/developer-repository-mapping/node";
3
+ import type { RepositoryLineage } from "./lineage";
4
+ /** One session that worked in a repository, as its inventory record says it, by title. */
5
+ export interface RepositorySession {
6
+ session_id: string;
7
+ tmux_session_name?: string;
8
+ status?: string;
9
+ /** `team_fit.team.id` (measured at inventory time), else `team` (the binding line's at session start). */
10
+ team?: string;
11
+ mission?: string;
12
+ /** the record's `date`, as YYYY-MM-DD */
13
+ date?: string;
14
+ /** titles of `work_completed` */
15
+ work_completed: string[];
16
+ /** the ending proposed for the session, and the one decided */
17
+ disposition?: {
18
+ proposed?: string;
19
+ decided?: string;
20
+ };
21
+ /** `links.evidence` refs: what the session started from */
22
+ evidence?: string[];
23
+ /** the record file's modification time */
24
+ modified_at: string;
25
+ }
26
+ /**
27
+ * Where the mapping stands on this host.
28
+ * - `no-hub`: no hub configured (`MIADI_REPOSITORY_MAPPING_HUB` unset).
29
+ * - `no-mapping-yet`: the hub clone holds no `.miadi/repository-mapping/`.
30
+ * - `read`: the hub was read (a meta hub with the hubs it registers).
31
+ * - `unreadable`: the folder is there and its manifest does not read.
32
+ */
33
+ export type MappingState = "no-hub" | "no-mapping-yet" | "read" | "unreadable";
34
+ export interface HubState {
35
+ state: MappingState;
36
+ /** the hub clone or mapping folder configured */
37
+ path?: string;
38
+ hubs: HubStatus[];
39
+ errors: number;
40
+ warnings: number;
41
+ }
42
+ export interface RepositoryView {
43
+ /** `repository:<owner>/<name>`, in the case the mapping holds, else the first record's */
44
+ nodeId: string;
45
+ owner: string;
46
+ name: string;
47
+ url: string;
48
+ /** whether a hub holds the repository's row */
49
+ mapped: boolean;
50
+ repository?: RepositoryFacet;
51
+ /** the declared lifecycle against git */
52
+ reading?: LifecycleReading;
53
+ /** the hub the row came from */
54
+ source?: string;
55
+ features: FeatureFacet[];
56
+ relations: RelationRow[];
57
+ /** newest first */
58
+ sessions: RepositorySession[];
59
+ /** what it learned from, and who learned from it */
60
+ lineage: RepositoryLineage;
61
+ }
62
+ export interface RepositorySummary {
63
+ nodeId: string;
64
+ owner: string;
65
+ name: string;
66
+ mapped: boolean;
67
+ lifecycle?: string;
68
+ drift?: string;
69
+ sessions: number;
70
+ /** the newest session's date */
71
+ last_session?: string;
72
+ /** distinct teams of its sessions, sorted */
73
+ teams: string[];
74
+ }
75
+ export interface InventoryState {
76
+ /** the inventory directory read */
77
+ from: string;
78
+ records: number;
79
+ /** records with no `repo`, or one that is not owner/name: counted, not shown */
80
+ without_repo: number;
81
+ }
82
+ export interface RepositoryListing {
83
+ hub: HubState;
84
+ inventory: InventoryState;
85
+ repositories: RepositorySummary[];
86
+ }
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // What P4 shows for a repository: the rows its owner hub holds, beside the
3
+ // agent sessions that worked in it. The rows come from
4
+ // @medicine-wheel/developer-repository-mapping; the sessions from the witness
5
+ // team's session inventory, read through @miadi/hooks-interpreter.
6
+ // Ref: rispecs/developer-suite/repository-mapping/STATUS.md (P4) in jgwill/medicine-wheel.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@miadi/relational-git-repository-mapper",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.0",
4
+ "description": "A git repository as Miadi sees it (git, never a database Repository or Data Mapper): the rows its owner hub holds (@medicine-wheel/developer-repository-mapping) beside the agent sessions that worked in it (the witness team's session inventory), joined by owner/name; and which git repository learned from which (a lineage, never a dependency).",
5
+ "license": "MIT",
6
+ "author": "Miadi",
7
+ "homepage": "https://github.com/jgwill/Miadi/tree/main/packages/relational-git-repository-mapper",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jgwill/Miadi.git",
11
+ "directory": "packages/relational-git-repository-mapper"
12
+ },
13
+ "type": "commonjs",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "bin": {
24
+ "miadi-repomap": "dist/cli.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ],
30
+ "dependencies": {
31
+ "@medicine-wheel/capabilities": "^0.25.0",
32
+ "@medicine-wheel/developer-repository-mapping": "^0.25.0",
33
+ "@miadi/hooks-interpreter": "^0.7.0",
34
+ "zod": "^3.23.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.0.0",
38
+ "typescript": "^5.4.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "engines": {
44
+ "node": ">=20"
45
+ },
46
+ "keywords": [
47
+ "miadi",
48
+ "git-repository",
49
+ "lineage",
50
+ "repository-mapping",
51
+ "session-inventory",
52
+ "medicine-wheel",
53
+ "relational"
54
+ ],
55
+ "scripts": {
56
+ "build": "tsc -p tsconfig.build.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
57
+ "type-check": "tsc -p tsconfig.build.json --noEmit",
58
+ "test": "d=$(mktemp -d \"${TMPDIR:-/tmp}/miadi-relational-git-repository-mapper-test.XXXXXX\") && trap 'rm -rf \"$d\"' EXIT && tsc -p tsconfig.test.json --outDir \"$d\" && NODE_PATH=\"$PWD/node_modules\" node --test \"$d\"/test/*.test.js"
59
+ }
6
60
  }