@amsterdamdatalabs/enact-extensions 0.1.0 → 0.1.3

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 (245) hide show
  1. package/README.md +96 -21
  2. package/dist/index.d.ts +5 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/install.d.ts +171 -1
  7. package/dist/install.d.ts.map +1 -1
  8. package/dist/install.js +402 -49
  9. package/dist/install.js.map +1 -1
  10. package/dist/internal/codex.d.ts.map +1 -1
  11. package/dist/internal/codex.js +7 -1
  12. package/dist/internal/codex.js.map +1 -1
  13. package/dist/internal/platform.d.ts +8 -0
  14. package/dist/internal/platform.d.ts.map +1 -1
  15. package/dist/internal/platform.js +46 -2
  16. package/dist/internal/platform.js.map +1 -1
  17. package/dist/provision.d.ts +30 -0
  18. package/dist/provision.d.ts.map +1 -0
  19. package/dist/provision.js +202 -0
  20. package/dist/provision.js.map +1 -0
  21. package/dist/validate/index.d.ts +44 -0
  22. package/dist/validate/index.d.ts.map +1 -1
  23. package/dist/validate/index.js +157 -0
  24. package/dist/validate/index.js.map +1 -1
  25. package/extensions/cmux/.agents/plugin.json +37 -0
  26. package/extensions/cmux/skills/cmux/SKILL.md +82 -0
  27. package/extensions/cmux/skills/cmux/agents/openai.yaml +4 -0
  28. package/extensions/cmux/skills/cmux/references/handles-and-identify.md +35 -0
  29. package/extensions/cmux/skills/cmux/references/panes-surfaces.md +37 -0
  30. package/extensions/cmux/skills/cmux/references/trigger-flash-and-health.md +23 -0
  31. package/extensions/cmux/skills/cmux/references/windows-workspaces.md +31 -0
  32. package/extensions/cmux/skills/cmux-vm-monitor/SKILL.md +122 -0
  33. package/extensions/cmux/skills/cmux-vm-monitor/agents/openai.yaml +4 -0
  34. package/extensions/cmux/skills/cmux-vm-monitor/references/cmux-commands.md +66 -0
  35. package/extensions/cmux/skills/cmux-vm-monitor/scripts/codex_vm_monitor.sh +45 -0
  36. package/extensions/cmux/skills/cmux-workspace/SKILL.md +93 -0
  37. package/extensions/dev-state/.agents/plugin.json +35 -0
  38. package/extensions/dev-state/skills/dev-state-plan-graduation/SKILL.md +194 -0
  39. package/extensions/dev-state/skills/dev-state-plan-graduation/agents/openai.yaml +4 -0
  40. package/extensions/dev-state/skills/dev-state-plan-graduation/references/reference.md +130 -0
  41. package/extensions/devops/.agents/plugin.json +36 -0
  42. package/extensions/devops/skills/azure-devops-cli/SKILL.md +431 -0
  43. package/extensions/devops/skills/azure-devops-cli/agents/openai.yaml +4 -0
  44. package/extensions/devops/skills/ci-pipeline-strategy/SKILL.md +217 -0
  45. package/extensions/devops/skills/ci-pipeline-strategy/agents/openai.yaml +4 -0
  46. package/extensions/enact-context/.agents/plugin.json +40 -0
  47. package/extensions/enact-context/.mcp.json +8 -0
  48. package/extensions/enact-context/README.md +25 -0
  49. package/extensions/enact-context/assets/icon.png +0 -0
  50. package/extensions/enact-context/assets/logo.png +0 -0
  51. package/extensions/enact-context/hooks/hooks.json +115 -0
  52. package/extensions/enact-context/skills/enact-context/SKILL.md +149 -0
  53. package/extensions/enact-context/skills/enact-context/scripts/install.sh +69 -0
  54. package/extensions/enact-factory/.agents/plugin.json +42 -0
  55. package/extensions/enact-factory/.mcp.json +8 -0
  56. package/extensions/enact-factory/assets/icon.png +0 -0
  57. package/extensions/enact-factory/assets/logo.png +0 -0
  58. package/extensions/enact-factory/hooks/user-prompt-submit.mjs +67 -0
  59. package/extensions/enact-factory/skills/testing-strategy/SKILL.md +167 -0
  60. package/extensions/enact-factory/skills/workitem-triage/SKILL.md +22 -0
  61. package/extensions/enact-operator/.agents/plugin.json +57 -0
  62. package/extensions/enact-operator/.app.json +3 -0
  63. package/extensions/enact-operator/.mcp.json +10 -0
  64. package/extensions/enact-operator/_taxonomy.md +86 -0
  65. package/extensions/enact-operator/agents/README.md +5 -0
  66. package/extensions/enact-operator/agents/architect.toml +25 -0
  67. package/extensions/enact-operator/agents/code-reviewer.toml +24 -0
  68. package/extensions/enact-operator/agents/critic.toml +30 -0
  69. package/extensions/enact-operator/agents/executor.toml +24 -0
  70. package/extensions/enact-operator/agents/explore.toml +23 -0
  71. package/extensions/enact-operator/agents/planner.toml +24 -0
  72. package/extensions/enact-operator/agents/verifier.toml +24 -0
  73. package/extensions/enact-operator/assets/icon.png +0 -0
  74. package/extensions/enact-operator/assets/logo.png +0 -0
  75. package/extensions/enact-operator/commands/doctor.md +39 -0
  76. package/extensions/enact-operator/commands/setup.md +51 -0
  77. package/extensions/enact-operator/hooks/hooks.json +146 -0
  78. package/extensions/enact-operator/skills/_variants.md +44 -0
  79. package/extensions/enact-operator/skills/ai-slop-cleaner/SKILL.md +50 -0
  80. package/extensions/enact-operator/skills/analyze/SKILL.md +91 -0
  81. package/extensions/enact-operator/skills/ask/SKILL.md +47 -0
  82. package/extensions/enact-operator/skills/autopilot/SKILL.md +170 -0
  83. package/extensions/enact-operator/skills/autoresearch-goal/SKILL.md +79 -0
  84. package/extensions/enact-operator/skills/cancel/SKILL.md +99 -0
  85. package/extensions/enact-operator/skills/configure-notifications/SKILL.md +77 -0
  86. package/extensions/enact-operator/skills/deep-interview/SKILL.md +80 -0
  87. package/extensions/enact-operator/skills/doctor/SKILL.md +48 -0
  88. package/extensions/enact-operator/skills/hud/SKILL.md +49 -0
  89. package/extensions/enact-operator/skills/hyperplan/SKILL.md +47 -0
  90. package/extensions/enact-operator/skills/plan/SKILL.md +78 -0
  91. package/extensions/enact-operator/skills/ralph/SKILL.md +201 -0
  92. package/extensions/enact-operator/skills/ralph/gemini.md +18 -0
  93. package/extensions/enact-operator/skills/ralplan/SKILL.md +151 -0
  94. package/extensions/enact-operator/skills/remove-deadcode/SKILL.md +45 -0
  95. package/extensions/enact-operator/skills/research/SKILL.md +74 -0
  96. package/extensions/enact-operator/skills/review/SKILL.md +58 -0
  97. package/extensions/enact-operator/skills/security-research/SKILL.md +54 -0
  98. package/extensions/enact-operator/skills/setup/SKILL.md +91 -0
  99. package/extensions/enact-operator/skills/setup/scripts/install.sh +50 -0
  100. package/extensions/enact-operator/skills/skill/SKILL.md +82 -0
  101. package/extensions/enact-operator/skills/tdd/SKILL.md +59 -0
  102. package/extensions/enact-operator/skills/team/SKILL.md +199 -0
  103. package/extensions/enact-operator/skills/trace/SKILL.md +41 -0
  104. package/extensions/enact-operator/skills/ultragoal/SKILL.md +99 -0
  105. package/extensions/enact-operator/skills/ultraqa/SKILL.md +113 -0
  106. package/extensions/enact-operator/skills/ultrawork/SKILL.md +145 -0
  107. package/extensions/enact-operator/skills/ultrawork/planner.md +28 -0
  108. package/extensions/enact-operator/skills/wiki/SKILL.md +41 -0
  109. package/extensions/enact-operator/skills/work-with-workitem/SKILL.md +51 -0
  110. package/extensions/enact-wiki/.agents/plugin.json +42 -0
  111. package/extensions/enact-wiki/.mcp.json +15 -0
  112. package/extensions/enact-wiki/README.md +44 -0
  113. package/extensions/enact-wiki/assets/icon.png +0 -0
  114. package/extensions/enact-wiki/assets/logo.png +0 -0
  115. package/extensions/enact-wiki/skills/document-parser/SKILL.md +17 -0
  116. package/extensions/enact-wiki/skills/document-parser/scripts/parse.sh +60 -0
  117. package/extensions/enact-wiki/skills/document-parser/skill.json +9 -0
  118. package/extensions/enact-wiki/skills/enact-wiki/SKILL.md +30 -0
  119. package/extensions/enact-wiki/skills/enact-wiki/references/ingest.md +62 -0
  120. package/extensions/enact-wiki/skills/enact-wiki/references/manage.md +34 -0
  121. package/extensions/enact-wiki/skills/enact-wiki/references/query.md +59 -0
  122. package/extensions/enact-wiki/skills/search-lab/SKILL.md +57 -0
  123. package/extensions/enact-wiki/skills/search-lab/scripts/analyze.ts +23 -0
  124. package/{plugins/net-revenue-management/.codex-plugin → extensions/net-revenue-management/.agents}/plugin.json +10 -6
  125. package/extensions/plugin-dev/.agents/plugin.json +42 -0
  126. package/extensions/plugin-dev/.mcp.json +3 -0
  127. package/extensions/plugin-dev/agents/agent-creator.md +199 -0
  128. package/extensions/plugin-dev/agents/plugin-validator.md +91 -0
  129. package/extensions/plugin-dev/agents/skill-reviewer.md +212 -0
  130. package/extensions/plugin-dev/commands/_archive/create-marketplace.md +427 -0
  131. package/extensions/plugin-dev/commands/_archive/plugin-dev-guide.md +12 -0
  132. package/extensions/plugin-dev/commands/create-plugin.md +498 -0
  133. package/extensions/plugin-dev/commands/start.md +81 -0
  134. package/extensions/plugin-dev/hooks/hooks.json +3 -0
  135. package/extensions/plugin-dev/skills/agent-development/SKILL.md +641 -0
  136. package/extensions/plugin-dev/skills/agent-development/examples/agent-creation-prompt.md +250 -0
  137. package/extensions/plugin-dev/skills/agent-development/examples/complete-agent-examples.md +461 -0
  138. package/extensions/plugin-dev/skills/agent-development/references/advanced-agent-fields.md +246 -0
  139. package/extensions/plugin-dev/skills/agent-development/references/agent-creation-system-prompt.md +216 -0
  140. package/extensions/plugin-dev/skills/agent-development/references/permission-modes-rules.md +226 -0
  141. package/extensions/plugin-dev/skills/agent-development/references/system-prompt-design.md +464 -0
  142. package/extensions/plugin-dev/skills/agent-development/references/triggering-examples.md +474 -0
  143. package/extensions/plugin-dev/skills/agent-development/scripts/create-agent-skeleton.sh +176 -0
  144. package/extensions/plugin-dev/skills/agent-development/scripts/test-agent-trigger.sh +227 -0
  145. package/extensions/plugin-dev/skills/agent-development/scripts/validate-agent.sh +227 -0
  146. package/extensions/plugin-dev/skills/command-development/SKILL.md +763 -0
  147. package/extensions/plugin-dev/skills/command-development/examples/plugin-commands.md +612 -0
  148. package/extensions/plugin-dev/skills/command-development/examples/simple-commands.md +527 -0
  149. package/extensions/plugin-dev/skills/command-development/references/advanced-workflows.md +762 -0
  150. package/extensions/plugin-dev/skills/command-development/references/documentation-patterns.md +769 -0
  151. package/extensions/plugin-dev/skills/command-development/references/frontmatter-reference.md +508 -0
  152. package/extensions/plugin-dev/skills/command-development/references/interactive-commands.md +966 -0
  153. package/extensions/plugin-dev/skills/command-development/references/marketplace-considerations.md +943 -0
  154. package/extensions/plugin-dev/skills/command-development/references/plugin-features-reference.md +637 -0
  155. package/extensions/plugin-dev/skills/command-development/references/plugin-integration.md +191 -0
  156. package/extensions/plugin-dev/skills/command-development/references/skill-tool.md +447 -0
  157. package/extensions/plugin-dev/skills/command-development/references/testing-strategies.md +723 -0
  158. package/extensions/plugin-dev/skills/command-development/scripts/check-frontmatter.sh +234 -0
  159. package/extensions/plugin-dev/skills/command-development/scripts/validate-command.sh +160 -0
  160. package/extensions/plugin-dev/skills/hook-development/SKILL.md +861 -0
  161. package/extensions/plugin-dev/skills/hook-development/examples/load-context.sh +55 -0
  162. package/extensions/plugin-dev/skills/hook-development/examples/validate-bash.sh +57 -0
  163. package/extensions/plugin-dev/skills/hook-development/examples/validate-write.sh +48 -0
  164. package/extensions/plugin-dev/skills/hook-development/references/advanced.md +871 -0
  165. package/extensions/plugin-dev/skills/hook-development/references/hook-input-schemas.md +145 -0
  166. package/extensions/plugin-dev/skills/hook-development/references/migration.md +392 -0
  167. package/extensions/plugin-dev/skills/hook-development/references/patterns.md +430 -0
  168. package/extensions/plugin-dev/skills/hook-development/scripts/README.md +181 -0
  169. package/extensions/plugin-dev/skills/hook-development/scripts/hook-linter.sh +153 -0
  170. package/extensions/plugin-dev/skills/hook-development/scripts/test-hook.sh +276 -0
  171. package/extensions/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
  172. package/extensions/plugin-dev/skills/mcp-integration/SKILL.md +775 -0
  173. package/extensions/plugin-dev/skills/mcp-integration/examples/http-server.json +20 -0
  174. package/extensions/plugin-dev/skills/mcp-integration/examples/sse-server.json +19 -0
  175. package/extensions/plugin-dev/skills/mcp-integration/examples/stdio-server.json +38 -0
  176. package/extensions/plugin-dev/skills/mcp-integration/examples/ws-server.json +26 -0
  177. package/extensions/plugin-dev/skills/mcp-integration/references/authentication.md +601 -0
  178. package/extensions/plugin-dev/skills/mcp-integration/references/server-discovery.md +190 -0
  179. package/extensions/plugin-dev/skills/mcp-integration/references/server-types.md +572 -0
  180. package/extensions/plugin-dev/skills/mcp-integration/references/tool-usage.md +623 -0
  181. package/extensions/plugin-dev/skills/plugin-dev-guide/SKILL.md +222 -0
  182. package/extensions/plugin-dev/skills/plugin-structure/SKILL.md +705 -0
  183. package/extensions/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md +774 -0
  184. package/extensions/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md +83 -0
  185. package/extensions/plugin-dev/skills/plugin-structure/examples/standard-plugin.md +611 -0
  186. package/extensions/plugin-dev/skills/plugin-structure/references/advanced-topics.md +289 -0
  187. package/extensions/plugin-dev/skills/plugin-structure/references/component-patterns.md +592 -0
  188. package/extensions/plugin-dev/skills/plugin-structure/references/github-actions.md +233 -0
  189. package/extensions/plugin-dev/skills/plugin-structure/references/headless-ci-mode.md +193 -0
  190. package/extensions/plugin-dev/skills/plugin-structure/references/manifest-reference.md +625 -0
  191. package/extensions/plugin-dev/skills/plugin-structure/references/output-styles.md +116 -0
  192. package/extensions/plugin-dev/skills/skill-development/SKILL.md +564 -0
  193. package/extensions/plugin-dev/skills/skill-development/examples/complete-skill.md +465 -0
  194. package/extensions/plugin-dev/skills/skill-development/examples/frontmatter-templates.md +167 -0
  195. package/extensions/plugin-dev/skills/skill-development/examples/minimal-skill.md +111 -0
  196. package/extensions/plugin-dev/skills/skill-development/references/advanced-frontmatter.md +225 -0
  197. package/extensions/plugin-dev/skills/skill-development/references/commands-vs-skills.md +39 -0
  198. package/extensions/plugin-dev/skills/skill-development/references/skill-creation-workflow.md +379 -0
  199. package/extensions/plugin-dev/skills/skill-development/references/skill-creator-original.md +210 -0
  200. package/package.json +8 -11
  201. package/scripts/enact-extensions.mjs +823 -21
  202. package/scripts/hooks/session-start-drift-check.mjs +58 -0
  203. package/scripts/lib/build-index.mjs +50 -0
  204. package/scripts/lib/bundle-hash.mjs +137 -0
  205. package/scripts/lib/hooks.mjs +741 -0
  206. package/scripts/lib/ledger.mjs +163 -0
  207. package/scripts/lib/list-bundles.mjs +70 -0
  208. package/scripts/lib/outdated.mjs +144 -0
  209. package/scripts/lib/provision-mcp.mjs +16 -0
  210. package/scripts/lib/resolve-bundle.mjs +121 -0
  211. package/scripts/lib/run-install.mjs +402 -38
  212. package/scripts/lib/run-prune.mjs +73 -0
  213. package/scripts/lib/run-sync.mjs +9 -1
  214. package/scripts/lib/run-uninstall.mjs +244 -0
  215. package/scripts/lib/run-update.mjs +152 -0
  216. package/scripts/lib/run-validate.mjs +21 -18
  217. package/scripts/lib/serve.mjs +472 -0
  218. package/scripts/postinstall.mjs +63 -0
  219. package/scripts/setup-enact-context.sh +2 -2
  220. package/scripts/version-bump.sh +463 -0
  221. package/spec/codex.json +1 -11
  222. package/spec/index.json +59 -0
  223. package/web/assets/README.md +111 -0
  224. package/web/assets/logo-full.png +0 -0
  225. package/web/assets/logo-slim.png +0 -0
  226. package/web/assets/tokens/base.css +45 -0
  227. package/web/assets/tokens/colors.css +248 -0
  228. package/web/assets/tokens/effects.css +24 -0
  229. package/web/assets/tokens/fonts.css +8 -0
  230. package/web/assets/tokens/index.css +18 -0
  231. package/web/assets/tokens/spacing.css +50 -0
  232. package/web/index.html +1188 -0
  233. package/.agents/plugins/marketplace.json +0 -20
  234. package/catalog/enact-context.json +0 -9
  235. package/catalog/enact-factory.json +0 -7
  236. package/catalog/enact-operator.json +0 -7
  237. package/catalog/enact-wiki.json +0 -7
  238. package/catalog/net-revenue-management.json +0 -8
  239. package/scripts/rename-supervisor-to-operator.pl +0 -66
  240. package/scripts/sync-manifests.mjs +0 -23
  241. package/scripts/validate-catalog.mjs +0 -37
  242. package/scripts/validate-plugin.mjs +0 -10
  243. /package/{plugins → extensions}/net-revenue-management/.mcp.json +0 -0
  244. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-risks/SKILL.md +0 -0
  245. /package/{plugins → extensions}/net-revenue-management/skills/net-revenue-scenario/SKILL.md +0 -0
@@ -1,40 +1,146 @@
1
1
  #!/usr/bin/env node
2
2
  import { resolvePluginRoot } from "./lib/resolve-plugin-root.mjs";
3
+ import { resolveBundlePath } from "./lib/resolve-bundle.mjs";
4
+ import { listBundles } from "./lib/list-bundles.mjs";
5
+ import { buildIndex } from "./lib/build-index.mjs";
3
6
  import { runValidate } from "./lib/run-validate.mjs";
4
7
  import { runSync } from "./lib/run-sync.mjs";
5
8
  import { runInstall } from "./lib/run-install.mjs";
9
+ import { runUpdate } from "./lib/run-update.mjs";
10
+ import { runPrune } from "./lib/run-prune.mjs";
11
+ import { runUninstall } from "./lib/run-uninstall.mjs";
12
+ import { readLedger } from "./lib/ledger.mjs";
13
+ import { computeOutdated } from "./lib/outdated.mjs";
14
+ import { startServer, resolveServePort } from "./lib/serve.mjs";
15
+ import { registerHook, removeHook, SUPPORTED_SURFACES } from "./lib/hooks.mjs";
16
+ import { dirname, join, resolve } from "node:path";
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
18
+ import { fileURLToPath } from "node:url";
19
+ import { cwd as processCwd } from "node:process";
20
+ import { homedir } from "node:os";
21
+ import { Ajv } from "ajv";
22
+ import addFormatsModule from "ajv-formats";
23
+
24
+ const __dirname = dirname(fileURLToPath(import.meta.url));
25
+ const PACKAGE_ROOT = resolve(__dirname, "..");
26
+ const PACKAGE_JSON = JSON.parse(readFileSync(join(PACKAGE_ROOT, "package.json"), "utf8"));
27
+ const VERSION = PACKAGE_JSON.version ?? "unknown";
6
28
 
7
29
  const HELP = `enact-extensions — Enact multi-platform plugin manifests
30
+ Version: ${VERSION}
8
31
 
9
32
  Usage:
10
- enact-extensions validate [path] Validate manifests (default: cwd)
11
- enact-extensions sync [path] Sync host manifests from .agents/plugin.json (default: cwd)
12
- enact-extensions sync [path] --name <id> Create .agents/plugin.json then sync (new plugin)
13
- enact-extensions install [path] Sync and install plugin into Codex-compatible homes (default: cwd)
14
- enact-extensions install [path] --platform claude Install to Claude Code
15
- enact-extensions install [path] --platform cursor Install to Cursor
16
- enact-extensions install [path] --platform enact Install to Enact (Codex fork)
17
- enact-extensions install [path] --platform codex Install to Codex (explicit)
33
+ enact-extensions list [dir] List available plugin bundles (default: bundled + cwd/extensions/)
34
+ enact-extensions list [dir] --json Emit machine-readable JSON array
35
+ enact-extensions log Print the install ledger (single global file), newest first
36
+ enact-extensions log --json Emit the raw ledger array as JSON
37
+ enact-extensions outdated Report freshness drift: installed vs canonical source (per plugin+surface)
38
+ enact-extensions outdated --json Emit JSON array [{name, platform, scope, home, status, installedHash, currentHash, version}]
39
+ enact-extensions update <name> Refresh an outdated plugin on every surface it is installed on (ledger-driven)
40
+ enact-extensions update --all Refresh EVERY outdated plugin/surface
41
+ enact-extensions update <name> --dry-run Show what would be refreshed; change nothing
42
+ enact-extensions update --all --dry-run Show every outdated surface that would be refreshed
43
+ enact-extensions prune --platform all Remove ledger-installed plugin surfaces whose local source bundle is gone
44
+ enact-extensions prune --platform shared Remove orphaned shared skill drops (explicit only)
45
+ enact-extensions prune --dry-run Show orphaned surfaces that would be removed
46
+ enact-extensions index [--out <path>] Generate a discovery index of all bundles (generated artifact, never committed)
47
+ enact-extensions index --out - Print the discovery index JSON to stdout
48
+ enact-extensions index --stdout Alias for --out -
49
+ enact-extensions validate [path|name] Validate manifests (default: cwd)
50
+ enact-extensions sync [path|name] Sync host manifests from .agents/plugin.json (default: cwd)
51
+ enact-extensions sync [path|name] --name <id> Create .agents/plugin.json then sync (new plugin)
52
+ enact-extensions install [path|name] Sync and install plugin into Codex-compatible homes (default: cwd)
53
+ enact-extensions install [path|name] --platform claude Install to Claude Code
54
+ enact-extensions install [path|name] --platform cursor Install to Cursor
55
+ enact-extensions install [path|name] --platform enact Install to Enact (Codex fork)
56
+ enact-extensions install [path|name] --platform codex Install to Codex (explicit)
57
+ enact-extensions install [path|name] --platform shared Install skills to host-neutral .agents/skills/
58
+ enact-extensions install [path|name] --platform all Install to every plugin platform (codex, claude, cursor, enact)
59
+ enact-extensions install [path|name] --platform claude,cursor Install to a subset of platforms
60
+ enact-extensions install [path|name] --global Install into the default agent home (default)
61
+ enact-extensions install [path|name] --local Install into a project home under cwd (./.codex, ...)
62
+ enact-extensions uninstall [path|name] Uninstall plugin from Codex-compatible homes (default: enact)
63
+ enact-extensions uninstall [path|name] --platform claude Uninstall from Claude Code
64
+ enact-extensions uninstall [path|name] --platform cursor Uninstall from Cursor
65
+ enact-extensions uninstall [path|name] --platform enact Uninstall from Enact (Codex fork)
66
+ enact-extensions uninstall [path|name] --platform codex Uninstall from Codex (explicit)
67
+ enact-extensions uninstall [path|name] --platform shared Remove skills from host-neutral .agents/skills/
68
+ enact-extensions uninstall [path|name] --platform all Uninstall from every plugin platform
69
+ enact-extensions uninstall [path|name] --platform claude,cursor Uninstall from a subset of platforms
70
+ enact-extensions serve [--port N] [--prod] [--host 127.0.0.1] [--open] Start the localhost management UI + API (dev 43217 / prod 53217)
71
+ enact-extensions hooks [setup] [--surfaces <list>|--all] [--remove] [--local]
72
+ Register (or remove) the session-start drift-check hook
73
+ for each named surface (claude, codex, cursor, enact).
74
+
75
+ Hooks command:
76
+ enact-extensions hooks setup --surfaces claude,codex Register the drift hook for Claude and Codex
77
+ enact-extensions hooks setup --all Register for all surfaces (claude, codex, cursor, enact)
78
+ enact-extensions hooks setup --surfaces claude --remove Remove the drift hook from Claude
79
+ enact-extensions hooks setup --all --remove Remove the drift hook from all surfaces
80
+ enact-extensions hooks setup --surfaces claude --local Register using project-local home (under cwd)
81
+ enact-extensions hooks setup Interactive surface picker (TTY only)
82
+ enact-extensions -v | --version Print version and exit
18
83
 
19
84
  Options:
20
- path Plugin root (skills/, .agents/, etc.). Defaults to process.cwd().
21
- --platform <name> Target platform: codex (default), claude, cursor, enact
85
+ path|name Plugin root path, or a bare plugin name resolved from bundled extensions.
86
+ Defaults to process.cwd() when omitted.
87
+ --out <path> (index only) Output file path. Use - or --stdout to print to stdout.
88
+ Default: generated/index.json under the package root.
89
+ --stdout (index only) Alias for --out -.
90
+ --json (list only) Emit a JSON array to stdout instead of a human table.
91
+ --platform <name> Target platform: codex (default), claude, cursor, enact, shared.
92
+ Use "all" to install to every plugin platform, or a comma-separated list
93
+ (e.g. "claude,cursor") to install to a named subset.
94
+ --global Install into the agent's default home (default)
95
+ --local Install into a project-scoped home under the current dir
22
96
  --codex-home <path> Install only into the given Codex-compatible home
23
- --enact-home <path> Target a specific local Enact home (default: ~/.enact)
97
+ --enact-home <path> Target a specific local Enact home (default: ~/.enact/agent)
24
98
  --claude-home <path> Target a specific local Claude home (default: ~/.claude)
25
99
  --cursor-home <path> Target a specific local Cursor home (default: ~/.cursor)
100
+ --shared-home <path> Base dir for shared install (skills land at <path>/.agents/skills/)
26
101
  --marketplace <name> Marketplace name (default: enact-os-plugins)
27
102
  --no-enable Install files without enabling the Codex/Enact plugin
28
103
  --skip-sync Install current manifests without regenerating them
104
+ --no-provision Skip auto-provisioning the bundle's MCP-server packages.
105
+ By default, install resolves each declared MCP server
106
+ (.mcp.json) and provisions its package: uvx → uv tool
107
+ install, npx → npm install -g, pipx → pipx install,
108
+ pip/pip3 → pip install. Best-effort; never fails install.
109
+
110
+ Name resolution (bare plugin names):
111
+ When a bare name (no "/" in it) is given, it is resolved in this order:
112
+ 1. <this-package-root>/extensions/<name> (bundled extensions in this repo)
113
+ 2. <cwd>/extensions/<name> (extensions in a sibling product repo)
114
+ 3. <npm-global-root>/@amsterdamdatalabs/enact-extensions/extensions/<name>
115
+
116
+ Multi-platform notes:
117
+ - Platforms are installed sequentially in deterministic order: codex, claude, cursor, enact.
118
+ - Per-platform --<platform>-home flags apply to their respective platform in a multi-target run.
119
+ - If any platform fails, the others still proceed; a non-zero exit is returned and the summary
120
+ of succeeded/failed platforms is printed to stderr.
29
121
 
30
122
  Examples:
31
- cd ../enact-operator/extensions && enact-extensions validate
123
+ enact-extensions list
124
+ enact-extensions list --json
125
+ enact-extensions list /path/to/extensions
126
+ enact-extensions index Generate generated/index.json (gitignored, local discovery artifact)
127
+ enact-extensions index --out - Print discovery index JSON to stdout (pipe-friendly)
128
+ enact-extensions index --stdout Same as --out -
129
+ enact-extensions index --out /tmp/my-index.json
130
+ cd extensions/enact-factory && enact-extensions validate
32
131
  enact-extensions sync . --name my-plugin
33
- enact-extensions install ../enact-operator/extensions
34
- enact-extensions install ../enact-operator/extensions --platform claude
35
- enact-extensions install ../enact-operator/extensions --platform cursor
36
- enact-extensions install ../enact-operator/extensions --platform enact
37
- enact-extensions validate ../enact-operator/extensions
132
+ enact-extensions install net-revenue-management --platform enact --global
133
+ enact-extensions install net-revenue-management --platform enact --local
134
+ enact-extensions install extensions/net-revenue-management --platform enact --global
135
+ enact-extensions install enact-factory --platform claude
136
+ enact-extensions install enact-factory --platform cursor
137
+ enact-extensions install net-revenue-management --platform shared
138
+ enact-extensions install net-revenue-management --platform shared --local
139
+ enact-extensions install net-revenue-management --platform all
140
+ enact-extensions install net-revenue-management --platform claude,cursor
141
+ enact-extensions install net-revenue-management --platform all --enact-home /path/to/enact
142
+ enact-extensions validate extensions/plugin-dev
143
+ enact-extensions validate plugin-dev
38
144
  `;
39
145
 
40
146
  function parseArgs(argv) {
@@ -43,7 +149,11 @@ function parseArgs(argv) {
43
149
 
44
150
  for (let i = 0; i < argv.length; i++) {
45
151
  const arg = argv[i];
46
- if (arg === "--name" && argv[i + 1]) {
152
+ if (arg === "--out" && argv[i + 1]) {
153
+ options.out = argv[++i];
154
+ } else if (arg === "--stdout") {
155
+ options.out = "-";
156
+ } else if (arg === "--name" && argv[i + 1]) {
47
157
  options.name = argv[++i];
48
158
  } else if (arg === "--codex-home" && argv[i + 1]) {
49
159
  options.codexHome = argv[++i];
@@ -53,6 +163,8 @@ function parseArgs(argv) {
53
163
  options.enable = false;
54
164
  } else if (arg === "--skip-sync") {
55
165
  options.sync = false;
166
+ } else if (arg === "--no-provision") {
167
+ options.noProvision = true;
56
168
  } else if (arg === "--platform" && argv[i + 1]) {
57
169
  options.platform = argv[++i];
58
170
  } else if (arg === "--claude-home" && argv[i + 1]) {
@@ -61,6 +173,31 @@ function parseArgs(argv) {
61
173
  options.cursorHome = argv[++i];
62
174
  } else if (arg === "--enact-home" && argv[i + 1]) {
63
175
  options.enactHome = argv[++i];
176
+ } else if (arg === "--shared-home" && argv[i + 1]) {
177
+ options.sharedHome = argv[++i];
178
+ } else if (arg === "--local") {
179
+ options.scope = "local";
180
+ } else if (arg === "--global") {
181
+ options.scope = "global";
182
+ } else if (arg === "--all") {
183
+ options.all = true;
184
+ } else if (arg === "--dry-run") {
185
+ options.dryRun = true;
186
+ } else if (arg === "--json") {
187
+ options.json = true;
188
+ } else if (arg === "--port" && argv[i + 1]) {
189
+ options.port = parseInt(argv[++i], 10);
190
+ } else if (arg === "--host" && argv[i + 1]) {
191
+ options.host = argv[++i];
192
+ } else if (arg === "--open") {
193
+ options.open = true;
194
+ } else if (arg === "--prod") {
195
+ options.prod = true;
196
+ } else if (arg === "--surfaces" && argv[i + 1]) {
197
+ // Comma-separated list of surfaces: claude,codex,cursor,enact
198
+ options.surfaces = argv[++i].split(",").map((s) => s.trim()).filter(Boolean);
199
+ } else if (arg === "--remove") {
200
+ options.remove = true;
64
201
  } else if (arg === "-h" || arg === "--help") {
65
202
  positional.push("help");
66
203
  } else if (!arg.startsWith("-")) {
@@ -71,14 +208,633 @@ function parseArgs(argv) {
71
208
  return { command: positional[0], path: positional[1], options };
72
209
  }
73
210
 
74
- const { command, path, options } = parseArgs(process.argv.slice(2));
211
+ const rawArgv = process.argv.slice(2);
212
+ if (rawArgv.length === 1 && (rawArgv[0] === "-v" || rawArgv[0] === "--version")) {
213
+ console.log(`enact-extensions ${VERSION}`);
214
+ process.exit(0);
215
+ }
216
+
217
+ const { command, path, options } = parseArgs(rawArgv);
75
218
 
76
219
  if (!command || command === "help") {
77
220
  console.log(HELP);
78
221
  process.exit(command ? 0 : 1);
79
222
  }
80
223
 
81
- const pluginRoot = resolvePluginRoot(path);
224
+ // ---------------------------------------------------------------------------
225
+ // `hooks` command — register or remove the session-start drift-check hook.
226
+ //
227
+ // Surfaces: claude, codex, cursor, enact
228
+ // Registration is idempotent and reversible.
229
+ // ---------------------------------------------------------------------------
230
+ if (command === "hooks") {
231
+ // Sub-command: `hooks setup` or just `hooks` (treat bare `hooks` as `hooks setup`).
232
+ // path is positional[1] — could be "setup" or undefined.
233
+ const subCommand = path ?? "setup";
234
+
235
+ if (subCommand !== "setup") {
236
+ process.stderr.write(`[enact-extensions hooks] Unknown sub-command: ${subCommand}. Did you mean 'setup'?\n`);
237
+ process.exit(1);
238
+ }
239
+
240
+ const isRemove = options.remove ?? false;
241
+ const isLocal = options.scope === "local";
242
+ const cwd = processCwd();
243
+
244
+ // Determine which surfaces to act on.
245
+ let surfaces = [];
246
+ if (options.all) {
247
+ surfaces = [...SUPPORTED_SURFACES];
248
+ } else if (options.surfaces && options.surfaces.length > 0) {
249
+ // Validate provided surface names.
250
+ const invalid = options.surfaces.filter((s) => !SUPPORTED_SURFACES.includes(s));
251
+ if (invalid.length > 0) {
252
+ process.stderr.write(`[enact-extensions hooks] Unknown surface(s): ${invalid.join(", ")}. Valid: ${SUPPORTED_SURFACES.join(", ")}\n`);
253
+ process.exit(1);
254
+ }
255
+ surfaces = options.surfaces;
256
+ } else {
257
+ // No surfaces specified — check if TTY for interactive picker.
258
+ if (process.stdin.isTTY) {
259
+ // Interactive picker via node:readline.
260
+ const { createInterface } = await import("node:readline");
261
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
262
+
263
+ const question = (prompt) => new Promise((resolve) => rl.question(prompt, resolve));
264
+
265
+ process.stdout.write(`\nenact-extensions hooks setup — interactive surface picker\n`);
266
+ process.stdout.write(`Available surfaces: ${SUPPORTED_SURFACES.map((s, i) => `${i + 1}. ${s}`).join(", ")}\n`);
267
+ process.stdout.write(`Enter surface names or numbers (comma-separated), or 'all':\n`);
268
+
269
+ const answer = await question("> ");
270
+ rl.close();
271
+
272
+ if (answer.trim().toLowerCase() === "all") {
273
+ surfaces = [...SUPPORTED_SURFACES];
274
+ } else {
275
+ surfaces = answer
276
+ .split(",")
277
+ .map((s) => s.trim())
278
+ .filter(Boolean)
279
+ .map((s) => {
280
+ // Allow numeric selection.
281
+ const idx = parseInt(s, 10);
282
+ if (!isNaN(idx) && idx >= 1 && idx <= SUPPORTED_SURFACES.length) {
283
+ return SUPPORTED_SURFACES[idx - 1];
284
+ }
285
+ return s.toLowerCase();
286
+ })
287
+ .filter((s) => SUPPORTED_SURFACES.includes(s));
288
+
289
+ if (surfaces.length === 0) {
290
+ process.stderr.write(`[enact-extensions hooks] No valid surfaces selected. Exiting.\n`);
291
+ process.exit(0);
292
+ }
293
+ }
294
+ } else {
295
+ // Non-TTY, no surface flags → print notice and exit 0.
296
+ process.stdout.write(
297
+ `[enact-extensions hooks] No surface specified. Run with --surfaces or --all:\n` +
298
+ ` enact-extensions hooks setup --surfaces claude,codex\n` +
299
+ ` enact-extensions hooks setup --all\n`,
300
+ );
301
+ process.exit(0);
302
+ }
303
+ }
304
+
305
+ // Execute registration or removal for each surface.
306
+ const hookOpts = {
307
+ claudeHome: options.claudeHome,
308
+ codexHome: options.codexHome,
309
+ cursorHome: options.cursorHome,
310
+ enactHome: options.enactHome,
311
+ local: isLocal,
312
+ cwd,
313
+ };
314
+
315
+ for (const surface of surfaces) {
316
+ let res;
317
+ if (isRemove) {
318
+ res = removeHook(surface, hookOpts);
319
+ } else {
320
+ res = registerHook(surface, hookOpts);
321
+ }
322
+
323
+ // Print per-surface result.
324
+ const status = res.result;
325
+ const location = res.location ? ` → ${res.location}` : "";
326
+ const note = res.note ? ` (${res.note})` : "";
327
+
328
+ if (status === "registered") {
329
+ process.stdout.write(` [hooks] ${surface}: registered${location}\n`);
330
+ } else if (status === "already_registered") {
331
+ process.stdout.write(` [hooks] ${surface}: already registered (skipped)${location}\n`);
332
+ } else if (status === "removed") {
333
+ process.stdout.write(` [hooks] ${surface}: removed${location}\n`);
334
+ } else if (status === "not_found") {
335
+ process.stdout.write(` [hooks] ${surface}: not found (nothing to remove)${location}\n`);
336
+ } else {
337
+ process.stdout.write(` [hooks] ${surface}: skipped${note}\n`);
338
+ }
339
+
340
+ if (res.note && status !== "skipped") {
341
+ process.stderr.write(` [hooks] ${surface} note: ${res.note}\n`);
342
+ }
343
+ }
344
+
345
+ process.exit(0);
346
+ }
347
+
348
+ // ---------------------------------------------------------------------------
349
+ // `list` command — enumerate available plugin bundles.
350
+ // ---------------------------------------------------------------------------
351
+ if (command === "list") {
352
+ // The package's own extensions/ dir, resolved relative to this script.
353
+ const PACKAGE_ROOT = resolve(__dirname, "..");
354
+ const packageExtensions = join(PACKAGE_ROOT, "extensions");
355
+
356
+ let roots;
357
+ if (path) {
358
+ // Explicit dir argument → scan only that dir.
359
+ roots = [resolve(processCwd(), path)];
360
+ } else {
361
+ // Default: package-bundled extensions/ + cwd/extensions/ (if it differs).
362
+ roots = [packageExtensions];
363
+ const cwdExtensions = join(processCwd(), "extensions");
364
+ if (resolve(cwdExtensions) !== resolve(packageExtensions) && existsSync(cwdExtensions)) {
365
+ roots.push(cwdExtensions);
366
+ }
367
+ }
368
+
369
+ const entries = listBundles(roots);
370
+
371
+ if (options.json) {
372
+ console.log(JSON.stringify(entries, null, 2));
373
+ process.exit(0);
374
+ }
375
+
376
+ // Human-readable table.
377
+ const TRUNC = 60;
378
+ function trunc(str, len) {
379
+ if (!str) return "";
380
+ return str.length > len ? str.slice(0, len - 1) + "…" : str;
381
+ }
382
+
383
+ if (entries.length === 0) {
384
+ console.log("No plugin bundles found.");
385
+ process.exit(0);
386
+ }
387
+
388
+ // Header.
389
+ const COL_NAME = 28;
390
+ const COL_VER = 8;
391
+ const COL_CAT = 18;
392
+ const COL_SURF = 22;
393
+
394
+ function padR(str, n) { return String(str ?? "").padEnd(n).slice(0, n); }
395
+
396
+ const hr = "─".repeat(COL_NAME + COL_VER + COL_CAT + COL_SURF + 3 + TRUNC);
397
+ console.log(hr);
398
+ console.log(
399
+ padR("Name", COL_NAME) + " " +
400
+ padR("Ver", COL_VER) + " " +
401
+ padR("Category", COL_CAT) + " " +
402
+ padR("Surfaces", COL_SURF) + " " +
403
+ "Description"
404
+ );
405
+ console.log(hr);
406
+
407
+ for (const e of entries) {
408
+ const surfaces = e.targets.join(", ");
409
+ console.log(
410
+ padR(e.name, COL_NAME) + " " +
411
+ padR(e.version, COL_VER) + " " +
412
+ padR(e.category, COL_CAT) + " " +
413
+ padR(surfaces, COL_SURF) + " " +
414
+ trunc(e.description, TRUNC)
415
+ );
416
+ }
417
+ console.log(hr);
418
+ console.log(`${entries.length} bundle${entries.length === 1 ? "" : "s"} found.`);
419
+ process.exit(0);
420
+ }
421
+
422
+ // ---------------------------------------------------------------------------
423
+ // `index` command — generate a discovery index of all plugin bundles.
424
+ //
425
+ // The index is a LOCAL GENERATED ARTIFACT (never committed). The generated/
426
+ // directory is gitignored. The schema at spec/index.json is the committed
427
+ // contract. No network, no marketplace, no catalog/ — purely local.
428
+ // ---------------------------------------------------------------------------
429
+ if (command === "index") {
430
+ const PACKAGE_ROOT = resolve(__dirname, "..");
431
+ const packageExtensions = join(PACKAGE_ROOT, "extensions");
432
+
433
+ // Same default roots as `list`.
434
+ const roots = [packageExtensions];
435
+ const cwdExtensions = join(processCwd(), "extensions");
436
+ if (resolve(cwdExtensions) !== resolve(packageExtensions) && existsSync(cwdExtensions)) {
437
+ roots.push(cwdExtensions);
438
+ }
439
+
440
+ // Build the index. The wall-clock timestamp is computed here at the CLI
441
+ // boundary and passed in — buildIndex itself stays pure (never calls Date).
442
+ let index;
443
+ try {
444
+ index = buildIndex(roots, { now: new Date().toISOString(), packageRoot: PACKAGE_ROOT });
445
+ } catch (err) {
446
+ console.error(`[enact-extensions index] Failed to build index: ${err instanceof Error ? err.message : String(err)}`);
447
+ process.exit(1);
448
+ }
449
+
450
+ // Validate against spec/index.json before writing.
451
+ const schemaPath = join(PACKAGE_ROOT, "spec", "index.json");
452
+ let schema;
453
+ try {
454
+ schema = JSON.parse(readFileSync(schemaPath, "utf8"));
455
+ } catch (err) {
456
+ console.error(`[enact-extensions index] Cannot read schema ${schemaPath}: ${err instanceof Error ? err.message : String(err)}`);
457
+ process.exit(1);
458
+ }
459
+
460
+ const addFormats = addFormatsModule.default ?? addFormatsModule;
461
+ const ajv = new Ajv({ allErrors: true, strict: false });
462
+ addFormats(ajv);
463
+ const validate = ajv.compile(schema);
464
+ const valid = validate(index);
465
+ if (!valid) {
466
+ const errs = (validate.errors ?? []).map((e) => ` ${e.instancePath || "/"}: ${e.message}`).join("\n");
467
+ console.error(`[enact-extensions index] Generated index failed schema validation:\n${errs}`);
468
+ process.exit(1);
469
+ }
470
+
471
+ const json = JSON.stringify(index, null, 2);
472
+ // --stdout is normalized to "-" during arg parsing, so this single check covers both.
473
+ const toStdout = options.out === "-";
474
+
475
+ if (toStdout) {
476
+ // Write JSON to stdout; summary to stderr (keeps stdout pipe-clean).
477
+ process.stdout.write(json + "\n");
478
+ process.stderr.write(`[enact-extensions index] ${index.count} plugin${index.count === 1 ? "" : "s"} indexed.\n`);
479
+ } else {
480
+ const outPath = options.out
481
+ ? resolve(processCwd(), options.out)
482
+ : join(PACKAGE_ROOT, "generated", "index.json");
483
+
484
+ // Ensure parent directory exists.
485
+ const outDir = resolve(outPath, "..");
486
+ mkdirSync(outDir, { recursive: true });
487
+
488
+ writeFileSync(outPath, json + "\n", "utf8");
489
+ process.stderr.write(`[enact-extensions index] Wrote ${index.count} plugin${index.count === 1 ? "" : "s"} to ${outPath}\n`);
490
+ }
491
+
492
+ process.exit(0);
493
+ }
494
+
495
+ // ---------------------------------------------------------------------------
496
+ // `log` command — print the install ledger (single global file), newest first.
497
+ //
498
+ // Human table to stdout (chrome to stderr) or `--json` (raw ledger array).
499
+ // Reading a missing ledger yields an empty list — never an error.
500
+ // ---------------------------------------------------------------------------
501
+ if (command === "log") {
502
+ const entries = readLedger();
503
+ // Most-recent-first.
504
+ const sorted = [...entries].sort((a, b) =>
505
+ String(b.ts ?? "").localeCompare(String(a.ts ?? "")),
506
+ );
507
+
508
+ if (options.json) {
509
+ process.stdout.write(JSON.stringify(sorted, null, 2) + "\n");
510
+ process.exit(0);
511
+ }
512
+
513
+ if (sorted.length === 0) {
514
+ process.stderr.write("No install ledger entries found.\n");
515
+ process.exit(0);
516
+ }
517
+
518
+ const COL_TS = 24;
519
+ const COL_ACT = 10;
520
+ const COL_NAME = 28;
521
+ const COL_PLAT = 8;
522
+ const COL_SCOPE = 7;
523
+ function padR(str, n) { return String(str ?? "").padEnd(n).slice(0, n); }
524
+
525
+ const hr = "─".repeat(COL_TS + COL_ACT + COL_NAME + COL_PLAT + COL_SCOPE + 4 + 40);
526
+ console.log(hr);
527
+ console.log(
528
+ padR("Timestamp", COL_TS) + " " +
529
+ padR("Action", COL_ACT) + " " +
530
+ padR("Name", COL_NAME) + " " +
531
+ padR("Platform", COL_PLAT) + " " +
532
+ padR("Scope", COL_SCOPE) + " " +
533
+ "Home",
534
+ );
535
+ console.log(hr);
536
+ for (const e of sorted) {
537
+ console.log(
538
+ padR(e.ts, COL_TS) + " " +
539
+ padR(e.action, COL_ACT) + " " +
540
+ padR(e.name, COL_NAME) + " " +
541
+ padR(e.platform, COL_PLAT) + " " +
542
+ padR(e.scope, COL_SCOPE) + " " +
543
+ String(e.home ?? ""),
544
+ );
545
+ }
546
+ console.log(hr);
547
+ process.stderr.write(`${sorted.length} ledger entr${sorted.length === 1 ? "y" : "ies"}.\n`);
548
+ process.exit(0);
549
+ }
550
+
551
+ // ---------------------------------------------------------------------------
552
+ // `outdated` command — report drift between installed plugins and canonical source.
553
+ //
554
+ // Classifies each installed (plugin, platform) surface as:
555
+ // fresh → installed hash matches canonical source hash
556
+ // outdated → hash mismatch (or recorded hash missing), needs re-install
557
+ // orphaned → canonical source does not exist (can't refresh)
558
+ //
559
+ // Exit code: always 0 (it's a report, not a failure gate).
560
+ // Human chrome → stderr; --json stdout is always pure JSON.
561
+ // ---------------------------------------------------------------------------
562
+ if (command === "outdated") {
563
+ let entries;
564
+ try {
565
+ entries = computeOutdated({ cwd: processCwd() });
566
+ } catch (err) {
567
+ process.stderr.write(
568
+ `[enact-extensions outdated] Error: ${err instanceof Error ? err.message : String(err)}\n`,
569
+ );
570
+ process.exit(1);
571
+ }
572
+
573
+ if (options.json) {
574
+ process.stdout.write(JSON.stringify(entries, null, 2) + "\n");
575
+ process.exit(0);
576
+ }
577
+
578
+ // Human-readable table.
579
+ if (entries.length === 0) {
580
+ process.stderr.write("No installed plugins found in the ledger.\n");
581
+ process.exit(0);
582
+ }
583
+
584
+ const COL_NAME = 30;
585
+ const COL_PLAT = 10;
586
+ const COL_SCOPE = 8;
587
+ const COL_VER = 10;
588
+ const COL_STAT = 10;
589
+
590
+ function padR(str, n) { return String(str ?? "").padEnd(n).slice(0, n); }
591
+
592
+ const hr = "─".repeat(COL_NAME + COL_PLAT + COL_SCOPE + COL_VER + COL_STAT + 4 + 8);
593
+ console.log(hr);
594
+ console.log(
595
+ padR("Plugin", COL_NAME) + " " +
596
+ padR("Platform", COL_PLAT) + " " +
597
+ padR("Scope", COL_SCOPE) + " " +
598
+ padR("Version", COL_VER) + " " +
599
+ padR("Status", COL_STAT),
600
+ );
601
+ console.log(hr);
602
+
603
+ for (const e of entries) {
604
+ console.log(
605
+ padR(e.name, COL_NAME) + " " +
606
+ padR(e.platform, COL_PLAT) + " " +
607
+ padR(e.scope, COL_SCOPE) + " " +
608
+ padR(e.version, COL_VER) + " " +
609
+ padR(e.status, COL_STAT),
610
+ );
611
+ }
612
+ console.log(hr);
613
+ process.stderr.write(`${entries.length} surface${entries.length === 1 ? "" : "s"} checked.\n`);
614
+ process.exit(0);
615
+ }
616
+
617
+ // ---------------------------------------------------------------------------
618
+ // `update` command — refresh outdated installed plugins, driven by the ledger.
619
+ //
620
+ // Re-installs each OUTDATED (plugin, surface, home) to the EXACT surface + home
621
+ // recorded in the ledger — never to a surface the plugin isn't already on.
622
+ //
623
+ // update <name> → refresh only that plugin (across its installed surfaces)
624
+ // update --all → refresh every outdated surface
625
+ // update --dry-run→ report what WOULD change; touch nothing
626
+ //
627
+ // Exit code: non-zero ONLY on a real install failure or a missing target (no
628
+ // name + no --all). Orphaned and fresh surfaces are never failures.
629
+ // Human chrome → stderr; the ledger self-updates via runInstall.
630
+ // ---------------------------------------------------------------------------
631
+ if (command === "update") {
632
+ let summary;
633
+ try {
634
+ summary = runUpdate({
635
+ name: path, // positional[1]: a bare plugin name (or undefined)
636
+ all: options.all,
637
+ dryRun: options.dryRun,
638
+ home: homedir(), // single global ledger home
639
+ cwd: processCwd(), // canonical bundle resolution
640
+ });
641
+ } catch (err) {
642
+ process.stderr.write(
643
+ `[enact-extensions update] ${err instanceof Error ? err.message : String(err)}\n`,
644
+ );
645
+ process.exit(1);
646
+ }
647
+
648
+ const verb = summary.dryRun ? "would update" : "updated";
649
+
650
+ if (summary.dryRun) {
651
+ if (summary.planned.length === 0) {
652
+ process.stderr.write("Nothing to update — no outdated surfaces in scope.\n");
653
+ }
654
+ for (const e of summary.planned) {
655
+ const from = e.installedHash ? String(e.installedHash).slice(0, 12) : "(none)";
656
+ const to = e.currentHash ? String(e.currentHash).slice(0, 12) : "(unknown)";
657
+ console.log(`${verb}: ${e.name} [${e.platform}] @ ${e.home} ${from} -> ${to}`);
658
+ }
659
+ } else {
660
+ for (const e of summary.updated) {
661
+ console.log(`updated: ${e.name} [${e.platform}] @ ${e.home}`);
662
+ }
663
+ }
664
+
665
+ for (const e of summary.skipped) {
666
+ process.stderr.write(
667
+ `skipped-orphaned: ${e.name} [${e.platform}] @ ${e.home} (canonical source gone)\n`,
668
+ );
669
+ }
670
+ for (const f of summary.failed) {
671
+ const e = f.entry;
672
+ process.stderr.write(
673
+ `failed: ${e.name} [${e.platform}] @ ${e.home}: ${f.error.message}\n`,
674
+ );
675
+ }
676
+
677
+ const doneCount = summary.dryRun ? summary.planned.length : summary.updated.length;
678
+ process.stderr.write(
679
+ `${doneCount} ${summary.dryRun ? "would be updated" : "updated"}, ` +
680
+ `${summary.skipped.length} skipped (orphaned), ${summary.failed.length} failed.\n`,
681
+ );
682
+
683
+ // Non-zero exit ONLY on a real install failure.
684
+ process.exit(summary.failed.length > 0 ? 1 : 0);
685
+ }
686
+
687
+ // ---------------------------------------------------------------------------
688
+ // `prune` command — remove orphaned installed surfaces, driven by the ledger.
689
+ //
690
+ // A surface is pruned only when:
691
+ // - the ledger still says it is installed,
692
+ // - it belongs to the requested marketplace,
693
+ // - its platform is in scope, and
694
+ // - no local source bundle exists for that plugin name.
695
+ // ---------------------------------------------------------------------------
696
+ if (command === "prune") {
697
+ let summary;
698
+ try {
699
+ summary = runPrune({
700
+ platform: options.platform ?? "all",
701
+ dryRun: options.dryRun,
702
+ ledgerHome: homedir(),
703
+ cwd: processCwd(),
704
+ marketplaceName: options.marketplaceName,
705
+ });
706
+ } catch (err) {
707
+ process.stderr.write(
708
+ `[enact-extensions prune] ${err instanceof Error ? err.message : String(err)}\n`,
709
+ );
710
+ process.exit(1);
711
+ }
712
+
713
+ if (options.json) {
714
+ process.stdout.write(JSON.stringify(summary, null, 2) + "\n");
715
+ process.exit(summary.failed.length > 0 ? 1 : 0);
716
+ }
717
+
718
+ const rows = summary.dryRun ? summary.candidates : summary.pruned;
719
+ const verb = summary.dryRun ? "would prune" : "pruned";
720
+ if (rows.length === 0) {
721
+ process.stderr.write("Nothing to prune — no orphaned installed surfaces in scope.\n");
722
+ }
723
+ for (const entry of rows) {
724
+ console.log(`${verb}: ${entry.name} [${entry.platform}] @ ${entry.home}`);
725
+ }
726
+ for (const f of summary.failed) {
727
+ process.stderr.write(
728
+ `failed: ${f.entry.name} [${f.entry.platform}] @ ${f.entry.home}: ${f.error.message}\n`,
729
+ );
730
+ }
731
+ process.stderr.write(
732
+ `${rows.length} ${summary.dryRun ? "would be pruned" : "pruned"}, ${summary.failed.length} failed.\n`,
733
+ );
734
+ process.exit(summary.failed.length > 0 ? 1 : 0);
735
+ }
736
+
737
+ // ---------------------------------------------------------------------------
738
+ // `serve` command — localhost API + static-file server (no pluginRoot needed).
739
+ // Handled here (before resolveRoot) because it is async + long-running.
740
+ // ---------------------------------------------------------------------------
741
+ if (command === "serve") {
742
+ const PACKAGE_ROOT = resolve(__dirname, "..");
743
+ const port = resolveServePort(options);
744
+ const host = options.host ?? "127.0.0.1";
745
+
746
+ if (host !== "127.0.0.1" && host !== "localhost" && host !== "::1") {
747
+ process.stderr.write(
748
+ `[enact-extensions serve] WARNING: binding to ${host} exposes the API to other machines on the network.\n`,
749
+ );
750
+ }
751
+
752
+ // Use async IIFE. The http.Server keeps the event loop alive after this IIFE resolves.
753
+ (async () => {
754
+ let serverInstance;
755
+ let url;
756
+ try {
757
+ const started = await startServer({
758
+ port,
759
+ host,
760
+ packageRoot: PACKAGE_ROOT,
761
+ installDefaults: { ledgerHome: homedir() },
762
+ });
763
+ serverInstance = started.server;
764
+ url = started.url;
765
+ } catch (err) {
766
+ process.stderr.write(`[enact-extensions serve] Failed to start server: ${err instanceof Error ? err.message : String(err)}\n`);
767
+ process.exit(1);
768
+ }
769
+
770
+ console.log(`enact-extensions serve: listening at ${url}`);
771
+
772
+ if (options.open) {
773
+ // Best-effort browser open; ignore all errors silently.
774
+ const { spawn } = await import("node:child_process");
775
+ const opener =
776
+ process.platform === "darwin"
777
+ ? "open"
778
+ : process.platform === "win32"
779
+ ? "start"
780
+ : "xdg-open";
781
+ try {
782
+ spawn(opener, [url], { detached: true, stdio: "ignore" }).unref();
783
+ } catch {
784
+ // xdg-open / open not available in all environments — ignore
785
+ }
786
+ }
787
+
788
+ // SIGINT / SIGTERM → graceful shutdown
789
+ const shutdown = () => serverInstance.close(() => process.exit(0));
790
+ process.on("SIGINT", shutdown);
791
+ process.on("SIGTERM", shutdown);
792
+ })();
793
+
794
+ // Do NOT fall through to resolveRoot / the plugin-root command block.
795
+ // process.exit is intentionally NOT called — the http.Server ref keeps Node alive.
796
+ // Use a throw inside a never-reached block OR just let the module end here.
797
+ // The trick: throw a synthetic signal so the try/catch-less module scope terminates.
798
+ // Actually: we use process.exitCode = 0 and allow the event loop to keep running.
799
+ process.exitCode = 0; // signal intent; overridden to 1 on error inside IIFE
800
+ }
801
+
802
+ // ---------------------------------------------------------------------------
803
+ // Commands that require resolving a plugin root path.
804
+ // (Only run when command !== "serve" — serve handled above and must not fall through.)
805
+ // ---------------------------------------------------------------------------
806
+ if (command !== "serve") {
807
+
808
+ // Resolve the plugin root:
809
+ // - If no path arg given → default to cwd (existing behaviour).
810
+ // - If a path arg is given → resolveBundlePath handles both explicit paths and
811
+ // bare plugin names, throwing meaningful errors when nothing resolves.
812
+ const resolveRoot = (pathArg) => {
813
+ if (!pathArg) return resolvePluginRoot(undefined);
814
+ return resolveBundlePath(pathArg);
815
+ };
816
+
817
+ // A bare name has no path separators (so it is not an explicit filesystem path).
818
+ const isBareName = (arg) =>
819
+ typeof arg === "string" && arg.length > 0 && !arg.includes("/") && !arg.includes("\\");
820
+
821
+ let pluginRoot = null;
822
+ try {
823
+ pluginRoot = resolveRoot(path);
824
+ } catch (err) {
825
+ // UNINSTALL-ONLY FALLBACK: uninstall must work even when the source bundle is
826
+ // gone. If the arg is a BARE NAME (not an explicit path) that did not resolve
827
+ // to a bundle, fall back to using the arg verbatim as the plugin name. The
828
+ // uninstall handler reads the name from `path` when pluginRoot is null.
829
+ // For an explicit path that does not exist, or for any other command, this is
830
+ // still a hard error.
831
+ if (command === "uninstall" && isBareName(path)) {
832
+ pluginRoot = null; // signal: use the raw `path` as the plugin name
833
+ } else {
834
+ console.error(err instanceof Error ? err.message : String(err));
835
+ process.exit(1);
836
+ }
837
+ }
82
838
 
83
839
  try {
84
840
  if (command === "validate") {
@@ -92,7 +848,51 @@ try {
92
848
  }
93
849
 
94
850
  if (command === "install") {
95
- runInstall(pluginRoot, options);
851
+ // Single global ledger: every install (local or global scope) records to
852
+ // <homedir>/.enact/extensions/ledger.jsonl so `log` always finds it,
853
+ // regardless of which per-platform home the bundle was installed to. The
854
+ // local/global distinction is carried in each entry's `scope` field.
855
+ runInstall(pluginRoot, { ...options, ledgerHome: homedir() });
856
+ process.exit(0);
857
+ }
858
+
859
+ if (command === "uninstall") {
860
+ // Resolve plugin name: if the source bundle resolved on disk, read its
861
+ // manifest name from .agents/plugin.json (or .codex-plugin/plugin.json).
862
+ // Otherwise (source bundle gone / bare-name fallback), treat the raw
863
+ // positional arg as the plugin name. This lets uninstall remove already-
864
+ // installed plugins even when their source bundle has been deleted.
865
+ let pluginName = null;
866
+ if (pluginRoot) {
867
+ try {
868
+ const enactManifestPath = join(pluginRoot, ".agents", "plugin.json");
869
+ if (existsSync(enactManifestPath)) {
870
+ const manifest = JSON.parse(readFileSync(enactManifestPath, "utf8"));
871
+ pluginName = typeof manifest.name === "string" ? manifest.name : null;
872
+ }
873
+ // Fall back to .codex-plugin/plugin.json
874
+ if (!pluginName) {
875
+ const codexManifestPath = join(pluginRoot, ".codex-plugin", "plugin.json");
876
+ if (existsSync(codexManifestPath)) {
877
+ const manifest = JSON.parse(readFileSync(codexManifestPath, "utf8"));
878
+ pluginName = typeof manifest.name === "string" ? manifest.name : null;
879
+ }
880
+ }
881
+ } catch {
882
+ // Source bundle unreadable — fall through to raw name.
883
+ }
884
+ }
885
+ // Fall back: treat the raw positional arg as the plugin name.
886
+ // `path` is the raw positional from the CLI. When the source bundle was gone
887
+ // (pluginRoot === null) this is the only source of the name.
888
+ if (!pluginName) {
889
+ pluginName = path ?? (pluginRoot ? pluginRoot.split("/").pop() : null);
890
+ }
891
+ if (!pluginName) {
892
+ console.error("uninstall requires a plugin name or path.");
893
+ process.exit(1);
894
+ }
895
+ runUninstall(pluginName, { ...options, ledgerHome: homedir() });
96
896
  process.exit(0);
97
897
  }
98
898
 
@@ -103,3 +903,5 @@ try {
103
903
  console.error(err instanceof Error ? err.message : String(err));
104
904
  process.exit(1);
105
905
  }
906
+
907
+ } // end if (command !== "serve")