@microsoft/agentrc 2.0.1-18 → 2.0.1-19

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/index.js CHANGED
@@ -3052,7 +3052,7 @@ var require_main = __commonJS({
3052
3052
  exports.createMessageConnection = exports.createServerSocketTransport = exports.createClientSocketTransport = exports.createServerPipeTransport = exports.createClientPipeTransport = exports.generateRandomPipeName = exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.PortMessageWriter = exports.PortMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
3053
3053
  var ril_1 = require_ril();
3054
3054
  ril_1.default.install();
3055
- var path23 = __require("path");
3055
+ var path26 = __require("path");
3056
3056
  var os2 = __require("os");
3057
3057
  var crypto_1 = __require("crypto");
3058
3058
  var net_1 = __require("net");
@@ -3188,9 +3188,9 @@ var require_main = __commonJS({
3188
3188
  }
3189
3189
  let result;
3190
3190
  if (XDG_RUNTIME_DIR) {
3191
- result = path23.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
3191
+ result = path26.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
3192
3192
  } else {
3193
- result = path23.join(os2.tmpdir(), `vscode-${randomSuffix}.sock`);
3193
+ result = path26.join(os2.tmpdir(), `vscode-${randomSuffix}.sock`);
3194
3194
  }
3195
3195
  const limit = safeIpcPathLengths.get(process.platform);
3196
3196
  if (limit !== void 0 && result.length > limit) {
@@ -5653,6 +5653,27 @@ function stripJsonComments(text) {
5653
5653
  if (i < text.length) i += 2;
5654
5654
  continue;
5655
5655
  }
5656
+ if (text[i] === ",") {
5657
+ let j = i + 1;
5658
+ while (j < text.length) {
5659
+ if (text[j] === " " || text[j] === " " || text[j] === "\n" || text[j] === "\r") {
5660
+ j++;
5661
+ } else if (text[j] === "/" && text[j + 1] === "/") {
5662
+ j += 2;
5663
+ while (j < text.length && text[j] !== "\n") j++;
5664
+ } else if (text[j] === "/" && text[j + 1] === "*") {
5665
+ j += 2;
5666
+ while (j < text.length && !(text[j] === "*" && text[j + 1] === "/")) j++;
5667
+ if (j < text.length) j += 2;
5668
+ } else {
5669
+ break;
5670
+ }
5671
+ }
5672
+ if (j < text.length && (text[j] === "}" || text[j] === "]")) {
5673
+ i++;
5674
+ continue;
5675
+ }
5676
+ }
5656
5677
  result += text[i];
5657
5678
  i++;
5658
5679
  }
@@ -6991,7 +7012,7 @@ async function checkReposForInstructions(token, repos, onProgress) {
6991
7012
  }
6992
7013
 
6993
7014
  // packages/core/src/services/batch.ts
6994
- import path10 from "path";
7015
+ import path13 from "path";
6995
7016
 
6996
7017
  // packages/core/src/utils/pr.ts
6997
7018
  function buildInstructionsPrBody() {
@@ -8377,9 +8398,8 @@ async function generateNestedAreaInstructions(options) {
8377
8398
  });
8378
8399
  }
8379
8400
 
8380
- // packages/core/src/services/readiness.ts
8381
- import fs7 from "fs/promises";
8382
- import path9 from "path";
8401
+ // packages/core/src/services/readiness/index.ts
8402
+ import path12 from "path";
8383
8403
 
8384
8404
  // packages/core/src/services/policy.ts
8385
8405
  import fs6 from "fs/promises";
@@ -9060,252 +9080,382 @@ function wrapImperativePolicy(config, baseCriteria) {
9060
9080
  return { plugin, compiled };
9061
9081
  }
9062
9082
 
9063
- // packages/core/src/services/readiness.ts
9064
- var PILLAR_GROUPS = {
9065
- "style-validation": "repo-health",
9066
- "build-system": "repo-health",
9067
- testing: "repo-health",
9068
- documentation: "repo-health",
9069
- "dev-environment": "repo-health",
9070
- "code-quality": "repo-health",
9071
- observability: "repo-health",
9072
- "security-governance": "repo-health",
9073
- "ai-tooling": "ai-setup"
9074
- };
9075
- var PILLAR_GROUP_NAMES = {
9076
- "repo-health": "Repo Health",
9077
- "ai-setup": "AI Setup"
9078
- };
9079
- function groupPillars(pillars) {
9080
- const groups = ["repo-health", "ai-setup"];
9081
- return groups.map((group) => ({
9082
- group,
9083
- label: PILLAR_GROUP_NAMES[group],
9084
- pillars: pillars.filter((p) => PILLAR_GROUPS[p.id] === group)
9085
- }));
9083
+ // packages/core/src/services/readiness/checkers.ts
9084
+ import fs7 from "fs/promises";
9085
+ import path9 from "path";
9086
+ function hasAnyFile(files, candidates) {
9087
+ return candidates.some((candidate) => files.includes(candidate));
9086
9088
  }
9087
- function getLevelName(level) {
9088
- const names = {
9089
- 1: "Functional",
9090
- 2: "Documented",
9091
- 3: "Standardized",
9092
- 4: "Optimized",
9093
- 5: "Autonomous"
9089
+ async function hasReadme(repoPath) {
9090
+ const files = await safeReadDir(repoPath);
9091
+ return files.some(
9092
+ (file) => file.toLowerCase() === "readme.md" || file.toLowerCase() === "readme"
9093
+ );
9094
+ }
9095
+ async function hasLintConfig(repoPath) {
9096
+ return hasAnyFile(await safeReadDir(repoPath), [
9097
+ "eslint.config.js",
9098
+ "eslint.config.mjs",
9099
+ ".eslintrc",
9100
+ ".eslintrc.js",
9101
+ ".eslintrc.cjs",
9102
+ ".eslintrc.json",
9103
+ ".eslintrc.yml",
9104
+ ".eslintrc.yaml",
9105
+ "biome.json",
9106
+ "biome.jsonc",
9107
+ ".prettierrc",
9108
+ ".prettierrc.json",
9109
+ ".prettierrc.js",
9110
+ ".prettierrc.cjs",
9111
+ "prettier.config.js",
9112
+ "prettier.config.cjs"
9113
+ ]);
9114
+ }
9115
+ async function hasFormatterConfig(repoPath) {
9116
+ return hasAnyFile(await safeReadDir(repoPath), [
9117
+ "biome.json",
9118
+ "biome.jsonc",
9119
+ ".prettierrc",
9120
+ ".prettierrc.json",
9121
+ ".prettierrc.js",
9122
+ ".prettierrc.cjs",
9123
+ "prettier.config.js",
9124
+ "prettier.config.cjs"
9125
+ ]);
9126
+ }
9127
+ async function hasTypecheckConfig(repoPath) {
9128
+ return hasAnyFile(await safeReadDir(repoPath), [
9129
+ "tsconfig.json",
9130
+ "tsconfig.base.json",
9131
+ "pyproject.toml",
9132
+ "mypy.ini"
9133
+ ]);
9134
+ }
9135
+ async function hasGithubWorkflows(repoPath) {
9136
+ return fileExists(path9.join(repoPath, ".github", "workflows"));
9137
+ }
9138
+ async function hasCodeowners(repoPath) {
9139
+ const root = await fileExists(path9.join(repoPath, "CODEOWNERS"));
9140
+ const github = await fileExists(path9.join(repoPath, ".github", "CODEOWNERS"));
9141
+ return root || github;
9142
+ }
9143
+ async function hasLicense(repoPath) {
9144
+ const files = await safeReadDir(repoPath);
9145
+ return files.some((file) => file.toLowerCase().startsWith("license"));
9146
+ }
9147
+ async function hasPullRequestTemplate(repoPath) {
9148
+ const direct = await fileExists(path9.join(repoPath, ".github", "PULL_REQUEST_TEMPLATE.md"));
9149
+ if (direct) return true;
9150
+ const dir = path9.join(repoPath, ".github", "PULL_REQUEST_TEMPLATE");
9151
+ try {
9152
+ const entries = await fs7.readdir(dir);
9153
+ return entries.some((entry) => entry.toLowerCase().endsWith(".md"));
9154
+ } catch {
9155
+ return false;
9156
+ }
9157
+ }
9158
+ async function hasPrecommitConfig(repoPath) {
9159
+ const precommit = await fileExists(path9.join(repoPath, ".pre-commit-config.yaml"));
9160
+ if (precommit) return true;
9161
+ return fileExists(path9.join(repoPath, ".husky"));
9162
+ }
9163
+ async function hasArchitectureDoc(repoPath) {
9164
+ const files = await safeReadDir(repoPath);
9165
+ if (files.some((file) => file.toLowerCase() === "architecture.md")) return true;
9166
+ return fileExists(path9.join(repoPath, "docs", "architecture.md"));
9167
+ }
9168
+ function validateAndNormalize(raw) {
9169
+ const trimmed = raw.trim();
9170
+ if (!trimmed || path9.isAbsolute(trimmed)) return void 0;
9171
+ const segments = trimmed.split(/[/\\]+/u);
9172
+ if (segments.some((s) => s === "..")) return void 0;
9173
+ let normalized = path9.normalize(trimmed).replace(/\\/gu, "/");
9174
+ normalized = normalized.replace(/\/+$/u, "");
9175
+ if (!normalized || normalized === ".") return void 0;
9176
+ return normalized;
9177
+ }
9178
+ function extractLocationPaths(entries) {
9179
+ if (!entries || typeof entries !== "object") return [];
9180
+ const paths = [];
9181
+ if (Array.isArray(entries)) {
9182
+ for (const entry of entries) {
9183
+ let raw;
9184
+ if (typeof entry === "string") {
9185
+ raw = entry;
9186
+ } else if (entry && typeof entry === "object" && !Array.isArray(entry)) {
9187
+ const obj = entry;
9188
+ if (typeof obj.path === "string") {
9189
+ raw = obj.path;
9190
+ }
9191
+ }
9192
+ if (raw) {
9193
+ const normalized = validateAndNormalize(raw);
9194
+ if (normalized) paths.push(normalized);
9195
+ }
9196
+ }
9197
+ return paths;
9198
+ }
9199
+ for (const [key, value] of Object.entries(entries)) {
9200
+ if (value !== true) continue;
9201
+ const normalized = validateAndNormalize(key);
9202
+ if (normalized) paths.push(normalized);
9203
+ }
9204
+ return paths;
9205
+ }
9206
+ function extractLocationsFromSettings(settings) {
9207
+ return {
9208
+ instructionsLocations: extractLocationPaths(settings["chat.instructionsFilesLocations"]),
9209
+ agentLocations: extractLocationPaths(settings["chat.agentFilesLocations"]),
9210
+ skillsLocations: extractLocationPaths(settings["chat.agentSkillsLocations"])
9094
9211
  };
9095
- return names[level] || "Unknown";
9096
9212
  }
9097
- function getLevelDescription(level) {
9098
- const descriptions = {
9099
- 1: "Repo builds, tests run, and basic tooling (linter, lockfile) is in place. AI agents can clone and get started.",
9100
- 2: "README, CONTRIBUTING guide, and custom instructions exist. Agents understand project context and conventions.",
9101
- 3: "CI/CD, security policies, CODEOWNERS, and observability are configured. Agents operate within well-defined guardrails.",
9102
- 4: "MCP servers, custom agents, and AI skills are set up. Agents have deep integration with project-specific tools and workflows.",
9103
- 5: "Full AI-native development: agents can independently plan, implement, test, and ship changes with minimal human oversight."
9213
+ function mergeLocations(a, b) {
9214
+ return {
9215
+ instructionsLocations: [...a.instructionsLocations, ...b.instructionsLocations],
9216
+ agentLocations: [...a.agentLocations, ...b.agentLocations],
9217
+ skillsLocations: [...a.skillsLocations, ...b.skillsLocations]
9104
9218
  };
9105
- return descriptions[level] || "";
9106
9219
  }
9107
- async function runReadinessReport(options) {
9108
- const repoPath = options.repoPath;
9109
- const analysis = await analyzeRepo(repoPath);
9110
- const rootFiles = await safeReadDir(repoPath);
9111
- const rootPackageJson = await readJson(path9.join(repoPath, "package.json"));
9112
- const apps = analysis.apps?.length ? analysis.apps : [];
9113
- const context = {
9114
- repoPath,
9115
- analysis,
9116
- apps,
9117
- rootFiles,
9118
- rootPackageJson
9220
+ async function parseVscodeLocations(repoPath, rootFiles) {
9221
+ const empty = {
9222
+ instructionsLocations: [],
9223
+ agentLocations: [],
9224
+ skillsLocations: []
9119
9225
  };
9120
- let policySources = options.policies;
9121
- let isConfigSourced = false;
9122
- if (!policySources?.length) {
9123
- const agentrcConfig = await loadAgentrcConfig(repoPath);
9124
- if (agentrcConfig?.policies?.length) {
9125
- policySources = agentrcConfig.policies;
9126
- isConfigSourced = true;
9226
+ let result = { ...empty };
9227
+ const settings = await readJson(path9.join(repoPath, ".vscode", "settings.json"));
9228
+ if (settings) {
9229
+ result = mergeLocations(result, extractLocationsFromSettings(settings));
9230
+ }
9231
+ const workspaceFiles = rootFiles.filter((f) => f.endsWith(".code-workspace"));
9232
+ for (const wsFile of workspaceFiles) {
9233
+ const ws = await readJson(path9.join(repoPath, wsFile));
9234
+ if (ws?.settings && typeof ws.settings === "object" && !Array.isArray(ws.settings)) {
9235
+ result = mergeLocations(
9236
+ result,
9237
+ extractLocationsFromSettings(ws.settings)
9238
+ );
9127
9239
  }
9128
9240
  }
9129
- const baseCriteria = buildCriteria();
9130
- const baseExtras = buildExtras();
9131
- let resolvedCriteria;
9132
- let resolvedExtras;
9133
- let passRateThreshold = 0.8;
9134
- let policyInfo;
9135
- if (policySources?.length) {
9136
- const policyConfigs = [];
9137
- for (const source of policySources) {
9138
- policyConfigs.push(await loadPolicy(source, { jsonOnly: isConfigSourced }));
9241
+ return {
9242
+ instructionsLocations: [...new Set(result.instructionsLocations)],
9243
+ agentLocations: [...new Set(result.agentLocations)],
9244
+ skillsLocations: [...new Set(result.skillsLocations)]
9245
+ };
9246
+ }
9247
+ async function hasCustomInstructions(repoPath) {
9248
+ const found = [];
9249
+ const candidates = [
9250
+ ".github/copilot-instructions.md",
9251
+ "CLAUDE.md",
9252
+ ".claude/CLAUDE.md",
9253
+ "AGENTS.md",
9254
+ ".github/AGENTS.md",
9255
+ ".cursorrules",
9256
+ ".cursorignore",
9257
+ ".windsurfrules",
9258
+ ".github/instructions.md",
9259
+ "copilot-instructions.md"
9260
+ ];
9261
+ for (const candidate of candidates) {
9262
+ if (await fileExists(path9.join(repoPath, candidate))) {
9263
+ found.push(candidate);
9139
9264
  }
9140
- const resolved = resolveChain(baseCriteria, baseExtras, policyConfigs);
9141
- resolvedCriteria = resolved.criteria;
9142
- resolvedExtras = resolved.extras;
9143
- passRateThreshold = resolved.thresholds.passRate;
9144
- policyInfo = { chain: resolved.chain, criteriaCount: resolved.criteria.length };
9145
- } else {
9146
- resolvedCriteria = baseCriteria;
9147
- resolvedExtras = baseExtras;
9148
9265
  }
9149
- const criteriaResults = [];
9150
- for (const criterion of resolvedCriteria) {
9151
- if (criterion.scope === "repo") {
9152
- const result = await criterion.check(context);
9153
- criteriaResults.push({
9154
- id: criterion.id,
9155
- title: criterion.title,
9156
- pillar: criterion.pillar,
9157
- level: criterion.level,
9158
- scope: criterion.scope,
9159
- impact: criterion.impact,
9160
- effort: criterion.effort,
9161
- status: result.status,
9162
- reason: result.reason,
9163
- evidence: result.evidence
9164
- });
9165
- continue;
9166
- }
9167
- if (criterion.scope === "area") {
9168
- if (!options.perArea) continue;
9169
- const areas2 = analysis.areas ?? [];
9170
- if (areas2.length === 0) continue;
9171
- criteriaResults.push({
9172
- id: criterion.id,
9173
- title: criterion.title,
9174
- pillar: criterion.pillar,
9175
- level: criterion.level,
9176
- scope: criterion.scope,
9177
- impact: criterion.impact,
9178
- effort: criterion.effort,
9179
- status: "skip",
9180
- reason: "Run with --per-area for area breakdown."
9181
- });
9182
- continue;
9183
- }
9184
- const appResults = await Promise.all(
9185
- apps.map(async (app) => ({
9186
- app,
9187
- result: await criterion.check(context, app)
9188
- }))
9266
+ return found;
9267
+ }
9268
+ async function hasFileBasedInstructions(repoPath, extraDirs) {
9269
+ const found = [];
9270
+ const defaultDir = path9.join(repoPath, ".github", "instructions");
9271
+ try {
9272
+ const entries = await fs7.readdir(defaultDir);
9273
+ found.push(
9274
+ ...entries.filter((e) => e.endsWith(".instructions.md")).map((e) => `.github/instructions/${e}`)
9189
9275
  );
9190
- if (!appResults.length) {
9191
- criteriaResults.push({
9192
- id: criterion.id,
9193
- title: criterion.title,
9194
- pillar: criterion.pillar,
9195
- level: criterion.level,
9196
- scope: criterion.scope,
9197
- impact: criterion.impact,
9198
- effort: criterion.effort,
9199
- status: "skip",
9200
- reason: "No application packages detected."
9201
- });
9202
- continue;
9276
+ } catch {
9277
+ }
9278
+ for (const dir of extraDirs ?? []) {
9279
+ const fullDir = path9.join(repoPath, dir);
9280
+ const normalizedDir = dir.replace(/\\/gu, "/").replace(/\/+$/u, "");
9281
+ try {
9282
+ const entries = await fs7.readdir(fullDir);
9283
+ found.push(
9284
+ ...entries.filter((e) => e.endsWith(".instructions.md")).map((e) => `${normalizedDir}/${e}`)
9285
+ );
9286
+ } catch {
9203
9287
  }
9204
- const passed = appResults.filter((entry) => entry.result.status === "pass").length;
9205
- const total = appResults.length;
9206
- const passRate = total ? passed / total : 0;
9207
- const status = passRate >= passRateThreshold ? "pass" : "fail";
9208
- const failures = appResults.filter((entry) => entry.result.status !== "pass").map((entry) => entry.app.name);
9209
- criteriaResults.push({
9210
- id: criterion.id,
9211
- title: criterion.title,
9212
- pillar: criterion.pillar,
9213
- level: criterion.level,
9214
- scope: criterion.scope,
9215
- impact: criterion.impact,
9216
- effort: criterion.effort,
9217
- status,
9218
- reason: status === "pass" ? void 0 : `Only ${passed}/${total} apps pass this check.`,
9219
- passRate,
9220
- appSummary: { passed, total },
9221
- appFailures: failures
9222
- });
9223
9288
  }
9224
- let areaReports;
9225
- const areas = analysis.areas ?? [];
9226
- if (options.perArea && areas.length > 0) {
9227
- const areaCriteria = resolvedCriteria.filter((c) => c.scope === "area");
9228
- areaReports = [];
9229
- for (const area of areas) {
9230
- if (!area.path) continue;
9231
- const areaFiles = await safeReadDir(area.path);
9232
- const areaContext = {
9233
- ...context,
9234
- areaPath: area.path,
9235
- areaFiles
9236
- };
9237
- const areaResults = [];
9238
- for (const criterion of areaCriteria) {
9239
- const result = await criterion.check(areaContext, void 0, area);
9240
- areaResults.push({
9241
- id: criterion.id,
9242
- title: criterion.title,
9243
- pillar: criterion.pillar,
9244
- level: criterion.level,
9245
- scope: criterion.scope,
9246
- impact: criterion.impact,
9247
- effort: criterion.effort,
9248
- status: result.status,
9249
- reason: result.reason,
9250
- evidence: result.evidence
9251
- });
9252
- }
9253
- const areaPillars = summarizePillars(areaResults);
9254
- areaReports.push({ area, criteria: areaResults, pillars: areaPillars });
9289
+ return [...new Set(found)];
9290
+ }
9291
+ function contentSimilarity(a, b) {
9292
+ const normalize = (s) => new Set(
9293
+ s.toLowerCase().split("\n").map((l) => l.trim().replace(/\s+/gu, " ")).filter((l) => l.length > 0)
9294
+ );
9295
+ const setA = normalize(a);
9296
+ const setB = normalize(b);
9297
+ if (setA.size === 0 && setB.size === 0) return 1;
9298
+ let intersection = 0;
9299
+ for (const line of setA) {
9300
+ if (setB.has(line)) intersection++;
9301
+ }
9302
+ const union = (/* @__PURE__ */ new Set([...setA, ...setB])).size;
9303
+ return union === 0 ? 1 : intersection / union;
9304
+ }
9305
+ async function checkInstructionConsistency(repoPath, foundFiles) {
9306
+ if (foundFiles.length <= 1) {
9307
+ return { unified: true, files: foundFiles };
9308
+ }
9309
+ const realPathMap = /* @__PURE__ */ new Map();
9310
+ for (const file of foundFiles) {
9311
+ const fullPath = path9.join(repoPath, file);
9312
+ try {
9313
+ const real = await fs7.realpath(fullPath);
9314
+ const group = realPathMap.get(real) ?? [];
9315
+ group.push(file);
9316
+ realPathMap.set(real, group);
9317
+ } catch {
9318
+ realPathMap.set(fullPath, [file]);
9255
9319
  }
9256
- for (const criterion of criteriaResults) {
9257
- if (criterion.scope !== "area") continue;
9258
- const perAreaResults = areaReports.map((ar) => ar.criteria.find((c) => c.id === criterion.id)).filter(Boolean);
9259
- if (!perAreaResults.length) continue;
9260
- const passed = perAreaResults.filter((r) => r.status === "pass").length;
9261
- const total = perAreaResults.length;
9262
- const passRate = total ? passed / total : 0;
9263
- criterion.status = passRate >= passRateThreshold ? "pass" : "fail";
9264
- criterion.reason = criterion.status === "pass" ? void 0 : `Only ${passed}/${total} areas pass this check.`;
9265
- criterion.passRate = passRate;
9266
- criterion.areaSummary = { passed, total };
9267
- criterion.areaFailures = areaReports.filter((ar) => ar.criteria.find((c) => c.id === criterion.id)?.status !== "pass").map((ar) => ar.area.name);
9320
+ }
9321
+ const groups = [...realPathMap.values()];
9322
+ if (groups.length <= 1) {
9323
+ return { unified: true, files: foundFiles };
9324
+ }
9325
+ const contents = [];
9326
+ for (const group of groups) {
9327
+ try {
9328
+ contents.push(await fs7.readFile(path9.join(repoPath, group[0]), "utf8"));
9329
+ } catch {
9330
+ contents.push("");
9268
9331
  }
9269
9332
  }
9270
- const pillars = summarizePillars(criteriaResults);
9271
- const levels = summarizeLevels(criteriaResults, passRateThreshold);
9272
- const achievedLevel = levels.filter((level) => level.achieved).reduce((acc, level) => Math.max(acc, level.level), 0);
9273
- const extras = options.includeExtras === false ? [] : await runExtras(context, resolvedExtras);
9274
- let engine;
9275
- if (options.shadow) {
9276
- const policyCtx = {
9277
- repoPath,
9278
- rootFiles,
9279
- rootPackageJson,
9280
- cache: /* @__PURE__ */ new Map(),
9281
- analysis,
9282
- apps
9283
- };
9284
- const engineChain = await loadPluginChain(policySources ?? [], { jsonOnly: isConfigSourced });
9285
- const engineReport = await executePlugins(engineChain.plugins, policyCtx, engineChain.options);
9286
- engine = {
9287
- signals: engineReport.signals,
9288
- recommendations: engineReport.recommendations,
9289
- policyWarnings: engineReport.policyWarnings,
9290
- score: engineReport.score,
9291
- grade: engineReport.grade
9292
- };
9333
+ let minSimilarity = 1;
9334
+ for (let i = 0; i < contents.length; i++) {
9335
+ for (let j = i + 1; j < contents.length; j++) {
9336
+ minSimilarity = Math.min(minSimilarity, contentSimilarity(contents[i], contents[j]));
9337
+ }
9293
9338
  }
9294
9339
  return {
9295
- repoPath,
9296
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
9297
- isMonorepo: analysis.isMonorepo ?? false,
9298
- apps: apps.map((app) => ({ name: app.name, path: app.path })),
9299
- pillars,
9300
- levels,
9301
- achievedLevel,
9302
- criteria: criteriaResults,
9303
- extras,
9304
- areaReports,
9305
- policies: policyInfo,
9306
- engine
9340
+ unified: minSimilarity >= 0.9,
9341
+ files: foundFiles,
9342
+ similarity: Math.round(minSimilarity * 100) / 100
9307
9343
  };
9308
9344
  }
9345
+ async function hasMcpConfig(repoPath) {
9346
+ const found = [];
9347
+ if (await fileExists(path9.join(repoPath, ".vscode", "mcp.json"))) {
9348
+ found.push(".vscode/mcp.json");
9349
+ }
9350
+ if (await fileExists(path9.join(repoPath, "mcp.json"))) {
9351
+ found.push("mcp.json");
9352
+ }
9353
+ const settings = await readJson(path9.join(repoPath, ".vscode", "settings.json"));
9354
+ if (settings && (settings["mcp"] || settings["github.copilot.chat.mcp.enabled"])) {
9355
+ found.push(".vscode/settings.json (mcp section)");
9356
+ }
9357
+ if (await fileExists(path9.join(repoPath, ".claude", "mcp.json"))) {
9358
+ found.push(".claude/mcp.json");
9359
+ }
9360
+ return found;
9361
+ }
9362
+ async function hasCustomAgents(repoPath, extraDirs) {
9363
+ const found = [];
9364
+ const agentDirs = [".github/agents", ".copilot/agents", ".github/copilot/agents"];
9365
+ for (const dir of agentDirs) {
9366
+ if (await fileExists(path9.join(repoPath, dir))) {
9367
+ found.push(dir);
9368
+ }
9369
+ }
9370
+ const agentFiles = [".github/copilot-agents.yml", ".github/copilot-agents.yaml"];
9371
+ for (const agentFile of agentFiles) {
9372
+ if (await fileExists(path9.join(repoPath, agentFile))) {
9373
+ found.push(agentFile);
9374
+ }
9375
+ }
9376
+ for (const dir of extraDirs ?? []) {
9377
+ if (await fileExists(path9.join(repoPath, dir))) {
9378
+ found.push(dir);
9379
+ }
9380
+ }
9381
+ return [...new Set(found)];
9382
+ }
9383
+ async function hasCopilotSkills(repoPath, extraDirs) {
9384
+ const found = [];
9385
+ const skillDirs = [
9386
+ ".copilot/skills",
9387
+ ".github/skills",
9388
+ ".claude/skills",
9389
+ ".github/copilot/skills"
9390
+ ];
9391
+ for (const dir of skillDirs) {
9392
+ if (await fileExists(path9.join(repoPath, dir))) {
9393
+ found.push(dir);
9394
+ }
9395
+ }
9396
+ for (const dir of extraDirs ?? []) {
9397
+ if (await fileExists(path9.join(repoPath, dir))) {
9398
+ found.push(dir);
9399
+ }
9400
+ }
9401
+ return [...new Set(found)];
9402
+ }
9403
+ async function hasApmConfig(repoPath) {
9404
+ return fileExists(path9.join(repoPath, "apm.yml"));
9405
+ }
9406
+ async function hasApmLockfile(repoPath) {
9407
+ return fileExists(path9.join(repoPath, "apm.lock.yaml"));
9408
+ }
9409
+ async function hasApmInWorkflows(repoPath) {
9410
+ const workflowDir = path9.join(repoPath, ".github", "workflows");
9411
+ let files;
9412
+ try {
9413
+ files = await fs7.readdir(workflowDir);
9414
+ } catch {
9415
+ return false;
9416
+ }
9417
+ for (const file of files) {
9418
+ if (!file.endsWith(".yml") && !file.endsWith(".yaml")) continue;
9419
+ try {
9420
+ const content = await fs7.readFile(path9.join(workflowDir, file), "utf8");
9421
+ if (/\bmicrosoft\/apm-action\b/.test(content) || /\bapm\s+(audit|install)\b/.test(content)) {
9422
+ return true;
9423
+ }
9424
+ } catch {
9425
+ }
9426
+ }
9427
+ return false;
9428
+ }
9429
+ async function readAllDependencies(context) {
9430
+ const dependencies = [];
9431
+ const apps = context.apps.length ? context.apps : [];
9432
+ for (const app of apps) {
9433
+ if (!app.packageJsonPath) continue;
9434
+ const pkg = await readJson(app.packageJsonPath);
9435
+ const deps = pkg?.dependencies ?? {};
9436
+ const devDeps = pkg?.devDependencies ?? {};
9437
+ dependencies.push(
9438
+ ...Object.keys({
9439
+ ...deps,
9440
+ ...devDeps
9441
+ })
9442
+ );
9443
+ }
9444
+ if (!apps.length && context.rootPackageJson) {
9445
+ const rootDeps = context.rootPackageJson.dependencies ?? {};
9446
+ const rootDevDeps = context.rootPackageJson.devDependencies ?? {};
9447
+ dependencies.push(
9448
+ ...Object.keys({
9449
+ ...rootDeps,
9450
+ ...rootDevDeps
9451
+ })
9452
+ );
9453
+ }
9454
+ return Array.from(new Set(dependencies));
9455
+ }
9456
+
9457
+ // packages/core/src/services/readiness/criteria.ts
9458
+ import path10 from "path";
9309
9459
  function buildCriteria() {
9310
9460
  return [
9311
9461
  {
@@ -9417,7 +9567,7 @@ function buildCriteria() {
9417
9567
  impact: "medium",
9418
9568
  effort: "low",
9419
9569
  check: async (context) => {
9420
- const found = await fileExists(path9.join(context.repoPath, "CONTRIBUTING.md"));
9570
+ const found = await fileExists(path10.join(context.repoPath, "CONTRIBUTING.md"));
9421
9571
  return {
9422
9572
  status: found ? "pass" : "fail",
9423
9573
  reason: found ? void 0 : "Missing CONTRIBUTING.md for contributor workflows."
@@ -9518,7 +9668,7 @@ function buildCriteria() {
9518
9668
  impact: "high",
9519
9669
  effort: "low",
9520
9670
  check: async (context) => {
9521
- const found = await fileExists(path9.join(context.repoPath, "SECURITY.md"));
9671
+ const found = await fileExists(path10.join(context.repoPath, "SECURITY.md"));
9522
9672
  return {
9523
9673
  status: found ? "pass" : "fail",
9524
9674
  reason: found ? void 0 : "Missing SECURITY.md policy."
@@ -9534,7 +9684,7 @@ function buildCriteria() {
9534
9684
  impact: "medium",
9535
9685
  effort: "medium",
9536
9686
  check: async (context) => {
9537
- const found = await fileExists(path9.join(context.repoPath, ".github", "dependabot.yml"));
9687
+ const found = await fileExists(path10.join(context.repoPath, ".github", "dependabot.yml"));
9538
9688
  return {
9539
9689
  status: found ? "pass" : "fail",
9540
9690
  reason: found ? void 0 : "Missing .github/dependabot.yml configuration."
@@ -9583,7 +9733,10 @@ function buildCriteria() {
9583
9733
  ]
9584
9734
  };
9585
9735
  }
9586
- const fileBasedInstructions = await hasFileBasedInstructions(context.repoPath);
9736
+ const fileBasedInstructions = await hasFileBasedInstructions(
9737
+ context.repoPath,
9738
+ context.vscodeLocations?.instructionsLocations
9739
+ );
9587
9740
  const areas = context.analysis.areas ?? [];
9588
9741
  if (areas.length > 0) {
9589
9742
  if (fileBasedInstructions.length === 0) {
@@ -9599,7 +9752,14 @@ function buildCriteria() {
9599
9752
  evidence: [...rootFound, ...fileBasedInstructions]
9600
9753
  };
9601
9754
  }
9602
- if (context.analysis.isMonorepo && context.apps.length > 1) {
9755
+ if (fileBasedInstructions.length > 0) {
9756
+ return {
9757
+ status: "pass",
9758
+ reason: `Root + ${fileBasedInstructions.length} file-based instruction(s) found.`,
9759
+ evidence: [...rootFound, ...fileBasedInstructions]
9760
+ };
9761
+ }
9762
+ if (context.analysis.isMonorepo && context.apps.length > 1) {
9603
9763
  const appsMissing = [];
9604
9764
  for (const app of context.apps) {
9605
9765
  const appFound = await hasCustomInstructions(app.path);
@@ -9678,7 +9838,10 @@ function buildCriteria() {
9678
9838
  impact: "medium",
9679
9839
  effort: "medium",
9680
9840
  check: async (context) => {
9681
- const found = await hasCustomAgents(context.repoPath);
9841
+ const found = await hasCustomAgents(
9842
+ context.repoPath,
9843
+ context.vscodeLocations?.agentLocations
9844
+ );
9682
9845
  return {
9683
9846
  status: found.length > 0 ? "pass" : "fail",
9684
9847
  reason: "No custom AI agents configured (e.g. .github/agents/, .copilot/agents/).",
@@ -9695,7 +9858,10 @@ function buildCriteria() {
9695
9858
  impact: "medium",
9696
9859
  effort: "medium",
9697
9860
  check: async (context) => {
9698
- const found = await hasCopilotSkills(context.repoPath);
9861
+ const found = await hasCopilotSkills(
9862
+ context.repoPath,
9863
+ context.vscodeLocations?.skillsLocations
9864
+ );
9699
9865
  return {
9700
9866
  status: found.length > 0 ? "pass" : "fail",
9701
9867
  reason: "No Copilot or Claude skills found (e.g. .copilot/skills/, .github/skills/).",
@@ -9703,6 +9869,65 @@ function buildCriteria() {
9703
9869
  };
9704
9870
  }
9705
9871
  },
9872
+ {
9873
+ id: "apm-config",
9874
+ title: "APM package manifest present",
9875
+ pillar: "ai-tooling",
9876
+ level: 2,
9877
+ scope: "repo",
9878
+ impact: "medium",
9879
+ effort: "low",
9880
+ check: async (context) => {
9881
+ const found = await hasApmConfig(context.repoPath);
9882
+ return {
9883
+ status: found ? "pass" : "fail",
9884
+ reason: found ? void 0 : "No apm.yml found. Use APM to install shared agent packages and keep instructions in sync across repos. See: https://github.com/microsoft/apm",
9885
+ evidence: ["apm.yml"]
9886
+ };
9887
+ }
9888
+ },
9889
+ {
9890
+ id: "apm-locked-deps",
9891
+ title: "APM dependencies locked",
9892
+ pillar: "ai-tooling",
9893
+ level: 3,
9894
+ scope: "repo",
9895
+ impact: "medium",
9896
+ effort: "low",
9897
+ check: async (context) => {
9898
+ const hasConfig = await hasApmConfig(context.repoPath);
9899
+ if (!hasConfig) {
9900
+ return { status: "skip", reason: "No apm.yml found \u2014 skipping lockfile check." };
9901
+ }
9902
+ const found = await hasApmLockfile(context.repoPath);
9903
+ return {
9904
+ status: found ? "pass" : "fail",
9905
+ reason: found ? void 0 : "apm.yml found but dependencies are not locked. Run `apm install` to generate apm.lock.yaml.",
9906
+ evidence: ["apm.lock.yaml"]
9907
+ };
9908
+ }
9909
+ },
9910
+ {
9911
+ id: "apm-ci-integration",
9912
+ title: "APM integrated in CI pipeline",
9913
+ pillar: "ai-tooling",
9914
+ level: 4,
9915
+ scope: "repo",
9916
+ impact: "high",
9917
+ effort: "medium",
9918
+ check: async (context) => {
9919
+ const hasConfig = await hasApmConfig(context.repoPath);
9920
+ if (!hasConfig) {
9921
+ return { status: "skip", reason: "No apm.yml found \u2014 skipping CI check." };
9922
+ }
9923
+ const found = await hasApmInWorkflows(context.repoPath);
9924
+ return {
9925
+ status: found ? "pass" : "fail",
9926
+ reason: found ? void 0 : "No APM step found in CI. Add `microsoft/apm-action` to your workflow to audit agent packages on every PR. See: https://github.com/microsoft/apm-action",
9927
+ evidence: [".github/workflows/*.{yml,yaml}"]
9928
+ };
9929
+ }
9930
+ },
9706
9931
  // ── Area-scoped criteria (only run when areaPath is set) ──
9707
9932
  {
9708
9933
  id: "area-readme",
@@ -9740,7 +9965,7 @@ function buildCriteria() {
9740
9965
  if (area?.scripts?.build) {
9741
9966
  return { status: "pass" };
9742
9967
  }
9743
- const pkgPath = path9.join(context.areaPath, "package.json");
9968
+ const pkgPath = path10.join(context.areaPath, "package.json");
9744
9969
  const pkg = await readJson(pkgPath);
9745
9970
  const scripts = pkg?.scripts ?? {};
9746
9971
  const found = Boolean(scripts.build);
@@ -9765,7 +9990,7 @@ function buildCriteria() {
9765
9990
  if (area?.scripts?.test) {
9766
9991
  return { status: "pass" };
9767
9992
  }
9768
- const pkgPath = path9.join(context.areaPath, "package.json");
9993
+ const pkgPath = path10.join(context.areaPath, "package.json");
9769
9994
  const pkg = await readJson(pkgPath);
9770
9995
  const scripts = pkg?.scripts ?? {};
9771
9996
  const found = Boolean(scripts.test);
@@ -9788,7 +10013,7 @@ function buildCriteria() {
9788
10013
  return { status: "skip", reason: "No area context." };
9789
10014
  }
9790
10015
  const sanitized = sanitizeAreaName(area.name);
9791
- const instructionPath = path9.join(
10016
+ const instructionPath = path10.join(
9792
10017
  context.repoPath,
9793
10018
  ".github",
9794
10019
  "instructions",
@@ -9803,13 +10028,16 @@ function buildCriteria() {
9803
10028
  }
9804
10029
  ];
9805
10030
  }
10031
+
10032
+ // packages/core/src/services/readiness/extras.ts
10033
+ import path11 from "path";
9806
10034
  function buildExtras() {
9807
10035
  return [
9808
10036
  {
9809
10037
  id: "agents-doc",
9810
10038
  title: "AGENTS.md present",
9811
10039
  check: async (context) => {
9812
- const found = await fileExists(path9.join(context.repoPath, "AGENTS.md"));
10040
+ const found = await fileExists(path11.join(context.repoPath, "AGENTS.md"));
9813
10041
  return {
9814
10042
  status: found ? "pass" : "fail",
9815
10043
  reason: found ? void 0 : "Missing AGENTS.md to guide coding agents."
@@ -9864,6 +10092,53 @@ async function runExtras(context, extraDefs) {
9864
10092
  }
9865
10093
  return results;
9866
10094
  }
10095
+
10096
+ // packages/core/src/services/readiness/types.ts
10097
+ var PILLAR_GROUPS = {
10098
+ "style-validation": "repo-health",
10099
+ "build-system": "repo-health",
10100
+ testing: "repo-health",
10101
+ documentation: "repo-health",
10102
+ "dev-environment": "repo-health",
10103
+ "code-quality": "repo-health",
10104
+ observability: "repo-health",
10105
+ "security-governance": "repo-health",
10106
+ "ai-tooling": "ai-setup"
10107
+ };
10108
+ var PILLAR_GROUP_NAMES = {
10109
+ "repo-health": "Repo Health",
10110
+ "ai-setup": "AI Setup"
10111
+ };
10112
+
10113
+ // packages/core/src/services/readiness/scoring.ts
10114
+ function groupPillars(pillars) {
10115
+ const groups = ["repo-health", "ai-setup"];
10116
+ return groups.map((group) => ({
10117
+ group,
10118
+ label: PILLAR_GROUP_NAMES[group],
10119
+ pillars: pillars.filter((p) => PILLAR_GROUPS[p.id] === group)
10120
+ }));
10121
+ }
10122
+ function getLevelName(level) {
10123
+ const names = {
10124
+ 1: "Functional",
10125
+ 2: "Documented",
10126
+ 3: "Standardized",
10127
+ 4: "Optimized",
10128
+ 5: "Autonomous"
10129
+ };
10130
+ return names[level] || "Unknown";
10131
+ }
10132
+ function getLevelDescription(level) {
10133
+ const descriptions = {
10134
+ 1: "Repo builds, tests run, and basic tooling (linter, lockfile) is in place. AI agents can clone and get started.",
10135
+ 2: "README, CONTRIBUTING guide, and custom instructions exist. Agents understand project context and conventions.",
10136
+ 3: "CI/CD, security policies, CODEOWNERS, and observability are configured. Agents operate within well-defined guardrails.",
10137
+ 4: "MCP servers, custom agents, and AI skills are set up. Agents have deep integration with project-specific tools and workflows.",
10138
+ 5: "Full AI-native development: agents can independently plan, implement, test, and ship changes with minimal human oversight."
10139
+ };
10140
+ return descriptions[level] || "";
10141
+ }
9867
10142
  function summarizePillars(criteria) {
9868
10143
  const pillarNames = {
9869
10144
  "style-validation": "Style & Validation",
@@ -9924,246 +10199,211 @@ function countStatus(items) {
9924
10199
  const passed = relevant.filter((item) => item.status === "pass").length;
9925
10200
  return { passed, total: relevant.length };
9926
10201
  }
9927
- function hasAnyFile(files, candidates) {
9928
- return candidates.some((candidate) => files.includes(candidate));
9929
- }
9930
- async function hasReadme(repoPath) {
9931
- const files = await safeReadDir(repoPath);
9932
- return files.some(
9933
- (file) => file.toLowerCase() === "readme.md" || file.toLowerCase() === "readme"
9934
- );
9935
- }
9936
- async function hasLintConfig(repoPath) {
9937
- return hasAnyFile(await safeReadDir(repoPath), [
9938
- "eslint.config.js",
9939
- "eslint.config.mjs",
9940
- ".eslintrc",
9941
- ".eslintrc.js",
9942
- ".eslintrc.cjs",
9943
- ".eslintrc.json",
9944
- ".eslintrc.yml",
9945
- ".eslintrc.yaml",
9946
- "biome.json",
9947
- "biome.jsonc",
9948
- ".prettierrc",
9949
- ".prettierrc.json",
9950
- ".prettierrc.js",
9951
- ".prettierrc.cjs",
9952
- "prettier.config.js",
9953
- "prettier.config.cjs"
9954
- ]);
9955
- }
9956
- async function hasFormatterConfig(repoPath) {
9957
- return hasAnyFile(await safeReadDir(repoPath), [
9958
- "biome.json",
9959
- "biome.jsonc",
9960
- ".prettierrc",
9961
- ".prettierrc.json",
9962
- ".prettierrc.js",
9963
- ".prettierrc.cjs",
9964
- "prettier.config.js",
9965
- "prettier.config.cjs"
9966
- ]);
9967
- }
9968
- async function hasTypecheckConfig(repoPath) {
9969
- return hasAnyFile(await safeReadDir(repoPath), [
9970
- "tsconfig.json",
9971
- "tsconfig.base.json",
9972
- "pyproject.toml",
9973
- "mypy.ini"
9974
- ]);
9975
- }
9976
- async function hasGithubWorkflows(repoPath) {
9977
- return fileExists(path9.join(repoPath, ".github", "workflows"));
9978
- }
9979
- async function hasCodeowners(repoPath) {
9980
- const root = await fileExists(path9.join(repoPath, "CODEOWNERS"));
9981
- const github = await fileExists(path9.join(repoPath, ".github", "CODEOWNERS"));
9982
- return root || github;
9983
- }
9984
- async function hasLicense(repoPath) {
9985
- const files = await safeReadDir(repoPath);
9986
- return files.some((file) => file.toLowerCase().startsWith("license"));
9987
- }
9988
- async function hasPullRequestTemplate(repoPath) {
9989
- const direct = await fileExists(path9.join(repoPath, ".github", "PULL_REQUEST_TEMPLATE.md"));
9990
- if (direct) return true;
9991
- const dir = path9.join(repoPath, ".github", "PULL_REQUEST_TEMPLATE");
9992
- try {
9993
- const entries = await fs7.readdir(dir);
9994
- return entries.some((entry) => entry.toLowerCase().endsWith(".md"));
9995
- } catch {
9996
- return false;
9997
- }
9998
- }
9999
- async function hasPrecommitConfig(repoPath) {
10000
- const precommit = await fileExists(path9.join(repoPath, ".pre-commit-config.yaml"));
10001
- if (precommit) return true;
10002
- return fileExists(path9.join(repoPath, ".husky"));
10003
- }
10004
- async function hasArchitectureDoc(repoPath) {
10005
- const files = await safeReadDir(repoPath);
10006
- if (files.some((file) => file.toLowerCase() === "architecture.md")) return true;
10007
- return fileExists(path9.join(repoPath, "docs", "architecture.md"));
10008
- }
10009
- async function hasCustomInstructions(repoPath) {
10010
- const found = [];
10011
- const candidates = [
10012
- ".github/copilot-instructions.md",
10013
- "CLAUDE.md",
10014
- ".claude/CLAUDE.md",
10015
- "AGENTS.md",
10016
- ".github/AGENTS.md",
10017
- ".cursorrules",
10018
- ".cursorignore",
10019
- ".windsurfrules",
10020
- ".github/instructions.md",
10021
- "copilot-instructions.md"
10022
- ];
10023
- for (const candidate of candidates) {
10024
- if (await fileExists(path9.join(repoPath, candidate))) {
10025
- found.push(candidate);
10202
+
10203
+ // packages/core/src/services/readiness/index.ts
10204
+ async function runReadinessReport(options) {
10205
+ const repoPath = options.repoPath;
10206
+ const analysis = await analyzeRepo(repoPath);
10207
+ const rootFiles = await safeReadDir(repoPath);
10208
+ const rootPackageJson = await readJson(path12.join(repoPath, "package.json"));
10209
+ const apps = analysis.apps?.length ? analysis.apps : [];
10210
+ const vscodeLocations = await parseVscodeLocations(repoPath, rootFiles);
10211
+ const context = {
10212
+ repoPath,
10213
+ analysis,
10214
+ apps,
10215
+ rootFiles,
10216
+ rootPackageJson,
10217
+ vscodeLocations
10218
+ };
10219
+ let policySources = options.policies;
10220
+ let isConfigSourced = false;
10221
+ if (!policySources?.length) {
10222
+ const agentrcConfig = await loadAgentrcConfig(repoPath);
10223
+ if (agentrcConfig?.policies?.length) {
10224
+ policySources = agentrcConfig.policies;
10225
+ isConfigSourced = true;
10026
10226
  }
10027
10227
  }
10028
- return found;
10029
- }
10030
- async function hasFileBasedInstructions(repoPath) {
10031
- const instructionsDir = path9.join(repoPath, ".github", "instructions");
10032
- try {
10033
- const entries = await fs7.readdir(instructionsDir);
10034
- return entries.filter((e) => e.endsWith(".instructions.md")).map((e) => `.github/instructions/${e}`);
10035
- } catch {
10036
- return [];
10037
- }
10038
- }
10039
- function contentSimilarity(a, b) {
10040
- const normalize = (s) => new Set(
10041
- s.toLowerCase().split("\n").map((l) => l.trim().replace(/\s+/gu, " ")).filter((l) => l.length > 0)
10042
- );
10043
- const setA = normalize(a);
10044
- const setB = normalize(b);
10045
- if (setA.size === 0 && setB.size === 0) return 1;
10046
- let intersection = 0;
10047
- for (const line of setA) {
10048
- if (setB.has(line)) intersection++;
10049
- }
10050
- const union = (/* @__PURE__ */ new Set([...setA, ...setB])).size;
10051
- return union === 0 ? 1 : intersection / union;
10052
- }
10053
- async function checkInstructionConsistency(repoPath, foundFiles) {
10054
- if (foundFiles.length <= 1) {
10055
- return { unified: true, files: foundFiles };
10056
- }
10057
- const realPathMap = /* @__PURE__ */ new Map();
10058
- for (const file of foundFiles) {
10059
- const fullPath = path9.join(repoPath, file);
10060
- try {
10061
- const real = await fs7.realpath(fullPath);
10062
- const group = realPathMap.get(real) ?? [];
10063
- group.push(file);
10064
- realPathMap.set(real, group);
10065
- } catch {
10066
- realPathMap.set(fullPath, [file]);
10228
+ const baseCriteria = buildCriteria();
10229
+ const baseExtras = buildExtras();
10230
+ let resolvedCriteria;
10231
+ let resolvedExtras;
10232
+ let passRateThreshold = 0.8;
10233
+ let policyInfo;
10234
+ if (policySources?.length) {
10235
+ const policyConfigs = [];
10236
+ for (const source of policySources) {
10237
+ policyConfigs.push(await loadPolicy(source, { jsonOnly: isConfigSourced }));
10067
10238
  }
10239
+ const resolved = resolveChain(baseCriteria, baseExtras, policyConfigs);
10240
+ resolvedCriteria = resolved.criteria;
10241
+ resolvedExtras = resolved.extras;
10242
+ passRateThreshold = resolved.thresholds.passRate;
10243
+ policyInfo = { chain: resolved.chain, criteriaCount: resolved.criteria.length };
10244
+ } else {
10245
+ resolvedCriteria = baseCriteria;
10246
+ resolvedExtras = baseExtras;
10068
10247
  }
10069
- const groups = [...realPathMap.values()];
10070
- if (groups.length <= 1) {
10071
- return { unified: true, files: foundFiles };
10072
- }
10073
- const contents = [];
10074
- for (const group of groups) {
10075
- try {
10076
- contents.push(await fs7.readFile(path9.join(repoPath, group[0]), "utf8"));
10077
- } catch {
10078
- contents.push("");
10248
+ const criteriaResults = [];
10249
+ for (const criterion of resolvedCriteria) {
10250
+ if (criterion.scope === "repo") {
10251
+ const result = await criterion.check(context);
10252
+ criteriaResults.push({
10253
+ id: criterion.id,
10254
+ title: criterion.title,
10255
+ pillar: criterion.pillar,
10256
+ level: criterion.level,
10257
+ scope: criterion.scope,
10258
+ impact: criterion.impact,
10259
+ effort: criterion.effort,
10260
+ status: result.status,
10261
+ reason: result.reason,
10262
+ evidence: result.evidence
10263
+ });
10264
+ continue;
10079
10265
  }
10080
- }
10081
- let minSimilarity = 1;
10082
- for (let i = 0; i < contents.length; i++) {
10083
- for (let j = i + 1; j < contents.length; j++) {
10084
- minSimilarity = Math.min(minSimilarity, contentSimilarity(contents[i], contents[j]));
10266
+ if (criterion.scope === "area") {
10267
+ if (!options.perArea) continue;
10268
+ const areas2 = analysis.areas ?? [];
10269
+ if (areas2.length === 0) continue;
10270
+ criteriaResults.push({
10271
+ id: criterion.id,
10272
+ title: criterion.title,
10273
+ pillar: criterion.pillar,
10274
+ level: criterion.level,
10275
+ scope: criterion.scope,
10276
+ impact: criterion.impact,
10277
+ effort: criterion.effort,
10278
+ status: "skip",
10279
+ reason: "Run with --per-area for area breakdown."
10280
+ });
10281
+ continue;
10085
10282
  }
10086
- }
10087
- return {
10088
- unified: minSimilarity >= 0.9,
10089
- files: foundFiles,
10090
- similarity: Math.round(minSimilarity * 100) / 100
10091
- };
10092
- }
10093
- async function hasMcpConfig(repoPath) {
10094
- const found = [];
10095
- if (await fileExists(path9.join(repoPath, ".vscode", "mcp.json"))) {
10096
- found.push(".vscode/mcp.json");
10097
- }
10098
- if (await fileExists(path9.join(repoPath, "mcp.json"))) {
10099
- found.push("mcp.json");
10100
- }
10101
- const settings = await readJson(path9.join(repoPath, ".vscode", "settings.json"));
10102
- if (settings && (settings["mcp"] || settings["github.copilot.chat.mcp.enabled"])) {
10103
- found.push(".vscode/settings.json (mcp section)");
10104
- }
10105
- if (await fileExists(path9.join(repoPath, ".claude", "mcp.json"))) {
10106
- found.push(".claude/mcp.json");
10107
- }
10108
- return found;
10109
- }
10110
- async function hasCustomAgents(repoPath) {
10111
- const found = [];
10112
- const agentDirs = [".github/agents", ".copilot/agents", ".github/copilot/agents"];
10113
- for (const dir of agentDirs) {
10114
- if (await fileExists(path9.join(repoPath, dir))) {
10115
- found.push(dir);
10283
+ const appResults = await Promise.all(
10284
+ apps.map(async (app) => ({
10285
+ app,
10286
+ result: await criterion.check(context, app)
10287
+ }))
10288
+ );
10289
+ if (!appResults.length) {
10290
+ criteriaResults.push({
10291
+ id: criterion.id,
10292
+ title: criterion.title,
10293
+ pillar: criterion.pillar,
10294
+ level: criterion.level,
10295
+ scope: criterion.scope,
10296
+ impact: criterion.impact,
10297
+ effort: criterion.effort,
10298
+ status: "skip",
10299
+ reason: "No application packages detected."
10300
+ });
10301
+ continue;
10116
10302
  }
10303
+ const passed = appResults.filter((entry) => entry.result.status === "pass").length;
10304
+ const total = appResults.length;
10305
+ const passRate = total ? passed / total : 0;
10306
+ const status = passRate >= passRateThreshold ? "pass" : "fail";
10307
+ const failures = appResults.filter((entry) => entry.result.status !== "pass").map((entry) => entry.app.name);
10308
+ criteriaResults.push({
10309
+ id: criterion.id,
10310
+ title: criterion.title,
10311
+ pillar: criterion.pillar,
10312
+ level: criterion.level,
10313
+ scope: criterion.scope,
10314
+ impact: criterion.impact,
10315
+ effort: criterion.effort,
10316
+ status,
10317
+ reason: status === "pass" ? void 0 : `Only ${passed}/${total} apps pass this check.`,
10318
+ passRate,
10319
+ appSummary: { passed, total },
10320
+ appFailures: failures
10321
+ });
10117
10322
  }
10118
- const agentFiles = [".github/copilot-agents.yml", ".github/copilot-agents.yaml"];
10119
- for (const agentFile of agentFiles) {
10120
- if (await fileExists(path9.join(repoPath, agentFile))) {
10121
- found.push(agentFile);
10323
+ let areaReports;
10324
+ const areas = analysis.areas ?? [];
10325
+ if (options.perArea && areas.length > 0) {
10326
+ const areaCriteria = resolvedCriteria.filter((c) => c.scope === "area");
10327
+ areaReports = [];
10328
+ for (const area of areas) {
10329
+ if (!area.path) continue;
10330
+ const areaFiles = await safeReadDir(area.path);
10331
+ const areaContext = {
10332
+ ...context,
10333
+ areaPath: area.path,
10334
+ areaFiles
10335
+ };
10336
+ const areaResults = [];
10337
+ for (const criterion of areaCriteria) {
10338
+ const result = await criterion.check(areaContext, void 0, area);
10339
+ areaResults.push({
10340
+ id: criterion.id,
10341
+ title: criterion.title,
10342
+ pillar: criterion.pillar,
10343
+ level: criterion.level,
10344
+ scope: criterion.scope,
10345
+ impact: criterion.impact,
10346
+ effort: criterion.effort,
10347
+ status: result.status,
10348
+ reason: result.reason,
10349
+ evidence: result.evidence
10350
+ });
10351
+ }
10352
+ const areaPillars = summarizePillars(areaResults);
10353
+ areaReports.push({ area, criteria: areaResults, pillars: areaPillars });
10122
10354
  }
10123
- }
10124
- return found;
10125
- }
10126
- async function hasCopilotSkills(repoPath) {
10127
- const found = [];
10128
- const skillDirs = [
10129
- ".copilot/skills",
10130
- ".github/skills",
10131
- ".claude/skills",
10132
- ".github/copilot/skills"
10133
- ];
10134
- for (const dir of skillDirs) {
10135
- if (await fileExists(path9.join(repoPath, dir))) {
10136
- found.push(dir);
10355
+ for (const criterion of criteriaResults) {
10356
+ if (criterion.scope !== "area") continue;
10357
+ const perAreaResults = areaReports.map((ar) => ar.criteria.find((c) => c.id === criterion.id)).filter(Boolean);
10358
+ if (!perAreaResults.length) continue;
10359
+ const passed = perAreaResults.filter((r) => r.status === "pass").length;
10360
+ const total = perAreaResults.length;
10361
+ const passRate = total ? passed / total : 0;
10362
+ criterion.status = passRate >= passRateThreshold ? "pass" : "fail";
10363
+ criterion.reason = criterion.status === "pass" ? void 0 : `Only ${passed}/${total} areas pass this check.`;
10364
+ criterion.passRate = passRate;
10365
+ criterion.areaSummary = { passed, total };
10366
+ criterion.areaFailures = areaReports.filter((ar) => ar.criteria.find((c) => c.id === criterion.id)?.status !== "pass").map((ar) => ar.area.name);
10137
10367
  }
10138
10368
  }
10139
- return found;
10140
- }
10141
- async function readAllDependencies(context) {
10142
- const dependencies = [];
10143
- const apps = context.apps.length ? context.apps : [];
10144
- for (const app of apps) {
10145
- if (!app.packageJsonPath) continue;
10146
- const pkg = await readJson(app.packageJsonPath);
10147
- const deps = pkg?.dependencies ?? {};
10148
- const devDeps = pkg?.devDependencies ?? {};
10149
- dependencies.push(
10150
- ...Object.keys({
10151
- ...deps,
10152
- ...devDeps
10153
- })
10154
- );
10155
- }
10156
- if (!apps.length && context.rootPackageJson) {
10157
- const rootDeps = context.rootPackageJson.dependencies ?? {};
10158
- const rootDevDeps = context.rootPackageJson.devDependencies ?? {};
10159
- dependencies.push(
10160
- ...Object.keys({
10161
- ...rootDeps,
10162
- ...rootDevDeps
10163
- })
10164
- );
10369
+ const pillars = summarizePillars(criteriaResults);
10370
+ const levels = summarizeLevels(criteriaResults, passRateThreshold);
10371
+ const achievedLevel = levels.filter((level) => level.achieved).reduce((acc, level) => Math.max(acc, level.level), 0);
10372
+ const extras = options.includeExtras === false ? [] : await runExtras(context, resolvedExtras);
10373
+ let engine;
10374
+ if (options.shadow) {
10375
+ const policyCtx = {
10376
+ repoPath,
10377
+ rootFiles,
10378
+ rootPackageJson,
10379
+ cache: /* @__PURE__ */ new Map(),
10380
+ analysis,
10381
+ apps
10382
+ };
10383
+ const engineChain = await loadPluginChain(policySources ?? [], { jsonOnly: isConfigSourced });
10384
+ const engineReport = await executePlugins(engineChain.plugins, policyCtx, engineChain.options);
10385
+ engine = {
10386
+ signals: engineReport.signals,
10387
+ recommendations: engineReport.recommendations,
10388
+ policyWarnings: engineReport.policyWarnings,
10389
+ score: engineReport.score,
10390
+ grade: engineReport.grade
10391
+ };
10165
10392
  }
10166
- return Array.from(new Set(dependencies));
10393
+ return {
10394
+ repoPath,
10395
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
10396
+ isMonorepo: analysis.isMonorepo ?? false,
10397
+ apps: apps.map((app) => ({ name: app.name, path: app.path })),
10398
+ pillars,
10399
+ levels,
10400
+ achievedLevel,
10401
+ criteria: criteriaResults,
10402
+ extras,
10403
+ areaReports,
10404
+ policies: policyInfo,
10405
+ engine
10406
+ };
10167
10407
  }
10168
10408
 
10169
10409
  // packages/core/src/services/batch.ts
@@ -10185,7 +10425,7 @@ async function processRepo(params) {
10185
10425
  } = params;
10186
10426
  try {
10187
10427
  progress?.update(`${label}: Cloning...`);
10188
- const cacheRoot = path10.join(process.cwd(), ".agentrc-cache");
10428
+ const cacheRoot = path13.join(process.cwd(), ".agentrc-cache");
10189
10429
  const repoPath = validateCachePath(cacheRoot, ...cacheParts);
10190
10430
  await ensureDir(repoPath);
10191
10431
  if (!await isGitRepo(repoPath)) {
@@ -10211,8 +10451,8 @@ async function processRepo(params) {
10211
10451
  if (!instructions.trim()) {
10212
10452
  throw new Error("Generated instructions were empty");
10213
10453
  }
10214
- const instructionsPath = path10.join(repoPath, ".github", "copilot-instructions.md");
10215
- await ensureDir(path10.dirname(instructionsPath));
10454
+ const instructionsPath = path13.join(repoPath, ".github", "copilot-instructions.md");
10455
+ await ensureDir(path13.dirname(instructionsPath));
10216
10456
  const { wrote, reason } = await safeWriteFile(instructionsPath, instructions, true);
10217
10457
  if (!wrote) {
10218
10458
  throw new Error(
@@ -10349,7 +10589,7 @@ async function processBatchReadinessRepo(options) {
10349
10589
  try {
10350
10590
  progress(`Cloning ${repo.fullName}...`);
10351
10591
  const authedUrl = buildAuthedUrl(repo.cloneUrl, token, "github");
10352
- await ensureDir(path10.dirname(repoDir));
10592
+ await ensureDir(path13.dirname(repoDir));
10353
10593
  await cloneRepo(authedUrl, repoDir, { shallow: true });
10354
10594
  await setRemoteUrl(repoDir, repo.cloneUrl).catch(() => {
10355
10595
  });
@@ -11399,7 +11639,7 @@ import { render as render2 } from "ink";
11399
11639
  // src/ui/BatchReadinessTui.tsx
11400
11640
  import fs8 from "fs/promises";
11401
11641
  import os from "os";
11402
- import path11 from "path";
11642
+ import path14 from "path";
11403
11643
 
11404
11644
  // packages/core/src/services/visualReport.ts
11405
11645
  function generateVisualReport(options) {
@@ -12425,7 +12665,7 @@ function BatchReadinessTui({ token, outputPath, policies }) {
12425
12665
  setStatus("processing");
12426
12666
  const selectedRepos = Array.from(selectedRepoIndices).map((i) => repos[i]);
12427
12667
  const results2 = [];
12428
- const tmpDir = path11.join(os.tmpdir(), `agentrc-batch-readiness-${Date.now()}`);
12668
+ const tmpDir = path14.join(os.tmpdir(), `agentrc-batch-readiness-${Date.now()}`);
12429
12669
  try {
12430
12670
  await ensureDir(tmpDir);
12431
12671
  for (let i = 0; i < selectedRepos.length; i++) {
@@ -12462,7 +12702,7 @@ function BatchReadinessTui({ token, outputPath, policies }) {
12462
12702
  title: "Batch Readiness Report",
12463
12703
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
12464
12704
  });
12465
- const finalOutputPath = outputPath ?? path11.join(process.cwd(), "batch-readiness-report.html");
12705
+ const finalOutputPath = outputPath ?? path14.join(process.cwd(), "batch-readiness-report.html");
12466
12706
  const { wrote, reason } = await safeWriteFile(finalOutputPath, html, true);
12467
12707
  if (!wrote) throw new Error(reason === "symlink" ? "Path is a symlink" : "Write failed");
12468
12708
  setStatus("complete");
@@ -12644,7 +12884,7 @@ async function batchReadinessCommand(options) {
12644
12884
  }
12645
12885
 
12646
12886
  // src/commands/eval.ts
12647
- import path13 from "path";
12887
+ import path16 from "path";
12648
12888
 
12649
12889
  // packages/core/src/services/evalScaffold.ts
12650
12890
  var EVAL_SCAFFOLD_TIMEOUT_MS = 6e5;
@@ -12839,17 +13079,17 @@ function normalizeExpectation(value) {
12839
13079
 
12840
13080
  // packages/core/src/services/evaluator.ts
12841
13081
  import fs9 from "fs/promises";
12842
- import path12 from "path";
13082
+ import path15 from "path";
12843
13083
  var DEFAULT_SYSTEM_MESSAGE = "Research using read-only tools and make a plan for the given task, including concrete implementation steps and verification steps.";
12844
13084
  async function runEval(options) {
12845
13085
  const config = await loadConfig(options.configPath);
12846
13086
  const instructionFile = config.instructionFile ?? ".github/copilot-instructions.md";
12847
- const instructionPath = path12.resolve(options.repoPath, instructionFile);
13087
+ const instructionPath = path15.resolve(options.repoPath, instructionFile);
12848
13088
  const instructionText = await readOptionalFile(instructionPath);
12849
13089
  const baseSystemMessage = config.systemMessage ?? DEFAULT_SYSTEM_MESSAGE;
12850
13090
  const progress = options.onProgress ?? (() => {
12851
13091
  });
12852
- const defaultOutputPath = path12.resolve(
13092
+ const defaultOutputPath = path15.resolve(
12853
13093
  options.repoPath,
12854
13094
  ".agentrc",
12855
13095
  "evals",
@@ -12869,9 +13109,9 @@ async function runEval(options) {
12869
13109
  const caseStartedAt = Date.now();
12870
13110
  let caseWorkingDir;
12871
13111
  if (testCase.workingDirectory) {
12872
- const resolved = path12.resolve(options.repoPath, testCase.workingDirectory);
12873
- const root = path12.resolve(options.repoPath);
12874
- if (resolved !== root && !resolved.startsWith(root + path12.sep)) {
13112
+ const resolved = path15.resolve(options.repoPath, testCase.workingDirectory);
13113
+ const root = path15.resolve(options.repoPath);
13114
+ if (resolved !== root && !resolved.startsWith(root + path15.sep)) {
12875
13115
  throw new Error(
12876
13116
  `Invalid workingDirectory "${testCase.workingDirectory}": escapes repo boundary`
12877
13117
  );
@@ -12943,7 +13183,7 @@ async function runEval(options) {
12943
13183
  };
12944
13184
  let viewerPath;
12945
13185
  if (outputPath) {
12946
- await fs9.mkdir(path12.dirname(outputPath), { recursive: true });
13186
+ await fs9.mkdir(path15.dirname(outputPath), { recursive: true });
12947
13187
  await safeWriteFile(outputPath, JSON.stringify(output, null, 2), true);
12948
13188
  viewerPath = buildViewerPath(outputPath);
12949
13189
  await safeWriteFile(viewerPath, buildTrajectoryViewerHtml(output), true);
@@ -13258,7 +13498,7 @@ function formatTokenUsage(usage) {
13258
13498
  function resolveOutputPath(repoPath, override, configValue) {
13259
13499
  const chosen = override ?? configValue;
13260
13500
  if (!chosen) return void 0;
13261
- return path12.isAbsolute(chosen) ? chosen : path12.resolve(repoPath, chosen);
13501
+ return path15.isAbsolute(chosen) ? chosen : path15.resolve(repoPath, chosen);
13262
13502
  }
13263
13503
  function buildViewerPath(outputPath) {
13264
13504
  if (outputPath.endsWith(".json")) {
@@ -13613,7 +13853,7 @@ function sanitizeValue(value, depth) {
13613
13853
 
13614
13854
  // src/commands/eval.ts
13615
13855
  async function evalCommand(configPathArg, options) {
13616
- const repoPath = path13.resolve(options.repo ?? process.cwd());
13856
+ const repoPath = path16.resolve(options.repo ?? process.cwd());
13617
13857
  if (options.listModels) {
13618
13858
  try {
13619
13859
  const models = await listCopilotModels();
@@ -13649,7 +13889,7 @@ async function evalCommand(configPathArg, options) {
13649
13889
  return;
13650
13890
  }
13651
13891
  if (options.init) {
13652
- const outputPath = path13.join(repoPath, "agentrc.eval.json");
13892
+ const outputPath = path16.join(repoPath, "agentrc.eval.json");
13653
13893
  const desiredCount = Math.max(1, Number.parseInt(options.count ?? "5", 10) || 5);
13654
13894
  try {
13655
13895
  const progress = createProgressReporter(!shouldLog(options));
@@ -13691,7 +13931,7 @@ async function evalCommand(configPathArg, options) {
13691
13931
  }
13692
13932
  return;
13693
13933
  }
13694
- const configPath = path13.resolve(configPathArg ?? path13.join(repoPath, "agentrc.eval.json"));
13934
+ const configPath = path16.resolve(configPathArg ?? path16.join(repoPath, "agentrc.eval.json"));
13695
13935
  try {
13696
13936
  const progress = createProgressReporter(!shouldLog(options));
13697
13937
  const { summary, results, viewerPath } = await runEval({
@@ -13738,12 +13978,12 @@ async function evalCommand(configPathArg, options) {
13738
13978
  }
13739
13979
 
13740
13980
  // src/commands/generate.ts
13741
- import path16 from "path";
13981
+ import path19 from "path";
13742
13982
 
13743
13983
  // packages/core/src/services/generator.ts
13744
- import path14 from "path";
13984
+ import path17 from "path";
13745
13985
  async function writeOrPreview(filePath, content, opts) {
13746
- const relPath = path14.relative(process.cwd(), filePath);
13986
+ const relPath = path17.relative(process.cwd(), filePath);
13747
13987
  if (opts.dryRun) {
13748
13988
  const wouldWrite = await canSafeWrite(filePath, opts.force);
13749
13989
  return {
@@ -13752,7 +13992,7 @@ async function writeOrPreview(filePath, content, opts) {
13752
13992
  bytes: Buffer.byteLength(content, "utf8")
13753
13993
  };
13754
13994
  }
13755
- await ensureDir(path14.dirname(filePath));
13995
+ await ensureDir(path17.dirname(filePath));
13756
13996
  const { wrote } = await safeWriteFile(filePath, content, opts.force);
13757
13997
  return { path: relPath, action: wrote ? "wrote" : "skipped" };
13758
13998
  }
@@ -13761,7 +14001,7 @@ async function generateConfigs(options) {
13761
14001
  const files = [];
13762
14002
  if (selections.includes("mcp")) {
13763
14003
  files.push(
13764
- await writeOrPreview(path14.join(repoPath, ".vscode", "mcp.json"), renderMcp(), {
14004
+ await writeOrPreview(path17.join(repoPath, ".vscode", "mcp.json"), renderMcp(), {
13765
14005
  dryRun,
13766
14006
  force
13767
14007
  })
@@ -13770,7 +14010,7 @@ async function generateConfigs(options) {
13770
14010
  if (selections.includes("vscode")) {
13771
14011
  files.push(
13772
14012
  await writeOrPreview(
13773
- path14.join(repoPath, ".vscode", "settings.json"),
14013
+ path17.join(repoPath, ".vscode", "settings.json"),
13774
14014
  renderVscodeSettings(analysis),
13775
14015
  { dryRun, force }
13776
14016
  )
@@ -13823,16 +14063,16 @@ function renderVscodeSettings(analysis) {
13823
14063
  }
13824
14064
 
13825
14065
  // src/commands/instructions.ts
13826
- import path15 from "path";
14066
+ import path18 from "path";
13827
14067
  function skipReason(action) {
13828
14068
  if (action === "symlink") return "symlink";
13829
14069
  if (action === "empty") return "empty content";
13830
14070
  return "exists, use --force";
13831
14071
  }
13832
14072
  async function instructionsCommand(options) {
13833
- const repoPath = path15.resolve(options.repo ?? process.cwd());
13834
- const outputPath = path15.resolve(
13835
- options.output ?? path15.join(repoPath, ".github", "copilot-instructions.md")
14073
+ const repoPath = path18.resolve(options.repo ?? process.cwd());
14074
+ const outputPath = path18.resolve(
14075
+ options.output ?? path18.join(repoPath, ".github", "copilot-instructions.md")
13836
14076
  );
13837
14077
  const progress = createProgressReporter(!shouldLog(options));
13838
14078
  const wantAreas = options.areas || options.areasOnly || options.area;
@@ -13879,7 +14119,7 @@ async function instructionsCommand(options) {
13879
14119
  ] : []
13880
14120
  ];
13881
14121
  for (const file of dryFiles) {
13882
- const relPath = path15.relative(process.cwd(), path15.join(repoPath, file.path));
14122
+ const relPath = path18.relative(process.cwd(), path18.join(repoPath, file.path));
13883
14123
  if (shouldLog(options)) {
13884
14124
  progress.update(
13885
14125
  `[dry-run] Would write ${relPath} (${Buffer.byteLength(file.content, "utf8")} bytes)`
@@ -13900,7 +14140,7 @@ async function instructionsCommand(options) {
13900
14140
  } else {
13901
14141
  const actions = await writeNestedInstructions(repoPath, nestedResult, options.force);
13902
14142
  for (const action of actions) {
13903
- const relPath = path15.relative(process.cwd(), action.path);
14143
+ const relPath = path18.relative(process.cwd(), action.path);
13904
14144
  if (action.action === "wrote") {
13905
14145
  if (shouldLog(options)) progress.succeed(`Wrote ${relPath}`);
13906
14146
  } else if (shouldLog(options)) {
@@ -13943,8 +14183,8 @@ async function instructionsCommand(options) {
13943
14183
  }
13944
14184
  if (content) {
13945
14185
  if (options.dryRun) {
13946
- const relPath = path15.relative(repoPath, outputPath);
13947
- const displayPath = path15.relative(process.cwd(), outputPath);
14186
+ const relPath = path18.relative(repoPath, outputPath);
14187
+ const displayPath = path18.relative(process.cwd(), outputPath);
13948
14188
  const byteCount = Buffer.byteLength(content, "utf8");
13949
14189
  if (shouldLog(options)) {
13950
14190
  progress.update(`[dry-run] Would write ${displayPath} (${byteCount} bytes)`);
@@ -13953,14 +14193,14 @@ async function instructionsCommand(options) {
13953
14193
  dryRunFiles.push({ path: relPath, bytes: byteCount });
13954
14194
  }
13955
14195
  } else {
13956
- await ensureDir(path15.dirname(outputPath));
14196
+ await ensureDir(path18.dirname(outputPath));
13957
14197
  const { wrote, reason } = await safeWriteFile(
13958
14198
  outputPath,
13959
14199
  content,
13960
14200
  Boolean(options.force)
13961
14201
  );
13962
14202
  if (!wrote) {
13963
- const relPath = path15.relative(process.cwd(), outputPath);
14203
+ const relPath = path18.relative(process.cwd(), outputPath);
13964
14204
  const why = reason === "symlink" ? "path is a symlink" : "file exists (use --force)";
13965
14205
  if (options.json) {
13966
14206
  const result = {
@@ -13982,7 +14222,7 @@ async function instructionsCommand(options) {
13982
14222
  };
13983
14223
  outputResult(result, true);
13984
14224
  } else if (shouldLog(options)) {
13985
- progress.succeed(`Updated ${path15.relative(process.cwd(), outputPath)}`);
14225
+ progress.succeed(`Updated ${path18.relative(process.cwd(), outputPath)}`);
13986
14226
  }
13987
14227
  }
13988
14228
  }
@@ -14049,7 +14289,7 @@ async function instructionsCommand(options) {
14049
14289
  ] : []
14050
14290
  ];
14051
14291
  for (const file of dryFiles) {
14052
- const relPath = path15.relative(process.cwd(), path15.join(repoPath, file.path));
14292
+ const relPath = path18.relative(process.cwd(), path18.join(repoPath, file.path));
14053
14293
  if (shouldLog(options)) {
14054
14294
  progress.update(
14055
14295
  `[dry-run] Would write ${relPath} (${Buffer.byteLength(file.content, "utf8")} bytes)`
@@ -14067,7 +14307,7 @@ async function instructionsCommand(options) {
14067
14307
  } else {
14068
14308
  const actions = await writeNestedInstructions(repoPath, nestedResult, options.force);
14069
14309
  for (const action of actions) {
14070
- const relPath = path15.relative(process.cwd(), action.path);
14310
+ const relPath = path18.relative(process.cwd(), action.path);
14071
14311
  if (action.action === "wrote") {
14072
14312
  if (shouldLog(options)) progress.succeed(`Wrote ${relPath}`);
14073
14313
  } else if (shouldLog(options)) {
@@ -14099,7 +14339,7 @@ async function instructionsCommand(options) {
14099
14339
  }
14100
14340
  if (options.json) {
14101
14341
  dryRunFiles.push({
14102
- path: path15.relative(repoPath, areaInstructionPath(repoPath, area)),
14342
+ path: path18.relative(repoPath, areaInstructionPath(repoPath, area)),
14103
14343
  bytes: Buffer.byteLength(body, "utf8")
14104
14344
  });
14105
14345
  }
@@ -14120,7 +14360,7 @@ async function instructionsCommand(options) {
14120
14360
  continue;
14121
14361
  }
14122
14362
  if (shouldLog(options)) {
14123
- progress.succeed(`Wrote ${path15.relative(process.cwd(), result.filePath)}`);
14363
+ progress.succeed(`Wrote ${path18.relative(process.cwd(), result.filePath)}`);
14124
14364
  }
14125
14365
  }
14126
14366
  }
@@ -14155,7 +14395,7 @@ async function instructionsCommand(options) {
14155
14395
 
14156
14396
  // src/commands/generate.ts
14157
14397
  async function generateCommand(type, repoPathArg, options) {
14158
- const repoPath = path16.resolve(repoPathArg ?? process.cwd());
14398
+ const repoPath = path19.resolve(repoPathArg ?? process.cwd());
14159
14399
  if (type === "instructions" || type === "agents") {
14160
14400
  if (!options.quiet) {
14161
14401
  process.stderr.write(
@@ -14169,7 +14409,7 @@ async function generateCommand(type, repoPathArg, options) {
14169
14409
  `
14170
14410
  );
14171
14411
  }
14172
- const output = type === "agents" ? path16.join(repoPath, "AGENTS.md") : void 0;
14412
+ const output = type === "agents" ? path19.join(repoPath, "AGENTS.md") : void 0;
14173
14413
  await instructionsCommand({
14174
14414
  repo: repoPath,
14175
14415
  output,
@@ -14235,17 +14475,19 @@ async function generateCommand(type, repoPathArg, options) {
14235
14475
  }
14236
14476
 
14237
14477
  // src/commands/init.ts
14238
- import path18 from "path";
14478
+ import { execFile as execFile3 } from "child_process";
14479
+ import path21 from "path";
14480
+ import { promisify as promisify3 } from "util";
14239
14481
 
14240
14482
  // packages/core/src/services/configScaffold.ts
14241
- import path17 from "path";
14483
+ import path20 from "path";
14242
14484
  async function scaffoldAgentrcConfig(repoPath, areas, force = false) {
14243
- const configPath = path17.join(repoPath, "agentrc.config.json");
14485
+ const configPath = path20.join(repoPath, "agentrc.config.json");
14244
14486
  const workspaces = areas.length > 0 ? await detectWorkspaces(repoPath, areas) : [];
14245
14487
  const workspacePaths = workspaces.map((ws) => ws.path + "/");
14246
14488
  const standaloneAreas = areas.filter((a) => {
14247
14489
  if (!a.path) return true;
14248
- const rel = path17.relative(repoPath, a.path).replace(/\\/gu, "/");
14490
+ const rel = path20.relative(repoPath, a.path).replace(/\\/gu, "/");
14249
14491
  return !workspacePaths.some((prefix) => rel.startsWith(prefix));
14250
14492
  }).map((a) => ({
14251
14493
  name: a.name,
@@ -14261,9 +14503,9 @@ async function scaffoldAgentrcConfig(repoPath, areas, force = false) {
14261
14503
  }
14262
14504
 
14263
14505
  // src/commands/init.ts
14264
- import { checkbox, select } from "@inquirer/prompts";
14506
+ import { checkbox, confirm, select } from "@inquirer/prompts";
14265
14507
  async function initCommand(repoPathArg, options) {
14266
- let repoPath = path18.resolve(repoPathArg ?? process.cwd());
14508
+ let repoPath = path21.resolve(repoPathArg ?? process.cwd());
14267
14509
  const provider = options.provider ?? (options.github ? "github" : void 0);
14268
14510
  if (provider && provider !== "github" && provider !== "azure") {
14269
14511
  outputError("Invalid provider. Use github or azure.", Boolean(options.json));
@@ -14301,7 +14543,7 @@ async function initCommand(repoPathArg, options) {
14301
14543
  value: repo
14302
14544
  }))
14303
14545
  });
14304
- const cacheRoot = path18.join(process.cwd(), ".agentrc-cache");
14546
+ const cacheRoot = path21.join(process.cwd(), ".agentrc-cache");
14305
14547
  repoPath = validateCachePath(cacheRoot, selection.owner, selection.name);
14306
14548
  await ensureDir(repoPath);
14307
14549
  const hasGit = await isGitRepo(repoPath);
@@ -14354,7 +14596,7 @@ async function initCommand(repoPathArg, options) {
14354
14596
  value: repo
14355
14597
  }))
14356
14598
  });
14357
- const cacheRoot = path18.join(process.cwd(), ".agentrc-cache");
14599
+ const cacheRoot = path21.join(process.cwd(), ".agentrc-cache");
14358
14600
  repoPath = validateCachePath(
14359
14601
  cacheRoot,
14360
14602
  orgSelection.name,
@@ -14393,17 +14635,17 @@ async function initCommand(repoPathArg, options) {
14393
14635
  });
14394
14636
  const allFiles = [];
14395
14637
  if (selections.includes("instructions")) {
14396
- const outputPath = path18.join(repoPath, ".github", "copilot-instructions.md");
14397
- await ensureDir(path18.dirname(outputPath));
14638
+ const outputPath = path21.join(repoPath, ".github", "copilot-instructions.md");
14639
+ await ensureDir(path21.dirname(outputPath));
14398
14640
  try {
14399
14641
  const content = await generateCopilotInstructions({ repoPath, model: options.model });
14400
14642
  const { wrote } = await safeWriteFile(outputPath, content, Boolean(options.force));
14401
14643
  allFiles.push({
14402
- path: path18.relative(process.cwd(), outputPath),
14644
+ path: path21.relative(process.cwd(), outputPath),
14403
14645
  action: wrote ? "wrote" : "skipped"
14404
14646
  });
14405
14647
  if (shouldLog(options)) {
14406
- const rel = path18.relative(process.cwd(), outputPath);
14648
+ const rel = path21.relative(process.cwd(), outputPath);
14407
14649
  process.stderr.write((wrote ? `Wrote ${rel}` : `Skipped ${rel} (exists)`) + "\n");
14408
14650
  }
14409
14651
  } catch (error) {
@@ -14436,12 +14678,13 @@ async function initCommand(repoPathArg, options) {
14436
14678
  analysis.areas ?? [],
14437
14679
  Boolean(options.force)
14438
14680
  );
14439
- const rel = path18.relative(process.cwd(), result.configPath);
14681
+ const rel = path21.relative(process.cwd(), result.configPath);
14440
14682
  allFiles.push({ path: rel, action: result.wrote ? "wrote" : "skipped" });
14441
14683
  if (shouldLog(options)) {
14442
14684
  process.stderr.write((result.wrote ? `Wrote ${rel}` : `Skipped ${rel} (exists)`) + "\n");
14443
14685
  }
14444
14686
  }
14687
+ await offerApmInit(repoPath, options);
14445
14688
  if (options.json) {
14446
14689
  const { ok, status } = deriveFileStatus(allFiles);
14447
14690
  const result = {
@@ -14463,9 +14706,52 @@ async function initCommand(repoPathArg, options) {
14463
14706
  process.stderr.write(" agentrc eval --init Scaffold evaluation test cases\n");
14464
14707
  }
14465
14708
  }
14709
+ var execFileAsync3 = promisify3(execFile3);
14710
+ var APM_TIMEOUT_MS = 1e4;
14711
+ async function isApmInstalled() {
14712
+ try {
14713
+ await execFileAsync3("apm", ["--version"], { timeout: APM_TIMEOUT_MS });
14714
+ return true;
14715
+ } catch {
14716
+ return false;
14717
+ }
14718
+ }
14719
+ async function offerApmInit(repoPath, options) {
14720
+ if (options.json) return;
14721
+ const hasApmYml = await fileExists(path21.join(repoPath, "apm.yml"));
14722
+ if (hasApmYml) return;
14723
+ const apmAvailable = await isApmInstalled();
14724
+ if (apmAvailable) {
14725
+ const accepted = options.yes ? true : await confirm({
14726
+ message: "Set up APM to install and share agent packages across your team?",
14727
+ default: false
14728
+ });
14729
+ if (accepted) {
14730
+ try {
14731
+ await execFileAsync3("apm", ["init", "--yes"], { cwd: repoPath, timeout: APM_TIMEOUT_MS });
14732
+ if (shouldLog(options)) {
14733
+ process.stderr.write(
14734
+ "APM initialized \u2014 run `apm install <package>` to add shared agent packages.\n"
14735
+ );
14736
+ }
14737
+ } catch (error) {
14738
+ if (shouldLog(options)) {
14739
+ process.stderr.write(
14740
+ `Warning: APM init failed; continuing without APM: ${error instanceof Error ? error.message : String(error)}
14741
+ `
14742
+ );
14743
+ }
14744
+ }
14745
+ }
14746
+ } else if (shouldLog(options)) {
14747
+ process.stderr.write(
14748
+ "\nTip: use APM to install shared agent packages and distribute your instructions across repos.\n https://github.com/microsoft/apm\n"
14749
+ );
14750
+ }
14751
+ }
14466
14752
 
14467
14753
  // src/commands/pr.ts
14468
- import path19 from "path";
14754
+ import path22 from "path";
14469
14755
  var DEFAULT_PR_BRANCH = "agentrc/add-ai-config";
14470
14756
  async function prCommand(repo, options) {
14471
14757
  const provider = options.provider ?? "github";
@@ -14499,7 +14785,7 @@ async function prCommand(repo, options) {
14499
14785
  try {
14500
14786
  progress.update("Fetching repo info...");
14501
14787
  const repoInfo = await getRepo(token2, organization, project, name2);
14502
- const cacheRoot = path19.join(process.cwd(), ".agentrc-cache");
14788
+ const cacheRoot = path22.join(process.cwd(), ".agentrc-cache");
14503
14789
  const repoPath = validateCachePath(cacheRoot, organization, project, name2);
14504
14790
  await ensureDir(repoPath);
14505
14791
  if (!await isGitRepo(repoPath)) {
@@ -14513,8 +14799,8 @@ async function prCommand(repo, options) {
14513
14799
  await checkoutBranch(repoPath, branch);
14514
14800
  progress.update("Generating instructions...");
14515
14801
  const instructions = await generateCopilotInstructions({ repoPath, model: options.model });
14516
- const instructionsPath = path19.join(repoPath, ".github", "copilot-instructions.md");
14517
- await ensureDir(path19.dirname(instructionsPath));
14802
+ const instructionsPath = path22.join(repoPath, ".github", "copilot-instructions.md");
14803
+ await ensureDir(path22.dirname(instructionsPath));
14518
14804
  const { wrote, reason } = await safeWriteFile(instructionsPath, instructions, true);
14519
14805
  if (!wrote) {
14520
14806
  throw new Error(
@@ -14581,7 +14867,7 @@ async function prCommand(repo, options) {
14581
14867
  try {
14582
14868
  progress.update("Fetching repo info...");
14583
14869
  const repoInfo = await getRepo2(token, owner, name);
14584
- const cacheRoot = path19.join(process.cwd(), ".agentrc-cache");
14870
+ const cacheRoot = path22.join(process.cwd(), ".agentrc-cache");
14585
14871
  const repoPath = validateCachePath(cacheRoot, owner, name);
14586
14872
  await ensureDir(repoPath);
14587
14873
  if (!await isGitRepo(repoPath)) {
@@ -14593,8 +14879,8 @@ async function prCommand(repo, options) {
14593
14879
  await checkoutBranch(repoPath, branch);
14594
14880
  progress.update("Generating instructions...");
14595
14881
  const instructions = await generateCopilotInstructions({ repoPath, model: options.model });
14596
- const instructionsPath = path19.join(repoPath, ".github", "copilot-instructions.md");
14597
- await ensureDir(path19.dirname(instructionsPath));
14882
+ const instructionsPath = path22.join(repoPath, ".github", "copilot-instructions.md");
14883
+ await ensureDir(path22.dirname(instructionsPath));
14598
14884
  const { wrote, reason } = await safeWriteFile(instructionsPath, instructions, true);
14599
14885
  if (!wrote) {
14600
14886
  throw new Error(
@@ -14643,13 +14929,13 @@ async function prCommand(repo, options) {
14643
14929
  }
14644
14930
 
14645
14931
  // src/commands/readiness.ts
14646
- import path20 from "path";
14932
+ import path23 from "path";
14647
14933
  import chalk3 from "chalk";
14648
14934
  async function readinessCommand(repoPathArg, options) {
14649
- const repoPath = path20.resolve(repoPathArg ?? process.cwd());
14650
- const repoName = path20.basename(repoPath);
14651
- const resolvedOutputPath = options.output ? path20.resolve(options.output) : "";
14652
- const outputExt = options.output ? path20.extname(options.output).toLowerCase() : "";
14935
+ const repoPath = path23.resolve(repoPathArg ?? process.cwd());
14936
+ const repoName = path23.basename(repoPath);
14937
+ const resolvedOutputPath = options.output ? path23.resolve(options.output) : "";
14938
+ const outputExt = options.output ? path23.extname(options.output).toLowerCase() : "";
14653
14939
  let failLevelError;
14654
14940
  let report;
14655
14941
  try {
@@ -14711,7 +14997,7 @@ async function readinessCommand(repoPathArg, options) {
14711
14997
  title: `Readiness Report: ${repoName}`,
14712
14998
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
14713
14999
  });
14714
- const outputPath = options.output ? resolvedOutputPath : path20.join(repoPath, "readiness-report.html");
15000
+ const outputPath = options.output ? resolvedOutputPath : path23.join(repoPath, "readiness-report.html");
14715
15001
  const { wrote, reason } = await safeWriteFile(outputPath, html, Boolean(options.force));
14716
15002
  if (!wrote) {
14717
15003
  const why = reason === "symlink" ? "path is a symlink" : "file exists (use --force)";
@@ -14946,12 +15232,12 @@ function formatReadinessMarkdown(report, repoName) {
14946
15232
  }
14947
15233
 
14948
15234
  // src/commands/tui.tsx
14949
- import path22 from "path";
15235
+ import path25 from "path";
14950
15236
  import { render as render3 } from "ink";
14951
15237
 
14952
15238
  // src/ui/tui.tsx
14953
15239
  import fs10 from "fs/promises";
14954
- import path21 from "path";
15240
+ import path24 from "path";
14955
15241
  import { Box as Box5, Text as Text5, useApp as useApp4, useInput as useInput4, useStdout, useIsScreenReaderEnabled as useIsScreenReaderEnabled5 } from "ink";
14956
15242
  import { useEffect as useEffect5, useMemo, useState as useState5 } from "react";
14957
15243
  import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
@@ -15066,7 +15352,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15066
15352
  const [isMonorepo, setIsMonorepo] = useState5(false);
15067
15353
  const [repoAreas, setRepoAreas] = useState5([]);
15068
15354
  const [areaCursor, setAreaCursor] = useState5(0);
15069
- const repoLabel = useMemo(() => path21.basename(repoPath), [repoPath]);
15355
+ const repoLabel = useMemo(() => path24.basename(repoPath), [repoPath]);
15070
15356
  const repoFull = useMemo(() => repoPath, [repoPath]);
15071
15357
  const isLoading = status === "generating" || status === "bootstrapping" || status === "evaluating" || status === "generating-areas" || status === "readiness-running";
15072
15358
  const isMenu = status === "model-pick" || status === "eval-pick" || status === "batch-pick" || status === "generate-pick" || status === "generate-app-pick" || status === "generate-area-pick";
@@ -15078,11 +15364,11 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15078
15364
  setStatus("idle");
15079
15365
  };
15080
15366
  useEffect5(() => {
15081
- const configPath = path21.join(repoPath, "agentrc.eval.json");
15367
+ const configPath = path24.join(repoPath, "agentrc.eval.json");
15082
15368
  fs10.access(configPath).then(() => setHasEvalConfig(true)).catch(() => setHasEvalConfig(false));
15083
15369
  const agentrcConfigCandidates = [
15084
- path21.join(repoPath, "agentrc.config.json"),
15085
- path21.join(repoPath, ".github", "agentrc.config.json")
15370
+ path24.join(repoPath, "agentrc.config.json"),
15371
+ path24.join(repoPath, ".github", "agentrc.config.json")
15086
15372
  ];
15087
15373
  Promise.all(
15088
15374
  agentrcConfigCandidates.map(
@@ -15149,7 +15435,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15149
15435
  };
15150
15436
  useEffect5(() => {
15151
15437
  let active = true;
15152
- const configPath = path21.join(repoPath, "agentrc.eval.json");
15438
+ const configPath = path24.join(repoPath, "agentrc.eval.json");
15153
15439
  fs10.readFile(configPath, "utf8").then((raw) => {
15154
15440
  if (!active) return;
15155
15441
  const parsed = JSON.parse(raw);
@@ -15164,7 +15450,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15164
15450
  };
15165
15451
  }, [repoPath]);
15166
15452
  const bootstrapEvalConfig = async (count, force) => {
15167
- const configPath = path21.join(repoPath, "agentrc.eval.json");
15453
+ const configPath = path24.join(repoPath, "agentrc.eval.json");
15168
15454
  try {
15169
15455
  setStatus("bootstrapping");
15170
15456
  setMessage("Generating eval cases with Copilot SDK...");
@@ -15203,13 +15489,13 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15203
15489
  if (status === "preview") {
15204
15490
  if (input.toLowerCase() === "s") {
15205
15491
  try {
15206
- const outputPath = generateSavePath || path21.join(repoPath, ".github", "copilot-instructions.md");
15207
- await fs10.mkdir(path21.dirname(outputPath), { recursive: true });
15492
+ const outputPath = generateSavePath || path24.join(repoPath, ".github", "copilot-instructions.md");
15493
+ await fs10.mkdir(path24.dirname(outputPath), { recursive: true });
15208
15494
  const { wrote, reason } = await safeWriteFile(outputPath, generatedContent, true);
15209
15495
  if (!wrote)
15210
15496
  throw new Error(reason === "symlink" ? "Path is a symlink" : "Write failed");
15211
15497
  setStatus("done");
15212
- const relPath = path21.relative(repoPath, outputPath);
15498
+ const relPath = path24.relative(repoPath, outputPath);
15213
15499
  const msg = `Saved to ${relPath}`;
15214
15500
  setMessage(msg);
15215
15501
  addLog(msg, "success");
@@ -15243,7 +15529,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15243
15529
  setMessage("Enter a positive number of eval cases, then press Enter.");
15244
15530
  return;
15245
15531
  }
15246
- const configPath = path21.join(repoPath, "agentrc.eval.json");
15532
+ const configPath = path24.join(repoPath, "agentrc.eval.json");
15247
15533
  setEvalBootstrapCount(count);
15248
15534
  try {
15249
15535
  await fs10.access(configPath);
@@ -15302,7 +15588,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15302
15588
  setStatus("generate-app-pick");
15303
15589
  setMessage("Generate for root or per-app?");
15304
15590
  } else {
15305
- const savePath = path21.join(repoPath, ".github", "copilot-instructions.md");
15591
+ const savePath = path24.join(repoPath, ".github", "copilot-instructions.md");
15306
15592
  setGenerateSavePath(savePath);
15307
15593
  await doGenerate(repoPath, savePath, "copilot-instructions");
15308
15594
  }
@@ -15314,7 +15600,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15314
15600
  setStatus("generate-app-pick");
15315
15601
  setMessage("Generate for root or per-app?");
15316
15602
  } else {
15317
- const savePath = path21.join(repoPath, "AGENTS.md");
15603
+ const savePath = path24.join(repoPath, "AGENTS.md");
15318
15604
  setGenerateSavePath(savePath);
15319
15605
  await doGenerate(repoPath, savePath, "agents-md");
15320
15606
  }
@@ -15339,7 +15625,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15339
15625
  }
15340
15626
  if (status === "generate-app-pick") {
15341
15627
  if (input.toLowerCase() === "r") {
15342
- const savePath = generateTarget === "copilot-instructions" ? path21.join(repoPath, ".github", "copilot-instructions.md") : path21.join(repoPath, "AGENTS.md");
15628
+ const savePath = generateTarget === "copilot-instructions" ? path24.join(repoPath, ".github", "copilot-instructions.md") : path24.join(repoPath, "AGENTS.md");
15343
15629
  setGenerateSavePath(savePath);
15344
15630
  await doGenerate(repoPath, savePath, generateTarget);
15345
15631
  return;
@@ -15349,7 +15635,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15349
15635
  addLog(`Generating ${generateTarget} for ${repoApps.length} apps...`, "progress");
15350
15636
  let count = 0;
15351
15637
  for (const app2 of repoApps) {
15352
- const savePath = generateTarget === "copilot-instructions" ? path21.join(app2.path, ".github", "copilot-instructions.md") : path21.join(app2.path, "AGENTS.md");
15638
+ const savePath = generateTarget === "copilot-instructions" ? path24.join(app2.path, ".github", "copilot-instructions.md") : path24.join(app2.path, "AGENTS.md");
15353
15639
  setMessage(`Generating for ${app2.name} (${count + 1}/${repoApps.length})...`);
15354
15640
  try {
15355
15641
  const content = await generateCopilotInstructions({
@@ -15357,11 +15643,11 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15357
15643
  onProgress: (msg) => setMessage(`${app2.name}: ${msg}`)
15358
15644
  });
15359
15645
  if (content.trim()) {
15360
- await fs10.mkdir(path21.dirname(savePath), { recursive: true });
15646
+ await fs10.mkdir(path24.dirname(savePath), { recursive: true });
15361
15647
  const { wrote: saved } = await safeWriteFile(savePath, content, true);
15362
15648
  if (!saved) continue;
15363
15649
  count++;
15364
- addLog(`${app2.name}: saved ${path21.basename(savePath)}`, "success");
15650
+ addLog(`${app2.name}: saved ${path24.basename(savePath)}`, "success");
15365
15651
  }
15366
15652
  } catch (error) {
15367
15653
  const msg = error instanceof Error ? error.message : "Failed.";
@@ -15375,7 +15661,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15375
15661
  const num = Number.parseInt(input, 10);
15376
15662
  if (Number.isFinite(num) && num >= 1 && num <= repoApps.length) {
15377
15663
  const app2 = repoApps[num - 1];
15378
- const savePath = generateTarget === "copilot-instructions" ? path21.join(app2.path, ".github", "copilot-instructions.md") : path21.join(app2.path, "AGENTS.md");
15664
+ const savePath = generateTarget === "copilot-instructions" ? path24.join(app2.path, ".github", "copilot-instructions.md") : path24.join(app2.path, "AGENTS.md");
15379
15665
  setGenerateSavePath(savePath);
15380
15666
  await doGenerate(app2.path, savePath, generateTarget);
15381
15667
  return;
@@ -15403,7 +15689,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15403
15689
  const result = await writeAreaInstruction(repoPath, area, body);
15404
15690
  if (result.status === "written") {
15405
15691
  written++;
15406
- addLog(`${area.name}: saved ${path21.basename(result.filePath)}`, "success");
15692
+ addLog(`${area.name}: saved ${path24.basename(result.filePath)}`, "success");
15407
15693
  } else if (result.status === "skipped") {
15408
15694
  addLog(`${area.name}: skipped (file exists)`, "info");
15409
15695
  }
@@ -15497,8 +15783,8 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15497
15783
  }
15498
15784
  if (status === "eval-pick") {
15499
15785
  if (input.toLowerCase() === "r") {
15500
- const configPath = path21.join(repoPath, "agentrc.eval.json");
15501
- const outputPath = path21.join(
15786
+ const configPath = path24.join(repoPath, "agentrc.eval.json");
15787
+ const outputPath = path24.join(
15502
15788
  repoPath,
15503
15789
  ".agentrc",
15504
15790
  "evals",
@@ -15865,7 +16151,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15865
16151
  /* @__PURE__ */ jsx7(Text5, { color: "white", children: app2.name }),
15866
16152
  /* @__PURE__ */ jsxs4(Text5, { color: "gray", dimColor: true, children: [
15867
16153
  " ",
15868
- path21.relative(repoPath, app2.path)
16154
+ path24.relative(repoPath, app2.path)
15869
16155
  ] })
15870
16156
  ] }, app2.name)) })
15871
16157
  ] }),
@@ -15899,7 +16185,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
15899
16185
  children: [
15900
16186
  /* @__PURE__ */ jsxs4(Text5, { color: "cyan", bold: true, children: [
15901
16187
  "Preview (",
15902
- path21.relative(repoPath, generateSavePath) || generateTarget,
16188
+ path24.relative(repoPath, generateSavePath) || generateTarget,
15903
16189
  ")"
15904
16190
  ] }),
15905
16191
  /* @__PURE__ */ jsx7(Text5, { color: "gray", children: truncatedPreview })
@@ -16008,7 +16294,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
16008
16294
  // src/commands/tui.tsx
16009
16295
  import { jsx as jsx8 } from "react/jsx-runtime";
16010
16296
  async function tuiCommand(options) {
16011
- const repoPath = path22.resolve(options.repo ?? process.cwd());
16297
+ const repoPath = path25.resolve(options.repo ?? process.cwd());
16012
16298
  const skipAnimation = options.animation === false;
16013
16299
  try {
16014
16300
  const accessible = options.accessible ? true : void 0;