waypoint-codex 0.1.4 → 0.1.6
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
-
import {
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
@@ -25,7 +25,7 @@ function ensureDir(dirPath) {
|
|
|
25
25
|
|
|
26
26
|
function safeExec(command, cwd) {
|
|
27
27
|
try {
|
|
28
|
-
return
|
|
28
|
+
return execFileSync(command[0], command.slice(1), {
|
|
29
29
|
cwd,
|
|
30
30
|
stdio: ["ignore", "pipe", "ignore"],
|
|
31
31
|
encoding: "utf8",
|
|
@@ -55,8 +55,21 @@ function redactSecrets(text) {
|
|
|
55
55
|
return SECRET_PATTERNS.reduce((current, pattern) => current.replace(pattern, "[REDACTED]"), text);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
function safeRealpath(targetPath) {
|
|
59
|
+
try {
|
|
60
|
+
return realpathSync(targetPath);
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
function isWithinPath(childPath, parentPath) {
|
|
59
|
-
const
|
|
67
|
+
const resolvedParent = safeRealpath(parentPath);
|
|
68
|
+
const resolvedChild = safeRealpath(childPath);
|
|
69
|
+
if (!resolvedParent || !resolvedChild) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const rel = path.relative(resolvedParent, resolvedChild);
|
|
60
73
|
return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
|
|
61
74
|
}
|
|
62
75
|
|
|
@@ -316,21 +329,43 @@ function main() {
|
|
|
316
329
|
contextDir,
|
|
317
330
|
"UNCOMMITTED_CHANGES.md",
|
|
318
331
|
"Uncommitted Changes",
|
|
319
|
-
|
|
332
|
+
[
|
|
333
|
+
"## Status",
|
|
334
|
+
"",
|
|
335
|
+
"```",
|
|
336
|
+
safeExec(["git", "status", "--short", "--branch"], projectRoot) || "No uncommitted changes.",
|
|
337
|
+
"```",
|
|
338
|
+
"",
|
|
339
|
+
"## Diff Stat",
|
|
340
|
+
"",
|
|
341
|
+
"```",
|
|
342
|
+
safeExec(["git", "diff", "--stat"], projectRoot) || "No unstaged tracked diff.",
|
|
343
|
+
"```",
|
|
344
|
+
"",
|
|
345
|
+
"## Staged Diff Stat",
|
|
346
|
+
"",
|
|
347
|
+
"```",
|
|
348
|
+
safeExec(["git", "diff", "--stat", "--cached"], projectRoot) || "No staged diff.",
|
|
349
|
+
"```",
|
|
350
|
+
].join("\n")
|
|
320
351
|
);
|
|
321
352
|
|
|
322
353
|
const recentCommitsPath = writeContextFile(
|
|
323
354
|
contextDir,
|
|
324
355
|
"RECENT_COMMITS.md",
|
|
325
356
|
"Recent Commits",
|
|
326
|
-
|
|
357
|
+
[
|
|
358
|
+
"```",
|
|
359
|
+
safeExec(["git", "log", "--format=%h%d %s (%cr)", "-20", "--all"], projectRoot) || "No recent commits found.",
|
|
360
|
+
"```",
|
|
361
|
+
].join("\n")
|
|
327
362
|
);
|
|
328
363
|
|
|
329
364
|
const nestedRepos = collectNestedGitRepos(projectRoot);
|
|
330
365
|
const nestedRepoSections = nestedRepos.map((repoPath) => {
|
|
331
366
|
const rel = path.relative(projectRoot, repoPath) || ".";
|
|
332
|
-
const branch = safeExec("git branch --show-current", repoPath) || "unknown";
|
|
333
|
-
const commits = safeExec("git log --format=%h %s (%cr) -10", repoPath) || "No recent commits found.";
|
|
367
|
+
const branch = safeExec(["git", "branch", "--show-current"], repoPath) || "unknown";
|
|
368
|
+
const commits = safeExec(["git", "log", "--format=%h %s (%cr)", "-10"], repoPath) || "No recent commits found.";
|
|
334
369
|
return `## ${rel}\n\nBranch: ${branch}\n\n\`\`\`\n${commits}\n\`\`\``;
|
|
335
370
|
});
|
|
336
371
|
const nestedReposPath = writeContextFile(
|
|
@@ -341,11 +376,39 @@ function main() {
|
|
|
341
376
|
);
|
|
342
377
|
|
|
343
378
|
const openPrs = safeExec(
|
|
344
|
-
|
|
379
|
+
[
|
|
380
|
+
"gh",
|
|
381
|
+
"pr",
|
|
382
|
+
"list",
|
|
383
|
+
"--state",
|
|
384
|
+
"open",
|
|
385
|
+
"--author",
|
|
386
|
+
"@me",
|
|
387
|
+
"--limit",
|
|
388
|
+
"5",
|
|
389
|
+
"--json",
|
|
390
|
+
"number,title,author,headRefName",
|
|
391
|
+
"--template",
|
|
392
|
+
"{{range .}}#{{.number}} {{.title}} ({{.author.login}}) [{{.headRefName}}]\n{{end}}",
|
|
393
|
+
],
|
|
345
394
|
projectRoot
|
|
346
395
|
);
|
|
347
396
|
const mergedPrs = safeExec(
|
|
348
|
-
|
|
397
|
+
[
|
|
398
|
+
"gh",
|
|
399
|
+
"pr",
|
|
400
|
+
"list",
|
|
401
|
+
"--state",
|
|
402
|
+
"merged",
|
|
403
|
+
"--author",
|
|
404
|
+
"@me",
|
|
405
|
+
"--limit",
|
|
406
|
+
"5",
|
|
407
|
+
"--json",
|
|
408
|
+
"number,title,author,mergedAt",
|
|
409
|
+
"--template",
|
|
410
|
+
"{{range .}}#{{.number}} {{.title}} ({{.author.login}}) merged {{timeago .mergedAt}}\n{{end}}",
|
|
411
|
+
],
|
|
349
412
|
projectRoot
|
|
350
413
|
);
|
|
351
414
|
const prsPath = writeContextFile(
|