@abdulr7man/pensieve 0.0.0-stage → 1.2.2

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 (179) hide show
  1. package/LICENSE +684 -0
  2. package/README.md +180 -2
  3. package/VERSION +1 -0
  4. package/agents/README.md +16 -0
  5. package/agents/pensieve-code-auditor.md +58 -0
  6. package/agents/pensieve-mapper.md +46 -0
  7. package/agents/pensieve-planner.md +67 -0
  8. package/agents/pensieve-reconner.md +76 -0
  9. package/agents/pensieve-reporter.md +61 -0
  10. package/agents/pensieve-roe-checker.md +46 -0
  11. package/agents/pensieve-scoper.md +77 -0
  12. package/agents/pensieve-tester.md +83 -0
  13. package/agents/pensieve-validator.md +62 -0
  14. package/bin/pensieve +452 -0
  15. package/bin/pensieve-installer.cjs +5 -0
  16. package/commands/pensieve-close.md +6 -0
  17. package/commands/pensieve-map.md +6 -0
  18. package/commands/pensieve-new-engagement.md +6 -0
  19. package/commands/pensieve-pause.md +15 -0
  20. package/commands/pensieve-plan.md +6 -0
  21. package/commands/pensieve-progress.md +34 -0
  22. package/commands/pensieve-quick.md +8 -0
  23. package/commands/pensieve-recon.md +6 -0
  24. package/commands/pensieve-report.md +6 -0
  25. package/commands/pensieve-resume.md +6 -0
  26. package/commands/pensieve-retest.md +10 -0
  27. package/commands/pensieve-scope.md +49 -0
  28. package/commands/pensieve-surface.md +8 -0
  29. package/commands/pensieve-test.md +6 -0
  30. package/commands/pensieve-validate.md +6 -0
  31. package/docker/Dockerfile.pensieve-toolbox +75 -0
  32. package/docker/compose.pensieve-net.yml +37 -0
  33. package/docker/squid.conf.template +21 -0
  34. package/package.json +39 -4
  35. package/packs/ad/ad-killchain/checklist.md +64 -0
  36. package/packs/ad/ad-killchain/pack.yaml +19 -0
  37. package/packs/cloud/cloud-cis/checklist.md +66 -0
  38. package/packs/cloud/cloud-cis/pack.yaml +20 -0
  39. package/packs/fintech/practice-core/checklist.md +33 -0
  40. package/packs/fintech/practice-core/learnings.md +5 -0
  41. package/packs/fintech/practice-core/pack.yaml +18 -0
  42. package/packs/infra/ptes-infra/checklist.md +22 -0
  43. package/packs/infra/ptes-infra/pack.yaml +19 -0
  44. package/packs/mobile/owasp-masvs/checklist.md +80 -0
  45. package/packs/mobile/owasp-masvs/pack.yaml +20 -0
  46. package/packs/owasp-api-v4/checklist.md +85 -0
  47. package/packs/owasp-api-v4/learnings.md +6 -0
  48. package/packs/owasp-api-v4/pack.yaml +23 -0
  49. package/packs/owasp-api-v4/runbooks/API1/SKILL.md +66 -0
  50. package/packs/owasp-api-v4/runbooks/API10/SKILL.md +67 -0
  51. package/packs/owasp-api-v4/runbooks/API2/SKILL.md +129 -0
  52. package/packs/owasp-api-v4/runbooks/API3/SKILL.md +55 -0
  53. package/packs/owasp-api-v4/runbooks/API4/SKILL.md +59 -0
  54. package/packs/owasp-api-v4/runbooks/API5/SKILL.md +60 -0
  55. package/packs/owasp-api-v4/runbooks/API6/SKILL.md +63 -0
  56. package/packs/owasp-api-v4/runbooks/API7/SKILL.md +70 -0
  57. package/packs/owasp-api-v4/runbooks/API8/SKILL.md +72 -0
  58. package/packs/owasp-api-v4/runbooks/API9/SKILL.md +66 -0
  59. package/packs/thickclient/thickclient-core/checklist.md +60 -0
  60. package/packs/thickclient/thickclient-core/pack.yaml +24 -0
  61. package/packs/web/asvs-l2/checklist.md +50 -0
  62. package/packs/web/asvs-l2/learnings.md +6 -0
  63. package/packs/web/asvs-l2/pack.yaml +19 -0
  64. package/packs/web/asvs-l2/runbooks/V2-AUTH-ENUM/SKILL.md +75 -0
  65. package/packs/web/asvs-l2/runbooks/V2-AUTH-LIVE/SKILL.md +78 -0
  66. package/packs/web/asvs-l2/runbooks/V2-AUTH-MFA/SKILL.md +76 -0
  67. package/packs/web/asvs-l2/runbooks/V2-AUTH-RATE/SKILL.md +72 -0
  68. package/packs/web/owasp-testing-checklist/checklist.md +52 -0
  69. package/packs/web/owasp-testing-checklist/learnings.md +47 -0
  70. package/packs/web/owasp-testing-checklist/pack.yaml +21 -0
  71. package/packs/web/unauth-perimeter/checklist.md +72 -0
  72. package/packs/web/unauth-perimeter/pack.yaml +18 -0
  73. package/packs/web/unauth-perimeter/runbooks/PERIM-01/SKILL.md +60 -0
  74. package/packs/web/unauth-perimeter/runbooks/PERIM-02/SKILL.md +63 -0
  75. package/packs/web/unauth-perimeter/runbooks/PERIM-03/SKILL.md +62 -0
  76. package/packs/web/unauth-perimeter/runbooks/PERIM-04/SKILL.md +75 -0
  77. package/packs/web/unauth-perimeter/runbooks/PERIM-05/SKILL.md +66 -0
  78. package/packs/web/unauth-perimeter/runbooks/PERIM-06/SKILL.md +59 -0
  79. package/packs/web/unauth-perimeter/runbooks/PERIM-07/SKILL.md +56 -0
  80. package/packs/web/unauth-perimeter/runbooks/PERIM-08/SKILL.md +57 -0
  81. package/packs/web/unauth-perimeter/runbooks/PERIM-09/SKILL.md +62 -0
  82. package/packs/web/unauth-perimeter/runbooks/PERIM-10/SKILL.md +60 -0
  83. package/packs/whitebox/code-audit-core/checklist.md +36 -0
  84. package/packs/whitebox/code-audit-core/learnings.md +6 -0
  85. package/packs/whitebox/code-audit-core/pack.yaml +14 -0
  86. package/prompts/orchestrator-core.md +52 -0
  87. package/reference/attack-playbooks.md +57 -0
  88. package/reference/otp-relay.md +98 -0
  89. package/reference/param-profiles.md +48 -0
  90. package/reference/templates/FINDING.md +97 -0
  91. package/reference/tool-selection.md +64 -0
  92. package/reference/vulnerability-finding-standard.md +80 -0
  93. package/runtimes/hermes/hooks/injection-scan.py +290 -0
  94. package/runtimes/hermes/hooks/scope-guard.py +136 -0
  95. package/skills/pensieve/SKILL.md +134 -0
  96. package/skills/pensieve-close/SKILL.md +31 -0
  97. package/skills/pensieve-map/SKILL.md +25 -0
  98. package/skills/pensieve-new-engagement/SKILL.md +28 -0
  99. package/skills/pensieve-pause/SKILL.md +22 -0
  100. package/skills/pensieve-plan/SKILL.md +39 -0
  101. package/skills/pensieve-progress/SKILL.md +35 -0
  102. package/skills/pensieve-quick/SKILL.md +47 -0
  103. package/skills/pensieve-recon/SKILL.md +30 -0
  104. package/skills/pensieve-report/SKILL.md +46 -0
  105. package/skills/pensieve-resume/SKILL.md +33 -0
  106. package/skills/pensieve-retest/SKILL.md +35 -0
  107. package/skills/pensieve-scope/SKILL.md +35 -0
  108. package/skills/pensieve-surface/SKILL.md +36 -0
  109. package/skills/pensieve-test/SKILL.md +35 -0
  110. package/skills/pensieve-validate/SKILL.md +28 -0
  111. package/skills/pensieve-wiki/SKILL.md +39 -0
  112. package/src/installer/cli.cjs +209 -0
  113. package/src/installer/home.cjs +155 -0
  114. package/src/installer/runtimes.cjs +276 -0
  115. package/src/installer/uninstall.cjs +342 -0
  116. package/src/pensieve-sdk/bin/pensieve-sdk.cjs +1045 -0
  117. package/src/pensieve-sdk/lib/agent-translate.cjs +50 -0
  118. package/src/pensieve-sdk/lib/approvals.cjs +408 -0
  119. package/src/pensieve-sdk/lib/audit.cjs +290 -0
  120. package/src/pensieve-sdk/lib/checklist.cjs +337 -0
  121. package/src/pensieve-sdk/lib/clientlist.cjs +814 -0
  122. package/src/pensieve-sdk/lib/close.cjs +133 -0
  123. package/src/pensieve-sdk/lib/config.cjs +156 -0
  124. package/src/pensieve-sdk/lib/cvss.cjs +91 -0
  125. package/src/pensieve-sdk/lib/env.cjs +272 -0
  126. package/src/pensieve-sdk/lib/evidence.cjs +217 -0
  127. package/src/pensieve-sdk/lib/findings.cjs +1096 -0
  128. package/src/pensieve-sdk/lib/frontmatter.cjs +178 -0
  129. package/src/pensieve-sdk/lib/graph.cjs +607 -0
  130. package/src/pensieve-sdk/lib/ids.cjs +63 -0
  131. package/src/pensieve-sdk/lib/init.cjs +79 -0
  132. package/src/pensieve-sdk/lib/liveness.cjs +176 -0
  133. package/src/pensieve-sdk/lib/loop.cjs +619 -0
  134. package/src/pensieve-sdk/lib/migrate.cjs +57 -0
  135. package/src/pensieve-sdk/lib/monitor.cjs +69 -0
  136. package/src/pensieve-sdk/lib/pack.cjs +607 -0
  137. package/src/pensieve-sdk/lib/paths.cjs +73 -0
  138. package/src/pensieve-sdk/lib/pdf.cjs +291 -0
  139. package/src/pensieve-sdk/lib/recon.cjs +296 -0
  140. package/src/pensieve-sdk/lib/renderers/__pycache__/formal_report.cpython-314.pyc +0 -0
  141. package/src/pensieve-sdk/lib/renderers/formal_report.py +608 -0
  142. package/src/pensieve-sdk/lib/report.cjs +1135 -0
  143. package/src/pensieve-sdk/lib/runbook.cjs +124 -0
  144. package/src/pensieve-sdk/lib/sarif.cjs +154 -0
  145. package/src/pensieve-sdk/lib/scope.cjs +621 -0
  146. package/src/pensieve-sdk/lib/security.cjs +61 -0
  147. package/src/pensieve-sdk/lib/skills.cjs +193 -0
  148. package/src/pensieve-sdk/lib/state.cjs +610 -0
  149. package/src/pensieve-sdk/lib/subagent.cjs +658 -0
  150. package/src/pensieve-sdk/lib/target.cjs +149 -0
  151. package/src/pensieve-sdk/lib/tools.cjs +66 -0
  152. package/src/pensieve-sdk/lib/vault.cjs +122 -0
  153. package/src/pensieve-sdk/lib/vendor/cvss40.LICENSE +22 -0
  154. package/src/pensieve-sdk/lib/vendor/cvss40.js +1208 -0
  155. package/src/pensieve-sdk/package.json +11 -0
  156. package/templates/ACCOUNTS.md +35 -0
  157. package/templates/ATTACK-SURFACE.md +30 -0
  158. package/templates/FINDING.md +43 -0
  159. package/templates/PLAN.md +33 -0
  160. package/templates/PROJECT.md +29 -0
  161. package/templates/ROE.md +50 -0
  162. package/templates/RUN-LOG.md +19 -0
  163. package/templates/SCOPE.md +32 -0
  164. package/templates/VALIDATION.md +62 -0
  165. package/templates/report/REPORT.md +49 -0
  166. package/workflows/close.md +34 -0
  167. package/workflows/map.md +39 -0
  168. package/workflows/new-engagement.md +37 -0
  169. package/workflows/plan.md +45 -0
  170. package/workflows/progress.md +28 -0
  171. package/workflows/quick.md +67 -0
  172. package/workflows/recon.md +87 -0
  173. package/workflows/report.md +51 -0
  174. package/workflows/resume.md +26 -0
  175. package/workflows/retest.md +53 -0
  176. package/workflows/scope.md +47 -0
  177. package/workflows/surface.md +29 -0
  178. package/workflows/test.md +95 -0
  179. package/workflows/validate.md +34 -0
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+ /**
3
+ * security.cjs — error/text sanitization (ADR-004).
4
+ * Agent-facing strings must never leak absolute paths, home dirs, or secrets.
5
+ */
6
+
7
+ const PATH_RE = /(?:\/[\w.@%+=:,~-]+){2,}\/?/g; // /a/b[/c...] absolute paths
8
+ const HOME_RE = new RegExp(escapeRe(process.env.HOME || '/nonexistent'), 'g');
9
+
10
+ const SECRET_PATTERNS = [
11
+ /Bearer\s+[A-Za-z0-9._~+/=-]{8,}/gi,
12
+ /\b(?:sk|pk|api|key|token|secret|password|passwd|pwd)[-_]?(?:=|:)\s*["']?[^\s"']{4,}/gi,
13
+ /\bsk-[A-Za-z0-9]{12,}\b/g, // OpenAI-style
14
+ /\bghp_[A-Za-z0-9]{20,}\b/g, // GitHub PAT
15
+ /\bgho_[A-Za-z0-9]{20,}\b/g,
16
+ /\bAIza[0-9A-Za-z_-]{20,}\b/g, // Google API key
17
+ /\bxox[baprs]-[0-9A-Za-z-]{10,}\b/g, // Slack
18
+ /\bAKIA[0-9A-Z]{16}\b/g, // AWS access key id
19
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\b/g, // JWT
20
+ ];
21
+
22
+ const CODE_MESSAGES = {
23
+ ENOENT: 'not found',
24
+ EACCES: 'permission denied',
25
+ EPERM: 'operation not permitted',
26
+ ECONNREFUSED: 'connection refused',
27
+ ETIMEDOUT: 'operation timed out',
28
+ ENOTFOUND: 'name could not be resolved',
29
+ EEXIST: 'already exists',
30
+ };
31
+
32
+ function escapeRe(s) {
33
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
34
+ }
35
+
36
+ function sanitizeText(text) {
37
+ let out = String(text);
38
+ out = out.replace(HOME_RE, '~');
39
+ out = out.replace(PATH_RE, '[path]');
40
+ for (const re of SECRET_PATTERNS) out = out.replace(re, '[redacted]');
41
+ return out;
42
+ }
43
+
44
+ function sanitizeError(err) {
45
+ let raw;
46
+ if (err == null) raw = 'unknown error';
47
+ else if (typeof err === 'string') raw = err;
48
+ else if (err instanceof Error) {
49
+ raw = err.message || String(err);
50
+ const friendly = err.code && CODE_MESSAGES[err.code];
51
+ if (friendly && !raw.toLowerCase().includes(friendly)) raw = `${raw} (${friendly})`;
52
+ } else {
53
+ try { raw = JSON.stringify(err); } catch { raw = String(err); }
54
+ }
55
+
56
+ let out = sanitizeText(raw);
57
+ if (out.length > 300) out = out.slice(0, 300) + '…';
58
+ return out;
59
+ }
60
+
61
+ module.exports = { sanitizeError, sanitizeText };
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+ /**
3
+ * skills.cjs — agent-skills resolver + path confinement (Phase 8, SKILL-01/02/03).
4
+ *
5
+ * Resolves an agent's runbooks from the engagement's ACTIVE methodology packs
6
+ * (PRIMARY, SKILL-03) plus an optional `agent_skills` config map (SECONDARY,
7
+ * SKILL-02), confines every path to a base dir (realpath, symlink-safe), and
8
+ * emits a verbatim <agent_skills> text block for a spawn prompt to embed raw.
9
+ *
10
+ * Every return is { data: <string>, format: 'text' } — INCLUDING the empty case —
11
+ * so the CLI writes a raw (possibly empty) line, never a JSON envelope. On a fresh
12
+ * repo (no runbooks, no config map) the correct end state is an empty block, no error.
13
+ *
14
+ * ponytail scope (Phase 8): lists ALL runbooks under active packs. Per-agent
15
+ * filtering WITHIN a pack is deferred to the Phase-9 runbook schema (runbook
16
+ * frontmatter will declare agent applicability); wire the filter when it exists.
17
+ *
18
+ * Zero-dependency: node: builtins + local lib only. lib/security.cjs is REDACTION,
19
+ * NOT confinement — intentionally not used here. config.cjs SCHEMA is untouched;
20
+ * the agent_skills map is read format-aware (flat vs fenced) directly, never via
21
+ * config.load (whose flat/fenced bug is a separate seed, out of scope here).
22
+ */
23
+
24
+ const { existsSync, realpathSync, readFileSync, readdirSync } = require('node:fs');
25
+ const path = require('node:path');
26
+ const { sep, resolve, join } = path;
27
+ const fm = require('./frontmatter.cjs');
28
+ const paths = require('./paths.cjs');
29
+ const pack = require('./pack.cjs');
30
+ const { parseYaml } = fm;
31
+
32
+ const EMPTY = { data: '', format: 'text' };
33
+
34
+ /**
35
+ * Resolve `target` against `baseDir` and reject (return null) anything that
36
+ * escapes the base — including via symlink (realpath-resolved). Returns null on
37
+ * any error. The confinement primitive PENSIEVE lacked (security.cjs is redaction).
38
+ */
39
+ function resolveWithinBase(target, baseDir) {
40
+ try {
41
+ const resolvedBase = existsSync(baseDir) ? realpathSync(baseDir) : resolve(baseDir);
42
+ const abs = resolve(resolvedBase, target);
43
+ const resolvedTarget = existsSync(abs) ? realpathSync(abs) : abs;
44
+ const baseWithSep = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
45
+ if (resolvedTarget !== resolvedBase && !resolvedTarget.startsWith(baseWithSep)) return null;
46
+ return resolvedTarget;
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+
52
+ function warn(msg) {
53
+ process.stderr.write(`[agent-skills] WARNING: ${msg}\n`);
54
+ }
55
+
56
+ /**
57
+ * Format-aware read of the agent_skills map. config.yaml exists in TWO shapes:
58
+ * flat (no leading ---): parseYaml(text).agent_skills (fm.get misses it)
59
+ * fenced (leading ---): fm.get(text, 'agent_skills') (parseYaml throws on ---)
60
+ * The fenced shape is the normal SKILL-03 precondition (packs enabled). Each
61
+ * branch degrades to undefined on any throw — never propagates.
62
+ */
63
+ function readAgentSkillsMap(engagementDir) {
64
+ let text;
65
+ try {
66
+ text = readFileSync(paths.configFile(engagementDir), 'utf8');
67
+ } catch {
68
+ return undefined;
69
+ }
70
+ const fenced = /^---\s*$/.test(text.split('\n')[0]);
71
+ if (fenced) {
72
+ try { return fm.get(text, 'agent_skills'); } catch { return undefined; }
73
+ }
74
+ try { return parseYaml(text).agent_skills; } catch { return undefined; }
75
+ }
76
+
77
+ // frontmatter.cjs has no flow-collection support, so an inline-flow `agents: [a, b]`
78
+ // comes back as the STRING "[a, b]" (not an array). Normalize to an array for
79
+ // membership testing; anything unrecognised -> [] (fail-closed, excludes the runbook).
80
+ function normalizeAgents(raw) {
81
+ if (Array.isArray(raw)) return raw.map((x) => String(x).trim()).filter(Boolean);
82
+ if (typeof raw === 'string') {
83
+ const s = raw.trim();
84
+ if (!s.startsWith('[') || !s.endsWith(']')) return [];
85
+ return s.slice(1, -1).split(',').map((x) => x.trim()).filter(Boolean);
86
+ }
87
+ return [];
88
+ }
89
+
90
+ // PRIMARY (SKILL-03): runbooks under the engagement's active methodology packs.
91
+ // Multi-root (31-01 / SCOP-03): each enabled slug resolves through pack's ONE
92
+ // resolver — a USER-root pack's runbooks flow identically. A colliding slug
93
+ // (both roots) injects NOTHING (fail-closed: ambiguity is never picked from)
94
+ // and warns with both paths; agentSkills still never throws.
95
+ // Agent-aware (INJECT-01): include a runbook only when `agent` is listed in its
96
+ // `agents:` frontmatter. Absent/empty/malformed agents -> excluded (fail-closed).
97
+ function packRunbookRefs(engagementDir, packsRoot, agent) {
98
+ const refs = [];
99
+ let slugs;
100
+ try {
101
+ slugs = pack.enabled(engagementDir); // fenced/flat-safe inside pack.cjs; guard anyway
102
+ } catch {
103
+ return refs;
104
+ }
105
+ for (const slug of slugs || []) {
106
+ let dirs = [];
107
+ try {
108
+ dirs = pack.resolveDirs(packsRoot, slug);
109
+ } catch {
110
+ dirs = []; // unreadable root -> no runbooks from this slug (fail-closed)
111
+ }
112
+ if (dirs.length > 1) {
113
+ warn(`pack slug "${slug}" collides across pack roots — runbooks skipped: ${dirs.join(' and ')}`);
114
+ continue;
115
+ }
116
+ for (const dir of dirs) {
117
+ const runbooksDir = join(dir, 'runbooks');
118
+ let entries;
119
+ try {
120
+ entries = readdirSync(runbooksDir, { withFileTypes: true });
121
+ } catch {
122
+ continue; // runbooks dir absent (fresh-repo case) -> correct empty result
123
+ }
124
+ for (const e of entries) {
125
+ if (!e.isDirectory()) continue;
126
+ const skillMd = join(runbooksDir, e.name, 'SKILL.md');
127
+ // confinement against the pack's OWN resolved dir (inside its root)
128
+ const confined = resolveWithinBase(skillMd, dir);
129
+ if (!confined || !existsSync(confined)) continue;
130
+ // T-10-02/T-10-03: read+parse+normalize per runbook, fail-closed on any throw.
131
+ let agents;
132
+ try {
133
+ agents = normalizeAgents(fm.parse(readFileSync(confined, 'utf8')).data.agents);
134
+ } catch {
135
+ continue; // malformed runbook -> skip, never abort the brief
136
+ }
137
+ if (!agents.includes(agent)) continue;
138
+ refs.push(`${slug}/runbooks/${e.name}/SKILL.md`); // same shape as path.relative(packsRoot, …)
139
+ }
140
+ }
141
+ }
142
+ return refs;
143
+ }
144
+
145
+ // SECONDARY (SKILL-02): operator-authored config map, confined to engagementDir.
146
+ function configMapRefs(agent, engagementDir) {
147
+ const refs = [];
148
+ const map = readAgentSkillsMap(engagementDir);
149
+ if (!map || typeof map !== 'object') return refs;
150
+ const raw = map[agent];
151
+ let entries;
152
+ if (typeof raw === 'string') entries = [raw];
153
+ else if (Array.isArray(raw)) entries = raw;
154
+ else return refs;
155
+ for (const entry of entries) {
156
+ if (typeof entry !== 'string') continue;
157
+ if (!resolveWithinBase(entry, engagementDir)) {
158
+ warn(`"${entry}" escapes engagement root — skipping`);
159
+ continue;
160
+ }
161
+ if (!existsSync(join(engagementDir, entry, 'SKILL.md'))) {
162
+ warn(`skill not found at "${entry}/SKILL.md" — skipping`);
163
+ continue;
164
+ }
165
+ refs.push(`${entry}/SKILL.md`);
166
+ }
167
+ return refs;
168
+ }
169
+
170
+ /**
171
+ * Resolve + emit the <agent_skills> block for `agent`. Always returns
172
+ * { data: <string>, format: 'text' }. Never throws.
173
+ */
174
+ function agentSkills(agent, engagementDir, options = {}) {
175
+ const name = String(agent || '').trim();
176
+ if (!name) return EMPTY;
177
+ // WARNING 1: guard before pack.enabled/paths.configFile — they path.join(undefined,…) throws.
178
+ if (!engagementDir) return EMPTY;
179
+ const packsRoot = options.packsRoot;
180
+
181
+ const refs = [];
182
+ if (packsRoot) refs.push(...packRunbookRefs(engagementDir, packsRoot, name));
183
+ refs.push(...configMapRefs(name, engagementDir));
184
+
185
+ if (refs.length === 0) return EMPTY;
186
+ const lines = refs.map((r) => `- @${r}`).join('\n');
187
+ return {
188
+ data: `<agent_skills>\nRead these runbooks:\n${lines}\n</agent_skills>`,
189
+ format: 'text',
190
+ };
191
+ }
192
+
193
+ module.exports = { agentSkills, resolveWithinBase };