@ferronhooi/aihub 0.1.0-next.2 → 0.1.0-next.3
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/dist/commands/doctor.js +21 -0
- package/dist/commands/init.js +18 -0
- package/dist/commands/skills.js +44 -0
- package/dist/lib/clients.js +26 -0
- package/dist/lib/doctor.js +118 -0
- package/dist/lib/init.js +157 -0
- package/dist/lib/install.js +141 -0
- package/dist/lib/pack.js +48 -0
- package/dist/lib/schema.js +56 -0
- package/dist/router.js +8 -1
- package/pack/commands/copilot/cherry-pick.prompt.md +6 -0
- package/pack/commands/copilot/pr-update.prompt.md +6 -0
- package/pack/commands/copilot/pr.prompt.md +6 -0
- package/pack/commands/copilot/refine.prompt.md +6 -0
- package/pack/commands/copilot/review.prompt.md +6 -0
- package/pack/commands/copilot/story.prompt.md +6 -0
- package/pack/commands/copilot/watch.prompt.md +6 -0
- package/pack/commands/opencode/cherry-pick.md +5 -0
- package/pack/commands/opencode/pr-update.md +5 -0
- package/pack/commands/opencode/pr.md +5 -0
- package/pack/commands/opencode/refine.md +5 -0
- package/pack/commands/opencode/review.md +5 -0
- package/pack/commands/opencode/story.md +5 -0
- package/pack/commands/opencode/watch.md +5 -0
- package/pack/skills/_shared/assets/commit-template.nl.txt +5 -0
- package/pack/skills/_shared/assets/commit-template.txt +5 -0
- package/pack/skills/_shared/assets/pull_request_template.md +16 -0
- package/pack/skills/_shared/assets/pull_request_template.nl.md +16 -0
- package/pack/skills/_shared/assets/story-template.md +12 -0
- package/pack/skills/_shared/assets/story-template.nl.md +12 -0
- package/pack/skills/_shared/references/team.schema.yaml +41 -0
- package/pack/skills/branch-sync/SKILL.md +31 -0
- package/pack/skills/implement/SKILL.md +25 -0
- package/pack/skills/pipeline-fix/SKILL.md +29 -0
- package/pack/skills/pr-create/SKILL.md +29 -0
- package/pack/skills/pr-update/SKILL.md +28 -0
- package/pack/skills/pr-watch/SKILL.md +30 -0
- package/pack/skills/release/SKILL.md +35 -0
- package/pack/skills/review-process/SKILL.md +35 -0
- package/pack/skills/start-here/SKILL.md +36 -0
- package/pack/skills/story-create/SKILL.md +28 -0
- package/pack/skills/story-refine/SKILL.md +28 -0
- package/package.json +4 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { AihubError } from "../lib/errors.js";
|
|
3
|
+
import { formatChecks, runChecks } from "../lib/doctor.js";
|
|
4
|
+
export async function run(argv, ctx) {
|
|
5
|
+
let json = false;
|
|
6
|
+
try {
|
|
7
|
+
json = !!parseArgs({ args: argv, options: { json: { type: "boolean" } } }).values.json;
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
throw new AihubError(e.message);
|
|
11
|
+
}
|
|
12
|
+
const checks = runChecks(ctx);
|
|
13
|
+
if (json) {
|
|
14
|
+
ctx.out(JSON.stringify({ ok: checks.every((c) => c.status === "OK"), checks }));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const l of formatChecks(checks))
|
|
18
|
+
ctx.out(l);
|
|
19
|
+
const bad = checks.filter((c) => c.status === "FIX").length;
|
|
20
|
+
ctx.out(bad ? `${bad} check(s) need a fix` : "all checks passed");
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { AihubError } from "../lib/errors.js";
|
|
3
|
+
import { reportInit, runInit } from "../lib/init.js";
|
|
4
|
+
export async function run(argv, ctx) {
|
|
5
|
+
let v;
|
|
6
|
+
try {
|
|
7
|
+
v = parseArgs({
|
|
8
|
+
args: argv,
|
|
9
|
+
options: { repo: { type: "string" }, "no-pr": { type: "boolean" }, language: { type: "string" } },
|
|
10
|
+
}).values;
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
throw new AihubError(e.message);
|
|
14
|
+
}
|
|
15
|
+
const r = await runInit(ctx, { repo: v.repo, noPr: !!v["no-pr"], language: v.language });
|
|
16
|
+
for (const l of reportInit(r))
|
|
17
|
+
ctx.out(l);
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { AihubError } from "../lib/errors.js";
|
|
3
|
+
import { repoRoot } from "../lib/git.js";
|
|
4
|
+
import { installClients, parseClients, uninstallClients } from "../lib/install.js";
|
|
5
|
+
function report(reports, out) {
|
|
6
|
+
for (const r of reports) {
|
|
7
|
+
const count = (a) => r.results.filter((x) => x.action === a).length;
|
|
8
|
+
out(`${r.client}: ${r.dir}`);
|
|
9
|
+
out(` created ${count("created")}, updated ${count("updated")}, unchanged ${count("unchanged")}, removed ${count("removed")}, skipped ${count("skipped")}`);
|
|
10
|
+
for (const s of r.results.filter((x) => x.action === "skipped"))
|
|
11
|
+
out(` skipped ${s.path} (${s.reason})`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function run(argv, ctx) {
|
|
15
|
+
const [sub, ...rest] = argv;
|
|
16
|
+
if (sub !== "install" && sub !== "uninstall")
|
|
17
|
+
throw new AihubError("usage: aihub skills install|uninstall [--global] [--client opencode|github-copilot|codex|all]");
|
|
18
|
+
let v;
|
|
19
|
+
try {
|
|
20
|
+
v = parseArgs({ args: rest, options: { global: { type: "boolean" }, client: { type: "string" } } }).values;
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new AihubError(e.message);
|
|
24
|
+
}
|
|
25
|
+
let clients;
|
|
26
|
+
try {
|
|
27
|
+
clients = parseClients(v.client);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
throw new AihubError(e.message);
|
|
31
|
+
}
|
|
32
|
+
const global = !!v.global;
|
|
33
|
+
let root;
|
|
34
|
+
if (!global) {
|
|
35
|
+
try {
|
|
36
|
+
root = repoRoot(ctx.cwd);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new AihubError("not inside a git repository: run in a repository for a project install, or add --global");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const opts = { global, root };
|
|
43
|
+
report(sub === "install" ? installClients(clients, ctx.env, opts) : uninstallClients(clients, ctx.env, opts), ctx.out);
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export const CLIENTS = ["opencode", "github-copilot", "codex"];
|
|
4
|
+
const home = (env) => env.HOME || env.USERPROFILE || homedir();
|
|
5
|
+
/** Global (per user) or project (inside `root`) locations of a client. Environment overrides come from `env`. */
|
|
6
|
+
export function clientDirs(client, env, opts) {
|
|
7
|
+
if (opts.global) {
|
|
8
|
+
if (client === "opencode") {
|
|
9
|
+
const base = env.OPENCODE_CONFIG_DIR || join(env.XDG_CONFIG_HOME || join(home(env), ".config"), "opencode");
|
|
10
|
+
return { skills: join(base, "skills"), commands: { dir: join(base, "command"), source: "opencode" } };
|
|
11
|
+
}
|
|
12
|
+
if (client === "codex") {
|
|
13
|
+
const base = env.CODEX_HOME || join(home(env), ".codex");
|
|
14
|
+
return { skills: join(base, "skills"), commands: { dir: join(base, "prompts"), source: "opencode" } };
|
|
15
|
+
}
|
|
16
|
+
return { skills: join(env.COPILOT_HOME || join(home(env), ".copilot"), "skills") };
|
|
17
|
+
}
|
|
18
|
+
const root = opts.root ?? ".";
|
|
19
|
+
if (client === "opencode") {
|
|
20
|
+
return { skills: join(root, ".opencode", "skills"), commands: { dir: join(root, ".opencode", "command"), source: "opencode" } };
|
|
21
|
+
}
|
|
22
|
+
if (client === "github-copilot") {
|
|
23
|
+
return { skills: join(root, ".github", "skills"), commands: { dir: join(root, ".github", "prompts"), source: "copilot" } };
|
|
24
|
+
}
|
|
25
|
+
return { skills: join(root, ".agents", "skills") };
|
|
26
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parse } from "yaml";
|
|
5
|
+
import { parseRemote } from "./ado.js";
|
|
6
|
+
import { defaultExec, ADO_RESOURCE } from "./auth.js";
|
|
7
|
+
import { CLIENTS, clientDirs } from "./clients.js";
|
|
8
|
+
import { originDefaultBranch, remoteUrl, repoRoot, showFile } from "./git.js";
|
|
9
|
+
import { packRoot } from "./pack.js";
|
|
10
|
+
import { requiredPaths, validateTeam } from "./schema.js";
|
|
11
|
+
import { defaultTargetFor, loadTeam, readUtf8, TEAM_FILE } from "./team.js";
|
|
12
|
+
import { resolveTemplate } from "./templates.js";
|
|
13
|
+
const ok = (name, detail) => ({ name, status: "OK", detail });
|
|
14
|
+
const fix = (name, detail, how) => ({ name, status: "FIX", detail, fix: how });
|
|
15
|
+
/** Never prompts: a credential helper that wants a terminal fails instead of hanging. */
|
|
16
|
+
const quietExec = (cmd, args, input) => {
|
|
17
|
+
if (cmd !== "git")
|
|
18
|
+
return defaultExec(cmd, args, input);
|
|
19
|
+
const r = spawnSync(cmd, args, {
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
input,
|
|
22
|
+
timeout: 10000,
|
|
23
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" },
|
|
24
|
+
});
|
|
25
|
+
if (r.error || r.status !== 0)
|
|
26
|
+
throw new Error(r.error?.message ?? (r.stderr || "").trim());
|
|
27
|
+
return r.stdout;
|
|
28
|
+
};
|
|
29
|
+
function checkAuth(ctx) {
|
|
30
|
+
const how = "run 'az login', set AIHUB_ADO_PAT, or sign in once with git (git credential manager)";
|
|
31
|
+
const pat = ctx.env.AIHUB_ADO_PAT ? "AIHUB_ADO_PAT" : ctx.env.AZURE_DEVOPS_EXT_PAT ? "AZURE_DEVOPS_EXT_PAT" : "";
|
|
32
|
+
if (pat)
|
|
33
|
+
return ok("auth", `PAT from environment (${pat})`);
|
|
34
|
+
const exec = ctx.exec ?? quietExec;
|
|
35
|
+
try {
|
|
36
|
+
const j = JSON.parse(exec("az", ["account", "get-access-token", "--resource", ADO_RESOURCE, "--output", "json"]));
|
|
37
|
+
if (j.accessToken)
|
|
38
|
+
return ok("auth", "Azure CLI token (az login)");
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
/* next method */
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
if (/^password=.+$/m.test(exec("git", ["credential", "fill"], "protocol=https\nhost=dev.azure.com\n\n"))) {
|
|
45
|
+
return ok("auth", "git credential");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* none */
|
|
50
|
+
}
|
|
51
|
+
return fix("auth", "no way to sign in to Azure DevOps works", how);
|
|
52
|
+
}
|
|
53
|
+
export function runChecks(ctx) {
|
|
54
|
+
const checks = [];
|
|
55
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
56
|
+
checks.push(major >= 18
|
|
57
|
+
? ok("node", `v${process.versions.node}`)
|
|
58
|
+
: fix("node", `v${process.versions.node} is too old (needs 18 or newer)`, "install Node 18 or newer from nodejs.org"));
|
|
59
|
+
const g = spawnSync("git", ["--version"], { encoding: "utf8" });
|
|
60
|
+
checks.push(g.status === 0 ? ok("git", g.stdout.trim()) : fix("git", "git is not available", "install git and make sure it is on the PATH"));
|
|
61
|
+
let root;
|
|
62
|
+
try {
|
|
63
|
+
root = repoRoot(ctx.cwd);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
checks.push(fix("repository", "not inside a git repository", "cd into a clone of your team repository"));
|
|
67
|
+
}
|
|
68
|
+
let repoName = "";
|
|
69
|
+
if (root) {
|
|
70
|
+
try {
|
|
71
|
+
const r = parseRemote(remoteUrl(root));
|
|
72
|
+
repoName = r.repo;
|
|
73
|
+
checks.push(ok("remote", `${r.org}/${r.project}/${r.repo}`));
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
checks.push(fix("remote", e.message, "set origin to the Azure DevOps clone URL: git remote set-url origin <url>"));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
checks.push(checkAuth(ctx));
|
|
80
|
+
if (root) {
|
|
81
|
+
const teamPath = join(root, TEAM_FILE);
|
|
82
|
+
if (!existsSync(teamPath)) {
|
|
83
|
+
checks.push(fix("team.yaml", `${TEAM_FILE} not found`, "run 'aihub init' (opens a pull request with the team pack)"));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
try {
|
|
87
|
+
const data = parse(readUtf8(teamPath));
|
|
88
|
+
const schemaFile = join(packRoot(), "skills", "_shared", "references", "team.schema.yaml");
|
|
89
|
+
const problems = validateTeam(data, requiredPaths(readFileSync(schemaFile, "utf8")));
|
|
90
|
+
checks.push(problems.length
|
|
91
|
+
? fix("team.yaml", problems.join("; "), `edit ${TEAM_FILE} (see docs/team-yaml.md) and open a pull request`)
|
|
92
|
+
: ok("team.yaml", `${TEAM_FILE} is valid`));
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
checks.push(fix("team.yaml", `cannot be read: ${e.message.split("\n")[0]}`, `repair ${TEAM_FILE} (valid YAML) or recreate it with 'aihub init'`));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const team = loadTeam(root);
|
|
99
|
+
const target = defaultTargetFor(team, repoName) || originDefaultBranch(root) || "main";
|
|
100
|
+
const tpl = resolveTemplate(target, { readRef: (b, p) => showFile(root, b, p), localRoot: root });
|
|
101
|
+
checks.push(tpl
|
|
102
|
+
? ok("pr-template", `${tpl.path} (${tpl.from === "ref" ? `on origin/${target}` : "in the working tree only"})`)
|
|
103
|
+
: fix("pr-template", "no pull request template found", "run 'aihub init' or add .azuredevops/pull_request_template.md"));
|
|
104
|
+
}
|
|
105
|
+
for (const c of CLIENTS) {
|
|
106
|
+
const places = [
|
|
107
|
+
{ label: "global", dir: clientDirs(c, ctx.env, { global: true }).skills },
|
|
108
|
+
...(root ? [{ label: "project", dir: clientDirs(c, ctx.env, { global: false, root }).skills }] : []),
|
|
109
|
+
].filter((p) => existsSync(join(p.dir, "start-here", "SKILL.md")));
|
|
110
|
+
checks.push(places.length
|
|
111
|
+
? ok(`skills:${c}`, places.map((p) => `${p.label} (${p.dir})`).join(", "))
|
|
112
|
+
: fix(`skills:${c}`, "aihub skills not installed", `aihub skills install --client ${c} --global`));
|
|
113
|
+
}
|
|
114
|
+
return checks;
|
|
115
|
+
}
|
|
116
|
+
export function formatChecks(checks) {
|
|
117
|
+
return checks.map((c) => `${c.status.padEnd(4)} ${c.name}: ${c.detail}${c.fix ? ` -> ${c.fix}` : ""}`);
|
|
118
|
+
}
|
package/dist/lib/init.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { stringify } from "yaml";
|
|
5
|
+
import { parseRemote } from "./ado.js";
|
|
6
|
+
import { AihubError } from "./errors.js";
|
|
7
|
+
import { git, hasRef, originDefaultBranch, pushIfNeeded, remoteUrl, repoRoot, showFile } from "./git.js";
|
|
8
|
+
import { listFiles, packRoot, readPackFile } from "./pack.js";
|
|
9
|
+
import { createPr } from "./pr.js";
|
|
10
|
+
import { TEAM_FILE } from "./team.js";
|
|
11
|
+
import { resolveTemplate } from "./templates.js";
|
|
12
|
+
export const PACK_BRANCH = "chore/aihub-team-pack";
|
|
13
|
+
export const STORY_TEMPLATE = ".agents/skills/_shared/assets/story-template.md";
|
|
14
|
+
export const COMMIT_TEMPLATE = ".agents/skills/_shared/assets/commit-template.txt";
|
|
15
|
+
export const PR_TEMPLATE = ".azuredevops/pull_request_template.md";
|
|
16
|
+
export function parseLanguage(v) {
|
|
17
|
+
if (!v)
|
|
18
|
+
return "en";
|
|
19
|
+
if (v === "nl" || v === "en")
|
|
20
|
+
return v;
|
|
21
|
+
throw new AihubError(`--language must be nl or en, not '${v}'`);
|
|
22
|
+
}
|
|
23
|
+
function teamYaml(o) {
|
|
24
|
+
const data = {
|
|
25
|
+
version: 1,
|
|
26
|
+
language: o.language,
|
|
27
|
+
azureDevOps: { organization: o.org, project: o.project },
|
|
28
|
+
repositories: [{ name: o.repo, defaultTarget: o.target, releaseBranches: ["release/*"] }],
|
|
29
|
+
pullRequest: {
|
|
30
|
+
template: o.prTemplate,
|
|
31
|
+
title: "{storyId}: {storyTitle}",
|
|
32
|
+
emptySection: o.language === "nl" ? "n.v.t." : "-",
|
|
33
|
+
},
|
|
34
|
+
workItems: { storyType: "User Story", storyTemplate: STORY_TEMPLATE },
|
|
35
|
+
branches: { feature: "feature/{storyId}-{slug}", protected: [o.target, "release/*"] },
|
|
36
|
+
};
|
|
37
|
+
const head = "# Team file proposed by 'aihub init': check every value and change it through a pull request.\n" +
|
|
38
|
+
"# Schema: skills/_shared/references/team.schema.yaml in the aihub pack; see docs/team-yaml.md.\n";
|
|
39
|
+
return head + stringify(data, { lineWidth: 0 });
|
|
40
|
+
}
|
|
41
|
+
/** Where Azure DevOps already finds a PR template for the target branch, or undefined. */
|
|
42
|
+
export function existingPrTemplate(root, target) {
|
|
43
|
+
return resolveTemplate(target, { readRef: (b, p) => showFile(root, b, p), localRoot: root })?.path;
|
|
44
|
+
}
|
|
45
|
+
/** Everything `aihub init` would like to have in the repository (before skipping what exists). */
|
|
46
|
+
export function planFiles(root, o) {
|
|
47
|
+
const pack = packRoot();
|
|
48
|
+
const assets = join(pack, "skills", "_shared", "assets");
|
|
49
|
+
const nl = o.language === "nl";
|
|
50
|
+
const asset = (name, nlName) => readPackFile(join(assets, nl ? nlName : name));
|
|
51
|
+
const found = existingPrTemplate(root, o.target);
|
|
52
|
+
const plan = [
|
|
53
|
+
{ path: TEAM_FILE, content: teamYaml({ ...o, prTemplate: found && !found.includes("/branches/") ? found : PR_TEMPLATE }) },
|
|
54
|
+
{ path: STORY_TEMPLATE, content: asset("story-template.md", "story-template.nl.md") },
|
|
55
|
+
{ path: COMMIT_TEMPLATE, content: asset("commit-template.txt", "commit-template.nl.txt") },
|
|
56
|
+
];
|
|
57
|
+
if (!found)
|
|
58
|
+
plan.push({ path: PR_TEMPLATE, content: asset("pull_request_template.md", "pull_request_template.nl.md") });
|
|
59
|
+
for (const f of listFiles(join(pack, "commands", "opencode"))) {
|
|
60
|
+
plan.push({ path: `.opencode/command/${f}`, content: readPackFile(join(pack, "commands", "opencode", f)) });
|
|
61
|
+
}
|
|
62
|
+
for (const f of listFiles(join(pack, "commands", "copilot"))) {
|
|
63
|
+
plan.push({ path: `.github/prompts/${f}`, content: readPackFile(join(pack, "commands", "copilot", f)) });
|
|
64
|
+
}
|
|
65
|
+
return { plan, skips: found ? { [PR_TEMPLATE]: `a pull request template already exists (${found})` } : {} };
|
|
66
|
+
}
|
|
67
|
+
/** Write planned files that do not exist yet; never touches an existing file. */
|
|
68
|
+
export function writePlanned(root, plan, skipExtra = {}) {
|
|
69
|
+
const res = { created: [], skipped: [] };
|
|
70
|
+
for (const [path, reason] of Object.entries(skipExtra))
|
|
71
|
+
res.skipped.push({ path, reason });
|
|
72
|
+
for (const p of plan) {
|
|
73
|
+
const abs = join(root, p.path);
|
|
74
|
+
if (existsSync(abs)) {
|
|
75
|
+
res.skipped.push({ path: p.path, reason: "exists" });
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
79
|
+
writeFileSync(abs, p.content, "utf8");
|
|
80
|
+
res.created.push(p.path);
|
|
81
|
+
}
|
|
82
|
+
return res;
|
|
83
|
+
}
|
|
84
|
+
function prBody(language, r) {
|
|
85
|
+
const nl = language === "nl";
|
|
86
|
+
const list = (xs) => (xs.length ? xs.map((x) => `- \`${x}\``).join("\n") : nl ? "- geen" : "- none");
|
|
87
|
+
return [
|
|
88
|
+
`## ${nl ? "Beschrijving" : "Description"}`,
|
|
89
|
+
"",
|
|
90
|
+
nl
|
|
91
|
+
? "Voorstel van `aihub init` voor het teampakket: teambestand, sjablonen en slash-commando's. Bestaande bestanden zijn niet aangepast. Controleer de waarden in `team.yaml` voor het mergen."
|
|
92
|
+
: "Proposal from `aihub init` for the team pack: team file, templates and slash commands. Existing files were not changed. Check the values in `team.yaml` before merging.",
|
|
93
|
+
"",
|
|
94
|
+
nl ? "Aangemaakt:" : "Created:",
|
|
95
|
+
list(r.created),
|
|
96
|
+
"",
|
|
97
|
+
nl ? "Overgeslagen (bestond al):" : "Skipped (already existed):",
|
|
98
|
+
list(r.skipped.map((s) => s.path)),
|
|
99
|
+
"",
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
export async function runInit(ctx, o) {
|
|
103
|
+
const language = parseLanguage(o.language);
|
|
104
|
+
const root = repoRoot(resolve(ctx.cwd, o.repo ?? "."));
|
|
105
|
+
const remote = parseRemote(remoteUrl(root));
|
|
106
|
+
const target = originDefaultBranch(root) || "main";
|
|
107
|
+
const info = { org: remote.org, project: remote.project, repo: remote.repo, target, language };
|
|
108
|
+
if (o.noPr) {
|
|
109
|
+
const p = planFiles(root, info);
|
|
110
|
+
return writePlanned(root, p.plan, p.skips);
|
|
111
|
+
}
|
|
112
|
+
const original = git(root, ["rev-parse", "--abbrev-ref", "HEAD"]).trim();
|
|
113
|
+
if (hasRef(root, `refs/heads/${PACK_BRANCH}`) || git(root, ["ls-remote", "--heads", "origin", PACK_BRANCH], { allowFail: true }).trim()) {
|
|
114
|
+
throw new AihubError(`branch '${PACK_BRANCH}' already exists; merge or delete it first, or run 'aihub init --no-pr'`);
|
|
115
|
+
}
|
|
116
|
+
git(root, ["switch", "-c", PACK_BRANCH, hasRef(root, `origin/${target}`) ? `origin/${target}` : "HEAD"]);
|
|
117
|
+
const back = () => {
|
|
118
|
+
if (original !== "HEAD")
|
|
119
|
+
git(root, ["switch", original], { allowFail: true });
|
|
120
|
+
};
|
|
121
|
+
try {
|
|
122
|
+
const p = planFiles(root, info);
|
|
123
|
+
const result = writePlanned(root, p.plan, p.skips);
|
|
124
|
+
result.branch = PACK_BRANCH;
|
|
125
|
+
if (!result.created.length) {
|
|
126
|
+
back();
|
|
127
|
+
git(root, ["branch", "-D", PACK_BRANCH], { allowFail: true });
|
|
128
|
+
result.branch = undefined;
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
git(root, ["add", "--", ...result.created]);
|
|
132
|
+
git(root, ["commit", "-m", "chore: aihub team pack", "--", ...result.created]);
|
|
133
|
+
pushIfNeeded(root, PACK_BRANCH);
|
|
134
|
+
const bodyFile = join(mkdtempSync(join(tmpdir(), "aihub-init-")), "body.md");
|
|
135
|
+
writeFileSync(bodyFile, prBody(language, result), "utf8");
|
|
136
|
+
result.pr = await createPr({ ...ctx, cwd: root }, { title: "chore: aihub team pack", bodyFile, target });
|
|
137
|
+
back();
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
back();
|
|
142
|
+
throw e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export function reportInit(r) {
|
|
146
|
+
const lines = [
|
|
147
|
+
...r.created.map((p) => `created ${p}`),
|
|
148
|
+
...r.skipped.map((s) => `skipped ${s.path} (${s.reason})`),
|
|
149
|
+
];
|
|
150
|
+
if (!r.created.length)
|
|
151
|
+
lines.push("nothing to create: the team pack is already in place");
|
|
152
|
+
if (r.pr)
|
|
153
|
+
lines.push(r.pr);
|
|
154
|
+
else if (r.created.length && !r.branch)
|
|
155
|
+
lines.push("files written, no pull request (--no-pr): review, commit and push them yourself");
|
|
156
|
+
return lines;
|
|
157
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { clientDirs, CLIENTS } from "./clients.js";
|
|
4
|
+
import { cliVersion, listFiles, packRoot, readPackFile, sha256, stamp } from "./pack.js";
|
|
5
|
+
export const MANIFEST = ".aihub-manifest.json";
|
|
6
|
+
function readManifest(dir) {
|
|
7
|
+
try {
|
|
8
|
+
const m = JSON.parse(readFileSync(join(dir, MANIFEST), "utf8"));
|
|
9
|
+
return { version: m.version, files: m.files ?? {} };
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return { version: "", files: {} };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const readNorm = (p) => readFileSync(p, "utf8").replace(/\r\n/g, "\n");
|
|
16
|
+
/**
|
|
17
|
+
* Write entries into dir. Files that are not ours (no manifest record) or that the user changed (checksum differs from
|
|
18
|
+
* what we wrote) are never overwritten. Idempotent. Files we installed earlier that left the pack are removed when unmodified.
|
|
19
|
+
*/
|
|
20
|
+
export function installEntries(dir, entries, version) {
|
|
21
|
+
const man = readManifest(dir);
|
|
22
|
+
const results = [];
|
|
23
|
+
const next = {};
|
|
24
|
+
for (const e of entries) {
|
|
25
|
+
const abs = join(dir, e.rel);
|
|
26
|
+
const want = sha256(e.content);
|
|
27
|
+
if (!existsSync(abs)) {
|
|
28
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
29
|
+
writeFileSync(abs, e.content, "utf8");
|
|
30
|
+
next[e.rel] = want;
|
|
31
|
+
results.push({ action: "created", path: abs });
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const cur = sha256(readNorm(abs));
|
|
35
|
+
if (cur === want) {
|
|
36
|
+
next[e.rel] = want;
|
|
37
|
+
results.push({ action: "unchanged", path: abs });
|
|
38
|
+
}
|
|
39
|
+
else if (man.files[e.rel] === cur) {
|
|
40
|
+
writeFileSync(abs, e.content, "utf8");
|
|
41
|
+
next[e.rel] = want;
|
|
42
|
+
results.push({ action: "updated", path: abs });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (man.files[e.rel])
|
|
46
|
+
next[e.rel] = man.files[e.rel];
|
|
47
|
+
results.push({ action: "skipped", path: abs, reason: man.files[e.rel] ? "changed by the user" : "exists and is not an aihub file" });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const [rel, sum] of Object.entries(man.files)) {
|
|
51
|
+
if (entries.some((e) => e.rel === rel))
|
|
52
|
+
continue;
|
|
53
|
+
const abs = join(dir, rel);
|
|
54
|
+
if (!existsSync(abs))
|
|
55
|
+
continue;
|
|
56
|
+
if (sha256(readNorm(abs)) === sum) {
|
|
57
|
+
unlinkSync(abs);
|
|
58
|
+
results.push({ action: "removed", path: abs, reason: "no longer in the pack" });
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
next[rel] = sum;
|
|
62
|
+
}
|
|
63
|
+
if (Object.keys(next).length) {
|
|
64
|
+
mkdirSync(dir, { recursive: true });
|
|
65
|
+
writeFileSync(join(dir, MANIFEST), JSON.stringify({ version, files: next }, null, 2) + "\n", "utf8");
|
|
66
|
+
}
|
|
67
|
+
pruneEmpty(dir, dir);
|
|
68
|
+
return results;
|
|
69
|
+
}
|
|
70
|
+
/** Remove only the files aihub wrote and the user did not change. */
|
|
71
|
+
export function uninstallDir(dir) {
|
|
72
|
+
const man = readManifest(dir);
|
|
73
|
+
const results = [];
|
|
74
|
+
const keep = {};
|
|
75
|
+
for (const [rel, sum] of Object.entries(man.files)) {
|
|
76
|
+
const abs = join(dir, rel);
|
|
77
|
+
if (!existsSync(abs))
|
|
78
|
+
continue;
|
|
79
|
+
if (sha256(readNorm(abs)) === sum) {
|
|
80
|
+
unlinkSync(abs);
|
|
81
|
+
results.push({ action: "removed", path: abs });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
keep[rel] = sum;
|
|
85
|
+
results.push({ action: "skipped", path: abs, reason: "changed by the user" });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const mf = join(dir, MANIFEST);
|
|
89
|
+
if (Object.keys(keep).length)
|
|
90
|
+
writeFileSync(mf, JSON.stringify({ version: man.version, files: keep }, null, 2) + "\n", "utf8");
|
|
91
|
+
else if (existsSync(mf))
|
|
92
|
+
unlinkSync(mf);
|
|
93
|
+
pruneEmpty(dir, dir);
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
/** Delete empty directories below dir and dir itself when it ends up empty. */
|
|
97
|
+
function pruneEmpty(dir, top) {
|
|
98
|
+
if (!existsSync(dir))
|
|
99
|
+
return;
|
|
100
|
+
for (const n of readdirSync(dir, { withFileTypes: true }))
|
|
101
|
+
if (n.isDirectory())
|
|
102
|
+
pruneEmpty(join(dir, n.name), top);
|
|
103
|
+
if (readdirSync(dir).length === 0)
|
|
104
|
+
rmdirSync(dir);
|
|
105
|
+
}
|
|
106
|
+
export function skillEntries(version = cliVersion()) {
|
|
107
|
+
const src = join(packRoot(), "skills");
|
|
108
|
+
return listFiles(src).map((rel) => ({ rel, content: stamp(rel, readPackFile(join(src, rel)), version) }));
|
|
109
|
+
}
|
|
110
|
+
export function commandEntries(source, version = cliVersion()) {
|
|
111
|
+
const src = join(packRoot(), "commands", source);
|
|
112
|
+
return listFiles(src).map((rel) => ({ rel, content: stamp(rel, readPackFile(join(src, rel)), version) }));
|
|
113
|
+
}
|
|
114
|
+
export function parseClients(value) {
|
|
115
|
+
if (!value || value === "all")
|
|
116
|
+
return [...CLIENTS];
|
|
117
|
+
if (CLIENTS.includes(value))
|
|
118
|
+
return [value];
|
|
119
|
+
throw new Error(`unknown client '${value}'; use opencode, github-copilot, codex or all`);
|
|
120
|
+
}
|
|
121
|
+
export function installClients(clients, env, opts) {
|
|
122
|
+
const version = cliVersion();
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const c of clients) {
|
|
125
|
+
const d = clientDirs(c, env, opts);
|
|
126
|
+
out.push({ client: c, dir: d.skills, results: installEntries(d.skills, skillEntries(version), version) });
|
|
127
|
+
if (d.commands)
|
|
128
|
+
out.push({ client: c, dir: d.commands.dir, results: installEntries(d.commands.dir, commandEntries(d.commands.source, version), version) });
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
export function uninstallClients(clients, env, opts) {
|
|
133
|
+
const out = [];
|
|
134
|
+
for (const c of clients) {
|
|
135
|
+
const d = clientDirs(c, env, opts);
|
|
136
|
+
out.push({ client: c, dir: d.skills, results: uninstallDir(d.skills) });
|
|
137
|
+
if (d.commands)
|
|
138
|
+
out.push({ client: c, dir: d.commands.dir, results: uninstallDir(d.commands.dir) });
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
package/dist/lib/pack.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { AihubError } from "./errors.js";
|
|
6
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
/** Directory that holds the bundled `skills/` and `commands/` (the repo root in a checkout, cli/pack in the npm package). */
|
|
8
|
+
export function packRoot() {
|
|
9
|
+
for (const c of [join(here, "..", "..", ".."), join(here, "..", "..", "pack")]) {
|
|
10
|
+
if (existsSync(join(c, "skills")) && existsSync(join(c, "commands")))
|
|
11
|
+
return c;
|
|
12
|
+
}
|
|
13
|
+
throw new AihubError("the bundled skills are missing from this installation; reinstall with 'npm i -g @ferronhooi/aihub'");
|
|
14
|
+
}
|
|
15
|
+
export function cliVersion() {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(readFileSync(join(here, "..", "..", "package.json"), "utf8")).version;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return "0.0.0";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const sha256 = (s) => createHash("sha256").update(s, "utf8").digest("hex");
|
|
24
|
+
/** Relative POSIX paths of all files below dir, sorted. */
|
|
25
|
+
export function listFiles(dir, base = dir) {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const name of readdirSync(dir).sort()) {
|
|
28
|
+
const p = join(dir, name);
|
|
29
|
+
if (statSync(p).isDirectory())
|
|
30
|
+
out.push(...listFiles(p, base));
|
|
31
|
+
else
|
|
32
|
+
out.push(p.slice(base.length + 1).replace(/\\/g, "/"));
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
export const readPackFile = (path) => readFileSync(path, "utf8").replace(/^/, "").replace(/\r\n/g, "\n");
|
|
37
|
+
/**
|
|
38
|
+
* Mark a file as installed by aihub: `<!-- aihub <version> -->` in markdown (after the front matter, which must stay
|
|
39
|
+
* first), `# aihub <version>` in other text files.
|
|
40
|
+
*/
|
|
41
|
+
export function stamp(rel, content, version) {
|
|
42
|
+
const isMd = rel.endsWith(".md");
|
|
43
|
+
const mark = isMd ? `<!-- aihub ${version} -->` : `# aihub ${version}`;
|
|
44
|
+
const fm = /^---\n[\s\S]*?\n---\n/.exec(content);
|
|
45
|
+
if (isMd && fm)
|
|
46
|
+
return `${fm[0]}${mark}\n${content.slice(fm[0].length)}`;
|
|
47
|
+
return `${mark}\n${content}`;
|
|
48
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The team schema file is a documented YAML example: every key carries a comment ending in "(required)" or "(optional)".
|
|
3
|
+
* This reads those comments to find the required key paths (lists are written `repositories[].name`).
|
|
4
|
+
*/
|
|
5
|
+
export function requiredPaths(schemaText) {
|
|
6
|
+
const stack = [];
|
|
7
|
+
const out = [];
|
|
8
|
+
for (const line of schemaText.replace(/\r\n/g, "\n").split("\n")) {
|
|
9
|
+
const m = /^(\s*)(-\s+)?([A-Za-z][A-Za-z0-9]*):(.*)$/.exec(line);
|
|
10
|
+
if (!m || line.trimStart().startsWith("#"))
|
|
11
|
+
continue;
|
|
12
|
+
const keyIndent = m[1].length + (m[2]?.length ?? 0);
|
|
13
|
+
while (stack.length && stack[stack.length - 1].indent >= keyIndent)
|
|
14
|
+
stack.pop();
|
|
15
|
+
if (m[2] && stack.length)
|
|
16
|
+
stack[stack.length - 1].isList = true;
|
|
17
|
+
stack.push({ indent: keyIndent, key: m[3], isList: false });
|
|
18
|
+
const comment = m[4].includes("#") ? m[4].slice(m[4].indexOf("#")) : "";
|
|
19
|
+
if (/\(required\b/.test(comment))
|
|
20
|
+
out.push(stack.map((s) => s.key + (s.isList ? "[]" : "")).join("."));
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
const get = (value, seg) => {
|
|
25
|
+
const isList = seg.endsWith("[]");
|
|
26
|
+
const key = isList ? seg.slice(0, -2) : seg;
|
|
27
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
28
|
+
return [];
|
|
29
|
+
const v = value[key];
|
|
30
|
+
if (v === undefined || v === null || v === "" || (Array.isArray(v) && v.length === 0))
|
|
31
|
+
return [];
|
|
32
|
+
return isList ? (Array.isArray(v) ? v : []) : [v];
|
|
33
|
+
};
|
|
34
|
+
/** Human-readable problems of a parsed team file against the required paths; empty when valid. */
|
|
35
|
+
export function validateTeam(data, required) {
|
|
36
|
+
const problems = [];
|
|
37
|
+
for (const path of required) {
|
|
38
|
+
const segs = path.split(".");
|
|
39
|
+
let level = [data];
|
|
40
|
+
let missing = false;
|
|
41
|
+
for (const s of segs) {
|
|
42
|
+
const next = level.flatMap((v) => get(v, s));
|
|
43
|
+
if (s.endsWith("[]") ? !next.length : next.length < level.length || !next.length)
|
|
44
|
+
missing = true;
|
|
45
|
+
level = next;
|
|
46
|
+
if (missing)
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
if (missing)
|
|
50
|
+
problems.push(`missing ${path}`);
|
|
51
|
+
}
|
|
52
|
+
const v = data?.version;
|
|
53
|
+
if (v !== undefined && !Number.isInteger(v))
|
|
54
|
+
problems.push("version must be an integer");
|
|
55
|
+
return problems;
|
|
56
|
+
}
|
package/dist/router.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AihubError } from "./lib/errors.js";
|
|
2
|
+
import { cliVersion } from "./lib/pack.js";
|
|
2
3
|
import * as comments from "./commands/comments.js";
|
|
4
|
+
import * as doctor from "./commands/doctor.js";
|
|
5
|
+
import * as init from "./commands/init.js";
|
|
3
6
|
import * as pr from "./commands/pr.js";
|
|
7
|
+
import * as skills from "./commands/skills.js";
|
|
4
8
|
/**
|
|
5
9
|
* Command registry. To add a command: create src/commands/<name>.ts exporting
|
|
6
10
|
* `run(argv, ctx)` and add one line here. Commands print through ctx.out and
|
|
@@ -9,8 +13,11 @@ import * as pr from "./commands/pr.js";
|
|
|
9
13
|
export const commands = {
|
|
10
14
|
pr: pr.run,
|
|
11
15
|
comments: comments.run,
|
|
16
|
+
init: init.run,
|
|
17
|
+
skills: skills.run,
|
|
18
|
+
doctor: doctor.run,
|
|
12
19
|
};
|
|
13
|
-
export const VERSION =
|
|
20
|
+
export const VERSION = cliVersion();
|
|
14
21
|
/** Returns the process exit code. */
|
|
15
22
|
export async function main(argv, ctx, registry = commands) {
|
|
16
23
|
const [name, ...rest] = argv;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
<what changed and why, in two or three sentences>
|
|
3
|
+
|
|
4
|
+
## Changes
|
|
5
|
+
- <change 1>
|
|
6
|
+
- <change 2>
|
|
7
|
+
|
|
8
|
+
## Tests
|
|
9
|
+
| Test | Result |
|
|
10
|
+
|---|---|
|
|
11
|
+
| <test that was really run> | <pass or fail> |
|
|
12
|
+
|
|
13
|
+
Not run: <what was not tested and why>
|
|
14
|
+
|
|
15
|
+
## Related
|
|
16
|
+
Story: <work item link>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Samenvatting
|
|
2
|
+
<wat is er veranderd en waarom, in twee of drie zinnen>
|
|
3
|
+
|
|
4
|
+
## Wijzigingen
|
|
5
|
+
- <wijziging 1>
|
|
6
|
+
- <wijziging 2>
|
|
7
|
+
|
|
8
|
+
## Tests
|
|
9
|
+
| Test | Resultaat |
|
|
10
|
+
|---|---|
|
|
11
|
+
| <test die echt is uitgevoerd> | <geslaagd of mislukt> |
|
|
12
|
+
|
|
13
|
+
Niet uitgevoerd: <wat niet is getest en waarom>
|
|
14
|
+
|
|
15
|
+
## Gerelateerd
|
|
16
|
+
Story: <link naar het werkitem>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
As a <role>, I want <goal>, so that <benefit>.
|
|
3
|
+
|
|
4
|
+
## Acceptance criteria
|
|
5
|
+
- [ ] <observable result 1>
|
|
6
|
+
- [ ] <observable result 2>
|
|
7
|
+
|
|
8
|
+
## Technical notes
|
|
9
|
+
<constraints, affected components, open questions>
|
|
10
|
+
|
|
11
|
+
## Out of scope
|
|
12
|
+
<what this story deliberately does not do>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## Beschrijving
|
|
2
|
+
Als <rol> wil ik <doel>, zodat <voordeel>.
|
|
3
|
+
|
|
4
|
+
## Acceptatiecriteria
|
|
5
|
+
- [ ] <waarneembaar resultaat 1>
|
|
6
|
+
- [ ] <waarneembaar resultaat 2>
|
|
7
|
+
|
|
8
|
+
## Technische notities
|
|
9
|
+
<randvoorwaarden, geraakte onderdelen, open vragen>
|
|
10
|
+
|
|
11
|
+
## Buiten scope
|
|
12
|
+
<wat deze story bewust niet doet>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Schema of the team file. Teams keep their copy in the team repository at
|
|
2
|
+
# .agents/skills/_shared/references/team.yaml (created by `aihub init`).
|
|
3
|
+
# Every key below is documented as "key: <type> # meaning (required|optional)".
|
|
4
|
+
# The values shown are the generic defaults, not team knowledge.
|
|
5
|
+
|
|
6
|
+
version: 1 # integer, schema version (required)
|
|
7
|
+
language: en # content language of stories, PRs, comments, e.g. en or nl (required)
|
|
8
|
+
|
|
9
|
+
azureDevOps:
|
|
10
|
+
organization: <organization> # Azure DevOps organization name (required)
|
|
11
|
+
project: <project> # project name (required)
|
|
12
|
+
|
|
13
|
+
repositories: # list (required, at least one)
|
|
14
|
+
- name: <repository> # exact repository name in Azure DevOps (required)
|
|
15
|
+
aliases: [] # list of short names users may say, e.g. ["tp"] (optional)
|
|
16
|
+
defaultTarget: main # branch a new PR targets (required)
|
|
17
|
+
releaseBranches: [] # release branch patterns or names, e.g. ["release/*"] (optional)
|
|
18
|
+
|
|
19
|
+
pullRequest:
|
|
20
|
+
template: .azuredevops/pull_request_template.md # path in the repo to the PR template (required)
|
|
21
|
+
title: "{storyId}: {storyTitle}" # title pattern; placeholders {storyId} {storyTitle} {branch} (optional)
|
|
22
|
+
emptySection: "-" # text the CLI writes into a template section left empty (optional)
|
|
23
|
+
|
|
24
|
+
workItems:
|
|
25
|
+
storyType: User Story # work item type used for stories (required)
|
|
26
|
+
storyTemplate: .agents/skills/_shared/assets/story-template.md # story template path (required)
|
|
27
|
+
|
|
28
|
+
branches:
|
|
29
|
+
feature: "feature/{storyId}-{slug}" # pattern for feature branches (required)
|
|
30
|
+
protected: # branches the CLI never pushes to or force-updates (optional)
|
|
31
|
+
- main
|
|
32
|
+
- release/*
|
|
33
|
+
|
|
34
|
+
cherryPick:
|
|
35
|
+
groups: # named sets of target branches, usable as --to <group> (optional)
|
|
36
|
+
supported: ["release/1.2", "release/1.3"]
|
|
37
|
+
|
|
38
|
+
pipelines: # pipelines to follow per repository (optional)
|
|
39
|
+
- repository: <repository> # repository name this pipeline belongs to
|
|
40
|
+
name: <pipeline> # pipeline name or id
|
|
41
|
+
required: true # true when a red run blocks the PR
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: branch-sync
|
|
3
|
+
description: "Use when a change must move between branches: 'cherry-pick to release', 'cherry-pick naar', 'update my branch', 'werk de branch bij met main', '/cherry-pick'."
|
|
4
|
+
---
|
|
5
|
+
# Cherry-pick and branch update
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
A merged change must go to other branches, or the own branch is behind its target.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
Cherry-pick a PR or commits to one or more branches (groups from `team.yaml` `cherryPick.groups` work too):
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
aihub cherry-pick --from 42 --to release/1.2 --to release/1.3
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Bring the own branch up to date with its target:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
aihub branch update
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Example: "cherry-pick PR 42 naar release/1.2" gives the first command; then show the new PR links.
|
|
24
|
+
|
|
25
|
+
## What the CLI fills
|
|
26
|
+
Merge commits, ordering, one new PR per target and protected-branch checks (`branches.protected`). Do not ask the user about targets that `team.yaml` defines.
|
|
27
|
+
|
|
28
|
+
## If it fails
|
|
29
|
+
Conflict: resolve it with your own git tools, commit, push, rerun. Never invent branch names or links.
|
|
30
|
+
|
|
31
|
+
Rules: direct command, 0 questions. Local git status, diff, commit and push use your own tools.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: implement
|
|
3
|
+
description: "Use when the user wants a story built: 'implement story 123', 'implementeer deze story', 'werk story 123 uit', 'start met de story'."
|
|
4
|
+
---
|
|
5
|
+
# Implement a story
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
A story id is known and code must change.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Read the story: `aihub story show 123`. Follow its acceptance criteria.
|
|
12
|
+
2. Create or switch to a feature branch with your own git tools, named per `team.yaml` (`branches.feature`).
|
|
13
|
+
3. Code and test with your own tools. Keep the change minimal.
|
|
14
|
+
4. Commit per the commit template ([default](../_shared/assets/commit-template.txt), or the team copy), one logical change per commit, story id in the message.
|
|
15
|
+
5. Push the own branch with git. Then follow pr-create.
|
|
16
|
+
|
|
17
|
+
Example: `aihub story show 123`, then `git switch -c feature/123-csv-export`, code, `git commit -m "feat: CSV export (#123)"`.
|
|
18
|
+
|
|
19
|
+
## What the CLI fills
|
|
20
|
+
The story text, links and the branch pattern. Do not ask the user for the story content or the commit format.
|
|
21
|
+
|
|
22
|
+
## If it fails
|
|
23
|
+
Unknown id: run `aihub doctor` and report. Requirement unclear: decide, and note the assumption in the PR instead of asking.
|
|
24
|
+
|
|
25
|
+
Rules: no ceremony. Local git status, diff, commit and push of the own branch use your own tools, never `aihub`. Commit language follows the team template. Never invent ids or links.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pipeline-fix
|
|
3
|
+
description: "Use when a build or pipeline failed: 'pipeline is rood', 'fix the build', 'de build faalt', 'tests falen in CI', a failed check on a pull request."
|
|
4
|
+
---
|
|
5
|
+
# Fix a failing pipeline
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
`aihub pipeline follow` or the PR reports a failed run.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Get the failing stage and log excerpt: `aihub pipeline follow`.
|
|
12
|
+
2. Reproduce locally with your own tools if cheap (same test or lint command).
|
|
13
|
+
3. Fix the cause, not the check. Never weaken a test.
|
|
14
|
+
4. Commit per the commit template, push the own branch with git.
|
|
15
|
+
5. Follow again until green:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
aihub pipeline follow
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Example: a red unit test gives a code fix, `git commit`, `git push`, `aihub pipeline follow`.
|
|
22
|
+
|
|
23
|
+
## What the CLI fills
|
|
24
|
+
Run id, failing step, trimmed log. Do not ask the user for run ids.
|
|
25
|
+
|
|
26
|
+
## If it fails
|
|
27
|
+
Log truncated or not signed in: `aihub doctor`. Infrastructure error (agent offline, quota): report it as such, do not change code. Never invent links.
|
|
28
|
+
|
|
29
|
+
Rules: direct task, 0 questions. Local git uses your own tools. Commit messages follow the team language.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-create
|
|
3
|
+
description: "Use when the user wants a pull request: 'maak een PR', 'create a PR', 'open a pull request', '/pr'."
|
|
4
|
+
---
|
|
5
|
+
# Create a pull request
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
Commits are pushed (or ready) on the own branch.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Check with git (own tools): `git status`, `git diff main...HEAD`. Push the branch if needed.
|
|
12
|
+
2. Write the description to a file following the team PR template ([default](../_shared/assets/pull_request_template.md)). State only what was really done and tested; write "not run" for the rest.
|
|
13
|
+
3. Run one command:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
aihub pr create --body-file pr.md
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
4. Show the PR link the CLI prints.
|
|
20
|
+
|
|
21
|
+
Example: `aihub pr create --body-file pr.md` creates the PR to the right target, linked to the story.
|
|
22
|
+
|
|
23
|
+
## What the CLI fills
|
|
24
|
+
Title, target branch and merge base, story link, reviewers, empty sections (`pullRequest.emptySection`) and the repository. Never ask the user about these.
|
|
25
|
+
|
|
26
|
+
## If it fails
|
|
27
|
+
Read the error text. Missing push: push, retry. Wrong target: run `aihub doctor`. Never invent links or ids.
|
|
28
|
+
|
|
29
|
+
Rules: a direct command is done at once with 0 questions. Content language follows the template. Local git uses your own tools.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-update
|
|
3
|
+
description: "Use when an open pull request needs new content: 'update de PR', 'update the PR description', 'werk de PR bij', '/pr-update', new commits were pushed."
|
|
4
|
+
---
|
|
5
|
+
# Update a pull request
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
The own branch has new commits or the description is out of date.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. With git (own tools): `git status`, push new commits.
|
|
12
|
+
2. See what changed on the PR: `aihub pr changes`.
|
|
13
|
+
3. Rewrite the description file from the template so it matches the current diff, keeping tested facts honest.
|
|
14
|
+
4. Run:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
aihub pr update --body-file pr.md
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Example: after a fix commit, `git push`, then `aihub pr update --body-file pr.md`.
|
|
21
|
+
|
|
22
|
+
## What the CLI fills
|
|
23
|
+
PR id from the current branch, title, template sections, links to the story. Do not ask the user for the PR id.
|
|
24
|
+
|
|
25
|
+
## If it fails
|
|
26
|
+
No PR for this branch: follow pr-create. Error unclear: run `aihub doctor`. Never invent ids or links.
|
|
27
|
+
|
|
28
|
+
Rules: direct command, 0 questions. Language follows the team template. Local git uses your own tools.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-watch
|
|
3
|
+
description: "Use when a PR or build must be followed: 'watch the PR', 'volg de build', 'is de pipeline groen', '/watch', a dev.azure.com pullrequest link."
|
|
4
|
+
---
|
|
5
|
+
# Watch a PR or pipeline
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
After creating or updating a PR, or when the user gives a PR link or id.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Follow the checks until they finish:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
aihub pipeline follow
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
2. Show state, failed stage and open review threads: `aihub pr changes`.
|
|
18
|
+
3. Green and no open threads: say so. Red: follow pipeline-fix. New comments: follow review-process.
|
|
19
|
+
|
|
20
|
+
While waiting, do not poll by hand and do not start other work on the same branch; `pipeline follow` returns when the run is finished. Report the final state in one short line per check.
|
|
21
|
+
|
|
22
|
+
Example: the link `.../pullrequest/42` gives `aihub pipeline follow --pr 42`.
|
|
23
|
+
|
|
24
|
+
## What the CLI fills
|
|
25
|
+
Branch, PR id, build id, log excerpt of the failing step. Do not ask the user for them.
|
|
26
|
+
|
|
27
|
+
## If it fails
|
|
28
|
+
Not signed in or no PR found: run `aihub doctor`. Report what the CLI printed; never guess a status.
|
|
29
|
+
|
|
30
|
+
Rules: direct command, 0 questions. Local git uses your own tools. Never invent ids or links.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release
|
|
3
|
+
description: "Use when several repositories or branches must be released together: 'maak een release', 'create a release', 'release alle repos', 'batch cherry-pick'."
|
|
4
|
+
---
|
|
5
|
+
# Release with batch
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
A release touches more than one repository or target branch.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Describe the batch in a file: repositories (names or aliases from `team.yaml`), source PRs, target release branches.
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
- repo: test-project
|
|
15
|
+
from: [42, 43]
|
|
16
|
+
to: [release/1.2]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Run it in one call:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
aihub batch --file release.yaml
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Show the resulting PR links per repository.
|
|
26
|
+
|
|
27
|
+
Example: two PRs to one release branch is one `release.yaml` and one command.
|
|
28
|
+
|
|
29
|
+
## What the CLI fills
|
|
30
|
+
Repository resolution, branch checks, ordering, one PR per target, summary table. Do not ask the user per repository.
|
|
31
|
+
|
|
32
|
+
## If it fails
|
|
33
|
+
One repo fails: the CLI reports it per repo; fix that one (see branch-sync) and rerun only it. Never invent ids or links.
|
|
34
|
+
|
|
35
|
+
Rules: direct command, 0 questions. Local git uses your own tools. Content language follows the team template.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-process
|
|
3
|
+
description: "Use when review comments must be handled: 'verwerk de comments', 'process the review', 'reageer op de review', '/review', open threads on a pull request."
|
|
4
|
+
---
|
|
5
|
+
# Process review comments
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
A PR has open reviewer threads.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Read them: `aihub comments get`.
|
|
12
|
+
2. Fix each valid point in code with your own tools. Commit per the commit template and push the own branch with git.
|
|
13
|
+
3. Write one reply per thread into a file, in the team language, short and factual (what changed, or why not):
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
- thread: 7
|
|
17
|
+
text: "Aangepast: null-check toegevoegd."
|
|
18
|
+
resolve: true
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
4. Send them in one call:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
aihub comments reply --replies-file replies.yaml
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Example: three threads give one `replies.yaml` with three entries and one command.
|
|
28
|
+
|
|
29
|
+
## What the CLI fills
|
|
30
|
+
PR id, thread lookup, author tags and status. Do not post replies one by one.
|
|
31
|
+
|
|
32
|
+
## If it fails
|
|
33
|
+
Unknown thread id: rerun `aihub comments get`. Disagree with a comment: say so in the reply, do not resolve. Never invent ids.
|
|
34
|
+
|
|
35
|
+
Rules: no questions for the direct command. Local git uses your own tools.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: start-here
|
|
3
|
+
description: "Use when the user starts an Azure DevOps team task and it is unclear which workflow applies, or sends a dev.azure.com link, a slash command, or says 'where do I start', 'waar begin ik', 'wat kan aihub', 'help met mijn story/PR'."
|
|
4
|
+
---
|
|
5
|
+
# Start here
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
Any Azure DevOps team request. Route it at once; do not explain the pack.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
Map the intent to a skill, then follow that skill:
|
|
12
|
+
|
|
13
|
+
| Intent or input | Skill |
|
|
14
|
+
|---|---|
|
|
15
|
+
| new story, "maak een story" | story-create |
|
|
16
|
+
| refine, "verfijn", story id without code | story-refine |
|
|
17
|
+
| build a story, "implementeer", "werk uit" | implement |
|
|
18
|
+
| "maak een PR", "create PR" | pr-create |
|
|
19
|
+
| "update de PR", new commits on open PR | pr-update |
|
|
20
|
+
| PR link `.../pullrequest/<id>`, "watch", "volg de build" | pr-watch |
|
|
21
|
+
| review comments, "verwerk de comments" | review-process |
|
|
22
|
+
| cherry-pick, "update branch", merge target | branch-sync |
|
|
23
|
+
| failing pipeline, "build is rood" | pipeline-fix |
|
|
24
|
+
| release, "maak een release", several repos | release |
|
|
25
|
+
|
|
26
|
+
Slash commands `/pr /pr-update /cherry-pick /story /refine /review /watch` map to the same skills.
|
|
27
|
+
|
|
28
|
+
Example: the user sends a pullrequest link, so follow pr-watch with that id.
|
|
29
|
+
|
|
30
|
+
## What the CLI fills
|
|
31
|
+
Templates, target branch, story links and repository come from `team.yaml` (see the [team schema](../_shared/references/team.schema.yaml)). Never ask the user for them.
|
|
32
|
+
|
|
33
|
+
## If it fails
|
|
34
|
+
Run `aihub doctor` and show its output. If `team.yaml` is missing, tell the user to run `aihub init` in the team repo.
|
|
35
|
+
|
|
36
|
+
Rules: a direct command ("maak een PR") is executed at once with 0 questions. Local git (status, diff, commit, push of the own branch) uses your own tools. Write content in the language of the team template. Never invent work item ids or links.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-create
|
|
3
|
+
description: "Use when the user wants a new user story or work item created: 'create a story', 'maak een story', 'nieuwe story', 'schrijf een story voor ...', '/story'."
|
|
4
|
+
---
|
|
5
|
+
# Create a story
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
The user describes new work and wants it in Azure DevOps.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Write the story text into a file following the team story template ([default](../_shared/assets/story-template.md), or the team's own copy). Fill only what the user said; leave unknown sections empty.
|
|
12
|
+
2. Run one command:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
aihub story create --title "Export report as CSV" --body-file story.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. Report the id and link the CLI prints. Do not guess them.
|
|
19
|
+
|
|
20
|
+
Example: "maak een story voor CSV-export" gives `aihub story create --title "CSV-export van het rapport" --body-file story.md` and then the printed id.
|
|
21
|
+
|
|
22
|
+
## What the CLI fills
|
|
23
|
+
Work item type, area and iteration, parent link, tags and the template skeleton come from `team.yaml` (`workItems`). Do not ask the user about template sections.
|
|
24
|
+
|
|
25
|
+
## If it fails
|
|
26
|
+
Missing field or template error: run `aihub doctor`, fix the file, retry once. Never invent a work item id or link.
|
|
27
|
+
|
|
28
|
+
Rules: a direct command is done at once with 0 questions. Write in the template language (for example Dutch). Local git uses your own tools.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-refine
|
|
3
|
+
description: "Use when an existing story must be refined or completed: 'refine story 123', 'verfijn deze story', 'vul de acceptatiecriteria aan', a dev.azure.com _workitems link, '/refine'."
|
|
4
|
+
---
|
|
5
|
+
# Refine a story
|
|
6
|
+
|
|
7
|
+
## When
|
|
8
|
+
A story exists but sections are vague, empty or missing.
|
|
9
|
+
|
|
10
|
+
## Steps
|
|
11
|
+
1. Read it: `aihub story show 123`.
|
|
12
|
+
2. Draft a proposal per template section in a file, using only facts from the story, the repo and what the user said. Mark guesses as open points.
|
|
13
|
+
3. Show the proposal per section to the user and wait for a yes. This is the one step where you ask.
|
|
14
|
+
4. After yes, apply it:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
aihub story refine 123 --body-file refined.md
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Example: the user says "verfijn 123". Run `aihub story show 123`, show the proposal, and after "ja" run `aihub story refine 123 --body-file refined.md`.
|
|
21
|
+
|
|
22
|
+
## What the CLI fills
|
|
23
|
+
Template headings, field mapping, history comment and links. Do not ask the user which sections exist.
|
|
24
|
+
|
|
25
|
+
## If it fails
|
|
26
|
+
Unknown id or no access: run `aihub doctor`, report the error text. Never invent ids or links.
|
|
27
|
+
|
|
28
|
+
Rules: write in the template language. Do not change code in this skill. Local git uses your own tools.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferronhooi/aihub",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.3",
|
|
4
4
|
"description": "One small CLI for Azure DevOps team workflows used by coding agents (stories, pull requests, reviews, cherry-picks).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"
|
|
12
|
+
"pack"
|
|
13
13
|
],
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=18"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"build": "tsc -p tsconfig.json && node scripts/copy-pack.mjs",
|
|
19
|
+
"prepack": "npm run build",
|
|
19
20
|
"test": "vitest run",
|
|
20
21
|
"lint:skills": "node dist/tools/lintSkills.js ../skills"
|
|
21
22
|
},
|