@aperant/framework 0.8.1 → 0.8.4

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 (248) hide show
  1. package/CHANGELOG.md +287 -1
  2. package/agents/apt-planner.md +5 -4
  3. package/dist/cli/commands/adr.mjs +1 -1
  4. package/dist/cli/commands/audit-branch-current.d.mts +25 -0
  5. package/dist/cli/commands/audit-branch-current.d.mts.map +1 -0
  6. package/dist/cli/commands/audit-branch-current.mjs +252 -0
  7. package/dist/cli/commands/audit-branch-current.mjs.map +1 -0
  8. package/dist/cli/commands/audit.d.mts.map +1 -1
  9. package/dist/cli/commands/audit.mjs +13 -2
  10. package/dist/cli/commands/audit.mjs.map +1 -1
  11. package/dist/cli/commands/check-version.d.mts.map +1 -1
  12. package/dist/cli/commands/check-version.mjs +19 -1
  13. package/dist/cli/commands/check-version.mjs.map +1 -1
  14. package/dist/cli/commands/context.mjs +3 -3
  15. package/dist/cli/commands/context.mjs.map +1 -1
  16. package/dist/cli/commands/detect-runtime.d.mts +6 -0
  17. package/dist/cli/commands/detect-runtime.d.mts.map +1 -0
  18. package/dist/cli/commands/detect-runtime.mjs +136 -0
  19. package/dist/cli/commands/detect-runtime.mjs.map +1 -0
  20. package/dist/cli/commands/driver-doctor.d.mts +29 -0
  21. package/dist/cli/commands/driver-doctor.d.mts.map +1 -0
  22. package/dist/cli/commands/driver-doctor.mjs +291 -0
  23. package/dist/cli/commands/driver-doctor.mjs.map +1 -0
  24. package/dist/cli/commands/gate.mjs +14 -0
  25. package/dist/cli/commands/gate.mjs.map +1 -1
  26. package/dist/cli/commands/init.d.mts.map +1 -1
  27. package/dist/cli/commands/init.mjs +9 -6
  28. package/dist/cli/commands/init.mjs.map +1 -1
  29. package/dist/cli/commands/install-from-source.d.mts +2 -0
  30. package/dist/cli/commands/install-from-source.d.mts.map +1 -0
  31. package/dist/cli/commands/install-from-source.mjs +2 -0
  32. package/dist/cli/commands/install-from-source.mjs.map +1 -0
  33. package/dist/cli/commands/modes.mjs +1 -1
  34. package/dist/cli/commands/route.d.mts.map +1 -1
  35. package/dist/cli/commands/route.mjs +38 -1
  36. package/dist/cli/commands/route.mjs.map +1 -1
  37. package/dist/cli/commands/triage.mjs +1 -1
  38. package/dist/cli/config/load.d.mts.map +1 -1
  39. package/dist/cli/config/load.mjs +9 -3
  40. package/dist/cli/config/load.mjs.map +1 -1
  41. package/dist/cli/coordination/auto-emit-artifact-ready.mjs +1 -1
  42. package/dist/cli/coordination/event-schema.d.mts.map +1 -1
  43. package/dist/cli/coordination/event-schema.mjs +18 -0
  44. package/dist/cli/coordination/event-schema.mjs.map +1 -1
  45. package/dist/cli/dispatch.d.mts.map +1 -1
  46. package/dist/cli/dispatch.mjs +18 -1
  47. package/dist/cli/dispatch.mjs.map +1 -1
  48. package/dist/cli/gate/context.d.mts +1 -0
  49. package/dist/cli/gate/context.d.mts.map +1 -1
  50. package/dist/cli/gate/context.mjs +14 -1
  51. package/dist/cli/gate/context.mjs.map +1 -1
  52. package/dist/cli/gate/gates/consistency-check.d.mts +1 -0
  53. package/dist/cli/gate/gates/consistency-check.d.mts.map +1 -1
  54. package/dist/cli/gate/gates/consistency-check.mjs +1 -0
  55. package/dist/cli/gate/gates/consistency-check.mjs.map +1 -1
  56. package/dist/cli/gate/gates/review-clean.d.mts +1 -0
  57. package/dist/cli/gate/gates/review-clean.d.mts.map +1 -1
  58. package/dist/cli/gate/gates/review-clean.mjs +1 -0
  59. package/dist/cli/gate/gates/review-clean.mjs.map +1 -1
  60. package/dist/cli/gate/gates/verify-approved.d.mts +1 -0
  61. package/dist/cli/gate/gates/verify-approved.d.mts.map +1 -1
  62. package/dist/cli/gate/gates/verify-approved.mjs +1 -0
  63. package/dist/cli/gate/gates/verify-approved.mjs.map +1 -1
  64. package/dist/cli/gate/registry.d.mts.map +1 -1
  65. package/dist/cli/gate/registry.mjs +9 -1
  66. package/dist/cli/gate/registry.mjs.map +1 -1
  67. package/dist/cli/install/find-workspace-framework-version.d.mts +16 -0
  68. package/dist/cli/install/find-workspace-framework-version.d.mts.map +1 -0
  69. package/dist/cli/install/find-workspace-framework-version.mjs +85 -0
  70. package/dist/cli/install/find-workspace-framework-version.mjs.map +1 -0
  71. package/dist/cli/install/install-from-source.d.mts +10 -0
  72. package/dist/cli/install/install-from-source.d.mts.map +1 -0
  73. package/dist/cli/install/install-from-source.mjs +271 -0
  74. package/dist/cli/install/install-from-source.mjs.map +1 -0
  75. package/dist/cli/install/install-kernel.d.mts.map +1 -1
  76. package/dist/cli/install/install-kernel.mjs +24 -0
  77. package/dist/cli/install/install-kernel.mjs.map +1 -1
  78. package/dist/cli/install/legacy-paths.d.mts +33 -11
  79. package/dist/cli/install/legacy-paths.d.mts.map +1 -1
  80. package/dist/cli/install/legacy-paths.mjs +161 -39
  81. package/dist/cli/install/legacy-paths.mjs.map +1 -1
  82. package/dist/cli/install/runtime-detect.mjs +1 -1
  83. package/dist/cli/install/runtime-detect.mjs.map +1 -1
  84. package/dist/cli/install/runtime-migrate.d.mts +34 -14
  85. package/dist/cli/install/runtime-migrate.d.mts.map +1 -1
  86. package/dist/cli/install/runtime-migrate.mjs +63 -30
  87. package/dist/cli/install/runtime-migrate.mjs.map +1 -1
  88. package/dist/cli/install/transforms/codex.d.mts.map +1 -1
  89. package/dist/cli/install/transforms/codex.mjs +28 -17
  90. package/dist/cli/install/transforms/codex.mjs.map +1 -1
  91. package/dist/cli/skill-author/contract.mjs +2 -2
  92. package/dist/cli/skill-author/contract.mjs.map +1 -1
  93. package/dist/cli/verify-proof/audit.d.mts +34 -0
  94. package/dist/cli/verify-proof/audit.d.mts.map +1 -0
  95. package/dist/cli/verify-proof/audit.mjs +53 -0
  96. package/dist/cli/verify-proof/audit.mjs.map +1 -0
  97. package/dist/cli/verify-proof/exec.d.mts +20 -0
  98. package/dist/cli/verify-proof/exec.d.mts.map +1 -0
  99. package/dist/cli/verify-proof/exec.mjs +74 -0
  100. package/dist/cli/verify-proof/exec.mjs.map +1 -0
  101. package/dist/cli/verify-proof/idl/index.d.mts +2 -0
  102. package/dist/cli/verify-proof/idl/index.d.mts.map +1 -0
  103. package/dist/cli/verify-proof/idl/index.mjs +14 -0
  104. package/dist/cli/verify-proof/idl/index.mjs.map +1 -0
  105. package/dist/cli/verify-proof/idl/types.d.ts +9 -0
  106. package/dist/cli/verify-proof/idl/types.d.ts.map +1 -0
  107. package/dist/cli/verify-proof/idl/types.js +9 -0
  108. package/dist/cli/verify-proof/idl/types.js.map +1 -0
  109. package/dist/cli/verify-proof/manifest-validator.d.mts +19 -0
  110. package/dist/cli/verify-proof/manifest-validator.d.mts.map +1 -0
  111. package/dist/cli/verify-proof/manifest-validator.mjs +182 -0
  112. package/dist/cli/verify-proof/manifest-validator.mjs.map +1 -0
  113. package/dist/cli/verify-proof/resolver.d.mts +43 -0
  114. package/dist/cli/verify-proof/resolver.d.mts.map +1 -0
  115. package/dist/cli/verify-proof/resolver.mjs +160 -0
  116. package/dist/cli/verify-proof/resolver.mjs.map +1 -0
  117. package/dist/cli/verify-proof/runtime-detect.d.mts +27 -0
  118. package/dist/cli/verify-proof/runtime-detect.d.mts.map +1 -0
  119. package/dist/cli/verify-proof/runtime-detect.mjs +116 -0
  120. package/dist/cli/verify-proof/runtime-detect.mjs.map +1 -0
  121. package/dist/cli/verify-proof/trust.d.mts +70 -0
  122. package/dist/cli/verify-proof/trust.d.mts.map +1 -0
  123. package/dist/cli/verify-proof/trust.mjs +174 -0
  124. package/dist/cli/verify-proof/trust.mjs.map +1 -0
  125. package/dist/plugin/.claude-plugin/plugin.json +3 -1
  126. package/dist/plugin/agents/apt-planner.md +5 -4
  127. package/dist/plugin/skills/apt/SKILL.md +75 -6
  128. package/dist/plugin/skills/apt-caveman/SKILL.md +64 -0
  129. package/dist/plugin/skills/apt-debug/SKILL.md +36 -4
  130. package/dist/plugin/skills/apt-debug/appendices/diagnose-discipline.md +2 -11
  131. package/dist/plugin/skills/apt-discuss/SKILL.md +4 -4
  132. package/dist/plugin/skills/apt-discuss/appendices/grill-discipline.md +2 -11
  133. package/dist/plugin/skills/apt-discuss/appendices/zoom-out-helper.md +0 -8
  134. package/dist/plugin/skills/apt-execute/SKILL.md +27 -4
  135. package/dist/plugin/skills/apt-execute/appendices/tdd-mode.md +2 -10
  136. package/dist/plugin/skills/apt-fan-out/SKILL.md +36 -1
  137. package/dist/plugin/skills/apt-handoff/SKILL.md +228 -0
  138. package/dist/plugin/skills/apt-improve/DEEPENING.md +0 -8
  139. package/dist/plugin/skills/apt-improve/INTERFACE-DESIGN.md +0 -8
  140. package/dist/plugin/skills/apt-improve/LANGUAGE.md +0 -8
  141. package/dist/plugin/skills/apt-improve/SKILL.md +4 -4
  142. package/dist/plugin/skills/apt-plan/SKILL.md +23 -5
  143. package/dist/plugin/skills/apt-plan/adapters/conductor.md +1 -1
  144. package/dist/plugin/skills/apt-prototype/LOGIC.md +0 -8
  145. package/dist/plugin/skills/apt-prototype/SKILL.md +4 -4
  146. package/dist/plugin/skills/apt-prototype/UI.md +0 -8
  147. package/dist/plugin/skills/apt-quick/SKILL.md +31 -1
  148. package/dist/plugin/skills/apt-resume/SKILL.md +54 -31
  149. package/dist/plugin/skills/apt-run/SKILL.md +114 -16
  150. package/dist/plugin/skills/apt-setup/SKILL.md +97 -8
  151. package/dist/plugin/skills/apt-ship/SKILL.md +165 -9
  152. package/dist/plugin/skills/apt-spar/SKILL.md +65 -16
  153. package/dist/plugin/skills/apt-triage/AGENT-BRIEF.md +0 -8
  154. package/dist/plugin/skills/apt-triage/OUT-OF-SCOPE.md +0 -7
  155. package/dist/plugin/skills/apt-triage/SKILL.md +2 -2
  156. package/dist/plugin/skills/apt-update/SKILL.md +74 -17
  157. package/dist/plugin/skills/apt-verify-proof/SKILL.md +48 -1
  158. package/dist/plugin/skills/apt-zoom-out/SKILL.md +3 -3
  159. package/dist/schemas/quick-task.d.ts.map +1 -1
  160. package/dist/schemas/quick-task.js +2 -2
  161. package/dist/schemas/quick-task.js.map +1 -1
  162. package/dist/types/config.d.ts +33 -0
  163. package/dist/types/config.d.ts.map +1 -1
  164. package/dist/types/state.d.ts +1 -1
  165. package/dist/types/state.d.ts.map +1 -1
  166. package/dist/types/task-record.d.ts +1 -1
  167. package/dist/types/task-record.d.ts.map +1 -1
  168. package/package.json +134 -133
  169. package/prompts/planner.md +1 -1
  170. package/prompts/spec_writer.md +1 -1
  171. package/skills/apt/SKILL.md +75 -6
  172. package/skills/apt-caveman/SKILL.md +64 -0
  173. package/skills/apt-debug/SKILL.md +36 -4
  174. package/skills/apt-debug/appendices/diagnose-discipline.md +2 -11
  175. package/skills/apt-discuss/SKILL.md +4 -4
  176. package/skills/apt-discuss/appendices/grill-discipline.md +2 -11
  177. package/skills/apt-discuss/appendices/zoom-out-helper.md +0 -8
  178. package/skills/apt-execute/SKILL.md +27 -4
  179. package/skills/apt-execute/appendices/tdd-mode.md +2 -10
  180. package/skills/apt-fan-out/SKILL.md +36 -1
  181. package/skills/apt-handoff/SKILL.md +228 -0
  182. package/skills/apt-improve/DEEPENING.md +0 -8
  183. package/skills/apt-improve/INTERFACE-DESIGN.md +0 -8
  184. package/skills/apt-improve/LANGUAGE.md +0 -8
  185. package/skills/apt-improve/SKILL.md +4 -4
  186. package/skills/apt-plan/SKILL.md +23 -5
  187. package/skills/apt-plan/adapters/conductor.md +1 -1
  188. package/skills/apt-planner.md +1 -1
  189. package/skills/apt-prototype/LOGIC.md +0 -8
  190. package/skills/apt-prototype/SKILL.md +4 -4
  191. package/skills/apt-prototype/UI.md +0 -8
  192. package/skills/apt-quick/SKILL.md +31 -1
  193. package/skills/apt-resume/SKILL.md +54 -31
  194. package/skills/apt-run/SKILL.md +114 -16
  195. package/skills/apt-setup/SKILL.md +97 -8
  196. package/skills/apt-ship/SKILL.md +165 -9
  197. package/skills/apt-spar/SKILL.md +65 -16
  198. package/skills/apt-triage/AGENT-BRIEF.md +0 -8
  199. package/skills/apt-triage/OUT-OF-SCOPE.md +0 -7
  200. package/skills/apt-triage/SKILL.md +2 -2
  201. package/skills/apt-update/SKILL.md +74 -17
  202. package/skills/apt-verify-proof/SKILL.md +48 -1
  203. package/skills/apt-zoom-out/SKILL.md +3 -3
  204. package/src/cli/commands/adr.mjs +1 -1
  205. package/src/cli/commands/audit-branch-current.mjs +250 -0
  206. package/src/cli/commands/audit.mjs +13 -2
  207. package/src/cli/commands/check-version.mjs +20 -1
  208. package/src/cli/commands/context.mjs +3 -3
  209. package/src/cli/commands/detect-runtime.mjs +134 -0
  210. package/src/cli/commands/driver-doctor.mjs +294 -0
  211. package/src/cli/commands/gate.mjs +15 -0
  212. package/src/cli/commands/init.mjs +9 -6
  213. package/src/cli/commands/install-from-source.mjs +1 -0
  214. package/src/cli/commands/modes.mjs +1 -1
  215. package/src/cli/commands/route.mjs +42 -1
  216. package/src/cli/commands/triage.mjs +1 -1
  217. package/src/cli/config/load.mjs +9 -3
  218. package/src/cli/coordination/auto-emit-artifact-ready.mjs +1 -1
  219. package/src/cli/coordination/event-schema.mjs +19 -0
  220. package/src/cli/dispatch.mjs +17 -1
  221. package/src/cli/gate/context.mjs +20 -1
  222. package/src/cli/gate/gates/consistency-check.mjs +1 -0
  223. package/src/cli/gate/gates/review-clean.mjs +1 -0
  224. package/src/cli/gate/gates/verify-approved.mjs +1 -0
  225. package/src/cli/gate/registry.mjs +11 -1
  226. package/src/cli/install/find-workspace-framework-version.mjs +88 -0
  227. package/src/cli/install/install-from-source.mjs +276 -0
  228. package/src/cli/install/install-kernel.mjs +24 -0
  229. package/src/cli/install/legacy-paths.mjs +162 -39
  230. package/src/cli/install/runtime-detect.mjs +1 -1
  231. package/src/cli/install/runtime-migrate.mjs +63 -30
  232. package/src/cli/install/transforms/codex.mjs +26 -17
  233. package/src/cli/skill-author/contract.mjs +2 -2
  234. package/src/cli/verify-proof/.gitkeep +0 -0
  235. package/src/cli/verify-proof/audit.mjs +55 -0
  236. package/src/cli/verify-proof/exec.mjs +74 -0
  237. package/src/cli/verify-proof/idl/index.mjs +24 -0
  238. package/src/cli/verify-proof/idl/types.ts +41 -0
  239. package/src/cli/verify-proof/manifest-schema.json +211 -0
  240. package/src/cli/verify-proof/manifest-validator.mjs +184 -0
  241. package/src/cli/verify-proof/resolver.mjs +163 -0
  242. package/src/cli/verify-proof/runtime-detect.mjs +122 -0
  243. package/src/cli/verify-proof/trust.mjs +187 -0
  244. package/templates/adr-format.md +0 -8
  245. package/templates/aperant-claude-md-appendix.md +1 -1
  246. package/templates/context-format.md +1 -9
  247. package/templates/proof-verification.md +19 -5
  248. package/workflows/verify-proof.md +56 -14
@@ -0,0 +1,271 @@
1
+ /**
2
+ * install/install-from-source.mjs — Bundle D part 1.
3
+ *
4
+ * `apt-tools install-from-source <project-dir>` for the Aperant-contributor
5
+ * self-host case. Resolves the workspace `@aperant/framework` chain — packs
6
+ * the framework itself AND every `workspace:*` dependency (currently
7
+ * `@aperant/driver-sdk`, but the walker is general). Hands the full tarball
8
+ * list to a single `npm install --prefix` invocation so the same-PR
9
+ * unpublished-pair case stops blowing up with `EUNSUPPORTEDPROTOCOL`.
10
+ *
11
+ * Stable envelope:
12
+ * { status: 'ok', tarballs: string[], kernel_path: string }
13
+ * { status: 'error', error: string, ...optional context }
14
+ *
15
+ * Test seams: `APT_PNPM_BIN` + `APT_NPM_BIN` mirror the existing
16
+ * `install-kernel.mjs` + worker patterns.
17
+ */
18
+ import { spawnSync } from 'node:child_process';
19
+ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs';
20
+ import { tmpdir } from 'node:os';
21
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
22
+ import { err, ok } from '../util/result.mjs';
23
+ import { findWorkspaceFrameworkVersion } from './find-workspace-framework-version.mjs';
24
+ import { KERNEL_BIN_REL_PATH } from './install-kernel.mjs';
25
+ /**
26
+ * Locate the monorepo root given the workspace framework package.json path.
27
+ * `<root>/packages/framework/package.json` → `<root>`.
28
+ *
29
+ * @param {string} frameworkPkgPath
30
+ * @returns {string}
31
+ */
32
+ function monorepoRootFrom(frameworkPkgPath) {
33
+ // `<root>/packages/framework/package.json` — go up THREE levels.
34
+ return dirname(dirname(dirname(frameworkPkgPath)));
35
+ }
36
+ /**
37
+ * Scan `<monorepoRoot>/packages/` for a directory whose `package.json:name`
38
+ * matches `pkgName`. Returns the directory path (containing package.json),
39
+ * or null if no match.
40
+ *
41
+ * @param {string} monorepoRoot
42
+ * @param {string} pkgName
43
+ * @returns {string|null}
44
+ */
45
+ function findWorkspacePackage(monorepoRoot, pkgName) {
46
+ const packagesDir = join(monorepoRoot, 'packages');
47
+ if (!existsSync(packagesDir))
48
+ return null;
49
+ let entries;
50
+ try {
51
+ entries = readdirSync(packagesDir, { withFileTypes: true });
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ for (const entry of entries) {
57
+ if (!entry.isDirectory())
58
+ continue;
59
+ const candidate = join(packagesDir, entry.name, 'package.json');
60
+ if (!existsSync(candidate))
61
+ continue;
62
+ try {
63
+ const pkg = JSON.parse(readFileSync(candidate, 'utf-8'));
64
+ if (pkg?.name === pkgName)
65
+ return join(packagesDir, entry.name);
66
+ }
67
+ catch {
68
+ // Skip unreadable package.json files.
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ /**
74
+ * pnpm-pack a workspace package into `tmpDir` and return the resulting
75
+ * tarball path. Uses `pnpm --filter <name> pack --pack-destination <tmp>`
76
+ * so workspace protocols resolve to concrete versions inside the tarball.
77
+ *
78
+ * `knownBefore` is the set of .tgz filenames already present in `tmpDir`
79
+ * before this call; the mtime fallback uses it to find only the NEW file,
80
+ * avoiding coarse-timestamp ambiguity when multiple packs land in the same
81
+ * directory.
82
+ *
83
+ * @param {string} monorepoRoot
84
+ * @param {string} pkgName
85
+ * @param {string} tmpDir
86
+ * @param {Set<string>} knownBefore Filenames (not paths) present before this pack.
87
+ * @returns {{ tarball: string } | { error: string }}
88
+ */
89
+ function packWorkspace(monorepoRoot, pkgName, tmpDir, knownBefore) {
90
+ const pnpmBin = process.env.APT_PNPM_BIN || 'pnpm';
91
+ const result = spawnSync(pnpmBin, ['--filter', pkgName, 'pack', '--pack-destination', tmpDir], {
92
+ cwd: monorepoRoot,
93
+ stdio: ['ignore', 'pipe', 'pipe'],
94
+ encoding: 'utf-8',
95
+ timeout: 120_000,
96
+ });
97
+ if (result.error) {
98
+ return { error: `pnpm spawn failed for ${pkgName}: ${result.error.message}` };
99
+ }
100
+ if (result.status !== 0) {
101
+ const stderr = (result.stderr || '').trim().slice(-600);
102
+ return { error: `pnpm pack ${pkgName} exited with ${result.status}: ${stderr || 'no stderr'}` };
103
+ }
104
+ // pnpm pack prints the resulting tarball path on stdout. Take the last
105
+ // `.tgz` line (pnpm sometimes emits warnings above the path line).
106
+ const tarballLine = (result.stdout || '')
107
+ .split('\n')
108
+ .map((s) => s.trim())
109
+ .reverse()
110
+ .find((s) => s.endsWith('.tgz'));
111
+ if (tarballLine) {
112
+ // `tarballLine` may be a bare filename (older pnpm) or an absolute path.
113
+ // Use `isAbsolute` so Windows backslash + drive-letter paths are also
114
+ // recognized — `startsWith('/')` was POSIX-only.
115
+ const tarball = isAbsolute(tarballLine) ? tarballLine : join(tmpDir, tarballLine);
116
+ // SEC-001: containment check — tarball must resolve to a child of tmpDir.
117
+ const resolvedTmpDir = resolve(tmpDir);
118
+ const resolvedTarball = resolve(tarball);
119
+ if (!resolvedTarball.startsWith(`${resolvedTmpDir}/`) && resolvedTarball !== resolvedTmpDir) {
120
+ return { error: `pnpm pack ${pkgName}: tarball path escapes tmpDir: ${tarball}` };
121
+ }
122
+ return { tarball };
123
+ }
124
+ // Fall back to scanning tmpDir for the NEW tgz when stdout was
125
+ // uninformative (some pnpm builds print only progress to stderr).
126
+ // Use `knownBefore` to find only files added by this pack, avoiding
127
+ // mtime coarse-timestamp ambiguity on FAT32/network filesystems.
128
+ try {
129
+ for (const f of readdirSync(tmpDir)) {
130
+ if (!f.endsWith('.tgz'))
131
+ continue;
132
+ if (knownBefore.has(f))
133
+ continue;
134
+ return { tarball: join(tmpDir, f) };
135
+ }
136
+ }
137
+ catch {
138
+ // fall through
139
+ }
140
+ return {
141
+ error: `pnpm pack ${pkgName}: no .tgz produced (stdout: ${result.stdout?.slice(-200)})`,
142
+ };
143
+ }
144
+ /**
145
+ * `apt-tools install-from-source <project-dir>` — pack the workspace
146
+ * framework + every `workspace:*` dep, then npm-install the full tarball
147
+ * list into `<project-dir>/.aperant/deps/`.
148
+ *
149
+ * @param {string} projectDir
150
+ * @returns {import('../util/result.mjs').CommandResult}
151
+ */
152
+ export function cmdInstallFromSource(projectDir) {
153
+ if (!projectDir) {
154
+ return err('Usage: apt-tools install-from-source <project-dir>');
155
+ }
156
+ const targetDir = resolve(projectDir);
157
+ const workspace = findWorkspaceFrameworkVersion(targetDir);
158
+ if (!workspace) {
159
+ return err('install-from-source: no @aperant/framework workspace found above project-dir');
160
+ }
161
+ const monorepoRoot = monorepoRootFrom(workspace.source_path);
162
+ // QUA-001: re-read the workspace package.json with a try/catch — the file
163
+ // was validated by findWorkspaceFrameworkVersion but could change between
164
+ // the two reads (active monorepo, contributor machine).
165
+ let frameworkPkg;
166
+ try {
167
+ frameworkPkg = JSON.parse(readFileSync(workspace.source_path, 'utf-8'));
168
+ }
169
+ catch (e) {
170
+ return err(`install-from-source: failed to read ${workspace.source_path}: ${e instanceof Error ? e.message : String(e)}`);
171
+ }
172
+ // Enumerate workspace:* deps from dependencies + peerDependencies.
173
+ const depSources = [frameworkPkg.dependencies, frameworkPkg.peerDependencies];
174
+ const workspaceDeps = [];
175
+ for (const block of depSources) {
176
+ if (!block || typeof block !== 'object')
177
+ continue;
178
+ for (const [name, spec] of Object.entries(block)) {
179
+ if (typeof spec === 'string' && spec.startsWith('workspace:')) {
180
+ if (!workspaceDeps.includes(name))
181
+ workspaceDeps.push(name);
182
+ }
183
+ }
184
+ }
185
+ // Resolve each workspace dep to its `packages/<dir>` path. Reject hard
186
+ // when any dep cannot be located — we cannot pack what we cannot find.
187
+ const missingDeps = [];
188
+ const resolvedDeps = [];
189
+ for (const depName of workspaceDeps) {
190
+ const pkgDir = findWorkspacePackage(monorepoRoot, depName);
191
+ if (!pkgDir) {
192
+ missingDeps.push(depName);
193
+ continue;
194
+ }
195
+ resolvedDeps.push({ name: depName, dir: pkgDir });
196
+ }
197
+ if (missingDeps.length > 0) {
198
+ return err(`install-from-source: workspace:* dep(s) not found in packages/: ${missingDeps.join(', ')}`);
199
+ }
200
+ // PRF-001: include framework in the same pack loop — eliminates structural
201
+ // duplication and ensures per-pack knownBefore snapshots work uniformly.
202
+ const packTargets = [...resolvedDeps.map((d) => d.name), '@aperant/framework'];
203
+ // Pack everything into a fresh tmp dir so accumulated stale tarballs
204
+ // from prior runs don't sneak in.
205
+ const tmpDir = mkdtempSync(join(tmpdir(), 'apt-install-from-source-'));
206
+ const tarballs = [];
207
+ // QUA-002: wrap pack+install in try/finally so tmpDir is always removed.
208
+ try {
209
+ for (const pkgName of packTargets) {
210
+ // LOG-003: snapshot existing tgz filenames before each pack so the
211
+ // fallback can identify exactly the new file, even on coarse-timestamp
212
+ // filesystems (FAT32, some network mounts).
213
+ const knownBefore = new Set();
214
+ try {
215
+ for (const f of readdirSync(tmpDir)) {
216
+ if (f.endsWith('.tgz'))
217
+ knownBefore.add(f);
218
+ }
219
+ }
220
+ catch {
221
+ // tmpDir unreadable — proceed with empty set; fallback will still work.
222
+ }
223
+ const packResult = packWorkspace(monorepoRoot, pkgName, tmpDir, knownBefore);
224
+ if ('error' in packResult)
225
+ return err(packResult.error);
226
+ tarballs.push(packResult.tarball);
227
+ }
228
+ // npm install --prefix .aperant/deps <tarball1> <tarball2> ...
229
+ const depsDir = join(targetDir, '.aperant', 'deps');
230
+ mkdirSync(depsDir, { recursive: true });
231
+ const npmBin = process.env.APT_NPM_BIN || 'npm';
232
+ const args = [
233
+ 'install',
234
+ '--prefix',
235
+ depsDir,
236
+ ...tarballs,
237
+ '--no-save',
238
+ '--no-package-lock',
239
+ '--no-audit',
240
+ '--no-fund',
241
+ '--silent',
242
+ ];
243
+ const npmResult = spawnSync(npmBin, args, {
244
+ cwd: targetDir,
245
+ stdio: ['ignore', 'pipe', 'pipe'],
246
+ encoding: 'utf-8',
247
+ timeout: 180_000,
248
+ });
249
+ if (npmResult.error) {
250
+ return err(`install-from-source: npm spawn failed: ${npmResult.error.message}`);
251
+ }
252
+ if (npmResult.status !== 0) {
253
+ const stderr = (npmResult.stderr || '').trim().slice(-600);
254
+ return err(`install-from-source: npm install --prefix exited with ${npmResult.status}: ${stderr || 'no stderr'}`);
255
+ }
256
+ const kernelPath = join(targetDir, KERNEL_BIN_REL_PATH);
257
+ if (!existsSync(kernelPath)) {
258
+ return err(`install-from-source: npm reported success but kernel not found at ${kernelPath}`);
259
+ }
260
+ return ok({
261
+ status: 'ok',
262
+ command: 'install-from-source',
263
+ tarballs,
264
+ kernel_path: kernelPath,
265
+ });
266
+ }
267
+ finally {
268
+ rmSync(tmpDir, { recursive: true, force: true });
269
+ }
270
+ }
271
+ //# sourceMappingURL=install-from-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-from-source.mjs","sourceRoot":"","sources":["../../../src/cli/install/install-from-source.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA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AG,CACT,yDAAyD,SAAS,CAAC,MAAM,KAAK,MAAM,IAAI,WAAW,EAAE,CACrG,CAAA;QACF,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QACvD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO,GAAG,CAAC,qEAAqE,UAAU,EAAE,CAAC,CAAA;QAC9F,CAAC;QAED,OAAO,EAAE,CAAC;YACT,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,qBAAqB;YAC9B,QAAQ;YACR,WAAW,EAAE,UAAU;SACvB,CAAC,CAAA;IACH,CAAC;YAAS,CAAC;QACV,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"install-kernel.d.mts","sourceRoot":"","sources":["../../../src/cli/install/install-kernel.mjs"],"names":[],"mappings":"AA2FA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,yCARW,MAAM,WACN,MAAM,SAGd;IAAsB,SAAS;IACR,MAAM;CAC7B,GAAU,mBAAmB,CAqE/B;AApJD;;;;GAIG;AACH,kCAAmC,iEAAiE,CAAA;;YAyDtF,WAAW,GAAG,SAAS,GAAG,QAAQ;;;;gBAClC,MAAM"}
1
+ {"version":3,"file":"install-kernel.d.mts","sourceRoot":"","sources":["../../../src/cli/install/install-kernel.mjs"],"names":[],"mappings":"AA2FA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,yCARW,MAAM,WACN,MAAM,SAGd;IAAsB,SAAS;IACR,MAAM;CAC7B,GAAU,mBAAmB,CA6F/B;AA5KD;;;;GAIG;AACH,kCAAmC,iEAAiE,CAAA;;YAyDtF,WAAW,GAAG,SAAS,GAAG,QAAQ;;;;gBAClC,MAAM"}
@@ -115,6 +115,30 @@ export function installKernel(targetDir, version, opts = {}) {
115
115
  mkdirSync(depsDir, { recursive: true });
116
116
  const kernelPath = join(targetDir, KERNEL_BIN_REL_PATH);
117
117
  const npmBin = resolveNpmBin();
118
+ // Bundle B — idempotency short-circuit. When the kernel package.json
119
+ // already reports the requested version AND the kernel binary exists,
120
+ // skip the npm spawn entirely. Returns the same `status: 'installed'`
121
+ // envelope shape that downstream consumers branch on (init.mjs:1441,
122
+ // init.mjs:1735, apt-update/SKILL.md Scenario D) — no new enum value
123
+ // per D-02.
124
+ const installedPkgPath = join(depsDir, 'node_modules', '@aperant', 'framework', 'package.json');
125
+ if (existsSync(installedPkgPath) && existsSync(kernelPath)) {
126
+ try {
127
+ const installedPkg = JSON.parse(readFileSync(installedPkgPath, 'utf-8'));
128
+ if (installedPkg?.version === version) {
129
+ return {
130
+ status: 'installed',
131
+ kernelPath,
132
+ reason: 'already at target version',
133
+ durationMs: 0,
134
+ };
135
+ }
136
+ }
137
+ catch {
138
+ // Malformed package.json — fall through to the npm install path
139
+ // (npm will reconcile / repair).
140
+ }
141
+ }
118
142
  const t0 = Date.now();
119
143
  const args = [
120
144
  'install',
@@ -1 +1 @@
1
- {"version":3,"file":"install-kernel.mjs","sourceRoot":"","sources":["../../../src/cli/install/install-kernel.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,iEAAiE,CAAA;AAEpG;;;;;;GAMG;AACH,SAAS,aAAa;IACrB,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IA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MAAM,EAAE,oCAAoC,MAAM,CAAC,MAAM,KAAK,MAAM,IAAI,WAAW,EAAE;YACrF,UAAU;SACV,CAAA;IACF,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO;YACN,MAAM,EAAE,QAAQ;YAChB,UAAU;YACV,MAAM,EAAE,wDAAwD,UAAU,EAAE;YAC5E,UAAU;SACV,CAAA;IACF,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AACvD,CAAC"}
@@ -11,28 +11,50 @@
11
11
  * pre-manifest install still surfaces as "installed" rather than
12
12
  * "missing-skills".
13
13
  *
14
- * Derivation: the codex `framework_files` list was extracted from
15
- * `git show 1a8dd8a8 --stat` (the original "make Codex a first-class
16
- * skill install surface" commit) every `.agents/skills/…` path the
17
- * installer once wrote, including the `.apt-version` stamp and the
18
- * apt-pr-review / apt-discuss / apt-verify-proof sub-files. When the
19
- * codex installer was retargeted to `.codex/`, that entire tree became
20
- * orphaned on upgrading projects.
14
+ * Codex evolution: v0.7/v0.8 retargeted the codex transform to write
15
+ * markdown skills under `.codex/agents/` + `.codex/commands/` (with the
16
+ * apt-file-manifest.json next to them). Codex CLI 0.132.0 does not
17
+ * discover skills at either path its documented surface is
18
+ * `.agents/skills/<folder>/SKILL.md` (per
19
+ * https://developers.openai.com/codex/skills). The v0.8.2 fix inverts
20
+ * this registry: the dead `.codex/` markdown tree becomes the legacy
21
+ * target so `runLegacyCleanup` GCs it on the next `apt-tools init`.
21
22
  *
22
23
  * Schema:
23
24
  * { [runtimeId]: {
24
25
  * install_root: relative path the runtime once wrote into,
25
- * version_file: relative path of the legacy `.apt-version` stamp,
26
+ * version_file: relative path of the legacy `.apt-version` stamp
27
+ * (or a path known to never exist, when no version
28
+ * stamp was ever written for the legacy topology),
29
+ * honor_manifest: when true (default), a present apt-file-manifest.json
30
+ * at install_root signals a managed install and the
31
+ * cleanup no-ops (`reason: 'managed'`). When false,
32
+ * the legacy root is known-dead so the manifest is
33
+ * removed alongside framework files (used for surfaces
34
+ * like the v0.7/v0.8 codex misdirect that will never
35
+ * again be a managed install root).
26
36
  * framework_files: array of relative paths the installer once owned
27
37
  * (under install_root).
28
38
  * } }
29
39
  *
30
40
  * Frozen via Object.freeze so callers cannot mutate the shared registry.
31
41
  */
32
- /** @type {Record<string, { install_root: string, version_file: string, framework_files: ReadonlyArray<string> }>} */
33
- export const LEGACY_INSTALL_PATHS: Record<string, {
42
+ /**
43
+ * @typedef {Object} LegacyInstallPath
44
+ * @property {string} install_root
45
+ * @property {string} version_file
46
+ * @property {boolean} [honor_manifest] default true; false for known-dead surfaces
47
+ * @property {ReadonlyArray<string>} framework_files
48
+ */
49
+ /** @type {Record<string, LegacyInstallPath>} */
50
+ export const LEGACY_INSTALL_PATHS: Record<string, LegacyInstallPath>;
51
+ export type LegacyInstallPath = {
34
52
  install_root: string;
35
53
  version_file: string;
54
+ /**
55
+ * default true; false for known-dead surfaces
56
+ */
57
+ honor_manifest?: boolean | undefined;
36
58
  framework_files: ReadonlyArray<string>;
37
- }>;
59
+ };
38
60
  //# sourceMappingURL=legacy-paths.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-paths.d.mts","sourceRoot":"","sources":["../../../src/cli/install/legacy-paths.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,qHAAqH;AACrH,mCADW,MAAM,CAAC,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAoC/G"}
1
+ {"version":3,"file":"legacy-paths.d.mts","sourceRoot":"","sources":["../../../src/cli/install/legacy-paths.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;GAMG;AAEH,gDAAgD;AAChD,mCADW,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA6I1C;;kBAnJY,MAAM;kBACN,MAAM;;;;;qBAEN,aAAa,CAAC,MAAM,CAAC"}
@@ -11,58 +11,180 @@
11
11
  * pre-manifest install still surfaces as "installed" rather than
12
12
  * "missing-skills".
13
13
  *
14
- * Derivation: the codex `framework_files` list was extracted from
15
- * `git show 1a8dd8a8 --stat` (the original "make Codex a first-class
16
- * skill install surface" commit) every `.agents/skills/…` path the
17
- * installer once wrote, including the `.apt-version` stamp and the
18
- * apt-pr-review / apt-discuss / apt-verify-proof sub-files. When the
19
- * codex installer was retargeted to `.codex/`, that entire tree became
20
- * orphaned on upgrading projects.
14
+ * Codex evolution: v0.7/v0.8 retargeted the codex transform to write
15
+ * markdown skills under `.codex/agents/` + `.codex/commands/` (with the
16
+ * apt-file-manifest.json next to them). Codex CLI 0.132.0 does not
17
+ * discover skills at either path its documented surface is
18
+ * `.agents/skills/<folder>/SKILL.md` (per
19
+ * https://developers.openai.com/codex/skills). The v0.8.2 fix inverts
20
+ * this registry: the dead `.codex/` markdown tree becomes the legacy
21
+ * target so `runLegacyCleanup` GCs it on the next `apt-tools init`.
21
22
  *
22
23
  * Schema:
23
24
  * { [runtimeId]: {
24
25
  * install_root: relative path the runtime once wrote into,
25
- * version_file: relative path of the legacy `.apt-version` stamp,
26
+ * version_file: relative path of the legacy `.apt-version` stamp
27
+ * (or a path known to never exist, when no version
28
+ * stamp was ever written for the legacy topology),
29
+ * honor_manifest: when true (default), a present apt-file-manifest.json
30
+ * at install_root signals a managed install and the
31
+ * cleanup no-ops (`reason: 'managed'`). When false,
32
+ * the legacy root is known-dead so the manifest is
33
+ * removed alongside framework files (used for surfaces
34
+ * like the v0.7/v0.8 codex misdirect that will never
35
+ * again be a managed install root).
26
36
  * framework_files: array of relative paths the installer once owned
27
37
  * (under install_root).
28
38
  * } }
29
39
  *
30
40
  * Frozen via Object.freeze so callers cannot mutate the shared registry.
31
41
  */
32
- /** @type {Record<string, { install_root: string, version_file: string, framework_files: ReadonlyArray<string> }>} */
42
+ /**
43
+ * @typedef {Object} LegacyInstallPath
44
+ * @property {string} install_root
45
+ * @property {string} version_file
46
+ * @property {boolean} [honor_manifest] default true; false for known-dead surfaces
47
+ * @property {ReadonlyArray<string>} framework_files
48
+ */
49
+ /** @type {Record<string, LegacyInstallPath>} */
33
50
  export const LEGACY_INSTALL_PATHS = Object.freeze({
34
51
  codex: Object.freeze({
35
- install_root: '.agents/skills',
36
- version_file: '.agents/skills/.apt-version',
52
+ // The v0.7/v0.8 misdirect lived under `.codex/agents/` + `.codex/commands/`
53
+ // (with the orphan apt-file-manifest.json at `.codex/apt-file-manifest.json`).
54
+ // Codex CLI 0.132.0 does not consume any of those paths — see header.
55
+ install_root: '.codex',
56
+ // No `.apt-version` was ever written under `.codex/`; point at a path
57
+ // that doesn't exist so `existsSync` returns false in
58
+ // skill-installs.mjs:67-68 (legacy version_file fallback). The bare
59
+ // apt-file-manifest.json (handled by framework_files) is enough to
60
+ // signal the legacy install.
61
+ version_file: '.codex/.apt-version',
62
+ // Known-dead surface: this `.codex/` topology will never again be
63
+ // a managed Aperant install root, so a manifest sitting here is
64
+ // always stale. Skip the no-op-on-manifest safety and remove the
65
+ // manifest alongside framework_files. Default-true elsewhere
66
+ // preserves the safety for legacy roots that could legitimately
67
+ // re-host a managed install.
68
+ honor_manifest: false,
69
+ // Enumerated from BOTH canonical sources (drift-checked at test time
70
+ // by legacy-cleanup-codex.test.ts):
71
+ // - For each `packages/framework/skills/apt-*/` directory: the v0.7/v0.8
72
+ // transform emitted BOTH `agents/<dir>.md` AND `commands/<dir>.md`.
73
+ // - For each top-level `packages/framework/skills/apt-*.md` file
74
+ // (fileType=agent in the pipeline): the transform emitted
75
+ // `agents/<basename>.md`.
76
+ // - For each `packages/framework/agents/apt-*.md` file: the transform
77
+ // emitted `agents/<basename>.md` (last-write-wins de-dupe applied
78
+ // by the pipeline for overlapping outputs).
79
+ // - Plus the orphan apt-file-manifest.json the install pipeline
80
+ // stamps at install_root.
81
+ // TODO: follow-up — derive this programmatically per spec ID-06 so
82
+ // new apt-* skills auto-extend the legacy set without an edit here.
37
83
  framework_files: Object.freeze([
38
- '.apt-version',
39
- 'apt/SKILL.md',
40
- 'apt-debug/SKILL.md',
41
- 'apt-discuss/SKILL.md',
42
- 'apt-discuss/examples/rationalization-example.md',
43
- 'apt-docs/SKILL.md',
44
- 'apt-execute/SKILL.md',
45
- 'apt-pause/SKILL.md',
46
- 'apt-plan/SKILL.md',
47
- 'apt-pr-review/SCHEMA.md',
48
- 'apt-pr-review/SKILL.md',
49
- 'apt-pr-review/prompts/fp-gate-codex.md',
50
- 'apt-pr-review/templates/external-comment.md',
51
- 'apt-quick/SKILL.md',
52
- 'apt-resume/SKILL.md',
53
- 'apt-review/SKILL.md',
54
- 'apt-roadmap/SKILL.md',
55
- 'apt-roundtable/SKILL.md',
56
- 'apt-run/SKILL.md',
57
- 'apt-scan/SKILL.md',
58
- 'apt-setup/SKILL.md',
59
- 'apt-ship/SKILL.md',
60
- 'apt-stress-test/SKILL.md',
61
- 'apt-verify/SKILL.md',
62
- 'apt-verify-proof/SKILL.md',
63
- 'apt-verify-proof/references/multi-model-setup.md',
64
- 'apt-verify-proof/references/multi-model-verification.md',
65
- 'apt-verify-proof/references/proof-capture.md',
84
+ 'apt-file-manifest.json',
85
+ // agents/<dir>.md — one per skill directory (39 dirs)
86
+ 'agents/apt.md',
87
+ 'agents/apt-author-skill.md',
88
+ 'agents/apt-bootstrap.md',
89
+ 'agents/apt-caveman.md',
90
+ 'agents/apt-classify.md',
91
+ 'agents/apt-close-task.md',
92
+ 'agents/apt-create-docs.md',
93
+ 'agents/apt-debug.md',
94
+ 'agents/apt-design.md',
95
+ 'agents/apt-diagram.md',
96
+ 'agents/apt-discuss.md',
97
+ 'agents/apt-docs.md',
98
+ 'agents/apt-execute.md',
99
+ 'agents/apt-fan-out.md',
100
+ 'agents/apt-handoff.md',
101
+ 'agents/apt-improve.md',
102
+ 'agents/apt-mockup.md',
103
+ 'agents/apt-pause.md',
104
+ 'agents/apt-personas.md',
105
+ 'agents/apt-plan.md',
106
+ 'agents/apt-pr-review.md',
107
+ 'agents/apt-prototype.md',
108
+ 'agents/apt-quick.md',
109
+ 'agents/apt-release-notes.md',
110
+ 'agents/apt-resume.md',
111
+ 'agents/apt-review.md',
112
+ 'agents/apt-roadmap.md',
113
+ 'agents/apt-roundtable.md',
114
+ 'agents/apt-run.md',
115
+ 'agents/apt-scan.md',
116
+ 'agents/apt-setup.md',
117
+ 'agents/apt-ship.md',
118
+ 'agents/apt-spar.md',
119
+ 'agents/apt-stress-test.md',
120
+ 'agents/apt-terminal.md',
121
+ 'agents/apt-triage.md',
122
+ 'agents/apt-update.md',
123
+ 'agents/apt-verify.md',
124
+ 'agents/apt-verify-proof.md',
125
+ 'agents/apt-watch-ci.md',
126
+ 'agents/apt-zoom-out.md',
127
+ // commands/<dir>.md — one per skill directory (mirrors agents/)
128
+ 'commands/apt.md',
129
+ 'commands/apt-author-skill.md',
130
+ 'commands/apt-bootstrap.md',
131
+ 'commands/apt-caveman.md',
132
+ 'commands/apt-classify.md',
133
+ 'commands/apt-close-task.md',
134
+ 'commands/apt-create-docs.md',
135
+ 'commands/apt-debug.md',
136
+ 'commands/apt-design.md',
137
+ 'commands/apt-diagram.md',
138
+ 'commands/apt-discuss.md',
139
+ 'commands/apt-docs.md',
140
+ 'commands/apt-execute.md',
141
+ 'commands/apt-fan-out.md',
142
+ 'commands/apt-handoff.md',
143
+ 'commands/apt-improve.md',
144
+ 'commands/apt-mockup.md',
145
+ 'commands/apt-pause.md',
146
+ 'commands/apt-personas.md',
147
+ 'commands/apt-plan.md',
148
+ 'commands/apt-pr-review.md',
149
+ 'commands/apt-prototype.md',
150
+ 'commands/apt-quick.md',
151
+ 'commands/apt-release-notes.md',
152
+ 'commands/apt-resume.md',
153
+ 'commands/apt-review.md',
154
+ 'commands/apt-roadmap.md',
155
+ 'commands/apt-roundtable.md',
156
+ 'commands/apt-run.md',
157
+ 'commands/apt-scan.md',
158
+ 'commands/apt-setup.md',
159
+ 'commands/apt-ship.md',
160
+ 'commands/apt-spar.md',
161
+ 'commands/apt-stress-test.md',
162
+ 'commands/apt-terminal.md',
163
+ 'commands/apt-triage.md',
164
+ 'commands/apt-update.md',
165
+ 'commands/apt-verify.md',
166
+ 'commands/apt-verify-proof.md',
167
+ 'commands/apt-watch-ci.md',
168
+ 'commands/apt-zoom-out.md',
169
+ // agents/<basename>.md — packages/framework/agents/apt-*.md (17 files)
170
+ // (overlap with skills/apt-*.md top-level — same outputPath, de-dupe)
171
+ 'agents/apt-docs-author.md',
172
+ 'agents/apt-executor.md',
173
+ 'agents/apt-improver.md',
174
+ 'agents/apt-planner.md',
175
+ 'agents/apt-pr-review-codebase-fit.md',
176
+ 'agents/apt-pr-review-fixer.md',
177
+ 'agents/apt-pr-review-logic.md',
178
+ 'agents/apt-pr-review-performance.md',
179
+ 'agents/apt-pr-review-quality.md',
180
+ 'agents/apt-pr-review-security.md',
181
+ 'agents/apt-pr-review-self-reviewer.md',
182
+ 'agents/apt-pr-review-test-integrity.md',
183
+ 'agents/apt-pr-review-validator.md',
184
+ 'agents/apt-researcher.md',
185
+ 'agents/apt-reviewer.md',
186
+ 'agents/apt-team-docs-narrator.md',
187
+ 'agents/apt-verifier.md',
66
188
  ]),
67
189
  }),
68
190
  });
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-paths.mjs","sourceRoot":"","sources":["../../../src/cli/install/legacy-paths.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,qHAAqH;AACrH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,YAAY,EAAE,gBAAgB;QAC9B,YAAY,EAAE,6BAA6B;QAC3C,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC;YAC9B,cAAc;YACd,cAAc;YACd,oBAAoB;YACpB,sBAAsB;YACtB,iDAAiD;YACjD,mBAAmB;YACnB,sBAAsB;YACtB,oBAAoB;YACpB,mBAAmB;YACnB,yBAAyB;YACzB,wBAAwB;YACxB,wCAAwC;YACxC,6CAA6C;YAC7C,oBAAoB;YACpB,qBAAqB;YACrB,qBAAqB;YACrB,sBAAsB;YACtB,yBAAyB;YACzB,kBAAkB;YAClB,mBAAmB;YACnB,oBAAoB;YACpB,mBAAmB;YACnB,0BAA0B;YAC1B,qBAAqB;YACrB,2BAA2B;YAC3B,kDAAkD;YAClD,yDAAyD;YACzD,8CAA8C;SAC9C,CAAC;KACF,CAAC;CACF,CAAC,CAAA"}
1
+ {"version":3,"file":"legacy-paths.mjs","sourceRoot":"","sources":["../../../src/cli/install/legacy-paths.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;GAMG;AAEH,gDAAgD;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,4EAA4E;QAC5E,+EAA+E;QAC/E,sEAAsE;QACtE,YAAY,EAAE,QAAQ;QACtB,sEAAsE;QACtE,sDAAsD;QACtD,oEAAoE;QACpE,mEAAmE;QACnE,6BAA6B;QAC7B,YAAY,EAAE,qBAAqB;QACnC,kEAAkE;QAClE,gEAAgE;QAChE,iEAAiE;QACjE,6DAA6D;QAC7D,gEAAgE;QAChE,6BAA6B;QAC7B,cAAc,EAAE,KAAK;QACrB,qEAAqE;QACrE,oCAAoC;QACpC,2EAA2E;QAC3E,wEAAwE;QACxE,mEAAmE;QACnE,8DAA8D;QAC9D,8BAA8B;QAC9B,wEAAwE;QACxE,sEAAsE;QACtE,gDAAgD;QAChD,kEAAkE;QAClE,8BAA8B;QAC9B,mEAAmE;QACnE,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