@dadado/agent-kit-cli 5.15.1 → 5.17.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/dashboard/dashboard-data.mjs +69 -65
- package/dashboard/lib/guards.d.mts +5 -0
- package/dashboard/lib/guards.mjs +31 -0
- package/dashboard/lib/identity-probe.mjs +56 -0
- package/dashboard/lib/pipeline-cache.mjs +58 -0
- package/dashboard/lib/processes.mjs +71 -0
- package/dashboard/serve.mjs +43 -1
- package/dashboard/start-broadcast.mjs +2 -12
- package/dashboard/start.mjs +2 -13
- package/dist/add-HTYIFKMN.js +150 -0
- package/dist/chunk-2IPXQFJE.js +253 -0
- package/dist/chunk-2RDRMGD3.js +82 -0
- package/dist/chunk-2YU2H7I6.js +42 -0
- package/dist/chunk-4IWG5CVE.js +214 -0
- package/dist/chunk-5VCOWTTP.js +6 -0
- package/dist/chunk-77V75A7O.js +39 -0
- package/dist/chunk-7HDQEK6T.js +26 -0
- package/dist/chunk-AW74INUW.js +1456 -0
- package/dist/chunk-B73KQ5KX.js +972 -0
- package/dist/chunk-CBCW5R5J.js +484 -0
- package/dist/chunk-DE3LQFSJ.js +18 -0
- package/dist/chunk-DQA434Y4.js +106 -0
- package/dist/chunk-F4VMYR7U.js +318 -0
- package/dist/chunk-F6C3GFKV.js +57 -0
- package/dist/chunk-HFUH3HVS.js +282 -0
- package/dist/chunk-HS7LVVLO.js +74 -0
- package/dist/chunk-IHROBTNM.js +135 -0
- package/dist/chunk-KD2MYBB6.js +213 -0
- package/dist/chunk-MAPOQEA2.js +43 -0
- package/dist/chunk-N3HTJVBR.js +341 -0
- package/dist/chunk-NQ7IQ5XT.js +26 -0
- package/dist/chunk-OUQZC744.js +1315 -0
- package/dist/chunk-PCCQUWE5.js +817 -0
- package/dist/chunk-PNFF6OU3.js +273 -0
- package/dist/chunk-PNG7LO2F.js +53 -0
- package/dist/chunk-QTON2GQX.js +203 -0
- package/dist/chunk-S6GMFDKV.js +50 -0
- package/dist/chunk-SMGFN3Z4.js +503 -0
- package/dist/chunk-STGFBAYT.js +641 -0
- package/dist/chunk-TFZ2JUXH.js +1081 -0
- package/dist/chunk-VY7MTPJ2.js +205 -0
- package/dist/chunk-W24CMQ32.js +525 -0
- package/dist/chunk-WW3YZKHW.js +165 -0
- package/dist/chunk-ZB43YMHW.js +20 -0
- package/dist/chunk-ZCTSUQRR.js +874 -0
- package/dist/chunk-ZXKZBTXE.js +17 -0
- package/dist/contribute-C6AW2P6J.js +367 -0
- package/dist/cursor-awareness-KTL2RGKD.js +77 -0
- package/dist/dashboard-YSNUGBFY.js +21 -0
- package/dist/dashboard-broadcast-M4CMW7RX.js +119 -0
- package/dist/diff-VHNR62SI.js +74 -0
- package/dist/doctor-PET2HRRJ.js +236 -0
- package/dist/dogfood-KKFVRWT6.js +366 -0
- package/dist/guard-EHXF76ID.js +530 -0
- package/dist/handoff-3UI6VKVG.js +302 -0
- package/dist/hook-DYIMKJYL.js +1074 -0
- package/dist/index.js +62 -14068
- package/dist/init-Q4LBM6KT.js +127 -0
- package/dist/install-RHOS3OYZ.js +34 -0
- package/dist/mission-control-LJACEVVN.js +89 -0
- package/dist/monitors-QV2IS3MP.js +176 -0
- package/dist/plan-index-JMC7Z4DW.js +44 -0
- package/dist/public-inbound-radar-WP3XF7GS.js +68 -0
- package/dist/remote-issues-SZ4HDQL5.js +44 -0
- package/dist/run-I3BFGULT.js +243 -0
- package/dist/run-plan-FO7CL4M3.js +118 -0
- package/dist/scan-NI2SWJ2E.js +33 -0
- package/dist/setup-global-M42GEODI.js +340 -0
- package/dist/status-XPVQVQMX.js +150 -0
- package/dist/update-FJ2EBZVO.js +283 -0
- package/dist/validate-V2CW7J4B.js +201 -0
- package/package.json +3 -3
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PUBLIC_INBOUND_REPO,
|
|
3
|
+
detectFactoryCheckout
|
|
4
|
+
} from "./chunk-2IPXQFJE.js";
|
|
5
|
+
|
|
6
|
+
// src/lifecycle/remote-issues.ts
|
|
7
|
+
import { execFile } from "child_process";
|
|
8
|
+
import { access } from "fs/promises";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { promisify } from "util";
|
|
11
|
+
var execFileAsync = promisify(execFile);
|
|
12
|
+
var REMOTE_ISSUE_LABEL = "dogfood";
|
|
13
|
+
var REMOTE_ISSUE_TITLE_PREFIX = "[Dogfood]";
|
|
14
|
+
function parseRemoteUrl(url) {
|
|
15
|
+
const trimmed = url.trim();
|
|
16
|
+
const match = /^(?:[a-z+]+:\/\/)?(?:[^@/]+@)?([^:/\s]+)(?::\d+)?[:/](.+?)(?:\.git)?\/?$/i.exec(
|
|
17
|
+
trimmed
|
|
18
|
+
);
|
|
19
|
+
if (!match) return null;
|
|
20
|
+
const host = (match[1] ?? "").toLowerCase();
|
|
21
|
+
const repo = (match[2] ?? "").replace(/^\/+/, "");
|
|
22
|
+
if (!repo.includes("/")) return null;
|
|
23
|
+
const provider = /gitlab|(^|\.)git\.[^.]+\./i.test(host) ? "gitlab" : "github";
|
|
24
|
+
return { provider, host, repo };
|
|
25
|
+
}
|
|
26
|
+
function matchesProvenance(title, labels, env = process.env) {
|
|
27
|
+
const wanted = /* @__PURE__ */ new Set([
|
|
28
|
+
REMOTE_ISSUE_LABEL,
|
|
29
|
+
...(env.AGENT_KIT_REMOTE_ISSUE_LABELS ?? "").split(",").map((l) => l.trim().toLowerCase()).filter(Boolean)
|
|
30
|
+
]);
|
|
31
|
+
if (labels.some((label) => wanted.has(label.toLowerCase()))) return true;
|
|
32
|
+
return title.trim().toLowerCase().startsWith(REMOTE_ISSUE_TITLE_PREFIX.toLowerCase());
|
|
33
|
+
}
|
|
34
|
+
async function defaultRunCli(bin, args, options) {
|
|
35
|
+
const { stdout } = await execFileAsync(bin, args, {
|
|
36
|
+
cwd: options?.cwd,
|
|
37
|
+
encoding: "utf8",
|
|
38
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
39
|
+
timeout: 3e4
|
|
40
|
+
});
|
|
41
|
+
return stdout;
|
|
42
|
+
}
|
|
43
|
+
async function defaultGetRemoteUrl(cwd, name) {
|
|
44
|
+
try {
|
|
45
|
+
const { stdout } = await execFileAsync("git", ["remote", "get-url", name], {
|
|
46
|
+
cwd,
|
|
47
|
+
encoding: "utf8",
|
|
48
|
+
timeout: 5e3
|
|
49
|
+
});
|
|
50
|
+
return stdout.trim() || null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function classifyFailure(error) {
|
|
56
|
+
const err = error;
|
|
57
|
+
const text = `${String(err?.message ?? "")} ${String(err?.stderr ?? "")}`;
|
|
58
|
+
if (err?.code === "ENOENT" || /ENOENT|command not found/i.test(text))
|
|
59
|
+
return "skipped-cli-missing";
|
|
60
|
+
if (/auth|login|401|403|token|credential/i.test(text)) return "skipped-auth";
|
|
61
|
+
if (/ENOTFOUND|EAI_AGAIN|ECONNREFUSED|network|resolve host|timed? ?out|offline/i.test(text)) {
|
|
62
|
+
return "skipped-offline";
|
|
63
|
+
}
|
|
64
|
+
return "skipped-error";
|
|
65
|
+
}
|
|
66
|
+
function labelNames(labels) {
|
|
67
|
+
if (!Array.isArray(labels)) return [];
|
|
68
|
+
return labels.map((entry) => typeof entry === "string" ? entry : entry?.name).filter((name) => typeof name === "string" && name.length > 0);
|
|
69
|
+
}
|
|
70
|
+
function parseRows(stdout) {
|
|
71
|
+
const trimmed = stdout.trim();
|
|
72
|
+
if (!trimmed) return [];
|
|
73
|
+
const parsed = JSON.parse(trimmed);
|
|
74
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
75
|
+
}
|
|
76
|
+
async function listGithub(runCli, cwd, remote, role) {
|
|
77
|
+
const stdout = await runCli(
|
|
78
|
+
"gh",
|
|
79
|
+
[
|
|
80
|
+
"issue",
|
|
81
|
+
"list",
|
|
82
|
+
"--repo",
|
|
83
|
+
remote.repo,
|
|
84
|
+
"--state",
|
|
85
|
+
"open",
|
|
86
|
+
"--limit",
|
|
87
|
+
"100",
|
|
88
|
+
"--json",
|
|
89
|
+
"number,title,updatedAt,labels,url"
|
|
90
|
+
],
|
|
91
|
+
{ cwd }
|
|
92
|
+
);
|
|
93
|
+
return parseRows(stdout).flatMap(
|
|
94
|
+
(row) => toItem(role, remote, row.number, row.title, row.url, row.updatedAt, row.labels)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
async function listGitlab(runCli, cwd, remote, role) {
|
|
98
|
+
const project = encodeURIComponent(remote.repo);
|
|
99
|
+
const args = ["api"];
|
|
100
|
+
if (remote.host !== "gitlab.com") args.push("--hostname", remote.host);
|
|
101
|
+
args.push(`projects/${project}/issues?state=opened&per_page=100`);
|
|
102
|
+
const stdout = await runCli("glab", args, { cwd });
|
|
103
|
+
return parseRows(stdout).flatMap(
|
|
104
|
+
(row) => toItem(role, remote, row.iid, row.title, row.web_url, row.updated_at, row.labels)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function toItem(role, remote, rawNumber, rawTitle, rawUrl, rawUpdated, rawLabels) {
|
|
108
|
+
const number = typeof rawNumber === "number" ? rawNumber : Number(rawNumber);
|
|
109
|
+
if (!Number.isFinite(number) || number <= 0) return [];
|
|
110
|
+
const title = typeof rawTitle === "string" && rawTitle.trim() ? rawTitle.trim() : "(no title)";
|
|
111
|
+
const labels = labelNames(rawLabels);
|
|
112
|
+
if (!matchesProvenance(title, labels)) return [];
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
role,
|
|
116
|
+
provider: remote.provider,
|
|
117
|
+
repo: remote.repo,
|
|
118
|
+
number,
|
|
119
|
+
title,
|
|
120
|
+
url: typeof rawUrl === "string" && rawUrl.trim() ? rawUrl.trim() : `https://${remote.host}/${remote.repo}/issues/${number}`,
|
|
121
|
+
labels,
|
|
122
|
+
updatedAt: typeof rawUpdated === "string" ? rawUpdated.trim() : "",
|
|
123
|
+
cite: `${remote.repo}#${number}`
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
async function readTarget(runCli, cwd, role, url) {
|
|
128
|
+
const remote = url ? parseRemoteUrl(url) : null;
|
|
129
|
+
if (!remote) {
|
|
130
|
+
return { role, provider: null, host: null, repo: null, status: "skipped-no-remote", items: [] };
|
|
131
|
+
}
|
|
132
|
+
const base = { role, provider: remote.provider, host: remote.host, repo: remote.repo };
|
|
133
|
+
try {
|
|
134
|
+
const items = remote.provider === "gitlab" ? await listGitlab(runCli, cwd, remote, role) : await listGithub(runCli, cwd, remote, role);
|
|
135
|
+
return { ...base, status: "ok", items };
|
|
136
|
+
} catch (error) {
|
|
137
|
+
return { ...base, status: classifyFailure(error), items: [] };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function noteFor(target) {
|
|
141
|
+
if (target.status === "ok") return null;
|
|
142
|
+
const where = target.repo ? `${target.role} ${target.repo}` : `${target.role} remote`;
|
|
143
|
+
const bin = target.provider === "gitlab" ? "glab" : "gh";
|
|
144
|
+
const reason = {
|
|
145
|
+
"skipped-no-remote": "no remote configured",
|
|
146
|
+
"skipped-cli-missing": `${bin} not installed`,
|
|
147
|
+
"skipped-auth": `${bin} not authenticated`,
|
|
148
|
+
"skipped-offline": "offline or host unreachable",
|
|
149
|
+
"skipped-error": "remote read failed"
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
label: "note",
|
|
153
|
+
message: `Remote issues skipped for ${where}: ${reason[target.status]}. Local inbox only.`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function readRemoteIssues(cwd, options = {}) {
|
|
157
|
+
const now = options.now?.() ?? /* @__PURE__ */ new Date();
|
|
158
|
+
const runCli = options.runCli ?? defaultRunCli;
|
|
159
|
+
const getRemoteUrl = options.getRemoteUrl ?? defaultGetRemoteUrl;
|
|
160
|
+
const isFactory = options.isFactory ?? detectFactoryCheckout;
|
|
161
|
+
const root = path.resolve(cwd);
|
|
162
|
+
let readable = true;
|
|
163
|
+
try {
|
|
164
|
+
await access(root);
|
|
165
|
+
} catch {
|
|
166
|
+
readable = false;
|
|
167
|
+
}
|
|
168
|
+
const factory = readable ? await isFactory(root) : false;
|
|
169
|
+
const lane = factory ? "factory" : "consumer";
|
|
170
|
+
const targets = [];
|
|
171
|
+
if (readable) {
|
|
172
|
+
targets.push(await readTarget(runCli, root, "origin", await getRemoteUrl(root, "origin")));
|
|
173
|
+
if (factory) {
|
|
174
|
+
const publicUrl = await getRemoteUrl(root, "public") ?? `https://github.com/${PUBLIC_INBOUND_REPO}.git`;
|
|
175
|
+
targets.push(await readTarget(runCli, root, "public", publicUrl));
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
targets.push({
|
|
179
|
+
role: "origin",
|
|
180
|
+
provider: null,
|
|
181
|
+
host: null,
|
|
182
|
+
repo: null,
|
|
183
|
+
status: "skipped-error",
|
|
184
|
+
items: []
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const notes = targets.flatMap((target) => {
|
|
188
|
+
const note = noteFor(target);
|
|
189
|
+
return note ? [note] : [];
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
lane,
|
|
193
|
+
checkedAt: now.toISOString(),
|
|
194
|
+
targets,
|
|
195
|
+
items: targets.flatMap((target) => target.items),
|
|
196
|
+
notes,
|
|
197
|
+
mutateRecommended: false
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
REMOTE_ISSUE_TITLE_PREFIX,
|
|
203
|
+
parseRemoteUrl,
|
|
204
|
+
readRemoteIssues
|
|
205
|
+
};
|