agemon 0.1.0 → 6.0.0

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 (144) hide show
  1. package/README.md +732 -28
  2. package/assets/skills/architecture/agemon-architecture/LICENSE +21 -0
  3. package/assets/skills/architecture/agemon-architecture/NOTICE.md +9 -0
  4. package/assets/skills/architecture/agemon-architecture/SKILL.md +275 -0
  5. package/assets/skills/code-quality/agemon-clean-code/LICENSE +21 -0
  6. package/assets/skills/code-quality/agemon-clean-code/NOTICE.md +9 -0
  7. package/assets/skills/code-quality/agemon-clean-code/SKILL.md +78 -0
  8. package/assets/skills/code-quality/agemon-house-rules/SKILL.md +103 -0
  9. package/assets/skills/commit/agemon-commit/SKILL.md +87 -0
  10. package/assets/skills/design/agemon-design/LICENSE +21 -0
  11. package/assets/skills/design/agemon-design/NOTICE.md +9 -0
  12. package/assets/skills/design/agemon-design/SKILL.md +391 -0
  13. package/assets/skills/design/agemon-design/references/accessibility.md +182 -0
  14. package/assets/skills/design/agemon-design/references/agents.md +63 -0
  15. package/assets/skills/design/agemon-design/references/ai-chat.md +158 -0
  16. package/assets/skills/design/agemon-design/references/brief.md +186 -0
  17. package/assets/skills/design/agemon-design/references/color.md +216 -0
  18. package/assets/skills/design/agemon-design/references/components.md +91 -0
  19. package/assets/skills/design/agemon-design/references/copy.md +300 -0
  20. package/assets/skills/design/agemon-design/references/craft-intent.md +160 -0
  21. package/assets/skills/design/agemon-design/references/dashboard.md +131 -0
  22. package/assets/skills/design/agemon-design/references/dataviz.md +197 -0
  23. package/assets/skills/design/agemon-design/references/finish-bar.md +243 -0
  24. package/assets/skills/design/agemon-design/references/forms.md +192 -0
  25. package/assets/skills/design/agemon-design/references/heuristics.md +403 -0
  26. package/assets/skills/design/agemon-design/references/inspiration.md +287 -0
  27. package/assets/skills/design/agemon-design/references/layout.md +236 -0
  28. package/assets/skills/design/agemon-design/references/loops.md +155 -0
  29. package/assets/skills/design/agemon-design/references/metadata.md +98 -0
  30. package/assets/skills/design/agemon-design/references/modern-css.md +448 -0
  31. package/assets/skills/design/agemon-design/references/motion.md +434 -0
  32. package/assets/skills/design/agemon-design/references/personas.md +206 -0
  33. package/assets/skills/design/agemon-design/references/principles-catalog.md +299 -0
  34. package/assets/skills/design/agemon-design/references/recipe-auth.md +88 -0
  35. package/assets/skills/design/agemon-design/references/recipe-dashboard.md +130 -0
  36. package/assets/skills/design/agemon-design/references/recipe-landing.md +122 -0
  37. package/assets/skills/design/agemon-design/references/responsive.md +168 -0
  38. package/assets/skills/design/agemon-design/references/review.md +340 -0
  39. package/assets/skills/design/agemon-design/references/sound.md +150 -0
  40. package/assets/skills/design/agemon-design/references/spec.md +123 -0
  41. package/assets/skills/design/agemon-design/references/stack.md +522 -0
  42. package/assets/skills/design/agemon-design/references/state-design.md +188 -0
  43. package/assets/skills/design/agemon-design/references/themes.md +229 -0
  44. package/assets/skills/design/agemon-design/references/tokens.md +350 -0
  45. package/assets/skills/design/agemon-design/references/typography.md +246 -0
  46. package/assets/skills/design/agemon-design-dashboard/LICENSE +21 -0
  47. package/assets/skills/design/agemon-design-dashboard/NOTICE.md +9 -0
  48. package/assets/skills/design/agemon-design-dashboard/SKILL.md +113 -0
  49. package/assets/skills/design/agemon-design-editorial/LICENSE +21 -0
  50. package/assets/skills/design/agemon-design-editorial/NOTICE.md +9 -0
  51. package/assets/skills/design/agemon-design-editorial/SKILL.md +98 -0
  52. package/assets/skills/design/agemon-design-minimal/LICENSE +21 -0
  53. package/assets/skills/design/agemon-design-minimal/NOTICE.md +9 -0
  54. package/assets/skills/design/agemon-design-minimal/SKILL.md +97 -0
  55. package/assets/skills/geo-seo/geo/LICENSE +21 -0
  56. package/assets/skills/geo-seo/geo/NOTICE.md +18 -0
  57. package/assets/skills/geo-seo/geo/SKILL.md +145 -0
  58. package/assets/skills/geo-seo/geo-audit/LICENSE +21 -0
  59. package/assets/skills/geo-seo/geo-audit/NOTICE.md +17 -0
  60. package/assets/skills/geo-seo/geo-audit/SKILL.md +371 -0
  61. package/assets/skills/geo-seo/geo-audit/references/ai-visibility.md +233 -0
  62. package/assets/skills/geo-seo/geo-audit/references/content.md +329 -0
  63. package/assets/skills/geo-seo/geo-audit/references/platform-analysis.md +294 -0
  64. package/assets/skills/geo-seo/geo-audit/references/schema.md +383 -0
  65. package/assets/skills/geo-seo/geo-audit/references/technical.md +368 -0
  66. package/assets/skills/geo-seo/geo-brand-mentions/LICENSE +21 -0
  67. package/assets/skills/geo-seo/geo-brand-mentions/NOTICE.md +15 -0
  68. package/assets/skills/geo-seo/geo-brand-mentions/SKILL.md +459 -0
  69. package/assets/skills/geo-seo/geo-citability/LICENSE +21 -0
  70. package/assets/skills/geo-seo/geo-citability/NOTICE.md +14 -0
  71. package/assets/skills/geo-seo/geo-citability/SKILL.md +320 -0
  72. package/assets/skills/geo-seo/geo-content/LICENSE +21 -0
  73. package/assets/skills/geo-seo/geo-content/NOTICE.md +14 -0
  74. package/assets/skills/geo-seo/geo-content/SKILL.md +352 -0
  75. package/assets/skills/geo-seo/geo-crawlers/LICENSE +21 -0
  76. package/assets/skills/geo-seo/geo-crawlers/NOTICE.md +15 -0
  77. package/assets/skills/geo-seo/geo-crawlers/SKILL.md +388 -0
  78. package/assets/skills/geo-seo/geo-llmstxt/LICENSE +21 -0
  79. package/assets/skills/geo-seo/geo-llmstxt/NOTICE.md +14 -0
  80. package/assets/skills/geo-seo/geo-llmstxt/SKILL.md +433 -0
  81. package/assets/skills/geo-seo/geo-platform-optimizer/LICENSE +21 -0
  82. package/assets/skills/geo-seo/geo-platform-optimizer/NOTICE.md +14 -0
  83. package/assets/skills/geo-seo/geo-platform-optimizer/SKILL.md +282 -0
  84. package/assets/skills/geo-seo/geo-report/LICENSE +21 -0
  85. package/assets/skills/geo-seo/geo-report/NOTICE.md +14 -0
  86. package/assets/skills/geo-seo/geo-report/SKILL.md +406 -0
  87. package/assets/skills/geo-seo/geo-report-pdf/LICENSE +21 -0
  88. package/assets/skills/geo-seo/geo-report-pdf/NOTICE.md +20 -0
  89. package/assets/skills/geo-seo/geo-report-pdf/SKILL.md +153 -0
  90. package/assets/skills/geo-seo/geo-report-pdf/templates/geo-report-template.html +548 -0
  91. package/assets/skills/geo-seo/geo-schema/LICENSE +21 -0
  92. package/assets/skills/geo-seo/geo-schema/NOTICE.md +16 -0
  93. package/assets/skills/geo-seo/geo-schema/SKILL.md +396 -0
  94. package/assets/skills/geo-seo/geo-technical/LICENSE +21 -0
  95. package/assets/skills/geo-seo/geo-technical/NOTICE.md +15 -0
  96. package/assets/skills/geo-seo/geo-technical/SKILL.md +566 -0
  97. package/assets/skills/performance/agemon-performance/NOTICE.md +1 -0
  98. package/assets/skills/performance/agemon-performance/SKILL.md +76 -0
  99. package/assets/skills/security/agemon-security/LICENSE +21 -0
  100. package/assets/skills/security/agemon-security/NOTICE.md +8 -0
  101. package/assets/skills/security/agemon-security/SKILL.md +356 -0
  102. package/assets/skills/self-review/agemon-review-intake/LICENSE +21 -0
  103. package/assets/skills/self-review/agemon-review-intake/NOTICE.md +9 -0
  104. package/assets/skills/self-review/agemon-review-intake/SKILL.md +205 -0
  105. package/assets/skills/self-review/agemon-review-request/LICENSE +21 -0
  106. package/assets/skills/self-review/agemon-review-request/NOTICE.md +9 -0
  107. package/assets/skills/self-review/agemon-review-request/SKILL.md +104 -0
  108. package/assets/skills/self-review/agemon-review-request/code-reviewer.md +188 -0
  109. package/assets/skills/self-review/agemon-root-cause/LICENSE +21 -0
  110. package/assets/skills/self-review/agemon-root-cause/NOTICE.md +10 -0
  111. package/assets/skills/self-review/agemon-root-cause/SKILL.md +283 -0
  112. package/assets/skills/self-review/agemon-root-cause/condition-based-waiting-example.ts +158 -0
  113. package/assets/skills/self-review/agemon-root-cause/condition-based-waiting.md +115 -0
  114. package/assets/skills/self-review/agemon-root-cause/defense-in-depth.md +122 -0
  115. package/assets/skills/self-review/agemon-root-cause/find-polluter.sh +72 -0
  116. package/assets/skills/self-review/agemon-root-cause/root-cause-tracing.md +169 -0
  117. package/assets/skills/self-review/agemon-root-cause/test-academic.md +14 -0
  118. package/assets/skills/self-review/agemon-root-cause/test-pressure-1.md +58 -0
  119. package/assets/skills/self-review/agemon-root-cause/test-pressure-2.md +68 -0
  120. package/assets/skills/self-review/agemon-root-cause/test-pressure-3.md +69 -0
  121. package/assets/skills/self-review/agemon-verify-before-done/LICENSE +21 -0
  122. package/assets/skills/self-review/agemon-verify-before-done/NOTICE.md +9 -0
  123. package/assets/skills/self-review/agemon-verify-before-done/SKILL.md +120 -0
  124. package/assets/skills/team-lead/agemon-plan-rfc/SKILL.md +317 -0
  125. package/assets/skills/team-lead/prd-generator/SKILL.md +437 -0
  126. package/assets/skills/team-lead/skill-headofit-audit/SKILL.md +72 -0
  127. package/assets/skills/team-lead/skill-incident-rca/SKILL.md +66 -0
  128. package/assets/skills/team-lead/skill-meeting-lifecycle/SKILL.md +63 -0
  129. package/assets/skills/team-lead/skill-obsidian-vault-sync/SKILL.md +69 -0
  130. package/assets/skills/team-lead/skill-prd-decomposer/SKILL.md +71 -0
  131. package/assets/skills/team-lead/skill-sec-check/SKILL.md +70 -0
  132. package/assets/skills/team-lead/skill-task-extractor/SKILL.md +79 -0
  133. package/assets/skills/team-lead/skill-tech-spike/SKILL.md +57 -0
  134. package/assets/skills/team-lead/skill-techlead-reviewer/SKILL.md +81 -0
  135. package/assets/tools/code-review-graph-constraints.txt +1418 -0
  136. package/assets/tools/package-lock.json +111 -0
  137. package/assets/tools/package.json +6 -0
  138. package/dist/chunk-5LATHJYU.js +4026 -0
  139. package/dist/chunk-5LATHJYU.js.map +1 -0
  140. package/dist/fake-subprocess-2BETWZVZ.js +666 -0
  141. package/dist/fake-subprocess-2BETWZVZ.js.map +1 -0
  142. package/dist/index.js +21101 -1956
  143. package/dist/index.js.map +1 -1
  144. package/package.json +30 -17
@@ -0,0 +1,666 @@
1
+ import {
2
+ AGNIX_VERSION,
3
+ CANONICAL_SKILLS_DIRECTORY,
4
+ CLAUDE_SKILLS_DIRECTORY,
5
+ CODE_REVIEW_GRAPH_PACKAGE_SPEC,
6
+ CODE_REVIEW_GRAPH_VERSION,
7
+ ESSENTIALS_SKILLS_COMMIT,
8
+ FAKE_PINNED_SKILL_MANIFEST_FILE,
9
+ SKILLS_CLI_PATH_IN_TOOLS_DIR,
10
+ SKILLS_LOCK_FILE,
11
+ SKILL_GROUPS,
12
+ fakePinnedSkillManifest,
13
+ isLeftOutBySkillsCli,
14
+ isPlainSkillName,
15
+ resolveHomeDirectory,
16
+ resolveStateRoot,
17
+ sha256Hex,
18
+ skillPathInRepository
19
+ } from "./chunk-5LATHJYU.js";
20
+
21
+ // src/core/fake-subprocess.ts
22
+ import {
23
+ closeSync,
24
+ cpSync,
25
+ existsSync,
26
+ lstatSync,
27
+ mkdirSync,
28
+ openSync,
29
+ readdirSync,
30
+ readFileSync,
31
+ rmSync,
32
+ statSync,
33
+ unlinkSync,
34
+ writeFileSync
35
+ } from "fs";
36
+ import { basename, dirname, isAbsolute, join, relative } from "path";
37
+ var FAKE_CRG_ON_PATH = "/fake/bin/code-review-graph";
38
+ var PINNED_SKILLS_CLI_SUFFIX = `/${SKILLS_CLI_PATH_IN_TOOLS_DIR}`;
39
+ var FAKE_LOCK_VERSION = 1;
40
+ function formatCommand(command, args) {
41
+ return [command, ...args].join(" ");
42
+ }
43
+ var fakeCrgInstalledState = null;
44
+ var fakeInstalledGlobalNpmPackageNames = null;
45
+ var fakeVersionedAgentBinaryNames = null;
46
+ var fakeUsableAgentBinaryNames = null;
47
+ var fakeStateSignature = null;
48
+ var fakeVerifiedBinaryInstallRequests = [];
49
+ function buildFakeStateSignature() {
50
+ return [
51
+ process.env.AGEMON_FAKE_PREINSTALLED_CRG ?? "",
52
+ process.env.AGEMON_FAKE_PREINSTALLED_NPM_PACKAGES ?? "",
53
+ process.env.AGEMON_FAKE_INSTALLED_AGENTS ?? "",
54
+ process.env.AGEMON_FAKE_USABLE_AGENTS ?? ""
55
+ ].join("||");
56
+ }
57
+ function fakeGlobalNpmStatePath() {
58
+ return join(resolveStateRoot(), "agemon-fake", "npm-global.json");
59
+ }
60
+ function saveFakeGlobalNpmPackages() {
61
+ if (fakeInstalledGlobalNpmPackageNames?.size === 0) {
62
+ rmSync(fakeGlobalNpmStatePath(), { force: true });
63
+ return;
64
+ }
65
+ mkdirSync(dirname(fakeGlobalNpmStatePath()), { recursive: true });
66
+ writeFileSync(
67
+ fakeGlobalNpmStatePath(),
68
+ JSON.stringify([...fakeInstalledGlobalNpmPackageNames ?? []])
69
+ );
70
+ }
71
+ function loadSavedFakeGlobalNpmPackages() {
72
+ if (!existsSync(fakeGlobalNpmStatePath())) {
73
+ return null;
74
+ }
75
+ return JSON.parse(readFileSync(fakeGlobalNpmStatePath(), "utf8"));
76
+ }
77
+ function resetFakeSubprocessState() {
78
+ rmSync(fakeGlobalNpmStatePath(), { force: true });
79
+ fakeCrgInstalledState = null;
80
+ fakeInstalledGlobalNpmPackageNames = null;
81
+ fakeVersionedAgentBinaryNames = null;
82
+ fakeUsableAgentBinaryNames = null;
83
+ fakeStateSignature = null;
84
+ fakeVerifiedBinaryInstallRequests = [];
85
+ }
86
+ function createFakeVerifiedBinaryInstaller() {
87
+ return {
88
+ async install(request) {
89
+ initializeFakeStateIfNeeded();
90
+ fakeVerifiedBinaryInstallRequests.push(request);
91
+ fakeInstalledGlobalNpmPackageNames?.add(request.packageName);
92
+ saveFakeGlobalNpmPackages();
93
+ },
94
+ async inspect(request) {
95
+ initializeFakeStateIfNeeded();
96
+ return fakeInstalledGlobalNpmPackageNames?.has(request.packageName) ? { kind: "installed", version: AGNIX_VERSION, differences: [] } : { kind: "absent" };
97
+ }
98
+ };
99
+ }
100
+ function takeFakeVerifiedBinaryInstallRequests() {
101
+ return fakeVerifiedBinaryInstallRequests.splice(0);
102
+ }
103
+ function initializeFakeStateIfNeeded() {
104
+ const currentStateSignature = buildFakeStateSignature();
105
+ if (fakeCrgInstalledState !== null && fakeStateSignature === currentStateSignature) {
106
+ return;
107
+ }
108
+ fakeStateSignature = currentStateSignature;
109
+ fakeCrgInstalledState = process.env.AGEMON_FAKE_PREINSTALLED_CRG === "1";
110
+ const preinstalledGlobalNpmPackages = process.env.AGEMON_FAKE_PREINSTALLED_NPM_PACKAGES?.split(",").map((packageName) => packageName.trim()).filter((packageName) => packageName.length > 0);
111
+ fakeInstalledGlobalNpmPackageNames = new Set(
112
+ loadSavedFakeGlobalNpmPackages() ?? preinstalledGlobalNpmPackages ?? []
113
+ );
114
+ const versionedAgentBinaryNames = process.env.AGEMON_FAKE_INSTALLED_AGENTS?.split(",").map((binaryName) => binaryName.trim()).filter((binaryName) => binaryName.length > 0);
115
+ fakeVersionedAgentBinaryNames = new Set(versionedAgentBinaryNames ?? []);
116
+ const usableAgentBinaryNames = process.env.AGEMON_FAKE_USABLE_AGENTS?.split(
117
+ ","
118
+ ).map((binaryName) => binaryName.trim()).filter((binaryName) => binaryName.length > 0);
119
+ fakeUsableAgentBinaryNames = new Set(usableAgentBinaryNames ?? []);
120
+ }
121
+ function readOptionValue(args, optionName) {
122
+ const optionIndex = args.indexOf(optionName);
123
+ if (optionIndex < 0) {
124
+ return void 0;
125
+ }
126
+ return args[optionIndex + 1];
127
+ }
128
+ function declaredSkillName(manifestPath, directoryName) {
129
+ const nameLine = readFileSync(manifestPath, "utf8").split("\n").find((line) => line.startsWith("name:"));
130
+ return nameLine?.slice("name:".length).trim() || directoryName;
131
+ }
132
+ function installedSkillNamesIn(skillsDirectory) {
133
+ if (!existsSync(skillsDirectory)) {
134
+ return [];
135
+ }
136
+ return readdirSync(skillsDirectory).flatMap((directoryName) => {
137
+ const manifestPath = join(skillsDirectory, directoryName, "SKILL.md");
138
+ return existsSync(manifestPath) ? [declaredSkillName(manifestPath, directoryName)] : [];
139
+ });
140
+ }
141
+ function buildFakeSkillsList(cwd) {
142
+ const names = /* @__PURE__ */ new Set([
143
+ ...installedSkillNamesIn(join(cwd, CANONICAL_SKILLS_DIRECTORY)),
144
+ ...installedSkillNamesIn(join(cwd, CLAUDE_SKILLS_DIRECTORY))
145
+ ]);
146
+ const skills = [...names].sort().map((name) => ({
147
+ name,
148
+ path: join(cwd, CLAUDE_SKILLS_DIRECTORY, name),
149
+ scope: "project",
150
+ agents: ["Claude Code"]
151
+ }));
152
+ return {
153
+ code: 0,
154
+ stdout: `${JSON.stringify(skills, null, 2)}
155
+ `,
156
+ stderr: ""
157
+ };
158
+ }
159
+ function removeInstalledCopy(copyPath) {
160
+ const stats = lstatSync(copyPath, { throwIfNoEntry: false });
161
+ if (stats?.isSymbolicLink()) {
162
+ unlinkSync(copyPath);
163
+ } else if (stats !== void 0) {
164
+ rmSync(copyPath, { recursive: true, force: true });
165
+ }
166
+ }
167
+ function copyLikeSkillsCli(source, destination) {
168
+ cpSync(source, destination, {
169
+ recursive: true,
170
+ dereference: true,
171
+ filter: (path) => path === source || !isLeftOutBySkillsCli(basename(path), statSync(path))
172
+ });
173
+ }
174
+ function readFakeLockSkills(cwd) {
175
+ try {
176
+ const parsed = JSON.parse(
177
+ readFileSync(join(cwd, SKILLS_LOCK_FILE), "utf8")
178
+ );
179
+ return parsed.version === FAKE_LOCK_VERSION && parsed.skills ? parsed.skills : {};
180
+ } catch {
181
+ return {};
182
+ }
183
+ }
184
+ function writeFakeLockLikeSkillsCli(cwd, skills) {
185
+ const sortedSkills = Object.fromEntries(
186
+ Object.keys(skills).sort().map((name) => [name, skills[name]])
187
+ );
188
+ writeFileSync(
189
+ join(cwd, SKILLS_LOCK_FILE),
190
+ `${JSON.stringify({ version: FAKE_LOCK_VERSION, skills: sortedSkills }, null, 2)}
191
+ `
192
+ );
193
+ }
194
+ function fakeLockEntry(packageSource, cwd) {
195
+ const isLocal = existsSync(packageSource);
196
+ const source = isLocal ? relative(cwd, packageSource) : packageSource;
197
+ return {
198
+ source,
199
+ sourceType: isLocal ? "local" : "github",
200
+ computedHash: sha256Hex(source)
201
+ };
202
+ }
203
+ function refusedSkillName(skillName) {
204
+ return {
205
+ code: 1,
206
+ stdout: "",
207
+ stderr: `the fake skills CLI refuses the skill name ${JSON.stringify(skillName)}`
208
+ };
209
+ }
210
+ function buildFakeSkillsAdd(args, cwd) {
211
+ const packageSource = args[1];
212
+ if (!packageSource) {
213
+ return {
214
+ code: 1,
215
+ stdout: "",
216
+ stderr: "skills add requires a package source"
217
+ };
218
+ }
219
+ const skillName = readOptionValue(args, "--skill") ?? packageSource;
220
+ if (!isPlainSkillName(skillName)) {
221
+ return refusedSkillName(skillName);
222
+ }
223
+ const copyPath = join(cwd, CLAUDE_SKILLS_DIRECTORY, skillName);
224
+ removeInstalledCopy(copyPath);
225
+ mkdirSync(dirname(copyPath), { recursive: true });
226
+ if (existsSync(packageSource)) {
227
+ copyLikeSkillsCli(packageSource, copyPath);
228
+ } else {
229
+ mkdirSync(copyPath);
230
+ writeFileSync(
231
+ join(copyPath, "SKILL.md"),
232
+ `---
233
+ name: ${skillName}
234
+ ---
235
+ `,
236
+ "utf8"
237
+ );
238
+ }
239
+ writeFakeLockLikeSkillsCli(cwd, {
240
+ ...readFakeLockSkills(cwd),
241
+ [skillName]: fakeLockEntry(packageSource, cwd)
242
+ });
243
+ return {
244
+ code: 0,
245
+ stdout: `installed skill ${skillName} from ${packageSource}
246
+ `,
247
+ stderr: ""
248
+ };
249
+ }
250
+ function buildFakeSkillsRemove(args, cwd) {
251
+ const agentName = readOptionValue(args, "--agent");
252
+ const skillNames = args.slice(1).filter(
253
+ (arg) => arg.length > 0 && !arg.startsWith("-") && arg !== agentName
254
+ );
255
+ const unsafeName = skillNames.find(
256
+ (skillName) => !isPlainSkillName(skillName)
257
+ );
258
+ if (unsafeName !== void 0) {
259
+ return refusedSkillName(unsafeName);
260
+ }
261
+ for (const skillName of skillNames) {
262
+ removeInstalledCopy(join(cwd, CLAUDE_SKILLS_DIRECTORY, skillName));
263
+ rmSync(join(cwd, CANONICAL_SKILLS_DIRECTORY, skillName), {
264
+ recursive: true,
265
+ force: true
266
+ });
267
+ const lockSkills = readFakeLockSkills(cwd);
268
+ if (Object.hasOwn(lockSkills, skillName)) {
269
+ delete lockSkills[skillName];
270
+ writeFakeLockLikeSkillsCli(cwd, lockSkills);
271
+ }
272
+ }
273
+ return {
274
+ code: 0,
275
+ stdout: `removed ${skillNames.length} skill(s)
276
+ `,
277
+ stderr: ""
278
+ };
279
+ }
280
+ function buildFakeSkillsCliResponse(args, cwd) {
281
+ const subcommand = args[0];
282
+ const needsRepository = ["list", "ls", "add", "remove", "rm"].includes(
283
+ subcommand ?? ""
284
+ );
285
+ if (needsRepository && cwd === void 0) {
286
+ return {
287
+ code: 1,
288
+ stdout: "",
289
+ stderr: "the fake skills CLI needs the repository as its cwd"
290
+ };
291
+ }
292
+ if (cwd !== void 0 && (subcommand === "list" || subcommand === "ls")) {
293
+ return buildFakeSkillsList(cwd);
294
+ }
295
+ if (cwd !== void 0 && subcommand === "add") {
296
+ return buildFakeSkillsAdd(args, cwd);
297
+ }
298
+ if (cwd !== void 0 && (subcommand === "remove" || subcommand === "rm")) {
299
+ return buildFakeSkillsRemove(args, cwd);
300
+ }
301
+ return {
302
+ code: 0,
303
+ stdout: `[fake subprocess] skills ${args.join(" ")}
304
+ `,
305
+ stderr: ""
306
+ };
307
+ }
308
+ function writeFakePinnedSkills(sourceDirectory) {
309
+ const commit = basename(sourceDirectory);
310
+ for (const entry of SKILL_GROUPS.flatMap((group) => group.skills)) {
311
+ if (entry.pinnedRepository?.commit !== commit) {
312
+ continue;
313
+ }
314
+ const skillDirectory = join(
315
+ sourceDirectory,
316
+ skillPathInRepository(entry.skillName)
317
+ );
318
+ mkdirSync(skillDirectory, { recursive: true });
319
+ writeFileSync(
320
+ join(skillDirectory, FAKE_PINNED_SKILL_MANIFEST_FILE),
321
+ fakePinnedSkillManifest(entry.skillName),
322
+ "utf8"
323
+ );
324
+ }
325
+ }
326
+ function fakePipxHome() {
327
+ return join(resolveHomeDirectory(), ".agemon", "fake-pipx");
328
+ }
329
+ function fakeCrgVenvPath() {
330
+ return join(fakePipxHome(), "venvs", "code-review-graph");
331
+ }
332
+ function fakeCrgStubPath() {
333
+ return join(fakeCrgVenvPath(), "bin", "code-review-graph");
334
+ }
335
+ function fakeCodeReviewGraphOnPath() {
336
+ initializeFakeStateIfNeeded();
337
+ if (existsSync(fakeCrgStubPath())) {
338
+ return fakeCrgStubPath();
339
+ }
340
+ return fakeCrgInstalledState ? FAKE_CRG_ON_PATH : void 0;
341
+ }
342
+ function splitPipArgs(args) {
343
+ const pipArgsFlag = args.find((arg) => arg.startsWith("--pip-args="));
344
+ if (pipArgsFlag === void 0) {
345
+ return [];
346
+ }
347
+ return [
348
+ ...pipArgsFlag.slice("--pip-args=".length).matchAll(/'([^']*)'|(\S+)/g)
349
+ ].map((match) => match[1] ?? match[2]);
350
+ }
351
+ function writeFakeCrgVenv(pipArgs) {
352
+ const metadataPath = join(fakeCrgVenvPath(), "pipx_metadata.json");
353
+ if (existsSync(metadataPath)) {
354
+ return;
355
+ }
356
+ mkdirSync(dirname(fakeCrgStubPath()), { recursive: true });
357
+ writeFileSync(fakeCrgStubPath(), "#!/bin/sh\n", { flag: "wx", mode: 493 });
358
+ writeFileSync(join(fakeCrgVenvPath(), "bin", "python"), "#!/bin/sh\n", {
359
+ flag: "wx",
360
+ mode: 493
361
+ });
362
+ const metadata = {
363
+ main_package: {
364
+ package: "code-review-graph",
365
+ package_version: CODE_REVIEW_GRAPH_VERSION,
366
+ app_paths: [{ __Path__: fakeCrgStubPath(), __type__: "Path" }],
367
+ pip_args: pipArgs
368
+ },
369
+ pipx_metadata_version: "0.3"
370
+ };
371
+ writeFileSync(metadataPath, `${JSON.stringify(metadata, null, 2)}
372
+ `, {
373
+ flag: "wx"
374
+ });
375
+ }
376
+ function findProjectRootLikeCrg(cwd, repoRootOverride) {
377
+ if (repoRootOverride && existsSync(repoRootOverride)) {
378
+ return repoRootOverride;
379
+ }
380
+ for (let directory = cwd; ; directory = dirname(directory)) {
381
+ if (existsSync(join(directory, ".git"))) {
382
+ return directory;
383
+ }
384
+ if (directory === dirname(directory)) {
385
+ return cwd;
386
+ }
387
+ }
388
+ }
389
+ function fakeGraphDatabasePath(projectRoot) {
390
+ const graphDirectory = join(projectRoot, ".code-review-graph");
391
+ mkdirSync(graphDirectory, { recursive: true });
392
+ return join(graphDirectory, "graph.db");
393
+ }
394
+ function buildFakeGraph(projectRoot) {
395
+ if (projectRoot !== void 0) {
396
+ writeFileSync(fakeGraphDatabasePath(projectRoot), "fake graph\n", "utf8");
397
+ }
398
+ }
399
+ function openFakeGraph(projectRoot) {
400
+ if (projectRoot !== void 0) {
401
+ closeSync(openSync(fakeGraphDatabasePath(projectRoot), "a"));
402
+ }
403
+ }
404
+ function buildFakeCrgResponse(command, args, projectRoot) {
405
+ const installed = fakeCrgInstalledState || isAbsolute(command) && existsSync(command);
406
+ if (!installed) {
407
+ return {
408
+ code: 1,
409
+ stdout: "",
410
+ stderr: "code-review-graph: command not found"
411
+ };
412
+ }
413
+ if (args[0] === "status") {
414
+ openFakeGraph(projectRoot);
415
+ return {
416
+ code: 0,
417
+ stdout: "Files: 1\nNodes: 1\nEdges: 1\n",
418
+ stderr: ""
419
+ };
420
+ }
421
+ if (args[0] === "build") {
422
+ buildFakeGraph(projectRoot);
423
+ return {
424
+ code: 0,
425
+ stdout: "Graph build complete\n",
426
+ stderr: ""
427
+ };
428
+ }
429
+ return {
430
+ code: 0,
431
+ stdout: "code-review-graph 0.0.0-fake\n",
432
+ stderr: ""
433
+ };
434
+ }
435
+ function buildFakePipxResponse(args) {
436
+ const [operation, packageName] = args;
437
+ if (operation === "install" && packageName === CODE_REVIEW_GRAPH_PACKAGE_SPEC) {
438
+ writeFakeCrgVenv(splitPipArgs(args));
439
+ fakeCrgInstalledState = true;
440
+ return {
441
+ code: 0,
442
+ stdout: "installed package code-review-graph\n",
443
+ stderr: ""
444
+ };
445
+ }
446
+ if (operation === "uninstall" && packageName === "code-review-graph") {
447
+ rmSync(fakeCrgVenvPath(), { recursive: true, force: true });
448
+ fakeCrgInstalledState = false;
449
+ return {
450
+ code: 0,
451
+ stdout: "uninstalled package code-review-graph\n",
452
+ stderr: ""
453
+ };
454
+ }
455
+ return void 0;
456
+ }
457
+ function parseGlobalNpmPackageNames(args) {
458
+ const packageNames = [];
459
+ for (let index = 1; index < args.length; index += 1) {
460
+ const arg = args[index];
461
+ if (!arg || arg.startsWith("-")) {
462
+ continue;
463
+ }
464
+ packageNames.push(arg);
465
+ }
466
+ return packageNames;
467
+ }
468
+ function buildFakeNpmCi(args) {
469
+ const prefix = readOptionValue(args, "--prefix");
470
+ if (prefix) {
471
+ const cliPath = join(prefix, SKILLS_CLI_PATH_IN_TOOLS_DIR);
472
+ mkdirSync(dirname(cliPath), { recursive: true });
473
+ writeFileSync(cliPath, "", "utf8");
474
+ }
475
+ return {
476
+ code: 0,
477
+ stdout: `[fake subprocess] npm ${args.join(" ")}
478
+ `,
479
+ stderr: ""
480
+ };
481
+ }
482
+ function assertNpmIgnoresProjectConfig(args) {
483
+ const ignoresProjectConfig = args.some(
484
+ (arg) => arg === "--global" || arg === "--prefix" || arg.startsWith("--prefix=")
485
+ );
486
+ if (!ignoresProjectConfig) {
487
+ throw new Error(
488
+ `npm ${args.join(" ")} must pass --global or --prefix, so npm never reads a .npmrc from the repository it runs in.`
489
+ );
490
+ }
491
+ }
492
+ function buildFakeNpmResponse(args) {
493
+ const operation = args[0];
494
+ if (!operation) {
495
+ return void 0;
496
+ }
497
+ if (operation === "ci") {
498
+ return buildFakeNpmCi(args);
499
+ }
500
+ const hasGlobalFlag = args.includes("-g") || args.includes("--global");
501
+ if (operation === "root" && hasGlobalFlag) {
502
+ const fakeNpmRoot = join(resolveStateRoot(), "agemon-fake", "npm-root");
503
+ mkdirSync(fakeNpmRoot, { recursive: true });
504
+ return { code: 0, stdout: `${fakeNpmRoot}
505
+ `, stderr: "" };
506
+ }
507
+ if (!hasGlobalFlag) {
508
+ return {
509
+ code: 0,
510
+ stdout: `[fake subprocess] npm ${args.join(" ")}
511
+ `,
512
+ stderr: ""
513
+ };
514
+ }
515
+ const packageNames = parseGlobalNpmPackageNames(args);
516
+ if (operation === "install") {
517
+ throw new Error(
518
+ `npm install --global ${packageNames.join(" ")} installs by name; agemon installs global npm packages only from a verified tarball (ctx.verifiedBinaryInstaller).`
519
+ );
520
+ }
521
+ if (operation === "uninstall") {
522
+ for (const packageName of packageNames) {
523
+ fakeInstalledGlobalNpmPackageNames?.delete(packageName);
524
+ }
525
+ saveFakeGlobalNpmPackages();
526
+ return {
527
+ code: 0,
528
+ stdout: `removed ${packageNames.length} package(s) globally
529
+ `,
530
+ stderr: ""
531
+ };
532
+ }
533
+ return {
534
+ code: 0,
535
+ stdout: `[fake subprocess] npm ${args.join(" ")}
536
+ `,
537
+ stderr: ""
538
+ };
539
+ }
540
+ function buildFakeAgnixResponse(args) {
541
+ if (!fakeInstalledGlobalNpmPackageNames?.has("agnix")) {
542
+ return {
543
+ code: 1,
544
+ stdout: "",
545
+ stderr: "agnix: command not found"
546
+ };
547
+ }
548
+ if (args[0] === "--version") {
549
+ return {
550
+ code: 0,
551
+ stdout: "agnix 0.0.0-fake\n",
552
+ stderr: ""
553
+ };
554
+ }
555
+ if (args[0] === "lint") {
556
+ return {
557
+ code: 0,
558
+ stdout: "agnix lint passed\n",
559
+ stderr: ""
560
+ };
561
+ }
562
+ return {
563
+ code: 0,
564
+ stdout: `[fake subprocess] agnix ${args.join(" ")}
565
+ `,
566
+ stderr: ""
567
+ };
568
+ }
569
+ var FAKE_AGENT_BINARY_NAMES = /* @__PURE__ */ new Set([
570
+ "claude",
571
+ "gemini"
572
+ ]);
573
+ function buildFakeAgentVersionResponse(binaryName) {
574
+ if (fakeVersionedAgentBinaryNames?.has(binaryName)) {
575
+ return {
576
+ code: 0,
577
+ stdout: `${binaryName} 1.0.0-fake
578
+ `,
579
+ stderr: ""
580
+ };
581
+ }
582
+ return {
583
+ code: 0,
584
+ stdout: "unrecognized output\n",
585
+ stderr: ""
586
+ };
587
+ }
588
+ function buildFakeAgentUsabilityResponse(binaryName, args) {
589
+ if (fakeUsableAgentBinaryNames?.has(binaryName)) {
590
+ return {
591
+ code: 0,
592
+ stdout: `[fake subprocess] ${binaryName} ${args.join(" ")} ok
593
+ `,
594
+ stderr: ""
595
+ };
596
+ }
597
+ return {
598
+ code: 1,
599
+ stdout: "",
600
+ stderr: `${binaryName} ${args.join(" ")}: command failed
601
+ `
602
+ };
603
+ }
604
+ function buildFakeAgentResponse(binaryName, args) {
605
+ if (args[0] === "--version") {
606
+ return buildFakeAgentVersionResponse(binaryName);
607
+ }
608
+ return buildFakeAgentUsabilityResponse(binaryName, args);
609
+ }
610
+ function runFakeSubprocess(command, args, options = {}) {
611
+ initializeFakeStateIfNeeded();
612
+ if (command === "pipx") {
613
+ const pipxResponse = buildFakePipxResponse(args);
614
+ if (pipxResponse) {
615
+ return pipxResponse;
616
+ }
617
+ }
618
+ if (args[0]?.endsWith(PINNED_SKILLS_CLI_SUFFIX)) {
619
+ return buildFakeSkillsCliResponse(args.slice(1), options.cwd);
620
+ }
621
+ if (command === "git" && args.at(-2) === "rev-parse" && args.at(-1) === "HEAD") {
622
+ return { code: 0, stdout: `${ESSENTIALS_SKILLS_COMMIT}
623
+ `, stderr: "" };
624
+ }
625
+ if (command === "git" && args.slice(-3).join(" ") === "checkout -q FETCH_HEAD" && options.cwd !== void 0) {
626
+ writeFakePinnedSkills(options.cwd);
627
+ }
628
+ if (basename(command) === "npm") {
629
+ assertNpmIgnoresProjectConfig(args);
630
+ }
631
+ if (command === "npm") {
632
+ const npmResponse = buildFakeNpmResponse(args);
633
+ if (npmResponse) {
634
+ return npmResponse;
635
+ }
636
+ }
637
+ if (command === "agnix") {
638
+ return buildFakeAgnixResponse(args);
639
+ }
640
+ const commandBinaryName = basename(command);
641
+ if (commandBinaryName === "code-review-graph") {
642
+ return buildFakeCrgResponse(
643
+ command,
644
+ args,
645
+ options.cwd && findProjectRootLikeCrg(options.cwd, options.env?.CRG_REPO_ROOT)
646
+ );
647
+ }
648
+ if (FAKE_AGENT_BINARY_NAMES.has(commandBinaryName)) {
649
+ return buildFakeAgentResponse(commandBinaryName, args);
650
+ }
651
+ return {
652
+ code: 0,
653
+ stdout: `[fake subprocess] ${formatCommand(command, args)}
654
+ `,
655
+ stderr: ""
656
+ };
657
+ }
658
+ export {
659
+ createFakeVerifiedBinaryInstaller,
660
+ fakeCodeReviewGraphOnPath,
661
+ fakePipxHome,
662
+ resetFakeSubprocessState,
663
+ runFakeSubprocess,
664
+ takeFakeVerifiedBinaryInstallRequests
665
+ };
666
+ //# sourceMappingURL=fake-subprocess-2BETWZVZ.js.map