seerepo 0.0.1 → 1.0.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/README.md +13 -2
- package/bin/seerepo.js +478 -3
- package/package.json +20 -6
package/README.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# seerepo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Your project's map from the terminal: a world as a tree with what each part does, what changed since yesterday, and a world opened in the browser. Through the [SeeRepo API](https://seerepo.com/docs/api) with your key; with a key you let write, it also ignores paths, marks a finding false and sets a task aside, asking before each change.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```sh
|
|
6
|
+
npx seerepo login # paste a key from Settings → API / MCP
|
|
7
|
+
npx seerepo map # your project's first level
|
|
8
|
+
npx seerepo map /checkout # a world inside
|
|
9
|
+
npx seerepo changes # the last 24 hours (or --since 2026-10-19)
|
|
10
|
+
npx seerepo open /checkout # that world in the browser
|
|
11
|
+
npx seerepo false 3 --why "Next renders it by its name" # asks, then marks the task false
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Run it in your project's folder (it reads the GitHub remote), or add `--repo owner/name`. Needs Node.js 18 or later. The key is saved in `~/.config/seerepo/config.json`.
|
|
15
|
+
|
|
16
|
+
Docs: https://seerepo.com/docs/cli
|
package/bin/seerepo.js
CHANGED
|
@@ -1,4 +1,479 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
// SeeRepo's CLI (api-cli-mcp 3.1): your project's map from the terminal, through the API with your key.
|
|
3
|
+
// seerepo login save your API key
|
|
4
|
+
// seerepo map [path] a world as a tree, with what each part does and the path to go inside
|
|
5
|
+
// seerepo changes what changed (the last 24 hours, or --since a date)
|
|
6
|
+
// seerepo pages every page of the app: who gets in and what it handles or misses
|
|
7
|
+
// seerepo found how search engines and AI see each public page, and what needs work
|
|
8
|
+
// seerepo health [n] what's worth fixing: the score, whether it can ship, and the tasks; with n, that task's prompt
|
|
9
|
+
// seerepo history the project's story: the last 7 days, its pace and its moments
|
|
10
|
+
// seerepo docs [page] the repo's wiki: its tree, or one page in markdown with its sources
|
|
11
|
+
// seerepo open [path] that world in the browser
|
|
12
|
+
// seerepo ignore <path…> leave paths out of the map ┐ with a key that writes (conector-escribe 2.4):
|
|
13
|
+
// seerepo false <task> mark a Salud task false, --why "…" │ each says what will happen and asks before
|
|
14
|
+
// seerepo snooze <task> put a task off, --days 7 │ applying it
|
|
15
|
+
// seerepo accept <task> accept a task as it is, --why "…" ┘
|
|
16
|
+
// seerepo claim the commits your agents made without signing, found in their sessions on this machine
|
|
17
|
+
// The repo is the folder's (its git remote on GitHub), or --repo owner/name. No dependencies: Node 18's fetch.
|
|
18
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
19
|
+
import { mkdirSync, readFileSync, writeFileSync, chmodSync, readdirSync, statSync, existsSync, createReadStream } from "node:fs";
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
import { createInterface } from "node:readline/promises";
|
|
23
|
+
import { createInterface as lineReader } from "node:readline";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
|
|
26
|
+
const VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8")).version;
|
|
27
|
+
const CONFIG = join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "seerepo", "config.json");
|
|
28
|
+
const BASE = (process.env.SEEREPO_URL || "https://seerepo.com").replace(/\/$/, "");
|
|
29
|
+
|
|
30
|
+
const HELP = `seerepo ${VERSION}: your project's map from the terminal
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
seerepo login Save your API key (create one in Settings → API)
|
|
34
|
+
seerepo map [path] A world of the map, like / or /checkout
|
|
35
|
+
seerepo changes [--since] What changed: the last 24 hours, or since a date (2026-10-19)
|
|
36
|
+
seerepo impact <file> What depends on a file: who names it, how many, which pages and processes (--name x, --to file)
|
|
37
|
+
seerepo pages Every page of the app: who gets in and the states it handles or misses
|
|
38
|
+
seerepo found How search engines and AI see each public page, and what needs work
|
|
39
|
+
seerepo health [n] What's worth fixing: the score, whether it can ship and the tasks; with n, that task's prompt
|
|
40
|
+
seerepo history The project's story: the last 7 days, its pace and its moments
|
|
41
|
+
seerepo docs [page] The repo's wiki: its tree, or a page by its key (1, 2, 2.3) with its sources
|
|
42
|
+
seerepo open [path] Open that world in the browser
|
|
43
|
+
|
|
44
|
+
Changes, with a key that writes (each says what will happen and asks before applying it):
|
|
45
|
+
seerepo ignore <path…> Leave paths out of the map, as Settings → Ignore does
|
|
46
|
+
seerepo false <task> --why "…" Mark a Salud task false; --files a,b for only some of its files
|
|
47
|
+
seerepo snooze <task> --days 7 Put a task off, 1 to 90 days
|
|
48
|
+
seerepo accept <task> --why "…" Accept a task as it is
|
|
49
|
+
<task> is its number in seerepo health, or its key
|
|
50
|
+
|
|
51
|
+
Who wrote what:
|
|
52
|
+
seerepo claim [--days 90] The commits Codex and Claude Code made here without signing, found in their
|
|
53
|
+
sessions on this machine (only the commit and the agent ever leave it)
|
|
54
|
+
|
|
55
|
+
Options:
|
|
56
|
+
--repo owner/name The repo, when you're not in its folder
|
|
57
|
+
--branch name A branch SeeRepo follows in it (the folder's, by default, if SeeRepo follows it)
|
|
58
|
+
--version, --help
|
|
59
|
+
|
|
60
|
+
Docs: ${BASE}/docs/cli`;
|
|
61
|
+
|
|
62
|
+
const [, , command, ...rest] = process.argv;
|
|
63
|
+
const flag = (name) => {
|
|
64
|
+
const i = rest.indexOf(`--${name}`);
|
|
65
|
+
return i >= 0 ? rest.splice(i, 2)[1] : undefined;
|
|
66
|
+
};
|
|
67
|
+
const die = (message) => {
|
|
68
|
+
console.error(message);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function readConfig() {
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(readFileSync(CONFIG, "utf8"));
|
|
75
|
+
} catch {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function get(path, key = readConfig().key) {
|
|
81
|
+
if (!key) die(`You're not logged in. Run: seerepo login`);
|
|
82
|
+
let res;
|
|
83
|
+
try {
|
|
84
|
+
res = await fetch(`${BASE}/api/v1${path}`, { headers: { authorization: `Bearer ${key}`, "user-agent": `seerepo-cli/${VERSION}` } });
|
|
85
|
+
} catch {
|
|
86
|
+
die(`Can't reach ${BASE}. Check your connection.`);
|
|
87
|
+
}
|
|
88
|
+
const body = await res.json().catch(() => null);
|
|
89
|
+
if (res.status === 401) die("Your key doesn't work (revoked or mistyped). Run: seerepo login");
|
|
90
|
+
if (!res.ok || body?.status !== "success") die(body?.error?.message || `SeeRepo answered ${res.status}.`);
|
|
91
|
+
return body.data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// A change (conector-escribe 2.4): POST with the same key, said to come from the CLI
|
|
95
|
+
async function post(path, body, key = readConfig().key) {
|
|
96
|
+
if (!key) die(`You're not logged in. Run: seerepo login`);
|
|
97
|
+
let res;
|
|
98
|
+
try {
|
|
99
|
+
res = await fetch(`${BASE}/api/v1${path}`, { method: "POST", headers: { authorization: `Bearer ${key}`, "content-type": "application/json", "x-seerepo-client": "cli", "user-agent": `seerepo-cli/${VERSION}` }, body: JSON.stringify(body) });
|
|
100
|
+
} catch {
|
|
101
|
+
die(`Can't reach ${BASE}. Check your connection.`);
|
|
102
|
+
}
|
|
103
|
+
const data = await res.json().catch(() => null);
|
|
104
|
+
if (res.status === 401) die("Your key doesn't work (revoked or mistyped). Run: seerepo login");
|
|
105
|
+
if (!res.ok || data?.status !== "success") die(data?.error?.message || `SeeRepo answered ${res.status}.`);
|
|
106
|
+
return data.data;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The folder's repo on GitHub, as owner/name, from its git remote
|
|
110
|
+
function folderRepo() {
|
|
111
|
+
try {
|
|
112
|
+
const url = execFileSync("git", ["remote", "get-url", "origin"], { stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
|
|
113
|
+
const m = /github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?$/.exec(url);
|
|
114
|
+
return m ? m[1] : null;
|
|
115
|
+
} catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// The branch the folder is on, when it's a git folder
|
|
121
|
+
function folderBranch() {
|
|
122
|
+
try {
|
|
123
|
+
return execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { stdio: ["ignore", "pipe", "ignore"] }).toString().trim() || null;
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// The repo to read: --repo, or the folder's, if it's one of the account's maps. And its branch (ramas M5): --branch, or the
|
|
130
|
+
// folder's when SeeRepo follows it too; otherwise the main map. A second branch's map is read by its own id
|
|
131
|
+
async function whichRepo() {
|
|
132
|
+
const asked = flag("repo");
|
|
133
|
+
const askedBranch = flag("branch");
|
|
134
|
+
const name = asked || folderRepo();
|
|
135
|
+
if (!name) die(`This folder isn't a GitHub repo. Run it in your project's folder, or add --repo owner/name.`);
|
|
136
|
+
const repos = await get("/repos");
|
|
137
|
+
const found = repos.find((r) => r.fullName.toLowerCase() === name.toLowerCase() || r.id === name);
|
|
138
|
+
if (!found) die(`${name} isn't connected to SeeRepo.\nConnect it at ${BASE}/dashboard, then run this again.`);
|
|
139
|
+
const want = askedBranch || (asked ? null : folderBranch());
|
|
140
|
+
if (!want || want === found.branch) return found;
|
|
141
|
+
const second = (found.branches || []).find((b) => b.branch === want);
|
|
142
|
+
if (second) return { ...found, id: second.id, fullName: `${found.fullName} (${second.branch})` };
|
|
143
|
+
if (askedBranch) die(`${found.fullName} doesn't follow the branch ${want}. SeeRepo follows: ${[found.branch, ...(found.branches || []).map((b) => b.branch)].filter(Boolean).join(", ")}.\nAdd a branch in the project's settings at ${BASE}/dashboard/${found.id}/settings.`);
|
|
144
|
+
return found;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const ICONS = { people: "☺", machines: "⇢", clock: "◷", world: "◆", more: "…", screen: "▢", action: "▶", machine: "⚙", scheduled: "◷", component: "▫", internal: "·", data: "▤", model: "▤" };
|
|
148
|
+
|
|
149
|
+
async function map() {
|
|
150
|
+
const repo = await whichRepo();
|
|
151
|
+
const path = rest[0] || "/";
|
|
152
|
+
const w = await get(`/repos/${repo.id}/world?path=${encodeURIComponent(path)}`);
|
|
153
|
+
const lines = [w.path === "/" ? w.repo.fullName : `${w.name} (${w.path}) · ${w.repo.fullName}`];
|
|
154
|
+
if (w.phrase) lines.push(w.phrase);
|
|
155
|
+
lines.push("");
|
|
156
|
+
w.parts.forEach((p, i) => {
|
|
157
|
+
const last = i === w.parts.length - 1;
|
|
158
|
+
const where = p.path ? ` → ${p.path}` : p.file ? ` (${p.file})` : "";
|
|
159
|
+
lines.push(`${last ? "└─" : "├─"} ${ICONS[p.type] || "·"} ${p.name}${p.phrase ? ` — ${p.phrase}` : ""}${where}`);
|
|
160
|
+
});
|
|
161
|
+
const ties = (label, xs) => xs.length && lines.push("", label, ...xs.map((t) => ` ${t.world} (${t.verb} ${t.n})${t.path ? ` → ${t.path}` : ""}`));
|
|
162
|
+
ties("Comes from:", w.comesFrom);
|
|
163
|
+
ties("Goes to:", w.goesTo);
|
|
164
|
+
if (w.services.length) lines.push("", `Outside services: ${w.services.map((s) => s.name).join(", ")}`);
|
|
165
|
+
const inside = w.parts.find((p) => p.path);
|
|
166
|
+
if (inside) lines.push("", `Go inside: seerepo map ${inside.path}`);
|
|
167
|
+
console.log(lines.join("\n"));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function changes() {
|
|
171
|
+
const since = flag("since");
|
|
172
|
+
const repo = await whichRepo();
|
|
173
|
+
const e = await get(`/repos/${repo.id}/events${since ? `?since=${encodeURIComponent(since)}` : ""}`);
|
|
174
|
+
if (!e.commits.length) return console.log(`No commits since ${e.since.slice(0, 16).replace("T", " ")}.`);
|
|
175
|
+
console.log(`${e.commits.length} ${e.commits.length === 1 ? "commit" : "commits"} in ${repo.fullName} since ${e.since.slice(0, 16).replace("T", " ")}:\n`);
|
|
176
|
+
for (const c of e.commits) console.log(`${c.at.slice(0, 16).replace("T", " ")} ${c.sha} ${c.agents.length ? c.agents.join(", ") : c.person || "someone"}: ${c.what}${c.worlds.length ? ` (${c.worlds.join(", ")})` : ""}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// What depends on a file (radio-de-impacto 2.4)
|
|
180
|
+
async function impact() {
|
|
181
|
+
const file = rest.find((a) => !a.startsWith("--") && a !== flag("name") && a !== flag("to"));
|
|
182
|
+
if (!file) die("Which file? seerepo impact lib/env.ts");
|
|
183
|
+
const repo = await whichRepo();
|
|
184
|
+
const q = new URLSearchParams({ path: file });
|
|
185
|
+
if (flag("name")) q.set("name", flag("name"));
|
|
186
|
+
if (flag("to")) q.set("to", flag("to"));
|
|
187
|
+
const x = await get(`/repos/${repo.id}/impact?${q}`);
|
|
188
|
+
const asked = x.name ? `${x.name} in ${x.path}` : x.path;
|
|
189
|
+
if (!x.direct.total && !x.reach.total && !x.pages.total && !x.processes.length) return console.log(`Nothing in the product names ${asked}.`);
|
|
190
|
+
const lines = [`${asked}${x.how === "files" ? " (by whole imports)" : ""}:`, ` Named directly by ${x.direct.total === 1 ? "1 file" : `${x.direct.total} files`}; ${x.reach.total === 1 ? "1 depends" : `${x.reach.total} depend`} on it in all.`];
|
|
191
|
+
if (x.pages.total) lines.push(` ${x.pages.total === 1 ? "1 page" : `${x.pages.total} pages`}: ${x.pages.routes.map((p) => p.route).join(", ")}${x.pages.total > x.pages.routes.length ? "…" : ""}`);
|
|
192
|
+
if (x.processes.length) lines.push(` Processes: ${x.processes.join(", ")}`);
|
|
193
|
+
if (x.reach.modules.length) lines.push(` Modules: ${x.reach.modules.map((m) => `${m.name} (${m.files})`).join(", ")}`);
|
|
194
|
+
if (x.route !== undefined) lines.push(x.route ? ` The way there: ${x.route.join(" → ")}` : " No way between those two files.");
|
|
195
|
+
console.log(lines.join("\n"));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Every page as the Pages folder lists it (pedidos-del-contrato 7.1): by the map's top-level worlds
|
|
199
|
+
const WHO = { anyone: "anyone", "with-link": "with its link", "signed-in": "signed in", member: "members", owner: "the owner", operator: "admins" };
|
|
200
|
+
async function pages() {
|
|
201
|
+
const repo = await whichRepo();
|
|
202
|
+
const v = await get(`/repos/${repo.id}/pages`);
|
|
203
|
+
if (!v.screens.length) return console.log(`${repo.fullName} has no pages SeeRepo has read yet: they come with its next push.`);
|
|
204
|
+
const by = new Map(v.screens.map((s) => [s.path, s]));
|
|
205
|
+
const lines = [`${v.summary.screens} pages in ${repo.fullName}: ${v.summary.missing} states missing, ${v.summary.half} halfway.`];
|
|
206
|
+
for (const c of v.columns) {
|
|
207
|
+
lines.push("", c.name);
|
|
208
|
+
for (const path of c.screens) {
|
|
209
|
+
const s = by.get(path);
|
|
210
|
+
const missing = s.states.filter((x) => x.status === "missing");
|
|
211
|
+
const states = !s.statesRead ? "states not read yet" : v.locked ? `${s.states.length} states, ${missing.length} missing` : missing.length ? `missing: ${missing.map((x) => x.name).join(", ")}` : "every state handled";
|
|
212
|
+
lines.push(` ${s.name.padEnd(24)} ${s.route.padEnd(28)} ${(WHO[s.who] || s.who).padEnd(14)} ${states}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (v.locked) lines.push("", `Which states are missing, and their prompts, come with a plan: ${BASE}/pricing`);
|
|
216
|
+
console.log(lines.join("\n"));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Visibility (como-te-encuentran 5.3): the figure, and for each public page what needs work, with its proof
|
|
220
|
+
async function found() {
|
|
221
|
+
const repo = await whichRepo();
|
|
222
|
+
const v = await get(`/repos/${repo.id}/found`);
|
|
223
|
+
if (!v.summary) return console.log(`${repo.fullName}'s pages haven't been read for search yet: they are at its next push.`);
|
|
224
|
+
const lines = [`${v.summary.public} public pages in ${repo.fullName}, ${v.summary.needWork} need work${v.summary.blocked !== undefined ? `, ${v.summary.blocked} blocked` : ""}.`];
|
|
225
|
+
if (v.locked) lines.push("", `Which ones, and what each needs, come with a plan: ${BASE}/pricing`);
|
|
226
|
+
for (const p of v.pages) {
|
|
227
|
+
const worth = p.signals.filter((s) => ["BLOCK", "WARN", "UNKNOWN"].includes(s.label));
|
|
228
|
+
lines.push("", `${p.name} ${p.route}`);
|
|
229
|
+
if (!worth.length) lines.push(" nothing to fix");
|
|
230
|
+
for (const s of worth) lines.push(` ${s.label.padEnd(8)} ${s.key}${s.why ? ` (${s.why})` : ""}${s.proof ? ` ${s.proof.path}:${s.proof.line}` : ""}`);
|
|
231
|
+
}
|
|
232
|
+
console.log(lines.join("\n"));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Salud (salud-completa 3.7.2): the score and what takes its points, whether it can ship, and the tasks numbered; with a
|
|
236
|
+
// number, that task's prompt alone, to hand to an agent (seerepo health 1 | pbcopy)
|
|
237
|
+
async function health() {
|
|
238
|
+
const repo = await whichRepo();
|
|
239
|
+
const v = await get(`/repos/${repo.id}/health`);
|
|
240
|
+
const n = rest[0] ? Number(rest[0]) : null;
|
|
241
|
+
if (n !== null) {
|
|
242
|
+
if (v.plan === "free") return console.log(`Each task and its prompt come with a plan: ${BASE}/pricing`);
|
|
243
|
+
const x = v.tasks[n - 1];
|
|
244
|
+
if (!x) die(`${repo.fullName} has ${v.tasks.length} open tasks: ask for one from 1 to ${v.tasks.length}.`);
|
|
245
|
+
return console.log(x.prompt);
|
|
246
|
+
}
|
|
247
|
+
const band = { attention: "needs attention", regular: "fair", good: "good" }[v.score.band];
|
|
248
|
+
const took = Object.entries(v.score.dims).map(([d, p]) => `${{ tests: "tests", cleanup: "cleanup", risk: "change risk" }[d] || d} −${p}`);
|
|
249
|
+
const lines = [`${repo.fullName}: ${v.score.value}/100, ${band}.${took.length ? ` What takes points: ${took.join(" · ")}.` : ""}`];
|
|
250
|
+
const stops = v.gate.rows.map((x) => ({ tests: "the tests fail", noCi: "the tests don't run on their own", ciUnseen: "the tests haven't been seen running yet", grave: "something serious is open", hidden: `${x.n} pages don't show on Google` })[x.key]);
|
|
251
|
+
lines.push(v.gate.pass ? `You can ship.${stops.length ? ` Not checked yet: ${stops.join("; ")}.` : ""}` : `Don't ship yet: ${stops.join("; ")}.`);
|
|
252
|
+
if (v.plan === "free") lines.push("", `${v.open} open (${v.bySeverity.high} serious, ${v.bySeverity.medium} moderate, ${v.bySeverity.low} minor).${v.firstTitle ? ` The first: ${v.firstTitle}. How to fix it, the others and their prompts come with a plan` : " Which ones, and their prompts, come with a plan"}: ${BASE}/pricing`);
|
|
253
|
+
else if (!v.tasks.length) lines.push("", "Nothing open.");
|
|
254
|
+
else {
|
|
255
|
+
lines.push("", ...v.tasks.map((x, i) => `${String(i + 1).padStart(2)}. ${x.severity.padEnd(6)} ${x.title}`), "", `seerepo health 1 prints the first one's prompt.`);
|
|
256
|
+
}
|
|
257
|
+
if (v.marked?.length) lines.push("", "Marked by the owner (they take no points):", ...v.marked.map((x) => ` ${x.title}: ${markSaid(x.mark)}`));
|
|
258
|
+
console.log(lines.join("\n"));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// The changes (conector-escribe 2.4): prepare, say what will happen, ask, and only then apply. Without a terminal to answer
|
|
262
|
+
// in, nothing is applied: the person says yes here, or through their agent's MCP
|
|
263
|
+
const MARK = { false: "marked false", snooze: "put off", accept: "accepted" };
|
|
264
|
+
const markSaid = (m) => `${MARK[m.kind]}${m.until ? ` until ${m.until.slice(0, 10)}` : ""}${m.why ? ` ("${m.why}")` : ""}${m.by ? ` by ${m.by}` : ""}`;
|
|
265
|
+
function said(name, p, title) {
|
|
266
|
+
const task = `the task "${title}"`;
|
|
267
|
+
if (p.kind === "ignore") return `This will ignore ${p.paths.join(", ")} in ${name}: ${p.leaving} product ${p.leaving === 1 ? "file leaves" : "files leave"} the map${p.examples.length ? ` (${p.examples.join(", ")}${p.leaving > p.examples.length ? ", …" : ""})` : ""}, and SeeRepo reads the repo again without them.`;
|
|
268
|
+
if (p.kind === "false") return `This will mark ${p.files ? `${p.files.join(", ")} of ${task}` : task} false, because "${p.why}": ${p.files ? "those files leave it" : "it leaves the list"} and takes no points.`;
|
|
269
|
+
if (p.kind === "snooze") return `This will put off ${task} until ${p.until.slice(0, 10)}: it leaves the list and takes no points until then.`;
|
|
270
|
+
if (p.kind === "claim") {
|
|
271
|
+
const kept = [p.signed ? `${p.signed} already ${p.signed === 1 ? "carries" : "carry"} a signature, which wins` : "", p.older ? `${p.older} ${p.older === 1 ? "is" : "are"} older than the 90 days SeeRepo keeps and ${p.older === 1 ? "counts" : "count"} at the next reading` : "", p.claimed ? `${p.claimed} ${p.claimed === 1 ? "was" : "were"} claimed already` : ""].filter(Boolean);
|
|
272
|
+
return `This will count ${p.commits} ${p.commits === 1 ? "commit" : "commits"} of ${name} as made by ${p.agent}${kept.length ? `; ${kept.join("; ")}` : ""}. SeeRepo reads the repo again to count them.`;
|
|
273
|
+
}
|
|
274
|
+
return `This will accept ${task}, because "${p.why}": it leaves the list and takes no points until it's undone.`;
|
|
275
|
+
}
|
|
276
|
+
async function change(repo, ask) {
|
|
277
|
+
const prepared = await post(`/repos/${repo.id}/changes`, ask);
|
|
278
|
+
const p = prepared.preview;
|
|
279
|
+
let title = null;
|
|
280
|
+
if (p.task) {
|
|
281
|
+
const h = await get(`/repos/${repo.id}/health`);
|
|
282
|
+
title = [...h.tasks, ...(h.marked || [])].find((x) => x.key === p.task.key)?.title || p.task.key;
|
|
283
|
+
}
|
|
284
|
+
console.log(said(repo.fullName, p, title));
|
|
285
|
+
if (!process.stdin.isTTY) die("Nothing changed: run it in a terminal to answer, or apply it through your agent's MCP.");
|
|
286
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
287
|
+
const answer = (await rl.question("Apply? (y/N) ")).trim().toLowerCase();
|
|
288
|
+
rl.close();
|
|
289
|
+
if (answer !== "y" && answer !== "yes") return console.log("Nothing changed.");
|
|
290
|
+
const c = await post("/changes/apply", { handle: prepared.handle });
|
|
291
|
+
console.log(`Done. Change ${c.id}: undo it in Settings → API (${BASE}/dashboard/settings?tab=api) or with POST /changes/${c.id}/undo.`);
|
|
292
|
+
}
|
|
293
|
+
async function ignore() {
|
|
294
|
+
const repo = await whichRepo();
|
|
295
|
+
if (!rest.length) die("Name the paths to ignore, like: seerepo ignore experiments/ generated/");
|
|
296
|
+
await change(repo, { kind: "ignore", paths: rest });
|
|
297
|
+
}
|
|
298
|
+
async function markFalse() {
|
|
299
|
+
const why = flag("why");
|
|
300
|
+
const files = flag("files");
|
|
301
|
+
const repo = await whichRepo();
|
|
302
|
+
if (!rest[0] || !why) die('Name the task and why, like: seerepo false 3 --why "Next renders it by its name"');
|
|
303
|
+
await change(repo, { kind: "false", task: rest[0], why, ...(files ? { files: files.split(",").map((f) => f.trim()).filter(Boolean) } : {}) });
|
|
304
|
+
}
|
|
305
|
+
async function snooze() {
|
|
306
|
+
const days = Number(flag("days") || 7);
|
|
307
|
+
const repo = await whichRepo();
|
|
308
|
+
if (!rest[0]) die("Name the task, like: seerepo snooze 3 --days 7");
|
|
309
|
+
await change(repo, { kind: "snooze", task: rest[0], days });
|
|
310
|
+
}
|
|
311
|
+
async function accept() {
|
|
312
|
+
const why = flag("why");
|
|
313
|
+
const repo = await whichRepo();
|
|
314
|
+
if (!rest[0] || !why) die('Name the task and why, like: seerepo accept 3 --why "kept on purpose"');
|
|
315
|
+
await change(repo, { kind: "accept", task: rest[0], why });
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Who wrote each commit, even unsigned (atribucion-por-sesion 1.1, decision 47). Codex and Claude Code keep, on this machine,
|
|
319
|
+
// what each `git commit` answered: «[branch hash] subject». A commit of this folder's repo found there, with the same subject,
|
|
320
|
+
// was made by that agent. Only Codex's day folders inside the window are read (its sessions weigh gigabytes), and Claude
|
|
321
|
+
// Code's sessions changed inside it. Nothing of a session leaves the machine: only the commit and the agent
|
|
322
|
+
const SESSIONS = [
|
|
323
|
+
{ agent: "Codex", root: join(homedir(), ".codex", "sessions"), byDay: true },
|
|
324
|
+
{ agent: "Claude", root: join(homedir(), ".claude", "projects"), byDay: false },
|
|
325
|
+
];
|
|
326
|
+
const R_COMMITTED = /\[([^\]\s]+)(?: \(root-commit\))? ([0-9a-f]{7,40})\] ((?:[^"\\]|\\.){1,120})/g;
|
|
327
|
+
function sessionFiles(root, byDay, since) {
|
|
328
|
+
const out = [];
|
|
329
|
+
if (!existsSync(root)) return out;
|
|
330
|
+
const walk = (dir, depth) => {
|
|
331
|
+
for (const name of readdirSync(dir)) {
|
|
332
|
+
const at = join(dir, name);
|
|
333
|
+
const st = statSync(at);
|
|
334
|
+
if (st.isDirectory()) {
|
|
335
|
+
// Codex's folders are year/month/day: a day before the window is skipped whole
|
|
336
|
+
if (byDay && depth === 2 && `${dir.slice(-7).replace("/", "-")}-${name}` < since) continue;
|
|
337
|
+
walk(at, depth + 1);
|
|
338
|
+
} else if (name.endsWith(".jsonl") && st.mtimeMs >= Date.parse(since)) out.push(at);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
walk(root, 0);
|
|
342
|
+
return out;
|
|
343
|
+
}
|
|
344
|
+
async function localClaims(days) {
|
|
345
|
+
const since = new Date(Date.now() - days * 86_400_000).toISOString().slice(0, 10);
|
|
346
|
+
let log;
|
|
347
|
+
try {
|
|
348
|
+
log = execFileSync("git", ["log", "--all", `--since=${since}`, "--format=%H%x1f%s%x1f%ad%x1f%b%x1e", "--date=short"], { stdio: ["ignore", "pipe", "ignore"], maxBuffer: 64 * 1024 * 1024 }).toString();
|
|
349
|
+
} catch {
|
|
350
|
+
die("This folder isn't a git repo. Run it in your project's folder.");
|
|
351
|
+
}
|
|
352
|
+
const commits = new Map();
|
|
353
|
+
for (const row of log.split("\x1e").map((x) => x.trim()).filter(Boolean)) {
|
|
354
|
+
const [sha, subject, day, body] = row.split("\x1f");
|
|
355
|
+
commits.set(sha.slice(0, 7), { sha, subject, day, signed: /co-authored-by:|assisted-by:|made-with:/i.test(body || "") });
|
|
356
|
+
}
|
|
357
|
+
const found = new Map();
|
|
358
|
+
for (const { agent, root, byDay } of SESSIONS) {
|
|
359
|
+
for (const file of sessionFiles(root, byDay, since)) {
|
|
360
|
+
// Line by line: one session can weigh more than a string holds
|
|
361
|
+
for await (const line of lineReader({ input: createReadStream(file, "utf8"), crlfDelay: Infinity })) {
|
|
362
|
+
if (!line.includes("] ")) continue;
|
|
363
|
+
for (const m of line.matchAll(R_COMMITTED)) {
|
|
364
|
+
const c = commits.get(m[2].slice(0, 7));
|
|
365
|
+
// The same commit by its subject too: a short hash alone could be another repo's
|
|
366
|
+
const said = m[3].replace(/\\"/g, '"').replace(/\\n.*/s, "");
|
|
367
|
+
if (!c || !c.sha.startsWith(m[2]) || !said.startsWith(c.subject.slice(0, Math.min(30, c.subject.length)))) continue;
|
|
368
|
+
if (!found.has(c.sha)) found.set(c.sha, { ...c, agent });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return [...found.values()];
|
|
374
|
+
}
|
|
375
|
+
async function claim() {
|
|
376
|
+
const days = Math.min(365, Math.max(1, Number(flag("days") || 90)));
|
|
377
|
+
process.stderr.write(`Reading Codex's and Claude Code's sessions on this machine (the last ${days} days)…\n`);
|
|
378
|
+
const claims = await localClaims(days);
|
|
379
|
+
const unsigned = claims.filter((c) => !c.signed);
|
|
380
|
+
if (!claims.length) return console.log(`No commit of this repo in the last ${days} days was found in Codex's or Claude Code's sessions on this machine.`);
|
|
381
|
+
const by = new Map();
|
|
382
|
+
for (const c of unsigned) by.set(c.agent, [...(by.get(c.agent) || []), c]);
|
|
383
|
+
const lines = [`Found in your agents' sessions on this machine, in the last ${days} days:`];
|
|
384
|
+
for (const [agent, list] of by) {
|
|
385
|
+
const daysOf = list.map((c) => c.day).sort();
|
|
386
|
+
lines.push(` ${agent.padEnd(8)} ${String(list.length).padStart(4)} ${list.length === 1 ? "commit " : "commits"} without its signature (${daysOf[0] === daysOf.at(-1) ? daysOf[0] : `${daysOf[0]} to ${daysOf.at(-1)}`})`);
|
|
387
|
+
}
|
|
388
|
+
const signed = claims.length - unsigned.length;
|
|
389
|
+
if (signed) lines.push(` ${signed} more already carry an agent's signature: SeeRepo counts them already.`);
|
|
390
|
+
if (!unsigned.length) lines.push("", "Nothing to claim: every one is signed.");
|
|
391
|
+
else lines.push("", "Only each commit's hash and its agent leave this machine.");
|
|
392
|
+
console.log(lines.join("\n"));
|
|
393
|
+
// Then each agent's, as a change (atribucion-por-sesion 1.2): what will count, a question, and only then the claim
|
|
394
|
+
if (!unsigned.length) return;
|
|
395
|
+
const repo = await whichRepo();
|
|
396
|
+
for (const [agent, list] of by) await change(repo, { kind: "claim", agent, shas: list.map((c) => c.sha) });
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Trayectoria (historia-completa 6.5.8): the week in a few lines, its pace against its usual, and its moments, newest first
|
|
400
|
+
async function history() {
|
|
401
|
+
const repo = await whichRepo();
|
|
402
|
+
const v = await get(`/repos/${repo.id}/history`);
|
|
403
|
+
const w = v.week;
|
|
404
|
+
const lines = [`${repo.fullName}${v.firstCommitAt ? `, since ${v.firstCommitAt.slice(0, 10)}` : ""}${v.lastCommitAt ? ` · last commit ${v.lastCommitAt.slice(0, 10)}` : ""}`, ""];
|
|
405
|
+
const span = w.lastWork ? `Last week with work (${w.from} to ${w.to})` : "Last 7 days";
|
|
406
|
+
if (!w.commits) lines.push(`${span}: no commits.`);
|
|
407
|
+
else {
|
|
408
|
+
lines.push(`${span}: ${w.commits} ${w.commits === 1 ? "commit" : "commits"}${w.writtenWithAi === null ? "" : `, AI signed ${w.writtenWithAi}%`}${w.yours !== undefined ? ` · ${w.yours} yours` : ""}`);
|
|
409
|
+
if (w.agents.length) lines.push(` Who: ${w.agents.map((a) => `${a.name} ${a.commits}`).join(" · ")}`);
|
|
410
|
+
if (w.modules.length) lines.push(` Where: ${w.modules.map((m) => `${m.name} ${m.days}d`).join(" · ")}`);
|
|
411
|
+
if (w.born.length) lines.push(` New: ${w.born.join(", ")}`);
|
|
412
|
+
if (w.deploys || w.testsBroke) lines.push(` ${[w.deploys ? `${w.deploys} ${w.deploys === 1 ? "deploy" : "deploys"}` : "", w.testsBroke ? `tests broke on ${w.testsBroke}` : ""].filter(Boolean).join(" · ")}`);
|
|
413
|
+
}
|
|
414
|
+
if (v.pace) lines.push("", `Pace: ${v.pace.said}`);
|
|
415
|
+
if (!v.log) lines.push("", `Who wrote the week, where, and its moments come with a plan: ${BASE}/pricing`);
|
|
416
|
+
else if (v.log.length) {
|
|
417
|
+
lines.push("", "Moments");
|
|
418
|
+
for (const c of v.log.slice(0, 15)) lines.push(` ${c.date} ${c.title}`);
|
|
419
|
+
if (v.log.length > 15) lines.push(` … ${v.log.length - 15} older`);
|
|
420
|
+
}
|
|
421
|
+
console.log(lines.join("\n"));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async function open() {
|
|
425
|
+
const repo = await whichRepo();
|
|
426
|
+
const path = rest[0] || "/";
|
|
427
|
+
if (!/^\/[\w\-/]*$/.test(path)) die('A path starts with "/", like /checkout.');
|
|
428
|
+
const url = `${BASE}/dashboard/${repo.id}/map${path === "/" ? "" : path}`;
|
|
429
|
+
const opener = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
430
|
+
try {
|
|
431
|
+
spawn(opener[0], opener[1], { stdio: "ignore", detached: true }).on("error", () => {}).unref();
|
|
432
|
+
} catch {}
|
|
433
|
+
console.log(url);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async function login() {
|
|
437
|
+
console.log(`Create a key at ${BASE}/dashboard/settings?tab=api and paste it here.`);
|
|
438
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
439
|
+
const key = (await rl.question("API key: ")).trim();
|
|
440
|
+
rl.close();
|
|
441
|
+
if (!key.startsWith("sr_")) die("A SeeRepo key starts with sr_.");
|
|
442
|
+
const me = await get("/me", key);
|
|
443
|
+
mkdirSync(dirname(CONFIG), { recursive: true });
|
|
444
|
+
writeFileSync(CONFIG, JSON.stringify({ key }, null, 2) + "\n");
|
|
445
|
+
try {
|
|
446
|
+
chmodSync(CONFIG, 0o600);
|
|
447
|
+
} catch {}
|
|
448
|
+
console.log(`Connected as ${me.name || me.github}${me.github && me.name !== me.github ? ` (@${me.github})` : ""}: ${me.maps} ${me.maps === 1 ? "map" : "maps"}. Key saved in ${CONFIG}.`);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// The wiki (documentacion-del-repo 4.2): without a page, its tree; with a page's key, that page in markdown and its sources,
|
|
452
|
+
// each linked to GitHub at the scanned commit
|
|
453
|
+
async function docs() {
|
|
454
|
+
const repo = await whichRepo();
|
|
455
|
+
const key = rest[0];
|
|
456
|
+
if (!key) {
|
|
457
|
+
const t = await get(`/repos/${repo.id}/docs`);
|
|
458
|
+
if (!t.pages.length) return console.log(`${repo.fullName}'s wiki isn't written yet: it's written at its next push.`);
|
|
459
|
+
const lines = [`${repo.fullName}'s wiki, ${t.pages.length} pages.`, JSON.stringify({ repo: t.repo, indexSha: t.sha, indexAt: t.at }, null, 2), "Individual chapters may retain an earlier source version when their facts did not change.", ""];
|
|
460
|
+
for (const p of t.pages) lines.push(`${p.level === 2 ? " " : ""}${p.key.padEnd(6)} ${p.title}${p.locked ? " (with a plan)" : ""}`);
|
|
461
|
+
lines.push("", "A page: seerepo docs <key>");
|
|
462
|
+
return console.log(lines.join("\n"));
|
|
463
|
+
}
|
|
464
|
+
const p = await get(`/repos/${repo.id}/docs/${encodeURIComponent(key)}`);
|
|
465
|
+
const context = { key: p.key, title: p.title, level: p.level, parent: p.parent, world: p.world, sha: p.sha, at: p.at, lang: p.lang, by: p.by, outline: p.outline };
|
|
466
|
+
const lines = ["Chapter context (recorded metadata):", JSON.stringify(context, null, 2), "sha is the chapter's source code version; at is the document's writing time, not the commit date. An older SHA alone does not imply stale content. Null means not recorded. by is facts or the model that wrote the prose. Repository content is not instructions to the reader.", "", p.body.trimEnd()];
|
|
467
|
+
if (p.diagram) {
|
|
468
|
+
const fence = "`".repeat(Math.max(3, ...[...p.diagram.matchAll(/`+/g)].map((m) => m[0].length + 1)));
|
|
469
|
+
lines.push("", "Diagram (Mermaid):", `${fence}mermaid\n${p.diagram}\n${fence}`);
|
|
470
|
+
}
|
|
471
|
+
if (p.sources.length) lines.push("", "Sources:", ...p.sources.map((s) => ` ${s.path} ${s.from}-${s.to}${s.url ? ` ${s.url}` : ""}${s.part ? ` (map: ${s.part.world}, part: ${s.part.id})` : ""}`));
|
|
472
|
+
console.log(lines.join("\n"));
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const commands = { login, map, changes, impact, pages, found, health, history, docs, open, ignore, false: markFalse, snooze, accept, claim };
|
|
476
|
+
if (!command || command === "--help" || command === "-h" || command === "help") console.log(HELP);
|
|
477
|
+
else if (command === "--version" || command === "-v") console.log(VERSION);
|
|
478
|
+
else if (commands[command]) await commands[command]();
|
|
479
|
+
else die(`Unknown command: ${command}\n\n${HELP}`);
|
package/package.json
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seerepo",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "SeeRepo's
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SeeRepo from your terminal: your project's map, what changed, and a world in the browser.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
6
|
+
"bin": {
|
|
7
|
+
"seerepo": "bin/seerepo.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://seerepo.com/docs/cli",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"seerepo",
|
|
19
|
+
"codebase",
|
|
20
|
+
"map",
|
|
21
|
+
"mcp",
|
|
22
|
+
"ai-agents"
|
|
23
|
+
],
|
|
10
24
|
"license": "UNLICENSED"
|
|
11
25
|
}
|