@technomoron/agent-run 0.99.23 → 0.99.25

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.
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = main;
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const checks_1 = require("./checks");
7
+ const cli_1 = require("./cli");
8
+ const config_tree_1 = require("./config-tree");
9
+ const constants_1 = require("./constants");
10
+ const manifest_1 = require("./manifest");
11
+ const process_1 = require("./process");
12
+ const project_1 = require("./project");
13
+ const renderer_1 = require("./renderer");
14
+ const tools_1 = require("./tools");
15
+ const utils_1 = require("./utils");
16
+ function main(invokedTool, argv) {
17
+ dispatch((0, cli_1.parseInvocation)(invokedTool, argv));
18
+ }
19
+ function dispatch(command) {
20
+ switch (command.command) {
21
+ case 'check':
22
+ runCheck(command);
23
+ return;
24
+ case 'init':
25
+ runInit(command);
26
+ return;
27
+ case 'init-config':
28
+ runInitConfig(command);
29
+ return;
30
+ case 'edit':
31
+ runEdit(command);
32
+ return;
33
+ case 'update':
34
+ runUpdate(command);
35
+ return;
36
+ case 'migrate-config':
37
+ runMigrateConfig(command);
38
+ return;
39
+ default:
40
+ runTool(command);
41
+ }
42
+ }
43
+ function runTool(parsed) {
44
+ const { args, command, wrapperArgs } = parsed;
45
+ const projectRoot = (0, project_1.findProjectRoot)(process.cwd());
46
+ (0, utils_1.verbose)(`run ${command}: cwd=${process.cwd()} projectRoot=${projectRoot}`);
47
+ validateRunModes(parsed, projectRoot);
48
+ if (wrapperArgs.none || (0, project_1.isIgnoredDir)(projectRoot)) {
49
+ (0, utils_1.verbose)(`wrapper bypassed for ${command}${wrapperArgs.none ? ' via --none' : ' because project is ignored'}`);
50
+ (0, process_1.execTool)((0, process_1.findRealBinary)(command), [...(0, tools_1.getPermissionArgs)(command), ...args]);
51
+ return;
52
+ }
53
+ const profileResult = (0, project_1.resolveProfileResult)(projectRoot);
54
+ if (profileResult.profile === null) {
55
+ (0, utils_1.fail)(profileResult.reason);
56
+ }
57
+ const profile = profileResult.profile;
58
+ if (wrapperArgs.show) {
59
+ const configRoot = (0, project_1.defaultConfigRoot)(projectRoot);
60
+ const agentDir = path.join(configRoot, profile);
61
+ (0, utils_1.verbose)(`profile=${profile} configRoot=${configRoot} agentPath=${agentDir}`);
62
+ requireProfile(command, agentDir);
63
+ showToolProfile(command, projectRoot, agentDir);
64
+ return;
65
+ }
66
+ if (wrapperArgs.create) {
67
+ runInit({ command: 'init', targetPath: projectRoot });
68
+ }
69
+ const configRoot = (0, project_1.defaultConfigRoot)(projectRoot);
70
+ const agentDir = path.join(configRoot, profile);
71
+ (0, utils_1.verbose)(`profile=${profile} configRoot=${configRoot} agentPath=${agentDir}`);
72
+ prepareConfigRoot(configRoot);
73
+ requireProfile(command, agentDir);
74
+ const preview = (0, renderer_1.renderProfile)(projectRoot, agentDir, true, command);
75
+ ensureToolEnabled(preview.context, command);
76
+ if (wrapperArgs.generate) {
77
+ printUpdateSummary((0, renderer_1.syncAgentProfile)(projectRoot, agentDir));
78
+ return;
79
+ }
80
+ checkLocalAiFiles(command, projectRoot, agentDir, preview.context, wrapperArgs.local);
81
+ const realBinary = (0, process_1.findRealBinary)(command);
82
+ const permissionArgs = (0, tools_1.getPermissionArgs)(command);
83
+ const rendered = (0, renderer_1.syncAgentProfile)(projectRoot, agentDir);
84
+ if (command === 'codex') {
85
+ (0, tools_1.runCodex)(realBinary, permissionArgs, rendered.context, args, wrapperArgs);
86
+ }
87
+ else {
88
+ (0, tools_1.runClaude)(realBinary, permissionArgs, rendered.context, args, wrapperArgs);
89
+ }
90
+ }
91
+ function validateRunModes(parsed, projectRoot) {
92
+ const { command, wrapperArgs } = parsed;
93
+ if (wrapperArgs.show && wrapperArgs.none) {
94
+ (0, utils_1.fail)('--show cannot be combined with --none');
95
+ }
96
+ if (wrapperArgs.generate && wrapperArgs.none) {
97
+ (0, utils_1.fail)('--generate cannot be combined with --none');
98
+ }
99
+ if (wrapperArgs.generate && wrapperArgs.show) {
100
+ (0, utils_1.fail)('--generate cannot be combined with --show');
101
+ }
102
+ if ((wrapperArgs.show || wrapperArgs.generate) && (0, project_1.isIgnoredDir)(projectRoot)) {
103
+ (0, utils_1.fail)(`cannot ${wrapperArgs.show ? 'show' : 'generate'} generated ${command} files for ignored project: ${projectRoot}`);
104
+ }
105
+ }
106
+ function requireProfile(tool, agentDir) {
107
+ if ((0, manifest_1.isProfileConfigured)(agentDir)) {
108
+ return;
109
+ }
110
+ const label = tool ?? 'agent';
111
+ process.stderr.write(`agent-run: no ${label} profile found for this project: ${agentDir}\n`);
112
+ process.stderr.write('agent-run: run `agent-run init` or use the tool with `--create`.\n');
113
+ process.exit(1);
114
+ }
115
+ function checkLocalAiFiles(command, projectRoot, agentDir, context, allowLocal) {
116
+ const files = (0, project_1.findLocalAiFiles)(projectRoot, agentDir);
117
+ if (!context.guardrails.forbidRepoAiFiles || files.length === 0) {
118
+ return;
119
+ }
120
+ if (!allowLocal) {
121
+ (0, project_1.failForLocalAiFiles)(command, projectRoot, files);
122
+ }
123
+ (0, project_1.warnForLocalAiFiles)(command, projectRoot, files);
124
+ }
125
+ function showToolProfile(command, projectRoot, agentDir) {
126
+ const trace = { sourceFiles: new Set() };
127
+ const rendered = (0, renderer_1.renderProfile)(projectRoot, agentDir, true, command, trace);
128
+ ensureToolEnabled(rendered.context, command);
129
+ process.stdout.write([
130
+ `Agent: ${command}`,
131
+ `Profile: ${rendered.profile}`,
132
+ `Project root: ${projectRoot}`,
133
+ `Profile dir: ${agentDir}`,
134
+ '',
135
+ 'Reads/includes:',
136
+ ...(0, utils_1.formatPathList)((0, utils_1.uniqueSorted)([...trace.sourceFiles])),
137
+ '',
138
+ 'Generates:',
139
+ ...(0, utils_1.formatPathList)((0, utils_1.uniqueSorted)(rendered.files.map((file) => file.path))),
140
+ ''
141
+ ].join('\n'));
142
+ }
143
+ function ensureToolEnabled(context, command) {
144
+ if (!context.tools[command]) {
145
+ (0, utils_1.fail)(`${command} is disabled for agent-run profile ${context.profile}`);
146
+ }
147
+ }
148
+ function runInit(parsed) {
149
+ const projectRoot = activeProject(parsed.targetPath, 'init');
150
+ if (projectRoot === null) {
151
+ return;
152
+ }
153
+ const agentDir = initializeProfileSource(projectRoot, true);
154
+ printUpdateSummary((0, renderer_1.syncAgentProfile)(projectRoot, agentDir));
155
+ }
156
+ function runInitConfig(parsed) {
157
+ const sourcePath = (0, config_tree_1.starterConfigRootPath)();
158
+ if (!fs.existsSync(sourcePath)) {
159
+ (0, utils_1.fail)(`starter config skeleton not found: ${sourcePath}`);
160
+ }
161
+ (0, config_tree_1.copySkeletonTree)(sourcePath, path.resolve(parsed.targetPath));
162
+ process.stdout.write(`OK copied starter config to ${path.resolve(parsed.targetPath)}\n`);
163
+ }
164
+ function runEdit(parsed) {
165
+ const projectRoot = activeProject(parsed.targetPath, 'edit');
166
+ if (projectRoot === null) {
167
+ return;
168
+ }
169
+ const agentDir = initializeProfileSource(projectRoot, false);
170
+ const editPath = (0, manifest_1.createDefaultLocalFile)(agentDir);
171
+ (0, renderer_1.syncAgentProfile)(projectRoot, agentDir);
172
+ process.stdout.write(`Edit: ${editPath}\n`);
173
+ (0, process_1.openEditor)(editPath);
174
+ }
175
+ function runUpdate(parsed) {
176
+ if (parsed.all) {
177
+ runUpdateAll(parsed.targetPath);
178
+ return;
179
+ }
180
+ const projectRoot = (0, project_1.findProjectRoot)(parsed.targetPath);
181
+ (0, utils_1.verbose)(`update target=${parsed.targetPath} projectRoot=${projectRoot}`);
182
+ if ((0, project_1.isIgnoredDir)(projectRoot)) {
183
+ process.stdout.write(`SKIP ignored ${projectRoot}\n`);
184
+ return;
185
+ }
186
+ const configRoot = (0, project_1.defaultConfigRoot)(projectRoot);
187
+ const agentDir = (0, project_1.resolveAgentDir)(projectRoot);
188
+ prepareConfigRoot(configRoot);
189
+ requireProfile(null, agentDir);
190
+ printUpdateSummary((0, renderer_1.syncAgentProfile)(projectRoot, agentDir));
191
+ }
192
+ function runUpdateAll(targetPath) {
193
+ const configRoot = targetPath === path.resolve(process.cwd()) ? (0, project_1.defaultConfigRoot)() : path.resolve(targetPath);
194
+ if (!fs.existsSync(configRoot)) {
195
+ (0, utils_1.fail)(`missing config root: ${configRoot}`);
196
+ }
197
+ prepareConfigRoot(configRoot);
198
+ const profileDirs = (0, config_tree_1.findProfileDirs)(configRoot);
199
+ for (const agentDir of profileDirs) {
200
+ const profile = path.relative(configRoot, agentDir).replace(/\\/g, '/');
201
+ const projectRoot = (0, project_1.projectRootForProfile)(profile, configRoot);
202
+ (0, renderer_1.syncAgentProfile)(projectRoot, agentDir, { configRoot, profile });
203
+ process.stdout.write(`OK ${profile}\n`);
204
+ }
205
+ process.stdout.write(`Updated profiles: ${profileDirs.length}\n`);
206
+ }
207
+ function runMigrateConfig(parsed) {
208
+ const configRoot = parsed.configRoot;
209
+ if (!fs.existsSync(configRoot)) {
210
+ (0, utils_1.fail)(`missing config root: ${configRoot}`);
211
+ }
212
+ (0, config_tree_1.ensureConfigRootLayout)(configRoot);
213
+ (0, config_tree_1.ensureConfigRootGitignore)(configRoot);
214
+ (0, config_tree_1.migrateOldTemplates)(configRoot);
215
+ (0, config_tree_1.ensureDefaultGlobalTemplates)(configRoot);
216
+ (0, manifest_1.ensureRootDefaultsFile)(configRoot);
217
+ const profileDirs = (0, config_tree_1.findLegacyProfileDirs)(configRoot);
218
+ let createdManifestCount = 0;
219
+ let createdLocalCount = 0;
220
+ let movedRuntimeCount = 0;
221
+ let movedReviewCount = 0;
222
+ let movedMemoryCount = 0;
223
+ for (const agentDir of profileDirs) {
224
+ const localPath = path.join(agentDir, constants_1.LOCAL_TEMPLATE_FILE_NAME);
225
+ if (!fs.existsSync(localPath)) {
226
+ fs.writeFileSync(localPath, (0, config_tree_1.convertLegacyTemplateVars)(fs.readFileSync(path.join(agentDir, 'AGENTS-MODS.md'), 'utf8')), 'utf8');
227
+ createdLocalCount += 1;
228
+ }
229
+ if (!fs.existsSync(path.join(agentDir, constants_1.MANIFEST_FILE_NAME))) {
230
+ (0, manifest_1.createProfileMarker)(agentDir);
231
+ createdManifestCount += 1;
232
+ }
233
+ movedRuntimeCount += (0, config_tree_1.migrateCodexRuntimeFiles)(agentDir);
234
+ movedReviewCount += (0, config_tree_1.migrateLooseFiles)(agentDir, /^REVIEW(?:-.+)?\.md$/, 'reviews');
235
+ movedMemoryCount += (0, config_tree_1.migrateLooseFiles)(agentDir, /^memory.*\.md$/i, 'memories');
236
+ }
237
+ process.stdout.write(`OK migrated ${configRoot}\n`);
238
+ process.stdout.write(`Profiles converted: ${profileDirs.length}\n`);
239
+ process.stdout.write(`Created local.md.njk: ${createdLocalCount}\n`);
240
+ process.stdout.write(`Created agent-run.jsonc: ${createdManifestCount}\n`);
241
+ process.stdout.write(`Moved Codex runtime entries: ${movedRuntimeCount}\n`);
242
+ process.stdout.write(`Moved review files: ${movedReviewCount}\n`);
243
+ process.stdout.write(`Moved memory files: ${movedMemoryCount}\n`);
244
+ }
245
+ function runCheck(parsed) {
246
+ if (parsed.all) {
247
+ const report = (0, checks_1.checkSourceTree)(parsed.targetPath);
248
+ (0, checks_1.printBatchReport)(report.root, report.entries);
249
+ process.exit(report.hasErrors ? 1 : 0);
250
+ }
251
+ const projectRoot = (0, project_1.findProjectRoot)(parsed.targetPath);
252
+ if ((0, project_1.isIgnoredDir)(projectRoot)) {
253
+ process.stdout.write(`Check: ${projectRoot}\nSKIP ignored by .agent-run-ignore\n`);
254
+ process.exit(0);
255
+ }
256
+ const findings = (0, checks_1.checkProject)(projectRoot);
257
+ (0, checks_1.printProjectReport)(projectRoot, findings);
258
+ process.exit((0, checks_1.hasErrors)(findings) ? 1 : 0);
259
+ }
260
+ function prepareConfigRoot(configRoot) {
261
+ (0, config_tree_1.ensureConfigRootLayout)(configRoot);
262
+ (0, config_tree_1.ensureConfigRootGitignore)(configRoot);
263
+ (0, config_tree_1.ensureDefaultGlobalTemplates)(configRoot);
264
+ }
265
+ function activeProject(targetPath, action) {
266
+ const projectRoot = (0, project_1.findProjectRoot)(targetPath);
267
+ (0, utils_1.verbose)(`${action} target=${targetPath} projectRoot=${projectRoot}`);
268
+ if (!(0, project_1.isIgnoredDir)(projectRoot)) {
269
+ return projectRoot;
270
+ }
271
+ process.stdout.write(`SKIP ignored ${projectRoot}\n`);
272
+ return null;
273
+ }
274
+ function initializeProfileSource(projectRoot, preferProjectConfigRoot) {
275
+ const profile = (0, project_1.resolveProfile)(projectRoot);
276
+ const configRoot = (0, project_1.defaultConfigRoot)(projectRoot, { preferProjectRoot: preferProjectConfigRoot });
277
+ const agentDir = path.join(configRoot, profile);
278
+ prepareConfigRoot(configRoot);
279
+ (0, manifest_1.ensureRootDefaultsFile)(configRoot);
280
+ fs.mkdirSync(agentDir, { recursive: true });
281
+ (0, manifest_1.convertLegacyProfileIfNeeded)(agentDir);
282
+ (0, manifest_1.createProfileMarker)(agentDir);
283
+ return agentDir;
284
+ }
285
+ function printUpdateSummary(rendered) {
286
+ process.stdout.write(`OK profile ${rendered.profile}\n`);
287
+ process.stdout.write(`Profile dir: ${rendered.agentDir}\n`);
288
+ process.stdout.write(`Live dir: ${rendered.context.paths.liveDir}\n`);
289
+ process.stdout.write(`Generated files: ${rendered.files.length}\n`);
290
+ process.stdout.write(`Installed skills: ${rendered.skills.map((skill) => skill.name).join(', ') || '(none)'}\n`);
291
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureConfigRootLayout = ensureConfigRootLayout;
4
+ exports.ensureConfigRootGitignore = ensureConfigRootGitignore;
5
+ exports.ensureDefaultGlobalTemplates = ensureDefaultGlobalTemplates;
6
+ exports.migrateOldTemplates = migrateOldTemplates;
7
+ exports.findLegacyProfileDirs = findLegacyProfileDirs;
8
+ exports.findProfileDirs = findProfileDirs;
9
+ exports.convertLegacyTemplateVars = convertLegacyTemplateVars;
10
+ exports.migrateCodexRuntimeFiles = migrateCodexRuntimeFiles;
11
+ exports.migrateLooseFiles = migrateLooseFiles;
12
+ exports.starterConfigRootPath = starterConfigRootPath;
13
+ exports.copySkeletonTree = copySkeletonTree;
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+ const constants_1 = require("./constants");
17
+ const defaults_1 = require("./defaults");
18
+ const utils_1 = require("./utils");
19
+ const walk_tree_1 = require("./walk-tree");
20
+ const PRUNED_CONFIG_DIRS = new Set([
21
+ '.git',
22
+ 'orphaned',
23
+ 'global',
24
+ 'templates',
25
+ '.agents',
26
+ '.claude',
27
+ '.codex',
28
+ 'bin',
29
+ 'reviews',
30
+ 'memories',
31
+ 'cache',
32
+ 'log',
33
+ 'sessions',
34
+ 'shell_snapshots',
35
+ 'skills',
36
+ 'tmp',
37
+ '.tmp'
38
+ ]);
39
+ function ensureConfigRootLayout(configRoot) {
40
+ fs.mkdirSync(configRoot, { recursive: true });
41
+ }
42
+ function ensureConfigRootGitignore(configRoot) {
43
+ fs.mkdirSync(configRoot, { recursive: true });
44
+ const gitignorePath = path.join(configRoot, '.gitignore');
45
+ const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf8').replace(/\r\n/g, '\n') : '';
46
+ const lines = existing.length > 0 ? existing.replace(/\n+$/, '').split('\n') : [];
47
+ const present = new Set(lines);
48
+ let changed = !fs.existsSync(gitignorePath);
49
+ for (const entry of constants_1.GENERATED_GITIGNORE_ENTRIES) {
50
+ if (entry === '' || present.has(entry)) {
51
+ continue;
52
+ }
53
+ lines.push(entry);
54
+ present.add(entry);
55
+ changed = true;
56
+ }
57
+ if (changed) {
58
+ fs.writeFileSync(gitignorePath, `${lines.join('\n')}\n`, 'utf8');
59
+ }
60
+ }
61
+ function ensureDefaultGlobalTemplates(configRoot) {
62
+ for (const [relativePath, content] of (0, defaults_1.defaultGlobalTemplates)()) {
63
+ const filePath = path.join(configRoot, relativePath);
64
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
65
+ if (!fs.existsSync(filePath)) {
66
+ fs.writeFileSync(filePath, content, 'utf8');
67
+ (0, utils_1.verbose)(`created ${filePath}`);
68
+ }
69
+ }
70
+ }
71
+ function migrateOldTemplates(configRoot) {
72
+ const oldCodeTemplate = path.join(configRoot, 'templates', 'AGENTS-CODE.md');
73
+ const newCodeTemplate = path.join(configRoot, 'global', 'agents', 'code.md.njk');
74
+ if (!fs.existsSync(oldCodeTemplate) || fs.existsSync(newCodeTemplate)) {
75
+ return;
76
+ }
77
+ fs.mkdirSync(path.dirname(newCodeTemplate), { recursive: true });
78
+ fs.writeFileSync(newCodeTemplate, convertLegacyTemplateVars(fs.readFileSync(oldCodeTemplate, 'utf8')), 'utf8');
79
+ }
80
+ function findLegacyProfileDirs(configRoot) {
81
+ return findConfigDirs(configRoot, (dir) => fs.existsSync(path.join(dir, 'AGENTS-MODS.md')));
82
+ }
83
+ function findProfileDirs(configRoot) {
84
+ return findConfigDirs(configRoot, (dir) => fs.existsSync(path.join(dir, constants_1.MANIFEST_FILE_NAME)) ||
85
+ fs.existsSync(path.join(dir, constants_1.LOCAL_TEMPLATE_FILE_NAME)));
86
+ }
87
+ function findConfigDirs(configRoot, matches) {
88
+ const dirs = [];
89
+ (0, walk_tree_1.walkTree)(configRoot, (fullPath, entry) => {
90
+ if (!entry.isDirectory()) {
91
+ return undefined;
92
+ }
93
+ if (matches(fullPath)) {
94
+ dirs.push(fullPath);
95
+ return 'skip';
96
+ }
97
+ return undefined;
98
+ }, { shouldPrune: (entry) => entry.isDirectory() && PRUNED_CONFIG_DIRS.has(entry.name) });
99
+ return dirs.sort();
100
+ }
101
+ function convertLegacyTemplateVars(content) {
102
+ const replacements = new Map([
103
+ ['{{AGENT_DIR}}', '{{ agentDir }}'],
104
+ ['{{AGENTS_MODS_PATH}}', '{{ agentDir }}/AGENTS-MODS.md'],
105
+ ['{{AGENTS_PATH}}', '{{ agentDir }}/AGENTS.md'],
106
+ ['{{CLAUDE_PATH}}', '{{ agentDir }}/CLAUDE.md'],
107
+ ['{{CONFIG_ROOT}}', '{{ configRoot }}'],
108
+ ['{{PROFILE}}', '{{ profile }}']
109
+ ]);
110
+ let converted = content;
111
+ for (const [from, to] of replacements) {
112
+ converted = converted.split(from).join(to);
113
+ }
114
+ return converted.replace(/^@[^\n]*templates\/AGENTS-CODE\.md[^\n]*\n?/gm, '').replace(/^\n{2,}/, '\n');
115
+ }
116
+ function migrateCodexRuntimeFiles(agentDir) {
117
+ const runtimeName = /^(?:\.personality_migration|\.tmp|auth\.json|cache|history\.jsonl|installation_id|log|logs|models_cache\.json|sessions|archived_sessions|shell_snapshots|skills|tmp|version\.json)$/;
118
+ const databaseName = /^(?:logs|state)_.*\.sqlite(?:-.+)?$/;
119
+ const runtimeNames = fs.readdirSync(agentDir).filter((name) => runtimeName.test(name) || databaseName.test(name));
120
+ const codexHome = path.join(agentDir, constants_1.LIVE_DIR_NAME, 'memories', 'codex-home');
121
+ let moved = 0;
122
+ for (const name of runtimeNames) {
123
+ const source = path.join(agentDir, name);
124
+ if (!fs.existsSync(source) && !(0, utils_1.isSymlink)(source)) {
125
+ continue;
126
+ }
127
+ const initialTarget = path.join(codexHome, name);
128
+ const target = fs.existsSync(initialTarget) || (0, utils_1.isSymlink)(initialTarget) ? (0, utils_1.nextBackupPath)(initialTarget) : initialTarget;
129
+ fs.mkdirSync(path.dirname(target), { recursive: true });
130
+ fs.renameSync(source, target);
131
+ moved += 1;
132
+ }
133
+ return moved;
134
+ }
135
+ function migrateLooseFiles(agentDir, pattern, targetDirName) {
136
+ let moved = 0;
137
+ for (const entry of fs.readdirSync(agentDir, { withFileTypes: true })) {
138
+ if (!entry.isFile() || !pattern.test(entry.name)) {
139
+ continue;
140
+ }
141
+ const source = path.join(agentDir, entry.name);
142
+ const targetDir = path.join(agentDir, targetDirName);
143
+ const target = path.join(targetDir, entry.name);
144
+ if (fs.existsSync(target)) {
145
+ continue;
146
+ }
147
+ fs.mkdirSync(targetDir, { recursive: true });
148
+ fs.renameSync(source, target);
149
+ moved += 1;
150
+ }
151
+ return moved;
152
+ }
153
+ function starterConfigRootPath() {
154
+ return path.resolve(__dirname, '..', 'examples', 'basic-config', 'agent-config');
155
+ }
156
+ function copySkeletonTree(sourceDir, targetDir) {
157
+ fs.mkdirSync(targetDir, { recursive: true });
158
+ const entries = fs.readdirSync(sourceDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
159
+ for (const entry of entries) {
160
+ const sourcePath = path.join(sourceDir, entry.name);
161
+ const targetPath = path.join(targetDir, entry.name === 'gitignore' ? '.gitignore' : entry.name);
162
+ if (entry.isDirectory()) {
163
+ copySkeletonTree(sourcePath, targetPath);
164
+ }
165
+ else if (entry.isFile() && !fs.existsSync(targetPath)) {
166
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });
167
+ fs.copyFileSync(sourcePath, targetPath);
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REQUIRED_GLOBAL_TEMPLATES = exports.GENERATED_GITIGNORE_ENTRIES = exports.LOCAL_AI_DIRECTORY_NAMES = exports.LOCAL_AI_FILE_NAMES = exports.UNEXPANDED_TEMPLATE_RE = exports.PACKAGE_VERSION = exports.VERBOSE_ENV = exports.CONFIG_DIR_ENV = exports.CONFIG_ROOT_OVERRIDE_ENV = exports.LIVE_DIR_NAME = exports.LOCAL_TEMPLATE_FILE_NAME = exports.MANIFEST_FILE_NAME = exports.CONFIG_ROOT_DEFAULTS_FILE_NAME = exports.IGNORE_FILE_NAME = exports.ENV_FILE_NAME = exports.IS_WINDOWS = void 0;
4
+ exports.IS_WINDOWS = process.platform === 'win32';
5
+ exports.ENV_FILE_NAME = '.agent-run.env';
6
+ exports.IGNORE_FILE_NAME = '.agent-run-ignore';
7
+ exports.CONFIG_ROOT_DEFAULTS_FILE_NAME = 'agent-run.defaults.jsonc';
8
+ exports.MANIFEST_FILE_NAME = 'agent-run.jsonc';
9
+ exports.LOCAL_TEMPLATE_FILE_NAME = 'local.md.njk';
10
+ exports.LIVE_DIR_NAME = 'live';
11
+ exports.CONFIG_ROOT_OVERRIDE_ENV = 'AGENT_RUN_CONFIG_ROOT_OVERRIDE';
12
+ exports.CONFIG_DIR_ENV = 'AGENT_CONFIG_DIR';
13
+ exports.VERBOSE_ENV = 'AGENT_RUN_VERBOSE';
14
+ exports.PACKAGE_VERSION = '0.99.25';
15
+ exports.UNEXPANDED_TEMPLATE_RE = /\{\{[^}]+\}\}|\{%[^%]+%\}/;
16
+ exports.LOCAL_AI_FILE_NAMES = new Set([
17
+ 'AGENTS.md',
18
+ 'AGENTS-MODS.md',
19
+ 'AGENTS.override.md',
20
+ 'CLAUDE.md',
21
+ 'CLAUDE.local.md',
22
+ '.mcp.json',
23
+ 'codex.md'
24
+ ]);
25
+ exports.LOCAL_AI_DIRECTORY_NAMES = new Set(['.agents', '.claude', '.codex']);
26
+ exports.GENERATED_GITIGNORE_ENTRIES = [
27
+ '# Generated agent-run live profiles',
28
+ '**/live/',
29
+ '',
30
+ '# Optional generated caches',
31
+ '**/.agent-run-cache/',
32
+ '',
33
+ '# Legacy Codex runtime state',
34
+ '**/auth.json',
35
+ '**/history.jsonl',
36
+ '**/sessions/',
37
+ '**/archived_sessions/',
38
+ '**/log/',
39
+ '**/logs/',
40
+ '**/shell_snapshots/',
41
+ '**/*.sqlite*',
42
+ '**/models_cache.json',
43
+ '**/cache/',
44
+ '**/.tmp/',
45
+ '**/installation_id',
46
+ '**/version.json',
47
+ '**/.personality_migration',
48
+ '**/skills/.system/'
49
+ ];
50
+ exports.REQUIRED_GLOBAL_TEMPLATES = [
51
+ 'global/agents/code.md.njk',
52
+ 'global/agents/writing.md.njk',
53
+ 'global/snippets/git-rules.md.njk',
54
+ 'global/snippets/no-ai-files.md.njk',
55
+ 'global/snippets/verification.md.njk',
56
+ 'global/tool-templates/codex-config.toml.njk',
57
+ 'global/tool-templates/claude-settings.json.njk',
58
+ 'global/skills/commit-workflow/SKILL.md.njk',
59
+ 'global/skills/github-release/SKILL.md.njk',
60
+ 'global/skills/release-package-check/SKILL.md.njk',
61
+ 'global/skills/code-review-organizer/SKILL.md.njk'
62
+ ];