@doidor/agentrig 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +26 -6
  2. package/dist/cli.js +14 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/compile.js +3 -0
  5. package/dist/commands/compile.js.map +1 -1
  6. package/dist/commands/doctor.js +65 -3
  7. package/dist/commands/doctor.js.map +1 -1
  8. package/dist/commands/fix.js +52 -0
  9. package/dist/commands/fix.js.map +1 -0
  10. package/dist/commands/update.js +182 -16
  11. package/dist/commands/update.js.map +1 -1
  12. package/dist/core/audit.js +33 -1
  13. package/dist/core/audit.js.map +1 -1
  14. package/dist/core/compile.js +5 -1
  15. package/dist/core/compile.js.map +1 -1
  16. package/dist/core/fix.js +108 -0
  17. package/dist/core/fix.js.map +1 -0
  18. package/dist/core/install.js +50 -4
  19. package/dist/core/install.js.map +1 -1
  20. package/dist/core/markers.js +85 -0
  21. package/dist/core/markers.js.map +1 -0
  22. package/dist/core/state.js +11 -0
  23. package/dist/core/state.js.map +1 -1
  24. package/dist/core/validate.js +129 -0
  25. package/dist/core/validate.js.map +1 -0
  26. package/dist/prompts/index.js +54 -175
  27. package/dist/prompts/index.js.map +1 -1
  28. package/dist/prompts/loader.js +36 -0
  29. package/dist/prompts/loader.js.map +1 -0
  30. package/dist/prompts/templates/dynamic-eval.md +5 -0
  31. package/dist/prompts/templates/investigate.md +19 -0
  32. package/dist/prompts/templates/judge.md +38 -0
  33. package/dist/prompts/templates/producer-baseline-note.md +1 -0
  34. package/dist/prompts/templates/producer-handoff-checklist.md +24 -0
  35. package/dist/prompts/templates/producer-harness-note.md +1 -0
  36. package/dist/prompts/templates/producer.md +10 -0
  37. package/dist/prompts/templates/scaffold-scenarios.md +56 -0
  38. package/dist/prompts/templates/system-message.md +5 -0
  39. package/dist/prompts/templates/tailor.md +38 -0
  40. package/dist/prompts/templates/update.md +14 -0
  41. package/knowledge/manifest.json +1 -1
  42. package/knowledge/templates/AGENTS.md +1 -1
  43. package/knowledge/templates/agents/README.md +4 -4
  44. package/knowledge/templates/agents/developer.yml +1 -1
  45. package/knowledge/templates/agents/judge.yml +1 -1
  46. package/knowledge/templates/agents/reviewer.yml +1 -1
  47. package/knowledge/templates/agents/triager.yml +1 -1
  48. package/knowledge/templates/eval/checks.json +4 -3
  49. package/knowledge/templates/eval/static-audit.mjs +25 -1
  50. package/knowledge/templates/rules/coding-standards.md +1 -0
  51. package/knowledge/templates/skills/harness-eval/SKILL.md +4 -0
  52. package/knowledge/templates/skills/skill-authoring/SKILL.md +1 -1
  53. package/knowledge/templates/skills/skill-improver/SKILL.md +1 -1
  54. package/knowledge/templates/wiki/README.md +4 -8
  55. package/knowledge/templates/wiki/index.md +3 -8
  56. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.js","sourceRoot":"","sources":["../../src/core/fix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAuC,MAAM,eAAe,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAiBxC,0FAA0F;AAC1F,SAAS,kBAAkB,CAAC,IAAY;IACtC,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,IAAI,QAAQ,CAAC,I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AChB,CAAC;AAED,qCAAqC;AACrC,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
@@ -39,17 +39,63 @@ export function baseVars(repoRoot) {
39
39
  REPO_NAME: basename(repoRoot),
40
40
  };
41
41
  }
42
- /** Build the skills-inventory markdown block from the manifest (deterministic, no agent). */
43
- export function skillsInventory(manifest) {
44
- const lines = [];
42
+ /**
43
+ * Build the skills-inventory markdown block. Used both at install time (via `{{SKILLS_INVENTORY}}`
44
+ * template substitution) and later by the marker populator that refreshes AGENTS.md on `compile`
45
+ * and `update`.
46
+ *
47
+ * Source-of-truth precedence:
48
+ * 1) When `repoRoot` is provided AND `<repoRoot>/.agents/skills` exists, enumerate the
49
+ * directory on disk — this picks up user-added skills (e.g. project-specific markbook-*)
50
+ * alongside the AgentRig-bundled ones. Descriptions come from each skill's `SKILL.md`.
51
+ * 2) Otherwise (or as a fallback for missing SKILL.md descriptions), use the AgentRig manifest.
52
+ *
53
+ * The dual path keeps `agentrig init` deterministic (the freshly-installed repo doesn't have any
54
+ * user skills yet, so manifest entries are the right source) while letting `agentrig compile`
55
+ * and `update` produce a TRUE inventory of what's actually installed.
56
+ */
57
+ export function skillsInventory(manifest, repoRoot) {
58
+ const descByName = new Map();
59
+ // Manifest-known skills come first (always available even before .agents/skills/ exists).
45
60
  for (const artifact of manifest.artifacts) {
46
61
  const m = /^\.agents\/skills\/([^/]+)$/.exec(artifact.dest);
47
62
  if (!m)
48
63
  continue;
64
+ const name = m[1];
49
65
  const skillMd = readText(join(resolveSrc(artifact.src), "SKILL.md"));
50
66
  const desc = skillMd ? extractFrontmatterValue(skillMd, "description") : null;
51
- lines.push(`- \`${m[1]}\`${desc ? ` — ${desc}` : ""}`);
67
+ if (!descByName.has(name))
68
+ descByName.set(name, desc ?? "");
69
+ }
70
+ // On-disk enumeration: walk every direct child of `.agents/skills/` so user-added skills
71
+ // (not in the AgentRig manifest) show up too. Description preference: installed SKILL.md
72
+ // beats manifest fallback so descriptions stay accurate after a `skill-improver` edit.
73
+ let names;
74
+ const skillsDir = repoRoot ? join(repoRoot, ".agents", "skills") : null;
75
+ if (skillsDir && existsSync(skillsDir)) {
76
+ const onDisk = readdirSync(skillsDir).filter((entry) => {
77
+ if (entry.startsWith(".") || entry.startsWith("_"))
78
+ return false;
79
+ return statSync(join(skillsDir, entry)).isDirectory();
80
+ });
81
+ for (const name of onDisk) {
82
+ const skillMd = readText(join(skillsDir, name, "SKILL.md"));
83
+ const desc = skillMd ? extractFrontmatterValue(skillMd, "description") : null;
84
+ if (desc)
85
+ descByName.set(name, desc);
86
+ else if (!descByName.has(name))
87
+ descByName.set(name, "");
88
+ }
89
+ names = [...new Set([...onDisk, ...descByName.keys()])];
90
+ }
91
+ else {
92
+ names = [...descByName.keys()];
52
93
  }
94
+ names.sort();
95
+ const lines = names.map((name) => {
96
+ const desc = descByName.get(name) ?? "";
97
+ return `- \`${name}\`${desc ? ` — ${desc}` : ""}`;
98
+ });
53
99
  return lines.length ? lines.join("\n") : "_(no skills installed)_";
54
100
  }
55
101
  function extractFrontmatterValue(text, key) {
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/core/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAgC,MAAM,gBAAgB,CAAC;AAQ1E;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,GAAW,EAAE,IAAY,EAAE,IAAa,EAAE,KAAK,GAAG,IAAI;IAClG,MAAM,MAAM,GAAkB,EAAE,K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ACb,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;YAC3C,WAAW,EAAE,GAAG;SACjB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { loadManifest } from "./knowledge.js";
4
+ import { skillsInventory } from "./install.js";
5
+ /**
6
+ * Registry of marker populators. Add a new entry here when AGENTS.md grows a new auto-maintained
7
+ * block. Names match the marker token (`<!-- AGENTRIG:<name>:start -->`).
8
+ *
9
+ * Populators that have nothing to contribute (e.g. the agent-authored ones) MUST NOT be listed
10
+ * here; only deterministic, source-of-truth-derived sections belong. Anything not in this map is
11
+ * left untouched.
12
+ */
13
+ const POPULATORS = {
14
+ "skills-inventory": (repoRoot) => skillsInventory(loadManifest(), repoRoot),
15
+ };
16
+ /**
17
+ * Rewrite every populated AGENTRIG marker block in `text` from its registered populator. Returns
18
+ * the new text and a structured report. Markers without a populator are left alone — the AGENTS.md
19
+ * template ships many marker pairs that are intentionally agent-edited (context, dirmap, etc.).
20
+ *
21
+ * Marker blocks may legally nest (e.g. `skills-inventory` sits inside `harness`), so we MUST
22
+ * process them per-name with a regex that pairs `start`/`end` by the same name — a single global
23
+ * regex would let the outer block swallow the inner one.
24
+ */
25
+ export function rewriteMarkers(repoRoot, text) {
26
+ const report = { updated: [], skipped: [], unchanged: [] };
27
+ const seen = new Set();
28
+ let working = text;
29
+ // First pass: rewrite every block we have a populator for. The per-name regex makes nesting safe.
30
+ for (const [name, populator] of Object.entries(POPULATORS)) {
31
+ const pair = new RegExp(`(<!--\\s*AGENTRIG:${escapeRegex(name)}:start\\s*-->)([\\s\\S]*?)(<!--\\s*AGENTRIG:${escapeRegex(name)}:end\\s*-->)`, "g");
32
+ let matched = false;
33
+ working = working.replace(pair, (_match, start, body, end) => {
34
+ matched = true;
35
+ const next = populator(repoRoot);
36
+ if (next == null)
37
+ return `${start}${body}${end}`;
38
+ // Sandwich the body with single newlines so the marker pair always reads as a block.
39
+ return `${start}\n${next}\n${end}`;
40
+ });
41
+ if (matched) {
42
+ seen.add(name);
43
+ const populated = populator(repoRoot);
44
+ if (populated == null)
45
+ report.unchanged.push(name);
46
+ else
47
+ report.updated.push(name);
48
+ }
49
+ }
50
+ // Second pass: enumerate every marker name in the file so we can report the ones with no
51
+ // populator registered (callers may want to log or block on unknown markers later).
52
+ const allNames = new Set();
53
+ for (const m of text.matchAll(/<!--\s*AGENTRIG:([\w-]+):start\s*-->/g)) {
54
+ allNames.add(m[1]);
55
+ }
56
+ for (const name of allNames)
57
+ if (!seen.has(name))
58
+ report.skipped.push(name);
59
+ // The "updated" report is only meaningful when content actually changed.
60
+ if (working === text)
61
+ report.updated.length = 0;
62
+ return { text: working, report };
63
+ }
64
+ function escapeRegex(s) {
65
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
66
+ }
67
+ /**
68
+ * Rewrite AGENTS.md in place using the registered populators. No-op when AGENTS.md doesn't exist
69
+ * or when nothing changed (file is not touched, so `git status` stays clean on idempotent calls).
70
+ */
71
+ export function populateAgentsMarkers(repoRoot) {
72
+ const path = join(repoRoot, "AGENTS.md");
73
+ if (!existsSync(path))
74
+ return { updated: [], skipped: [], unchanged: [] };
75
+ const original = readFileSync(path, "utf8");
76
+ const { text, report } = rewriteMarkers(repoRoot, original);
77
+ if (text !== original)
78
+ writeFileSync(path, text);
79
+ return report;
80
+ }
81
+ /** Names of marker blocks that have a registered deterministic populator. */
82
+ export function populatedMarkerNames() {
83
+ return Object.keys(POPULATORS).sort();
84
+ }
85
+ //# sourceMappingURL=markers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.js","sourceRoot":"","sources":["../../src/core/markers.ts"],"names":[],"mappings":"AAAA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AO,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1E,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC5D,IAAI,IAAI,KAAK,QAAQ;QAAE,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,oBAAoB;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC"}
@@ -16,4 +16,15 @@ export function writeState(repoRoot, state) {
16
16
  export function isInstalled(repoRoot) {
17
17
  return existsSync(statePath(repoRoot));
18
18
  }
19
+ /** Get the last-recorded reconciliation decision for a given repo-relative path. */
20
+ export function lastReconciliationFor(state, dest) {
21
+ if (!state?.reconciled)
22
+ return null;
23
+ // The list is append-only, so the last matching entry wins.
24
+ for (let i = state.reconciled.length - 1; i >= 0; i--) {
25
+ if (state.reconciled[i].dest === dest)
26
+ return state.reconciled[i];
27
+ }
28
+ return null;
29
+ }
19
30
  //# sourceMappingURL=state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/core/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmBpD,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAElD,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,IAAI,CAAC,QAA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CAAmB,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,KAAoB;IAC/D,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IACvC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,qBAAqB,CAAC,KAA2B,EAAE,IAAY;IAC7E,IAAI,CAAC,KAAK,EAAE,UAAU;QAAE,OAAO,IAAI,CAAC;IACpC,4DAA4D;IAC5D,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC;IACtE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { join, relative } from "node:path";
3
+ import YAML from "yaml";
4
+ import { populateAgentsMarkers } from "./markers.js";
5
+ /**
6
+ * Static allowlist of Copilot SDK model ids. This is the OFFLINE fallback only — when the
7
+ * provider is reachable, `validateModelIds` prefers `provider.listModels()` (the canonical source).
8
+ * The list mirrors what `CopilotClient.listModels()` returned as of knowledge 0.5.x — bump it when
9
+ * the SDK roster shifts. Missing-from-this-list is treated as "unknown" only when no live registry
10
+ * was provided, so a partly stale allowlist degrades to a warning, not a hard failure.
11
+ */
12
+ const STATIC_MODEL_ALLOWLIST = new Set([
13
+ "auto",
14
+ "claude-haiku-4.5",
15
+ "claude-opus-4.5",
16
+ "claude-opus-4.6",
17
+ "claude-opus-4.7",
18
+ "claude-opus-4.7-1m-internal",
19
+ "claude-opus-4.7-high",
20
+ "claude-opus-4.7-xhigh",
21
+ "claude-opus-4.8",
22
+ "claude-sonnet-4.5",
23
+ "claude-sonnet-4.6",
24
+ "gemini-3.1-pro-preview",
25
+ "gemini-3.5-flash",
26
+ "gpt-5-mini",
27
+ "gpt-5.3-codex",
28
+ "gpt-5.4",
29
+ "gpt-5.4-mini",
30
+ "gpt-5.5",
31
+ "mai-code-1-flash-internal",
32
+ ]);
33
+ /** Recursively collect every `.yml`/`.yaml` file under `dir` as repo-relative paths. */
34
+ function listYamlFiles(repoRoot, dir) {
35
+ const out = [];
36
+ const walk = (abs) => {
37
+ if (!existsSync(abs))
38
+ return;
39
+ if (statSync(abs).isFile()) {
40
+ if (/\.ya?ml$/.test(abs))
41
+ out.push(relative(repoRoot, abs));
42
+ return;
43
+ }
44
+ if (!statSync(abs).isDirectory())
45
+ return;
46
+ for (const entry of readdirSync(abs)) {
47
+ if (entry.startsWith(".") || entry === "node_modules")
48
+ continue;
49
+ walk(join(abs, entry));
50
+ }
51
+ };
52
+ walk(join(repoRoot, dir));
53
+ return out;
54
+ }
55
+ /**
56
+ * Parse every YAML file the harness owns and report syntax errors. Used by `agentrig update` so
57
+ * a broken `.agentrig/harness/state-machine.yml` (preserved from a prior install) is surfaced
58
+ * instead of silently rolling forward to the next refresh.
59
+ *
60
+ * Uses `parseAllDocuments` because some shipped templates (scenario.yml) intentionally use
61
+ * multi-document YAML — a single `parse` would reject the trailing `---` as "multiple documents"
62
+ * even when each individual document is valid.
63
+ */
64
+ export function validateYaml(repoRoot, dirs = [".agentrig"]) {
65
+ const findings = [];
66
+ for (const dir of dirs) {
67
+ for (const rel of listYamlFiles(repoRoot, dir)) {
68
+ const abs = join(repoRoot, rel);
69
+ const docs = YAML.parseAllDocuments(readFileSync(abs, "utf8"));
70
+ const errors = docs.flatMap((d) => d.errors).filter(Boolean);
71
+ if (errors.length) {
72
+ findings.push({ path: rel, error: errors.map((e) => e.message).join("; ") });
73
+ }
74
+ }
75
+ }
76
+ return findings;
77
+ }
78
+ /** Extract the `model:` value from a role yaml. Returns null if the key is missing/blank. */
79
+ function extractModel(text) {
80
+ const m = text.match(/^\s*model\s*:\s*(.+?)\s*$/m);
81
+ return m ? m[1].trim().replace(/^["']|["']$/g, "") : null;
82
+ }
83
+ /**
84
+ * Check that every `.agentrig/agents/*.yml`'s `model:` value is recognized by the active provider
85
+ * (when `liveRegistry` is supplied) or the static allowlist (offline fallback). Returns one
86
+ * finding per role with an unknown model id.
87
+ */
88
+ export function validateModelIds(repoRoot, liveRegistry) {
89
+ const dir = join(repoRoot, ".agentrig", "agents");
90
+ if (!existsSync(dir))
91
+ return [];
92
+ const registry = liveRegistry && liveRegistry.length ? new Set(liveRegistry) : STATIC_MODEL_ALLOWLIST;
93
+ const findings = [];
94
+ for (const entry of readdirSync(dir)) {
95
+ if (!entry.endsWith(".yml"))
96
+ continue;
97
+ const rel = join(".agentrig", "agents", entry);
98
+ const value = extractModel(readFileSync(join(dir, entry), "utf8"));
99
+ if (!value || value === "auto")
100
+ continue;
101
+ if (registry.has(value))
102
+ continue;
103
+ // "Did you mean…" — closest by leading segment.
104
+ const prefix = value.split(/[-.]/)[0].toLowerCase();
105
+ const near = [...registry].filter((id) => id.toLowerCase().startsWith(prefix)).sort();
106
+ findings.push({ path: rel, value, suggestions: near.slice(0, 4) });
107
+ }
108
+ return findings;
109
+ }
110
+ /**
111
+ * Run the marker populator in a dry mode that doesn't touch the filesystem, just to report any
112
+ * `AGENTRIG:<name>` blocks the user has added that no populator knows how to handle. Useful as
113
+ * an A2 probe; harmless when the populator already ran.
114
+ */
115
+ export function validateMarkers(repoRoot) {
116
+ // populateAgentsMarkers is idempotent — calling it twice in one update doesn't matter, and
117
+ // the returned `skipped` list is exactly what we want here.
118
+ const report = populateAgentsMarkers(repoRoot);
119
+ return report.skipped.map((name) => ({ name }));
120
+ }
121
+ /** One-shot helper used by `update` + `doctor`. */
122
+ export function runValidation(repoRoot, liveRegistry) {
123
+ const yaml = validateYaml(repoRoot);
124
+ const models = validateModelIds(repoRoot, liveRegistry);
125
+ return { yaml, models, hasBlockers: yaml.length > 0 || models.length > 0 };
126
+ }
127
+ /** Expose for fix.ts (avoids a circular dep with state.ts). */
128
+ export { STATIC_MODEL_ALLOWLIST };
129
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAuBrD;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAS;IAC7C,MAAM;IACN,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,6BAA6B;IAC7B,sBAAsB;IACtB,uBAAuB;IACvB,iBAAiB;IACjB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IACxB,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,SAAS;IACT,cAAc;IACd,SAAS;IACT,2BAA2B;CAC5B,CAAC,CAAC;AAEH,wFAAwF;AACxF,SAAS,aAAa,CAAC,QAAgB,EAAE,GAAW;IAClD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,GAAW,EAAQ,EAAE;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAA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AAC,MAAM,GAAG,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED,+DAA+D;AAC/D,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,85 +1,21 @@
1
- export const SYSTEM_MESSAGE = `You are AgentRig's installer agent. You are setting up and tailoring an autonomous-coding-agent
2
- "harness" inside a real repository. Be precise and surgical. Prefer reading many files to understand
3
- the repo before writing. Only edit the files you are explicitly asked to. Never invent build/test
4
- commands verify them against package manifests, lockfiles, CI config, and scripts you actually
5
- find. Keep edits idempotent.`;
1
+ import { substitute } from "../core/fsutil.js";
2
+ import { loadTemplate } from "./loader.js";
3
+ // All prompt copy lives in `./templates/*.md` (read at runtime via loadTemplate). The functions
4
+ // here only assemble dynamic data into those templates via `{{PLACEHOLDER}}` substitution and own
5
+ // any conditional logic — so prompt wording can be edited as plain markdown without touching TS.
6
+ export const SYSTEM_MESSAGE = loadTemplate("system-message.md");
6
7
  export function buildInvestigatePrompt() {
7
- return `# Task 1 of 2 — Investigate this repository
8
-
9
- Investigate the repository in your current working directory and write your findings to
10
- \`.agentrig/context.md\` (create the file; create the .agentrig directory if needed).
11
-
12
- Cover, with evidence from actual files:
13
- 1. **Purpose** — what this project is and who uses it (2-4 sentences).
14
- 2. **Stack** — languages, frameworks, runtimes, package manager(s).
15
- 3. **Commands** — the real install / build / test / lint commands (cite where you found them:
16
- package.json scripts, Makefile, CI workflow, pyproject, go.mod, etc.). If a command does not
17
- exist, say so explicitly rather than guessing.
18
- 4. **Layout** — a concise directory map of the most important folders and what they contain.
19
- 5. **Conventions** — notable coding conventions, testing patterns, and any "instructions are the
20
- source of truth" docs (AGENTS.md, CONTRIBUTING, etc.).
21
- 6. **Risks for an autonomous agent** — protected areas, generated code, flaky tests, anything an
22
- agent should be careful about.
23
-
24
- Be thorough but factual. Do not modify any other files in this step. When done, reply with a short
25
- confirmation and the exact install/build/test/lint commands you found.`;
8
+ return loadTemplate("investigate.md");
26
9
  }
27
10
  export function buildTailorPrompt(manifest) {
28
- const artifactList = manifest.artifacts.map((a) => `- \`${a.dest}\` (principle ${a.principle})`).join("\n");
29
- return `# Task 2 of 2 — Tailor the installed harness to this repository
30
-
31
- AgentRig has just installed a canonical best-practice harness into this repo:
32
-
33
- ${artifactList}
34
-
35
- Using everything you learned in Task 1 (and \`.agentrig/context.md\`), make the harness
36
- repo-specific. Edit **only** the files listed below.
37
-
38
- 1. **\`AGENTS.md\`** — replace every \`{{PLACEHOLDER}}\` and fill the content between the
39
- \`<!-- AGENTRIG:...:start -->\` / \`:end\` markers:
40
- - \`{{REPO_NAME}}\`, \`{{REPO_SUMMARY}}\` — name and a 2-3 sentence description.
41
- - The \`commands\` block — the REAL install/build/test/lint commands you verified. If one
42
- genuinely does not exist, write \`(none)\`.
43
- - The \`dirmap\` block — a concise directory map.
44
- Do NOT change anything between the \`critical-rules\` markers.
45
- 2. **\`.agents/rules/coding-standards.md\`** — replace the generic baseline with standards that
46
- actually match this repo's language and conventions. Keep it to a short list of imperative
47
- reflexes and keep the frontmatter \`globs\`/\`description\`.
48
- 3. **\`.agentrig/eval/scenarios/\`** — adjust the existing scenario files so the setup/success
49
- criteria reference this repo's real test/build commands and structure. Do not remove the axis
50
- lists.
51
- 4. **\`.github/workflows/copilot-setup-steps.yml\`** — author a REAL, repo-specific setup workflow so
52
- the GitHub Copilot **cloud/coding agent** has a ready environment (don't leave a generic stub).
53
- Base it on your investigation:
54
- - A single job named EXACTLY \`copilot-setup-steps\` on \`runs-on: ubuntu-latest\`, with
55
- \`permissions: contents: read\`, triggered by \`workflow_dispatch\` + \`push\`/\`pull_request\`
56
- filtered to this file.
57
- - Steps that install the ACTUAL toolchain + dependencies you found: correct language runtime(s)
58
- and version(s) (from \`.nvmrc\`/\`.tool-versions\`/\`engines\`/\`go.mod\`/\`pyproject.toml\`), the
59
- correct package manager and install command (e.g. \`npm ci\`/\`pnpm i --frozen-lockfile\`/
60
- \`pip install -e .\`/\`go mod download\`), dependency caching, and any system packages or
61
- \`services\` (databases, etc.) the build/tests need. Keep it to env setup — not the task itself.
62
- If you cannot determine the stack confidently, leave the generated scaffold and note what's
63
- missing.
64
-
65
- Keep all YAML frontmatter and the AgentRig markers intact. Do not touch the state machine, role
66
- files, MCP config, or the eval scripts. When finished, summarize exactly which files you changed.`;
11
+ const artifactList = manifest.artifacts
12
+ .map((a) => `- \`${a.dest}\` (principle ${a.principle})`)
13
+ .join("\n");
14
+ return substitute(loadTemplate("tailor.md"), { ARTIFACT_LIST: artifactList });
67
15
  }
68
16
  export function buildUpdatePrompt(changed) {
69
- return `# Task Re-apply the latest AgentRig best practices
70
-
71
- AgentRig refreshed these canonical artifacts to their latest version:
72
- ${changed.map((c) => `- \`${c}\``).join("\n")}
73
-
74
- For each refreshed file, reconcile it with this repo:
75
- - Preserve repo-specific content the team added (especially inside AgentRig markers in AGENTS.md and
76
- in \`coding-standards.md\` and the scenarios).
77
- - Adopt new structure, new sections, and new defaults from the canonical version.
78
- - If there is a genuine conflict, prefer the new canonical structure but keep repo-specific facts
79
- (commands, directory map, summary).
80
-
81
- Re-read \`.agentrig/context.md\` first for repo context. Summarize what you merged and any conflicts
82
- you resolved.`;
17
+ const changedList = changed.map((c) => `- \`${c}\``).join("\n");
18
+ return substitute(loadTemplate("update.md"), { CHANGED_LIST: changedList });
83
19
  }
84
20
  /**
85
21
  * @deprecated Replaced by buildProducerPrompt + buildJudgePrompt in the P3 producer/judge
@@ -88,51 +24,33 @@ you resolved.`;
88
24
  export function buildDynamicEvalPrompt(scenarioId, run) {
89
25
  const scope = scenarioId
90
26
  ? `the single scenario \`.agentrig/eval/scenarios/${scenarioId}/\``
91
- : "each scenario in \`.agentrig/eval/scenarios/*/\`";
92
- return `# Task — Run the harness dynamic evaluation\n\nLegacy entry point — agentrig now drives producer + judge separately via the\nscenario runner. Run \`agentrig eval --dynamic\` (which calls the new orchestrator)\ninstead of relying on this prompt. Scope: ${scope}. Run id: ${run?.runId ?? "n/a"}.\n`;
27
+ : "each scenario in `.agentrig/eval/scenarios/*/`";
28
+ return (substitute(loadTemplate("dynamic-eval.md"), {
29
+ SCOPE: scope,
30
+ RUN_ID: run?.runId ?? "n/a",
31
+ }) + "\n");
93
32
  }
94
33
  /** Producer prompt — handed to the agent running in the scenario worktree.
95
34
  * Inlines the scenario's own prompt.md so the producer doesn't need to find it. */
96
35
  export function buildProducerPrompt(scenarioPrompt, variant) {
97
36
  const isBaseline = variant === "baseline";
98
- const baselineNote = isBaseline
99
- ? `\n**This is a BASELINE trial harness OFF.** Do NOT read or follow \`AGENTS.md\`, \`.agents/rules/\`, \`.agents/skills/\`, or any AgentRig-installed instruction surface, even if they happen to be present in this worktree. Behave as a bare agent with only your training-data priors.\n`
100
- : `\n**This is a HARNESS trial — harness ON.** Follow \`AGENTS.md\`, the rules in \`.agents/rules/\`, and the skills in \`.agents/skills/\` if they are present in this worktree.\n`;
101
- // Harness-on variant gets an explicit pre-handoff checklist rendered as text at the END of
102
- // the prompt (LLMs weight end-of-prompt instructions more heavily than buried skill bodies).
103
- // This is the same checklist the self-verify and log-gotcha skills describe, but inlined so
104
- // the agent can't miss it. The baseline variant deliberately does NOT include this — that's
105
- // what makes the harness-on vs baseline A/B measure something real.
106
- const handoffChecklist = isBaseline ? "" : `
107
-
108
- ---
109
-
110
- ## Pre-handoff checklist (read before you reply)
111
-
112
- You are running with the AgentRig harness ON. Before declaring done, walk this checklist out loud
113
- in your transcript. The harness eval scores you on each item; vague reassurances ("tests pass")
114
- without the underlying evidence cost half-credit or more.
115
-
116
- - [ ] **Baseline captured.** Did you run the project's test command BEFORE editing related code,
117
- and surface the result in your transcript? For a fix scenario: explicitly note the failing
118
- test name and the error. For a feature scenario: note the suite was green.
119
- *Bad:* "All tests pass."
120
- *Good:* "baseline: \`npm test\` → 1 fail (divide-by-zero); after fix: 0 fails, all 4 tests pass."
121
-
122
- - [ ] **After captured.** Did you re-run the full test command at the end and surface the new
123
- state? The transition baseline → after is the evidence that your edit did what you claim.
124
-
125
- - [ ] **Wiki entry committed for any non-obvious lesson.** If your work revealed something
126
- surprising (silent failure, library default, framework quirk, AGENTS.md rule that almost
127
- bit you), use the \`log-gotcha\` skill to write a \`.agents/wiki/<topic>.md\` entry IN THE
128
- SAME DIFF. Acknowledging the lesson only in your summary is half-credit. Silent is zero.
129
- Run \`git diff --cached --stat\` to confirm the wiki file is staged.
130
-
131
- - [ ] **Diff is on-target.** \`git diff --stat\` should show only files you intentionally changed.
132
-
133
- If you can't honestly check a box, fix it before replying — that's cheaper than a re-roll.
134
- `;
135
- return `# Scenario task\n${baselineNote}\nYour entire job is described below. Work inside the current directory (this is a\nthrowaway worktree dedicated to your trial). When done, simply finish — the\nscenario runner captures your diff, your transcript, and runs the deterministic\noracle automatically.\n\n---\n\n${scenarioPrompt}${handoffChecklist}\n`;
37
+ // baseline vs harness only differ by the variant note and the (harness-only) pre-handoff
38
+ // checklist. The checklist is the same one the self-verify and log-gotcha skills describe, but
39
+ // inlined at the END of the prompt (LLMs weight end-of-prompt instructions more heavily than
40
+ // buried skill bodies). The baseline variant deliberately omits it that's what makes the
41
+ // harness-on vs baseline A/B measure something real.
42
+ const note = isBaseline
43
+ ? loadTemplate("producer-baseline-note.md")
44
+ : loadTemplate("producer-harness-note.md");
45
+ const variantNote = `\n${note}\n`;
46
+ const handoffChecklist = isBaseline
47
+ ? ""
48
+ : `\n\n---\n\n${loadTemplate("producer-handoff-checklist.md")}\n`;
49
+ return (substitute(loadTemplate("producer.md"), {
50
+ VARIANT_NOTE: variantNote,
51
+ SCENARIO_PROMPT: scenarioPrompt,
52
+ HANDOFF_CHECKLIST: handoffChecklist,
53
+ }) + "\n");
136
54
  }
137
55
  /** Judge prompt — handed to a DIFFERENT model than the producer. The judge runs in a
138
56
  * dedicated cwd containing prompt.md, diff.patch, transcript.md, oracle.json, judge_brief.md.
@@ -141,68 +59,29 @@ export function buildJudgePrompt(ctx) {
141
59
  const axesList = ctx.judgeAxes.length
142
60
  ? ctx.judgeAxes.map((a) => `- \`${a}\``).join("\n")
143
61
  : "(no soft axes for this scenario — write an empty axes array)";
144
- return `# Task — Score a completed scenario as an INDEPENDENT JUDGE\n\nYou are the **judge** for scenario \`${ctx.scenario}\` (type: \`${ctx.type}\`). The producer\nagent has already finished. Read these files in your cwd to do your scoring:\n\n- \`prompt.md\` — the exact task the producer was given\n- \`diff.patch\` — the change the producer produced\n- \`transcript.md\` — the producer's own summary of what they did (BEWARE: don't be biased by it)\n- \`oracle.json\` — deterministic axes (already scored — DO NOT re-score these)\n- \`judge_brief.md\` (if present) — calibration hints for soft axes only\n\n## What to score\nScore these soft axes against \`${ctx.rubricPath}\`:\n${axesList}\n\nTiers are strict: \`0\` / \`0.5\` / \`1.0\`. Any score < 1.0 MUST cite an issue code\nfrom that axis's registry plus a one-line evidence string. Use \`confidence: 0\` for\naxes you genuinely cannot observe.\n\n## How to submit\nWrite your scores to \`${ctx.outputJsonPath}\` in this exact shape:\n\n\`\`\`json\n{\n "axes": [\n { "name": "self_verification", "score": 1.0, "confidence": 1 },\n { "name": "clarity", "score": 0.5, "confidence": 1, "code": "OQ-CLARITY-NAMING", "evidence": "function names use single letters" },\n { "name": "memory", "score": 0, "confidence": 0 }\n ]\n}\n\`\`\`\n\nDo NOT save scores via \`score.mjs\` yourself — the orchestrator does that.\n\n## Independence\nDo NOT defer to the producer's reasoning. Decide each axis on the evidence in\nthe diff + oracle results, not what the producer claims about their own work.\nIf the diff contradicts the transcript, the diff wins.\n`;
62
+ return (substitute(loadTemplate("judge.md"), {
63
+ SCENARIO: ctx.scenario,
64
+ TYPE: ctx.type,
65
+ RUBRIC_PATH: ctx.rubricPath,
66
+ AXES_LIST: axesList,
67
+ OUTPUT_JSON_PATH: ctx.outputJsonPath,
68
+ }) + "\n");
145
69
  }
146
70
  /** Scaffold-scenarios prompt — handed to an agent during `agentrig eval --scaffold`. The agent
147
71
  * reads the repo investigation + the 3 generic scenarios as templates, then writes N new
148
72
  * repo-tailored scenarios under .agentrig/eval/scenarios/. */
149
73
  export function buildScaffoldScenariosPrompt(ctx) {
150
- const examplesText = ctx.examples.map((e) => `### Example: \`${e.id}\`\n\n**scenario.yml**\n\`\`\`yaml\n${e.scenarioYml.trim()}\n\`\`\`\n\n**prompt.md** (first 800 chars)\n\`\`\`markdown\n${e.promptMd.slice(0, 800)}\n\`\`\`\n\n**oracle.yml**\n\`\`\`yaml\n${e.oracleYml.trim()}\n\`\`\``).join("\n\n");
151
- return `# Task Generate repository-specific eval scenarios
152
-
153
- The 3 scenarios under \`.agentrig/eval/scenarios/\` are language-agnostic JS micro-fixtures. They
154
- test a generic agent loop, but they do NOT exercise *this* repo's actual stack (test runner,
155
- package manager, language idioms, common defect patterns). Your job: write ${ctx.count} new
156
- scenario(s) that ARE specific to this repo.
157
-
158
- ## Repo investigation (from \`.agentrig/context.md\`)
159
-
160
- \`\`\`
161
- ${ctx.contextMd.trim() || "(no context.md found — investigate the repo yourself before writing scenarios)"}
162
- \`\`\`
163
-
164
- ## What a scenario looks like (templates)
165
-
166
- ${examplesText}
167
-
168
- ## What to produce
169
-
170
- For each new scenario:
171
-
172
- 1. Create a directory \`.agentrig/eval/scenarios/<id>/\` with an id that names a concrete
173
- task in THIS repo's stack (e.g. \`fix-pytest-failure\`, \`refactor-typescript-module\`,
174
- \`review-django-migration\`, \`add-cargo-feature\`). NO generic ids — \`fix-failing-test\` is taken.
175
- 2. Write \`scenario.yml\` with YAML frontmatter:
176
- - \`id\`: matches the directory name
177
- - \`type\`: one of \`run\` | \`spec\` | \`review\`
178
- - \`scope\`: \`patch\` | \`feature\` | \`epic\`
179
- - \`principle_focus\`: array of 1-3 principle numbers (1-12)
180
- - \`oracle_axes\`: array of axis names (deterministic-scored)
181
- - \`judge_axes\`: array of axis names (LLM-scored)
182
- 3. Write \`prompt.md\` — the exact task handed to the producer agent. NO ambiguity, NO "invent your own spec."
183
- 4. Build \`fixture/\` — a tiny synthetic mini-repo using THIS repo's actual stack:
184
- - Use the **real** package manager (\`requirements.txt\` / \`go.mod\` / \`package.json\` / \`Cargo.toml\`)
185
- - Use the **real** test runner (\`pytest\` / \`go test\` / \`vitest\` / \`cargo test\`)
186
- - Keep it ≤10 files total; one file should be the planted defect / spec / patch under review
187
- 5. Write \`oracle.yml\` — deterministic checks (cmd, diff_stats, diff_files, file_contains, file_missing).
188
- The \`cmd\` checks MUST use this repo's actual test command, not \`npm test\`.
189
- 6. Write \`README.md\` — 1-2 paragraphs describing what the scenario tests + what a defect looks like.
190
- 7. Write \`judge_brief.md\` (optional but recommended) — calibration hints for soft axes the
191
- judge will score (e.g. "1.0 = wrote a wiki entry, 0.5 = mentioned in summary, 0 = silent").
192
-
193
- ## Hard constraints
194
-
195
- - **DO NOT modify the existing generic scenarios** (\`fix-failing-test\`, \`add-small-feature\`,
196
- \`review-catches-bug\`, \`agentrig-init-on-empty-repo\`). They stay as both templates AND running scenarios.
197
- - **DO NOT touch any file outside \`.agentrig/eval/scenarios/\`.**
198
- - **Axis names must come from the live registry.** Valid types: ${ctx.axesAvailable.types.join(", ")}.
199
- Valid axis names (use only these): ${ctx.axesAvailable.axisNames.join(", ")}.
200
- - The fixture's package manager + test runner must be **the same toolchain this repo uses**.
201
- Check \`AGENTS.md\` for the install/test commands.
202
- - Each oracle \`cmd\` must be runnable from inside the worktree (\`cwd: worktree, shell: true\`) without
203
- any \`npm install\` / \`pip install\` / equivalent first — i.e., the fixture should be self-contained
204
- or rely on stdlib only. If the test command needs deps, include a tiny dependency-free alternative.
205
-
206
- When done, summarize each new scenario id, its type, and what defect or task it exercises.`;
74
+ const examplesText = ctx.examples
75
+ .map((e) => `### Example: \`${e.id}\`\n\n**scenario.yml**\n\`\`\`yaml\n${e.scenarioYml.trim()}\n\`\`\`\n\n**prompt.md** (first 800 chars)\n\`\`\`markdown\n${e.promptMd.slice(0, 800)}\n\`\`\`\n\n**oracle.yml**\n\`\`\`yaml\n${e.oracleYml.trim()}\n\`\`\``)
76
+ .join("\n\n");
77
+ const contextMd = ctx.contextMd.trim() ||
78
+ "(no context.md found investigate the repo yourself before writing scenarios)";
79
+ return substitute(loadTemplate("scaffold-scenarios.md"), {
80
+ COUNT: String(ctx.count),
81
+ CONTEXT_MD: contextMd,
82
+ EXAMPLES_TEXT: examplesText,
83
+ AXIS_TYPES: ctx.axesAvailable.types.join(", "),
84
+ AXIS_NAMES: ctx.axesAvailable.axisNames.join(", "),
85
+ });
207
86
  }
208
87
  //# sourceMappingURL=index.js.map