@baton-dx/cli 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/dist/context-detection-0m8_Fp0j.mjs +45 -0
- package/dist/context-detection-0m8_Fp0j.mjs.map +1 -0
- package/dist/create-CqfUSGj7.mjs +81 -0
- package/dist/create-CqfUSGj7.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3053 -0
- package/dist/index.mjs.map +1 -0
- package/dist/list-o76RXPxE.mjs +56 -0
- package/dist/list-o76RXPxE.mjs.map +1 -0
- package/dist/remove-BB883RDx.mjs +92 -0
- package/dist/remove-BB883RDx.mjs.map +1 -0
- package/dist/templates/profile/minimal/ai/memory/CLAUDE.md +3 -0
- package/dist/templates/profile/minimal/ai/memory/MEMORY.md +5 -0
- package/dist/templates/profile/minimal/baton.profile.yaml +11 -0
- package/dist/templates/profile/team/ai/commands/review.md +15 -0
- package/dist/templates/profile/team/ai/memory/CLAUDE.md +9 -0
- package/dist/templates/profile/team/ai/memory/MEMORY.md +11 -0
- package/dist/templates/profile/team/ai/rules/cursor/code-style.mdc +18 -0
- package/dist/templates/profile/team/ai/rules/universal/coding-standards.md +15 -0
- package/dist/templates/profile/team/ai/skills/code-review/SKILL.md +22 -0
- package/dist/templates/profile/team/baton.profile.yaml +33 -0
- package/dist/templates/profile/team/files/biome.json +17 -0
- package/dist/templates/profile/team/ide/vscode/extensions.json +3 -0
- package/dist/templates/profile/team/ide/vscode/settings.json +9 -0
- package/package.json +43 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { access } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/context-detection.ts
|
|
6
|
+
/**
|
|
7
|
+
* Check if the current directory is a source repository
|
|
8
|
+
* A source repository contains a baton.source.yaml file in the root
|
|
9
|
+
* @param cwd - Current working directory (defaults to process.cwd())
|
|
10
|
+
* @returns true if baton.source.yaml exists in cwd, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
async function isInSourceRepo(cwd = process.cwd()) {
|
|
13
|
+
const manifestPath = join(cwd, "baton.source.yaml");
|
|
14
|
+
try {
|
|
15
|
+
await access(manifestPath);
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Find the source repository root by searching upwards from cwd
|
|
23
|
+
* Checks the current directory and all parent directories for baton.source.yaml
|
|
24
|
+
* @param cwd - Starting directory (defaults to process.cwd())
|
|
25
|
+
* @param options.fallbackToStart - If true, return cwd instead of null when not found
|
|
26
|
+
* @returns The absolute path to the source root, or null (or cwd) if not found
|
|
27
|
+
*/
|
|
28
|
+
async function findSourceRoot(cwd = process.cwd(), options) {
|
|
29
|
+
let current = cwd;
|
|
30
|
+
while (true) {
|
|
31
|
+
const manifestPath = join(current, "baton.source.yaml");
|
|
32
|
+
try {
|
|
33
|
+
await access(manifestPath);
|
|
34
|
+
return current;
|
|
35
|
+
} catch {
|
|
36
|
+
const parent = dirname(current);
|
|
37
|
+
if (parent === current) return options?.fallbackToStart ? cwd : null;
|
|
38
|
+
current = parent;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { isInSourceRepo as n, findSourceRoot as t };
|
|
45
|
+
//# sourceMappingURL=context-detection-0m8_Fp0j.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-detection-0m8_Fp0j.mjs","names":[],"sources":["../src/utils/context-detection.ts"],"sourcesContent":["import { access } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\n/**\n * Check if the current directory is a source repository\n * A source repository contains a baton.source.yaml file in the root\n * @param cwd - Current working directory (defaults to process.cwd())\n * @returns true if baton.source.yaml exists in cwd, false otherwise\n */\nexport async function isInSourceRepo(cwd: string = process.cwd()): Promise<boolean> {\n const manifestPath = join(cwd, \"baton.source.yaml\");\n\n try {\n await access(manifestPath);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Find the source repository root by searching upwards from cwd\n * Checks the current directory and all parent directories for baton.source.yaml\n * @param cwd - Starting directory (defaults to process.cwd())\n * @param options.fallbackToStart - If true, return cwd instead of null when not found\n * @returns The absolute path to the source root, or null (or cwd) if not found\n */\nexport async function findSourceRoot(\n cwd: string = process.cwd(),\n options?: { fallbackToStart?: boolean },\n): Promise<string | null> {\n let current = cwd;\n\n while (true) {\n const manifestPath = join(current, \"baton.source.yaml\");\n try {\n await access(manifestPath);\n return current;\n } catch {\n const parent = dirname(current);\n if (parent === current) {\n return options?.fallbackToStart ? cwd : null;\n }\n current = parent;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,eAAsB,eAAe,MAAc,QAAQ,KAAK,EAAoB;CAClF,MAAM,eAAe,KAAK,KAAK,oBAAoB;AAEnD,KAAI;AACF,QAAM,OAAO,aAAa;AAC1B,SAAO;SACD;AACN,SAAO;;;;;;;;;;AAWX,eAAsB,eACpB,MAAc,QAAQ,KAAK,EAC3B,SACwB;CACxB,IAAI,UAAU;AAEd,QAAO,MAAM;EACX,MAAM,eAAe,KAAK,SAAS,oBAAoB;AACvD,MAAI;AACF,SAAM,OAAO,aAAa;AAC1B,UAAO;UACD;GACN,MAAM,SAAS,QAAQ,QAAQ;AAC/B,OAAI,WAAW,QACb,QAAO,SAAS,kBAAkB,MAAM;AAE1C,aAAU"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as findSourceRoot } from "./context-detection-0m8_Fp0j.mjs";
|
|
3
|
+
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import { KEBAB_CASE_REGEX } from "@baton-dx/core";
|
|
8
|
+
import * as p from "@clack/prompts";
|
|
9
|
+
import Handlebars from "handlebars";
|
|
10
|
+
|
|
11
|
+
//#region src/commands/profile/create.ts
|
|
12
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const createCommand = defineCommand({
|
|
14
|
+
meta: {
|
|
15
|
+
name: "create",
|
|
16
|
+
description: "Create a new profile in your source repository"
|
|
17
|
+
},
|
|
18
|
+
args: { name: {
|
|
19
|
+
type: "positional",
|
|
20
|
+
description: "Profile name (kebab-case)",
|
|
21
|
+
required: false
|
|
22
|
+
} },
|
|
23
|
+
async run({ args }) {
|
|
24
|
+
p.intro("Create Profile");
|
|
25
|
+
const sourceRoot = await findSourceRoot();
|
|
26
|
+
if (!sourceRoot) {
|
|
27
|
+
p.cancel("This command must be run inside a source directory (baton.source.yaml not found)");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
let name = args.name;
|
|
31
|
+
if (!name) {
|
|
32
|
+
const nameInput = await p.text({
|
|
33
|
+
message: "Profile name (kebab-case)",
|
|
34
|
+
placeholder: "e.g., backend, frontend, my-profile",
|
|
35
|
+
validate(value) {
|
|
36
|
+
if (!value || value.trim().length === 0) return "Profile name is required";
|
|
37
|
+
if (!KEBAB_CASE_REGEX.test(value.trim())) return "Profile name must be in kebab-case (e.g., my-profile, backend, frontend)";
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (p.isCancel(nameInput)) {
|
|
41
|
+
p.cancel("Cancelled.");
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
name = nameInput.trim();
|
|
45
|
+
}
|
|
46
|
+
if (!KEBAB_CASE_REGEX.test(name)) {
|
|
47
|
+
p.cancel("Profile name must be in kebab-case (e.g., my-profile, backend, frontend)");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const targetDir = join(sourceRoot, "profiles", name);
|
|
51
|
+
try {
|
|
52
|
+
await readdir(targetDir);
|
|
53
|
+
p.cancel(`Profile '${name}' already exists in profiles/${name}/`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
} catch {}
|
|
56
|
+
await mkdir(targetDir, { recursive: true });
|
|
57
|
+
await copyProfileTemplate(join(__dirname, "../src/templates/profile", "minimal"), targetDir, { name });
|
|
58
|
+
p.outro(`Profile '${name}' created in profiles/${name}/`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Recursively copy profile template with variable substitution
|
|
63
|
+
*/
|
|
64
|
+
async function copyProfileTemplate(sourceDir, targetDir, variables) {
|
|
65
|
+
const entries = await readdir(sourceDir, { withFileTypes: true });
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
const sourcePath = join(sourceDir, entry.name);
|
|
68
|
+
const targetPath = join(targetDir, entry.name);
|
|
69
|
+
if (entry.isDirectory()) {
|
|
70
|
+
await mkdir(targetPath, { recursive: true });
|
|
71
|
+
await copyProfileTemplate(sourcePath, targetPath, variables);
|
|
72
|
+
} else {
|
|
73
|
+
const content = await readFile(sourcePath, "utf-8");
|
|
74
|
+
await writeFile(targetPath, Handlebars.compile(content, { noEscape: true })(variables), "utf-8");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { createCommand };
|
|
81
|
+
//# sourceMappingURL=create-CqfUSGj7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-CqfUSGj7.mjs","names":[],"sources":["../src/commands/profile/create.ts"],"sourcesContent":["import { mkdir, readFile, readdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { KEBAB_CASE_REGEX } from \"@baton-dx/core\";\nimport * as p from \"@clack/prompts\";\nimport { defineCommand } from \"citty\";\nimport Handlebars from \"handlebars\";\nimport { findSourceRoot } from \"../../utils/context-detection.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const createCommand = defineCommand({\n meta: {\n name: \"create\",\n description: \"Create a new profile in your source repository\",\n },\n args: {\n name: {\n type: \"positional\",\n description: \"Profile name (kebab-case)\",\n required: false,\n },\n },\n async run({ args }) {\n p.intro(\"Create Profile\");\n\n // Check for baton.source.yaml in current or parent directories\n const sourceRoot = await findSourceRoot();\n if (!sourceRoot) {\n p.cancel(\"This command must be run inside a source directory (baton.source.yaml not found)\");\n process.exit(1);\n }\n\n // Get profile name — from argument or wizard prompt\n let name = args.name as string | undefined;\n\n if (!name) {\n const nameInput = await p.text({\n message: \"Profile name (kebab-case)\",\n placeholder: \"e.g., backend, frontend, my-profile\",\n validate(value) {\n if (!value || value.trim().length === 0) {\n return \"Profile name is required\";\n }\n if (!KEBAB_CASE_REGEX.test(value.trim())) {\n return \"Profile name must be in kebab-case (e.g., my-profile, backend, frontend)\";\n }\n },\n });\n\n if (p.isCancel(nameInput)) {\n p.cancel(\"Cancelled.\");\n process.exit(0);\n }\n\n name = (nameInput as string).trim();\n }\n\n // Validate name format (kebab-case)\n if (!KEBAB_CASE_REGEX.test(name)) {\n p.cancel(\"Profile name must be in kebab-case (e.g., my-profile, backend, frontend)\");\n process.exit(1);\n }\n\n // Check if profile already exists in profiles/ directory\n const targetDir = join(sourceRoot, \"profiles\", name);\n try {\n await readdir(targetDir);\n p.cancel(`Profile '${name}' already exists in profiles/${name}/`);\n process.exit(1);\n } catch {\n // Directory doesn't exist - good to proceed\n }\n\n // Create profile directory\n await mkdir(targetDir, { recursive: true });\n\n // Copy minimal template files\n const templateDir = join(__dirname, \"../src/templates/profile\", \"minimal\");\n await copyProfileTemplate(templateDir, targetDir, { name });\n\n p.outro(`Profile '${name}' created in profiles/${name}/`);\n },\n});\n\n/**\n * Recursively copy profile template with variable substitution\n */\nasync function copyProfileTemplate(\n sourceDir: string,\n targetDir: string,\n variables: { name: string },\n): Promise<void> {\n const entries = await readdir(sourceDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const sourcePath = join(sourceDir, entry.name);\n const targetPath = join(targetDir, entry.name);\n\n if (entry.isDirectory()) {\n await mkdir(targetPath, { recursive: true });\n await copyProfileTemplate(sourcePath, targetPath, variables);\n } else {\n // Read file content\n const content = await readFile(sourcePath, \"utf-8\");\n\n // Apply Handlebars substitution for text files\n const processed = Handlebars.compile(content, { noEscape: true })(variables);\n\n // Write processed content\n await writeFile(targetPath, processed, \"utf-8\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAa,gBAAgB,cAAc;CACzC,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM,EACJ,MAAM;EACJ,MAAM;EACN,aAAa;EACb,UAAU;EACX,EACF;CACD,MAAM,IAAI,EAAE,QAAQ;AAClB,IAAE,MAAM,iBAAiB;EAGzB,MAAM,aAAa,MAAM,gBAAgB;AACzC,MAAI,CAAC,YAAY;AACf,KAAE,OAAO,mFAAmF;AAC5F,WAAQ,KAAK,EAAE;;EAIjB,IAAI,OAAO,KAAK;AAEhB,MAAI,CAAC,MAAM;GACT,MAAM,YAAY,MAAM,EAAE,KAAK;IAC7B,SAAS;IACT,aAAa;IACb,SAAS,OAAO;AACd,SAAI,CAAC,SAAS,MAAM,MAAM,CAAC,WAAW,EACpC,QAAO;AAET,SAAI,CAAC,iBAAiB,KAAK,MAAM,MAAM,CAAC,CACtC,QAAO;;IAGZ,CAAC;AAEF,OAAI,EAAE,SAAS,UAAU,EAAE;AACzB,MAAE,OAAO,aAAa;AACtB,YAAQ,KAAK,EAAE;;AAGjB,UAAQ,UAAqB,MAAM;;AAIrC,MAAI,CAAC,iBAAiB,KAAK,KAAK,EAAE;AAChC,KAAE,OAAO,2EAA2E;AACpF,WAAQ,KAAK,EAAE;;EAIjB,MAAM,YAAY,KAAK,YAAY,YAAY,KAAK;AACpD,MAAI;AACF,SAAM,QAAQ,UAAU;AACxB,KAAE,OAAO,YAAY,KAAK,+BAA+B,KAAK,GAAG;AACjE,WAAQ,KAAK,EAAE;UACT;AAKR,QAAM,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;AAI3C,QAAM,oBADc,KAAK,WAAW,4BAA4B,UAAU,EACnC,WAAW,EAAE,MAAM,CAAC;AAE3D,IAAE,MAAM,YAAY,KAAK,wBAAwB,KAAK,GAAG;;CAE5D,CAAC;;;;AAKF,eAAe,oBACb,WACA,WACA,WACe;CACf,MAAM,UAAU,MAAM,QAAQ,WAAW,EAAE,eAAe,MAAM,CAAC;AAEjE,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,aAAa,KAAK,WAAW,MAAM,KAAK;EAC9C,MAAM,aAAa,KAAK,WAAW,MAAM,KAAK;AAE9C,MAAI,MAAM,aAAa,EAAE;AACvB,SAAM,MAAM,YAAY,EAAE,WAAW,MAAM,CAAC;AAC5C,SAAM,oBAAoB,YAAY,YAAY,UAAU;SACvD;GAEL,MAAM,UAAU,MAAM,SAAS,YAAY,QAAQ;AAMnD,SAAM,UAAU,YAHE,WAAW,QAAQ,SAAS,EAAE,UAAU,MAAM,CAAC,CAAC,UAAU,EAGrC,QAAQ"}
|
package/dist/index.d.mts
ADDED