bdy 1.23.4-dev-target-commands → 1.23.4-dev

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.
Files changed (54) hide show
  1. package/distTs/README.md +181 -0
  2. package/distTs/package.json +1 -3
  3. package/distTs/src/agent/agent.js +35 -2
  4. package/distTs/src/agent/manager.js +11 -0
  5. package/distTs/src/agent/system.js +6 -1
  6. package/distTs/src/api/client.js +0 -156
  7. package/distTs/src/cliIndex.js +0 -4
  8. package/distTs/src/command/artifact/list.js +6 -1
  9. package/distTs/src/command/distro/route/update.js +1 -1
  10. package/distTs/src/command/distro/update.js +9 -9
  11. package/distTs/src/command/project/get.js +18 -0
  12. package/distTs/src/command/project/set.js +31 -0
  13. package/distTs/src/command/sandbox/get/yaml.js +30 -0
  14. package/distTs/src/command/vt/scrape.js +193 -0
  15. package/distTs/src/input.js +0 -54
  16. package/distTs/src/texts.js +8 -196
  17. package/distTs/src/utils.js +7 -16
  18. package/package.json +1 -3
  19. package/distTs/detect-rules.json +0 -351
  20. package/distTs/src/command/environment/create.js +0 -70
  21. package/distTs/src/command/environment/delete.js +0 -29
  22. package/distTs/src/command/environment/get.js +0 -48
  23. package/distTs/src/command/environment/list.js +0 -44
  24. package/distTs/src/command/environment/resolve.js +0 -22
  25. package/distTs/src/command/environment/update.js +0 -59
  26. package/distTs/src/command/environment.js +0 -20
  27. package/distTs/src/command/pipeline/run/apply.js +0 -62
  28. package/distTs/src/command/target/create.js +0 -33
  29. package/distTs/src/command/target/delete.js +0 -30
  30. package/distTs/src/command/target/exec/command.js +0 -65
  31. package/distTs/src/command/target/exec/kill.js +0 -25
  32. package/distTs/src/command/target/exec/list.js +0 -54
  33. package/distTs/src/command/target/exec/logs.js +0 -25
  34. package/distTs/src/command/target/exec/status.js +0 -41
  35. package/distTs/src/command/target/exec.js +0 -24
  36. package/distTs/src/command/target/get.js +0 -62
  37. package/distTs/src/command/target/list.js +0 -48
  38. package/distTs/src/command/target/scope.js +0 -60
  39. package/distTs/src/command/target/update.js +0 -31
  40. package/distTs/src/command/target.js +0 -22
  41. package/distTs/src/command/yaml/actions/detect.js +0 -268
  42. package/distTs/src/command/yaml/actions/info.js +0 -56
  43. package/distTs/src/command/yaml/actions/list.js +0 -70
  44. package/distTs/src/command/yaml/actions/schema.js +0 -104
  45. package/distTs/src/command/yaml/actions.js +0 -13
  46. package/distTs/src/command/yaml/agents.js +0 -88
  47. package/distTs/src/command/yaml/cache.js +0 -98
  48. package/distTs/src/command/yaml/init.js +0 -110
  49. package/distTs/src/command/yaml/pipeline.js +0 -42
  50. package/distTs/src/command/yaml/render.js +0 -83
  51. package/distTs/src/command/yaml/schemaUtils.js +0 -139
  52. package/distTs/src/command/yaml/validate.js +0 -259
  53. package/distTs/src/command/yaml.js +0 -18
  54. package/distTs/src/diskCache.js +0 -82
@@ -1,268 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.detectActions = detectActions;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
9
- const picomatch_1 = __importDefault(require("picomatch"));
10
- const utils_1 = require("../../../utils");
11
- const cache_1 = require("../cache");
12
- const DETECT_CACHE_TTL = 10 * 60 * 1000; // 10 minutes
13
- const DETECT_CACHE_PREFIX = 'detect:';
14
- let cachedRules = null;
15
- function loadDetectRules() {
16
- if (cachedRules)
17
- return cachedRules;
18
- const filePath = path_1.default.resolve((0, utils_1.getRootDir)(), 'detect-rules.json');
19
- cachedRules = JSON.parse((0, fs_1.readFileSync)(filePath, 'utf8'));
20
- return cachedRules;
21
- }
22
- function safeReadDir(dir) {
23
- try {
24
- return (0, fs_1.readdirSync)(dir, { withFileTypes: true });
25
- }
26
- catch {
27
- return [];
28
- }
29
- }
30
- function readDirIndex(dir) {
31
- const names = [];
32
- const lowerNames = new Set();
33
- const lowerDirs = new Set();
34
- for (const entry of safeReadDir(dir)) {
35
- names.push(entry.name);
36
- lowerNames.add(entry.name.toLowerCase());
37
- if (entry.isDirectory())
38
- lowerDirs.add(entry.name.toLowerCase());
39
- }
40
- return { names, lowerNames, lowerDirs };
41
- }
42
- function existsCaseInsensitive(dir, relPath, mustBeDir) {
43
- const segments = relPath.split('/').filter(Boolean);
44
- if (segments.length === 0)
45
- return false;
46
- let current = dir;
47
- for (let i = 0; i < segments.length; i++) {
48
- const lower = segments[i].toLowerCase();
49
- const found = safeReadDir(current).find((e) => e.name.toLowerCase() === lower);
50
- if (!found)
51
- return false;
52
- if (i === segments.length - 1 && mustBeDir && !found.isDirectory())
53
- return false;
54
- current = path_1.default.join(current, found.name);
55
- }
56
- return true;
57
- }
58
- function fileMatchesAny(patterns, dir, index) {
59
- for (const pattern of patterns) {
60
- if (pattern.includes('*')) {
61
- const isMatch = (0, picomatch_1.default)(pattern, { nocase: true, dot: true });
62
- if (index.names.some((name) => isMatch(name)))
63
- return true;
64
- }
65
- else if (pattern.includes('/')) {
66
- const mustBeDir = pattern.endsWith('/');
67
- const rel = mustBeDir ? pattern.slice(0, -1) : pattern;
68
- if (rel.includes('/')) {
69
- if (existsCaseInsensitive(dir, rel, mustBeDir))
70
- return true;
71
- }
72
- else if (mustBeDir) {
73
- if (index.lowerDirs.has(rel.toLowerCase()))
74
- return true;
75
- }
76
- else if (index.lowerNames.has(rel.toLowerCase())) {
77
- return true;
78
- }
79
- }
80
- else if (index.lowerNames.has(pattern.toLowerCase())) {
81
- return true;
82
- }
83
- }
84
- return false;
85
- }
86
- function parsePackageJson(content) {
87
- const pkg = JSON.parse(content);
88
- return Object.keys({ ...pkg.dependencies, ...pkg.devDependencies });
89
- }
90
- function parseRequirementsTxt(content) {
91
- const names = [];
92
- for (const line of content.split('\n')) {
93
- const trimmed = line.trim();
94
- if (trimmed && !trimmed.startsWith('#') && !trimmed.startsWith('-')) {
95
- names.push(trimmed.split(/[>=<!~[;]/)[0].trim());
96
- }
97
- }
98
- return names;
99
- }
100
- function parseComposerJson(content) {
101
- const composer = JSON.parse(content);
102
- return Object.keys({ ...composer.require, ...composer['require-dev'] });
103
- }
104
- function parseGoMod(content) {
105
- const names = [];
106
- const requireBlocks = content.match(/require\s*\(([\s\S]*?)\)/g);
107
- if (requireBlocks) {
108
- for (const block of requireBlocks) {
109
- for (const line of block.split('\n')) {
110
- const trimmed = line.trim();
111
- if (trimmed && !trimmed.startsWith('//') && !trimmed.startsWith('require') && trimmed !== ')') {
112
- names.push(trimmed.split(/\s/)[0]);
113
- }
114
- }
115
- }
116
- }
117
- const singleReqs = content.match(/^require\s+(\S+)/gm);
118
- if (singleReqs) {
119
- for (const req of singleReqs)
120
- names.push(req.replace(/^require\s+/, '').trim());
121
- }
122
- return names;
123
- }
124
- function parseGemfile(content) {
125
- const names = [];
126
- for (const line of content.split('\n')) {
127
- const match = line.match(/^\s*gem\s+['"]([^'"]+)['"]/);
128
- if (match)
129
- names.push(match[1]);
130
- }
131
- return names;
132
- }
133
- function parsePubspec(content) {
134
- const YAML = require('yaml');
135
- const pubspec = YAML.parse(content) || {};
136
- return [
137
- ...Object.keys(pubspec.dependencies || {}),
138
- ...Object.keys(pubspec.dev_dependencies || {}),
139
- ];
140
- }
141
- function parseCargoToml(content) {
142
- const names = [];
143
- const depSection = content.match(/\[dependencies]([\s\S]*?)(?=\n\[|$)/);
144
- if (depSection) {
145
- for (const line of depSection[1].split('\n')) {
146
- const match = line.match(/^(\S+)\s*=/);
147
- if (match)
148
- names.push(match[1]);
149
- }
150
- }
151
- return names;
152
- }
153
- function parsePomXml(content) {
154
- const names = [];
155
- const artifacts = content.match(/<artifactId>([^<]+)<\/artifactId>/g);
156
- if (artifacts) {
157
- for (const a of artifacts)
158
- names.push(a.replace(/<\/?artifactId>/g, ''));
159
- }
160
- return names;
161
- }
162
- function parseGradle(content) {
163
- const names = [];
164
- const deps = content.match(/(?:implementation|api|compile|testImplementation)\s*[('"]([^'"()]+)['")\s]/g);
165
- if (deps) {
166
- for (const d of deps) {
167
- const match = d.match(/['"]([^'"]+)['"]/);
168
- if (match)
169
- names.push(match[1]);
170
- }
171
- }
172
- return names;
173
- }
174
- function parsePyproject(content) {
175
- const names = [];
176
- const depMatch = content.match(/dependencies\s*=\s*\[([\s\S]*?)]/);
177
- if (depMatch) {
178
- const items = depMatch[1].match(/["']([^"'>=<![;]+)/g);
179
- if (items) {
180
- for (const item of items)
181
- names.push(item.replace(/^["']/, '').trim());
182
- }
183
- }
184
- return names;
185
- }
186
- const MANIFEST_PARSERS = [
187
- { file: 'package.json', parse: parsePackageJson },
188
- { file: 'requirements.txt', parse: parseRequirementsTxt },
189
- { file: 'composer.json', parse: parseComposerJson },
190
- { file: 'go.mod', parse: parseGoMod },
191
- { file: 'Gemfile', parse: parseGemfile },
192
- { file: 'pubspec.yaml', parse: parsePubspec },
193
- { file: 'Cargo.toml', parse: parseCargoToml },
194
- { file: 'pom.xml', parse: parsePomXml },
195
- { file: 'build.gradle', parse: parseGradle },
196
- { file: 'build.gradle.kts', parse: parseGradle },
197
- { file: 'pyproject.toml', parse: parsePyproject },
198
- ];
199
- const LOCKFILES = ['package-lock.json', 'composer.lock', 'go.sum', 'Gemfile.lock', 'pubspec.lock', 'Cargo.lock'];
200
- const MANIFEST_FILES = [...new Set(MANIFEST_PARSERS.map((p) => p.file)), ...LOCKFILES];
201
- function readPackageNames(dir) {
202
- const packages = new Set();
203
- for (const { file, parse } of MANIFEST_PARSERS) {
204
- const filePath = path_1.default.join(dir, file);
205
- if (!(0, fs_1.existsSync)(filePath))
206
- continue;
207
- try {
208
- for (const name of parse((0, fs_1.readFileSync)(filePath, 'utf8'))) {
209
- if (name)
210
- packages.add(name);
211
- }
212
- }
213
- catch {
214
- // ignore malformed manifests
215
- }
216
- }
217
- return packages;
218
- }
219
- function packageMatchesPattern(pkg, pattern) {
220
- if (pattern.endsWith('/*')) {
221
- const prefix = pattern.slice(0, -2);
222
- return pkg.startsWith(prefix + '/');
223
- }
224
- return pkg === pattern;
225
- }
226
- function scanActions(dir) {
227
- const rules = loadDetectRules();
228
- const packages = readPackageNames(dir);
229
- const detectedTypes = [];
230
- const index = readDirIndex(dir);
231
- for (const [type, rule] of Object.entries(rules)) {
232
- let matched = false;
233
- if (rule.files) {
234
- matched = fileMatchesAny(rule.files, dir, index);
235
- }
236
- if (!matched && rule.packages) {
237
- for (const pkgPattern of rule.packages) {
238
- for (const pkg of packages) {
239
- if (packageMatchesPattern(pkg, pkgPattern)) {
240
- matched = true;
241
- break;
242
- }
243
- }
244
- if (matched)
245
- break;
246
- }
247
- }
248
- if (matched) {
249
- detectedTypes.push(type);
250
- }
251
- }
252
- return detectedTypes;
253
- }
254
- let pruneScheduled = false;
255
- function detectActions(dir) {
256
- const cacheKey = DETECT_CACHE_PREFIX + dir;
257
- const fingerprint = (0, cache_1.fingerprintFiles)(dir, MANIFEST_FILES);
258
- const cached = (0, cache_1.getCache)(cacheKey, fingerprint);
259
- if (cached)
260
- return new Set(cached);
261
- const detected = scanActions(dir);
262
- (0, cache_1.setCache)(cacheKey, fingerprint, detected, DETECT_CACHE_TTL);
263
- if (!pruneScheduled) {
264
- pruneScheduled = true;
265
- process.nextTick(() => (0, cache_1.pruneCache)());
266
- }
267
- return new Set(detected);
268
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../../../utils");
7
- const output_1 = __importDefault(require("../../../output"));
8
- const texts_1 = require("../../../texts");
9
- const schema_1 = require("./schema");
10
- const schemaUtils_1 = require("../schemaUtils");
11
- const detect_1 = require("./detect");
12
- const render_1 = require("../render");
13
- const commandYamlActionsInfo = (0, utils_1.newCommand)('info', texts_1.DESC_COMMAND_YAML_ACTIONS_INFO);
14
- commandYamlActionsInfo.argument('<type>', texts_1.OPTION_ACTION_TYPE);
15
- commandYamlActionsInfo.action(async (type) => {
16
- await (0, schemaUtils_1.ensureYamlSchema)();
17
- const actions = (0, schema_1.loadSchema)();
18
- const action = (0, schema_1.findAction)(actions, type);
19
- if (!action) {
20
- output_1.default.error((0, texts_1.ERR_ACTION_NOT_FOUND)(type));
21
- const suggestions = (0, schema_1.suggestActions)(actions, type);
22
- if (suggestions.length > 0) {
23
- output_1.default.muted((0, texts_1.TXT_ACTION_DID_YOU_MEAN)(suggestions.map((a) => `${a.type} (${a.name})`).join(', ')));
24
- }
25
- else {
26
- const detectedTypes = (0, detect_1.detectActions)(process.cwd());
27
- if (detectedTypes.size > 0) {
28
- const detected = actions.filter((a) => detectedTypes.has(a.type)).slice(0, 5);
29
- output_1.default.muted(`Suggested based on your repo: ${detected.map((a) => `${a.type} (${a.name})`).join(', ')}`);
30
- }
31
- }
32
- output_1.default.muted(texts_1.TXT_ACTION_USE_LIST);
33
- output_1.default.exitNormal();
34
- return;
35
- }
36
- output_1.default.blue(action.name, false);
37
- output_1.default.gray(` · ${action.type}`);
38
- output_1.default.gray(action.description);
39
- output_1.default.normal('');
40
- const { common, specific } = (0, schema_1.splitProperties)(action);
41
- if (Object.keys(specific).length > 0) {
42
- output_1.default.blue('Type-specific fields');
43
- (0, render_1.outputProperties)(specific, action.required);
44
- output_1.default.normal('');
45
- }
46
- if (Object.keys(common).length > 0) {
47
- output_1.default.blue('Common fields');
48
- (0, render_1.outputProperties)(common, action.required);
49
- }
50
- if (action.examples.length > 0) {
51
- output_1.default.normal('');
52
- (0, render_1.outputExamples)(action.examples);
53
- }
54
- output_1.default.exitNormal();
55
- });
56
- exports.default = commandYamlActionsInfo;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../../../utils");
7
- const output_1 = __importDefault(require("../../../output"));
8
- const texts_1 = require("../../../texts");
9
- const schema_1 = require("./schema");
10
- const schemaUtils_1 = require("../schemaUtils");
11
- const detect_1 = require("./detect");
12
- function actionTable(actions) {
13
- const data = [['TYPE', 'NAME', 'DESCRIPTION']];
14
- for (const action of actions) {
15
- const desc = action.description.length > 80
16
- ? action.description.substring(0, 77) + '...'
17
- : action.description;
18
- data.push([action.type, action.name, desc]);
19
- }
20
- return data;
21
- }
22
- const commandYamlActionsList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_YAML_ACTIONS_LIST);
23
- commandYamlActionsList.alias('ls');
24
- commandYamlActionsList.option('-s, --search <query>', texts_1.OPTION_ACTION_SEARCH);
25
- commandYamlActionsList.action(async (options) => {
26
- await (0, schemaUtils_1.ensureYamlSchema)();
27
- const actions = (0, schema_1.loadSchema)();
28
- const detectedTypes = (0, detect_1.detectActions)(process.cwd());
29
- if (options.search) {
30
- const index = (0, schema_1.createActionIndex)(actions);
31
- const hits = index.search(options.search);
32
- const slugSet = new Set(hits.map((h) => h.id));
33
- const results = actions.filter((a) => slugSet.has(a.slug));
34
- results.sort((a, b) => {
35
- const ai = hits.findIndex((h) => h.id === a.slug);
36
- const bi = hits.findIndex((h) => h.id === b.slug);
37
- return ai - bi;
38
- });
39
- if (results.length === 0) {
40
- const suggestions = index.autoSuggest(options.search);
41
- output_1.default.error((0, texts_1.ERR_ACTION_SEARCH_NO_RESULTS)(options.search));
42
- if (suggestions.length > 0) {
43
- output_1.default.muted((0, texts_1.TXT_ACTION_DID_YOU_MEAN)(suggestions.map((s) => s.suggestion).join(', ')));
44
- }
45
- if (detectedTypes.size > 0) {
46
- const detected = actions.filter((a) => detectedTypes.has(a.type));
47
- output_1.default.normal('');
48
- output_1.default.blue('Suggested based on your repo');
49
- output_1.default.table(actionTable(detected));
50
- }
51
- output_1.default.muted(texts_1.TXT_ACTION_USE_LIST);
52
- output_1.default.exitNormal();
53
- return;
54
- }
55
- output_1.default.table(actionTable(results));
56
- output_1.default.exitNormal();
57
- return;
58
- }
59
- const byType = (a, b) => a.type.localeCompare(b.type);
60
- if (detectedTypes.size > 0) {
61
- const detected = actions.filter((a) => detectedTypes.has(a.type)).sort(byType);
62
- output_1.default.blue('Suggested');
63
- output_1.default.table(actionTable(detected));
64
- output_1.default.normal('');
65
- }
66
- output_1.default.blue(`All actions (${actions.length})`);
67
- output_1.default.table(actionTable([...actions].sort(byType)));
68
- output_1.default.exitNormal();
69
- });
70
- exports.default = commandYamlActionsList;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadSchema = loadSchema;
4
- exports.getCommonFields = getCommonFields;
5
- exports.splitProperties = splitProperties;
6
- exports.findAction = findAction;
7
- exports.createActionIndex = createActionIndex;
8
- exports.suggestActions = suggestActions;
9
- const schemaUtils_1 = require("../schemaUtils");
10
- let memCached = null;
11
- function deriveSlug(defKey) {
12
- const base = defKey.replace(/ActionYaml$/, '');
13
- return base
14
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
15
- .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
16
- .toLowerCase();
17
- }
18
- function parseSchema(raw) {
19
- const defs = raw.$defs || {};
20
- const actionKeys = Object.keys(defs).filter((k) => k.endsWith('ActionYaml') && defs[k].deprecated !== true);
21
- const sharedDefs = (0, schemaUtils_1.getSharedDefs)();
22
- return actionKeys.map((key) => {
23
- const def = defs[key];
24
- const typeConst = def.properties?.type?.const || def.properties?.type?.enum?.[0] || '';
25
- const properties = def.properties ? (0, schemaUtils_1.resolveRefs)(def.properties, sharedDefs) : {};
26
- return {
27
- key,
28
- slug: deriveSlug(key),
29
- name: def['x-name'] || def.title || key,
30
- type: typeConst,
31
- description: def.description || '',
32
- properties,
33
- required: def.required || [],
34
- examples: def.examples || [],
35
- tags: [...new Set([
36
- ...(def['x-tags'] || []),
37
- ...((def['x-subtypes'] || []).flatMap((s) => s['x-tags'] || [])),
38
- ])],
39
- };
40
- });
41
- }
42
- function loadSchema() {
43
- if (memCached)
44
- return memCached;
45
- const raw = (0, schemaUtils_1.loadRawSchema)();
46
- memCached = parseSchema(raw);
47
- return memCached;
48
- }
49
- let commonCached = null;
50
- // Fields common to every action = intersection of property keys across all actions.
51
- function getCommonFields() {
52
- if (commonCached)
53
- return commonCached;
54
- const actions = loadSchema();
55
- let common = null;
56
- for (const action of actions) {
57
- const keys = Object.keys(action.properties);
58
- if (common === null) {
59
- common = new Set(keys);
60
- }
61
- else {
62
- common = new Set(keys.filter((k) => common.has(k)));
63
- }
64
- }
65
- commonCached = common || new Set();
66
- return commonCached;
67
- }
68
- function splitProperties(action) {
69
- const commonFields = getCommonFields();
70
- const common = {};
71
- const specific = {};
72
- for (const [key, prop] of Object.entries(action.properties)) {
73
- if (commonFields.has(key))
74
- common[key] = prop;
75
- else
76
- specific[key] = prop;
77
- }
78
- return { common, specific };
79
- }
80
- function findAction(actions, query) {
81
- const q = query.toLowerCase();
82
- return (actions.find((a) => a.slug === q) ||
83
- actions.find((a) => a.type.toLowerCase() === q));
84
- }
85
- function createActionIndex(actions) {
86
- const MiniSearch = require('minisearch');
87
- const index = new MiniSearch({
88
- fields: ['name', 'type', 'description', 'tags'],
89
- storeFields: ['slug'],
90
- searchOptions: {
91
- boost: { name: 3, type: 2, tags: 2, description: 1 },
92
- prefix: true,
93
- fuzzy: 0.3,
94
- combineWith: 'OR',
95
- },
96
- });
97
- index.addAll(actions.map((a) => ({ id: a.slug, name: a.name, type: a.type, description: a.description, tags: a.tags.join(' '), slug: a.slug })));
98
- return index;
99
- }
100
- function suggestActions(actions, query, limit = 5) {
101
- const hits = createActionIndex(actions).search(query).slice(0, limit);
102
- const bySlug = new Map(actions.map((a) => [a.slug, a]));
103
- return hits.map((h) => bySlug.get(h.id)).filter(Boolean);
104
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../../utils");
7
- const texts_1 = require("../../texts");
8
- const list_1 = __importDefault(require("./actions/list"));
9
- const info_1 = __importDefault(require("./actions/info"));
10
- const commandYamlActions = (0, utils_1.newCommand)('actions', texts_1.DESC_COMMAND_YAML_ACTIONS);
11
- commandYamlActions.addCommand(list_1.default);
12
- commandYamlActions.addCommand(info_1.default);
13
- exports.default = commandYamlActions;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AGENTS = void 0;
7
- exports.getAgentById = getAgentById;
8
- exports.detectExistingAgents = detectExistingAgents;
9
- exports.writeAgentInstructions = writeAgentInstructions;
10
- exports.updateExistingAgentInstructions = updateExistingAgentInstructions;
11
- exports.getUniqueAgentFiles = getUniqueAgentFiles;
12
- const fs_1 = require("fs");
13
- const path_1 = __importDefault(require("path"));
14
- const output_1 = __importDefault(require("../../output"));
15
- const texts_1 = require("../../texts");
16
- exports.AGENTS = [
17
- { id: 'claude', name: 'Claude Code', file: 'CLAUDE.md' },
18
- { id: 'chatgpt-codex', name: 'ChatGPT / Codex', file: 'AGENTS.md' },
19
- { id: 'gemini', name: 'Gemini CLI', file: 'GEMINI.md' },
20
- { id: 'copilot', name: 'GitHub Copilot', file: '.github/copilot-instructions.md' },
21
- { id: 'cursor', name: 'Cursor', file: '.cursor/rules/bdy.mdc' },
22
- { id: 'windsurf', name: 'Windsurf', file: '.windsurf/rules/bdy.md' },
23
- { id: 'jetbrains', name: 'JetBrains AI', file: '.aiassistant/rules/bdy.md' },
24
- { id: 'amp', name: 'Amp', file: 'AGENTS.md' },
25
- ];
26
- const MARKER_START = '<!--BDY START-->';
27
- const MARKER_END = '<!--BDY END-->';
28
- const MARKER_REGEX = /<!--BDY START-->[\s\S]*?<!--BDY END-->/;
29
- function wrapWithMarkers(content) {
30
- return `${MARKER_START}\n${content.trimEnd()}\n${MARKER_END}`;
31
- }
32
- function getAgentById(id) {
33
- return exports.AGENTS.find(a => a.id === id);
34
- }
35
- function detectExistingAgents(dir) {
36
- return exports.AGENTS.filter(agent => (0, fs_1.existsSync)(path_1.default.resolve(dir, agent.file)));
37
- }
38
- async function writeAgentInstructions(filePath, section) {
39
- const wrapped = wrapWithMarkers(section);
40
- const dir = path_1.default.dirname(filePath);
41
- if (!(0, fs_1.existsSync)(dir)) {
42
- (0, fs_1.mkdirSync)(dir, { recursive: true });
43
- }
44
- if (!(0, fs_1.existsSync)(filePath)) {
45
- (0, fs_1.writeFileSync)(filePath, wrapped + '\n', 'utf8');
46
- return 'created';
47
- }
48
- const content = (0, fs_1.readFileSync)(filePath, 'utf8');
49
- if (MARKER_REGEX.test(content)) {
50
- const updated = content.replace(MARKER_REGEX, wrapped);
51
- (0, fs_1.writeFileSync)(filePath, updated, 'utf8');
52
- return 'updated';
53
- }
54
- const shouldAppend = await output_1.default.confirm((0, texts_1.TXT_YAML_INIT_APPEND_CONFIRM)(path_1.default.basename(filePath)));
55
- if (!shouldAppend) {
56
- return 'skipped';
57
- }
58
- (0, fs_1.writeFileSync)(filePath, content.trimEnd() + '\n\n' + wrapped + '\n', 'utf8');
59
- return 'appended';
60
- }
61
- function updateExistingAgentInstructions(dir, section) {
62
- const wrapped = wrapWithMarkers(section);
63
- const updated = [];
64
- for (const agent of exports.AGENTS) {
65
- const filePath = path_1.default.resolve(dir, agent.file);
66
- if (!(0, fs_1.existsSync)(filePath))
67
- continue;
68
- const content = (0, fs_1.readFileSync)(filePath, 'utf8');
69
- if (!MARKER_REGEX.test(content))
70
- continue;
71
- const newContent = content.replace(MARKER_REGEX, wrapped);
72
- (0, fs_1.writeFileSync)(filePath, newContent, 'utf8');
73
- updated.push(agent.file);
74
- }
75
- return updated;
76
- }
77
- function getUniqueAgentFiles(agentIds) {
78
- const fileMap = new Map();
79
- for (const id of agentIds) {
80
- const agent = getAgentById(id);
81
- if (!agent)
82
- continue;
83
- const existing = fileMap.get(agent.file) || [];
84
- existing.push(agent);
85
- fileMap.set(agent.file, existing);
86
- }
87
- return Array.from(fileMap.entries()).map(([file, agents]) => ({ file, agents }));
88
- }