whygraph 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/dist/cli/commands/config.d.ts +14 -0
- package/dist/cli/commands/config.js +123 -0
- package/dist/cli/commands/down.d.ts +9 -0
- package/dist/cli/commands/down.js +46 -0
- package/dist/cli/commands/init.d.ts +17 -0
- package/dist/cli/commands/init.js +144 -0
- package/dist/cli/commands/issues.d.ts +10 -0
- package/dist/cli/commands/issues.js +376 -0
- package/dist/cli/commands/mcp.d.ts +2 -0
- package/dist/cli/commands/mcp.js +9 -0
- package/dist/cli/commands/restart.d.ts +11 -0
- package/dist/cli/commands/restart.js +43 -0
- package/dist/cli/commands/serve.d.ts +14 -0
- package/dist/cli/commands/serve.js +132 -0
- package/dist/cli/commands/server-utils.d.ts +6 -0
- package/dist/cli/commands/server-utils.js +94 -0
- package/dist/cli/commands/status.d.ts +11 -0
- package/dist/cli/commands/status.js +97 -0
- package/dist/cli/commands/up.d.ts +13 -0
- package/dist/cli/commands/up.js +62 -0
- package/dist/cli/commands/validate.d.ts +14 -0
- package/dist/cli/commands/validate.js +88 -0
- package/dist/cli/commands/viz.d.ts +7 -0
- package/dist/cli/commands/viz.js +97 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +33 -0
- package/dist/entity/id.d.ts +8 -0
- package/dist/entity/id.js +48 -0
- package/dist/entity/issues.d.ts +12 -0
- package/dist/entity/issues.js +68 -0
- package/dist/entity/parser.d.ts +6 -0
- package/dist/entity/parser.js +166 -0
- package/dist/entity/types.d.ts +54 -0
- package/dist/entity/types.js +21 -0
- package/dist/entity/validate.d.ts +12 -0
- package/dist/entity/validate.js +136 -0
- package/dist/entity/writer.d.ts +16 -0
- package/dist/entity/writer.js +142 -0
- package/dist/frontend/assets/index-ByZzPwVe.css +1 -0
- package/dist/frontend/assets/index-F9dxfzD_.js +170 -0
- package/dist/frontend/index.html +14 -0
- package/dist/graph/cascade.d.ts +10 -0
- package/dist/graph/cascade.js +49 -0
- package/dist/graph/decisions.d.ts +11 -0
- package/dist/graph/decisions.js +27 -0
- package/dist/graph/gaps.d.ts +10 -0
- package/dist/graph/gaps.js +58 -0
- package/dist/graph/nodes.d.ts +20 -0
- package/dist/graph/nodes.js +33 -0
- package/dist/graph/projection.d.ts +6 -0
- package/dist/graph/projection.js +44 -0
- package/dist/graph/query.d.ts +15 -0
- package/dist/graph/query.js +82 -0
- package/dist/graph/search.d.ts +2 -0
- package/dist/graph/search.js +23 -0
- package/dist/graph/supersede.d.ts +7 -0
- package/dist/graph/supersede.js +48 -0
- package/dist/graph/temporal.d.ts +13 -0
- package/dist/graph/temporal.js +28 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.js +340 -0
- package/dist/onboarding/interview.d.ts +22 -0
- package/dist/onboarding/interview.js +92 -0
- package/dist/onboarding/scan.d.ts +17 -0
- package/dist/onboarding/scan.js +106 -0
- package/dist/platform/rules.d.ts +8 -0
- package/dist/platform/rules.js +229 -0
- package/dist/server/core.d.ts +26 -0
- package/dist/server/core.js +111 -0
- package/dist/server/derived.d.ts +8 -0
- package/dist/server/derived.js +13 -0
- package/dist/server/etag.d.ts +9 -0
- package/dist/server/etag.js +25 -0
- package/dist/server/http.d.ts +13 -0
- package/dist/server/http.js +131 -0
- package/dist/server/pubsub.d.ts +12 -0
- package/dist/server/pubsub.js +19 -0
- package/dist/server/schema.d.ts +2 -0
- package/dist/server/schema.js +362 -0
- package/dist/server/stale-refs.d.ts +7 -0
- package/dist/server/stale-refs.js +23 -0
- package/dist/server/watcher.d.ts +21 -0
- package/dist/server/watcher.js +98 -0
- package/dist/server/worktree-watcher.d.ts +20 -0
- package/dist/server/worktree-watcher.js +79 -0
- package/dist/server/worktree.d.ts +22 -0
- package/dist/server/worktree.js +84 -0
- package/package.json +73 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import { execFile as execFileCb } from "node:child_process";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
const execFileAsync = promisify(execFileCb);
|
|
6
|
+
// ============================================================
|
|
7
|
+
// Parse porcelain output
|
|
8
|
+
// ============================================================
|
|
9
|
+
export function parseWorktreeList(output) {
|
|
10
|
+
const trimmed = output.trim();
|
|
11
|
+
if (trimmed === "")
|
|
12
|
+
return [];
|
|
13
|
+
const results = [];
|
|
14
|
+
const lines = trimmed.split("\n");
|
|
15
|
+
let current = {};
|
|
16
|
+
let isFirst = true;
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
if (line.startsWith("worktree ")) {
|
|
19
|
+
current = { path: line.slice("worktree ".length) };
|
|
20
|
+
}
|
|
21
|
+
else if (line.startsWith("branch ")) {
|
|
22
|
+
const ref = line.slice("branch ".length);
|
|
23
|
+
current.branch = ref.replace("refs/heads/", "");
|
|
24
|
+
}
|
|
25
|
+
else if (line === "detached") {
|
|
26
|
+
current.branch = null;
|
|
27
|
+
}
|
|
28
|
+
else if (line === "") {
|
|
29
|
+
if (current.path !== undefined) {
|
|
30
|
+
results.push({
|
|
31
|
+
path: current.path,
|
|
32
|
+
branch: current.branch ?? null,
|
|
33
|
+
isMain: isFirst,
|
|
34
|
+
});
|
|
35
|
+
isFirst = false;
|
|
36
|
+
current = {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Handle trailing entry without final blank line
|
|
41
|
+
if (current.path !== undefined) {
|
|
42
|
+
results.push({
|
|
43
|
+
path: current.path,
|
|
44
|
+
branch: current.branch ?? null,
|
|
45
|
+
isMain: isFirst,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
// ============================================================
|
|
51
|
+
// Detect worktrees with whygraph graphs
|
|
52
|
+
// ============================================================
|
|
53
|
+
export async function detectWorktrees(repoDir, deps) {
|
|
54
|
+
/* v8 ignore next 3 */
|
|
55
|
+
const run = deps?.execFile ?? ((cmd, args, opts) => execFileAsync(cmd, args, { cwd: opts.cwd }));
|
|
56
|
+
/* v8 ignore next 1 */
|
|
57
|
+
const checkAccess = deps?.access ?? ((p) => fs.access(p));
|
|
58
|
+
let stdout;
|
|
59
|
+
try {
|
|
60
|
+
const result = await run("git", ["worktree", "list", "--porcelain"], { cwd: repoDir });
|
|
61
|
+
stdout = result.stdout;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const parsed = parseWorktreeList(stdout);
|
|
67
|
+
const nonMain = parsed.filter((wt) => !wt.isMain && wt.branch !== null);
|
|
68
|
+
const results = [];
|
|
69
|
+
for (const wt of nonMain) {
|
|
70
|
+
const graphDir = path.join(wt.path, ".whygraph", "graph");
|
|
71
|
+
try {
|
|
72
|
+
await checkAccess(graphDir);
|
|
73
|
+
results.push({
|
|
74
|
+
path: wt.path,
|
|
75
|
+
branch: wt.branch,
|
|
76
|
+
graphDir,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// No .whygraph/graph/ — skip
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return results;
|
|
84
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "whygraph",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The graph of why. So your agent knows before it touches anything.",
|
|
5
|
+
"author": "Geovanie Ruiz",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"ai",
|
|
9
|
+
"agent",
|
|
10
|
+
"mcp",
|
|
11
|
+
"architecture",
|
|
12
|
+
"decision",
|
|
13
|
+
"adr",
|
|
14
|
+
"claude",
|
|
15
|
+
"cursor",
|
|
16
|
+
"vibe-coding"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/geovanie-ruiz/whygraph.git"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/geovanie-ruiz/whygraph#readme",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/geovanie-ruiz/whygraph/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"whygraph": "./dist/cli/index.js"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"build:frontend": "cd frontend && npm run build",
|
|
33
|
+
"build:all": "npm run build && npm run build:frontend",
|
|
34
|
+
"dev": "tsc --watch",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest",
|
|
37
|
+
"test:coverage": "vitest run --coverage",
|
|
38
|
+
"lint": "tsc --noEmit",
|
|
39
|
+
"prepublishOnly": "npm run build && npm run build:frontend"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
43
|
+
"chokidar": "^5.0.0",
|
|
44
|
+
"commander": "^14.0.3",
|
|
45
|
+
"graphology": "^0.25.0",
|
|
46
|
+
"graphql": "^16.13.1",
|
|
47
|
+
"graphql-ws": "^6.0.7",
|
|
48
|
+
"graphql-yoga": "^5.18.1",
|
|
49
|
+
"gray-matter": "^4.0.3",
|
|
50
|
+
"js-yaml": "^4.1.1",
|
|
51
|
+
"nanoid": "^5.1.7",
|
|
52
|
+
"open": "^11.0.0",
|
|
53
|
+
"prompts": "^2.4.2",
|
|
54
|
+
"ws": "^8.20.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/js-yaml": "^4.0.9",
|
|
58
|
+
"@types/node": "^20.0.0",
|
|
59
|
+
"@types/prompts": "^2.4.9",
|
|
60
|
+
"@types/ws": "^8.18.1",
|
|
61
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
62
|
+
"typescript": "^5.0.0",
|
|
63
|
+
"vitest": "^4.1.2"
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"dist/",
|
|
67
|
+
"README.md",
|
|
68
|
+
"LICENSE"
|
|
69
|
+
],
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=20.0.0"
|
|
72
|
+
}
|
|
73
|
+
}
|