@codyswann/lisa 4.101.5 → 4.101.6

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 (85) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  3. package/dist/core/upstream-evidence-manifest.js +12 -1
  4. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  5. package/package.json +4 -4
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/scripts/automation-run-record.mjs +678 -0
  9. package/plugins/lisa/.codex-plugin/scripts/blocker-edge-resolution.mjs +150 -0
  10. package/plugins/lisa/.codex-plugin/scripts/intake-blocker-reprobe.mjs +1379 -0
  11. package/plugins/lisa/.codex-plugin/scripts/intake-prework-denominator.mjs +249 -0
  12. package/plugins/lisa/.codex-plugin/scripts/operator-id-kinds.mjs +120 -0
  13. package/plugins/lisa/.codex-plugin/scripts/qa-signal-lifecycle.mjs +523 -0
  14. package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +549 -0
  15. package/plugins/lisa/.codex-plugin/scripts/resolve-lifecycle-role.mjs +347 -0
  16. package/plugins/lisa-agy/plugin.json +1 -1
  17. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  19. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  20. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  24. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  28. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  30. package/plugins/lisa-expo-agy/plugin.json +1 -1
  31. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  35. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  42. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  45. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  49. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  51. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  52. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  56. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  59. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  63. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  65. package/plugins/lisa-rails-agy/plugin.json +1 -1
  66. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  70. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  72. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  73. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  77. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  79. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  80. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  84. package/scripts/generate-codex-plugin-artifacts.mjs +6 -0
  85. package/scripts/lib/codex-shared-scripts.mjs +156 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-openclaw",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Connect staff roles to Telegram or Slack via OpenClaw — facilitator/specialist hub-and-spoke routing and repo-coding topics, for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific skills and hooks for RuboCop and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks for formatting, linting, and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "Distributable LLM Wiki kernel — ingest, query, lint, and maintain a git-native markdown knowledge base across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "4.101.5",
3
+ "version": "4.101.6",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -38,8 +38,11 @@ import fs from "node:fs";
38
38
  import path from "node:path";
39
39
  import { fileURLToPath } from "node:url";
40
40
 
41
+ import { emitCodexSharedScripts } from "./lib/codex-shared-scripts.mjs";
41
42
  import { invokedAsScript } from "./lib/invoked-as-script.mjs";
42
43
 
44
+ export { emitCodexSharedScripts };
45
+
43
46
  // Literals named once — each was repeated enough times that a typo in one
44
47
  // copy would diverge silently.
45
48
  const CODEX_PLUGIN_DIR = ".codex-plugin";
@@ -787,6 +790,9 @@ function main() {
787
790
  emitCodexHooks(pluginDir, claudeManifest);
788
791
  emitCodexSkillVariants(pluginDir);
789
792
  emitCommandSkills(pluginDir);
793
+ // After every skill is in `.codex-plugin/skills/`: their `../../../scripts/`
794
+ // imports land on `.codex-plugin/scripts/`, which only this step writes.
795
+ emitCodexSharedScripts(pluginDir);
790
796
  writeCodexManifest(pluginDir, claudeManifest, pluginName, versionArg);
791
797
  writeSkillAgents(pluginDir);
792
798
  }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Emit the shared plugin scripts that Codex skill scripts import
3
+ * (CodySwannGT/lisa#4730).
4
+ *
5
+ * Codex loads a plugin's skills from `.codex-plugin/skills/`, a copy of the
6
+ * plugin's authored `skills/`. Skill scripts reach shared modules with
7
+ * `../../../scripts/<m>.mjs`, which from the authored tree lands on the
8
+ * plugin's own `scripts/` but from the Codex copy lands on
9
+ * `.codex-plugin/scripts/`. This module follows every relative import of every
10
+ * emitted skill module, transitively, and copies each target that falls
11
+ * outside `.codex-plugin/skills/` from `<plugin>/<rel>` to
12
+ * `<plugin>/.codex-plugin/<rel>` — the place the unchanged specifier resolves.
13
+ * Specifiers are never rewritten, so the Claude tree and the Codex tree run
14
+ * byte-identical skill scripts.
15
+ *
16
+ * The specifier parse mirrors `src/opencode/relative-imports.ts` (a `.mjs`
17
+ * build script cannot import TypeScript); the guard test uses that TypeScript
18
+ * checker as an independent oracle over what this module emits.
19
+ * @module scripts/lib/codex-shared-scripts
20
+ */
21
+ import fs from "node:fs";
22
+ import path from "node:path";
23
+
24
+ const CODEX_PLUGIN_DIR = ".codex-plugin";
25
+ const SCRIPT_MODULE_EXTENSIONS = new Set([".mjs", ".js", ".cjs"]);
26
+ const RELATIVE_SPECIFIER_PATTERN =
27
+ /\b(?:from|import\(?|require\()\s*(["'])(\.\.?\/[^"'\n]*)\1/g;
28
+ const LINE_OPENING_BLOCK_COMMENT = /^[ \t]*\/\*[\s\S]*?\*\//gm;
29
+ const LINE_OPENING_LINE_COMMENT = /^[ \t]*\/\/.*$/gm;
30
+
31
+ /**
32
+ * Extract every static relative specifier from module source text. Exported
33
+ * so a parity test can hold it equal to the TypeScript checker's parse.
34
+ * @param {string} source JavaScript module source.
35
+ * @returns {string[]} Unique relative specifiers in first-seen order.
36
+ */
37
+ export function extractRelativeSpecifiers(source) {
38
+ const stripped = source
39
+ .replace(LINE_OPENING_BLOCK_COMMENT, "")
40
+ .replace(LINE_OPENING_LINE_COMMENT, "");
41
+ const specifiers = Array.from(
42
+ stripped.matchAll(RELATIVE_SPECIFIER_PATTERN),
43
+ match => match[2]
44
+ );
45
+ return [...new Set(specifiers)];
46
+ }
47
+
48
+ /**
49
+ * Predicate: is `candidate` the directory `root` or somewhere beneath it?
50
+ * @param {string} root Absolute directory.
51
+ * @param {string} candidate Absolute path.
52
+ * @returns {boolean} True when `candidate` does not escape `root`.
53
+ */
54
+ function isWithin(root, candidate) {
55
+ const rel = path.relative(root, candidate);
56
+ return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
57
+ }
58
+
59
+ /**
60
+ * List every script module beneath a directory, sorted for determinism.
61
+ * @param {string} dir Absolute directory.
62
+ * @returns {string[]} Absolute module paths.
63
+ */
64
+ function listScriptModules(dir) {
65
+ if (!fs.existsSync(dir)) return [];
66
+ return fs
67
+ .readdirSync(dir, { recursive: true, withFileTypes: true })
68
+ .filter(
69
+ entry =>
70
+ entry.isFile() && SCRIPT_MODULE_EXTENSIONS.has(path.extname(entry.name))
71
+ )
72
+ .map(entry => path.join(entry.parentPath, entry.name))
73
+ .sort();
74
+ }
75
+
76
+ /**
77
+ * Resolve the shared targets one emitted module imports. A target outside
78
+ * `.codex-plugin/skills/` must lie inside `.codex-plugin/scripts/`: that is
79
+ * the only directory this step clears, so it is the only one it may write —
80
+ * it can never overwrite `hooks.json`, `plugin.json`, or anything else.
81
+ * @param {string} codexDir Absolute `.codex-plugin/` directory.
82
+ * @param {string} importer Absolute emitted module path.
83
+ * @returns {{ specifier: string, target: string }[]} Imports whose absolute
84
+ * target lies inside `.codex-plugin/scripts/`.
85
+ */
86
+ function sharedTargetsOf(codexDir, importer) {
87
+ const skillsDir = path.join(codexDir, "skills");
88
+ const scriptsDir = path.join(codexDir, "scripts");
89
+ return extractRelativeSpecifiers(fs.readFileSync(importer, "utf8"))
90
+ .map(specifier => ({
91
+ specifier,
92
+ target: path.resolve(path.dirname(importer), specifier),
93
+ }))
94
+ .filter(({ specifier, target }) => {
95
+ if (isWithin(skillsDir, target)) return false;
96
+ if (!isWithin(scriptsDir, target)) {
97
+ throw new Error(
98
+ `${path.relative(codexDir, importer)} imports "${specifier}", which resolves outside ${CODEX_PLUGIN_DIR}/scripts/ and cannot be emitted`
99
+ );
100
+ }
101
+ return true;
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Copy one shared module from the plugin root into `.codex-plugin/`.
107
+ * @param {string} pluginDir Built plugin directory.
108
+ * @param {string} codexDir Absolute `.codex-plugin/` directory.
109
+ * @param {string} importer Absolute module that imports `target`.
110
+ * @param {{ specifier: string, target: string }} edge The import being emitted.
111
+ */
112
+ function copySharedModule(
113
+ pluginDir,
114
+ codexDir,
115
+ importer,
116
+ { specifier, target }
117
+ ) {
118
+ const rel = path.relative(codexDir, target);
119
+ const source = path.join(pluginDir, rel);
120
+ if (!fs.existsSync(source)) {
121
+ throw new Error(
122
+ `${path.relative(codexDir, importer)} imports "${specifier}", but its source ${rel} does not exist in the plugin`
123
+ );
124
+ }
125
+ fs.mkdirSync(path.dirname(target), { recursive: true });
126
+ fs.copyFileSync(source, target);
127
+ }
128
+
129
+ /**
130
+ * Emit every shared module the plugin's Codex skill scripts import,
131
+ * transitively, into `<plugin>/.codex-plugin/`. Must run after the skill
132
+ * variants are emitted. Stale emitted shared modules are removed first.
133
+ * @param {string} pluginDir Built plugin directory.
134
+ * @returns {string[]} Emitted paths relative to `.codex-plugin/`, sorted.
135
+ */
136
+ export function emitCodexSharedScripts(pluginDir) {
137
+ const codexDir = path.join(pluginDir, CODEX_PLUGIN_DIR);
138
+ fs.rmSync(path.join(codexDir, "scripts"), { force: true, recursive: true });
139
+ const emitted = new Set();
140
+ const pending = listScriptModules(path.join(codexDir, "skills"));
141
+ while (pending.length > 0) {
142
+ const importer = pending.shift();
143
+ for (const edge of sharedTargetsOf(codexDir, importer)) {
144
+ const { target } = edge;
145
+ if (emitted.has(target)) continue;
146
+ copySharedModule(pluginDir, codexDir, importer, edge);
147
+ emitted.add(target);
148
+ if (SCRIPT_MODULE_EXTENSIONS.has(path.extname(target))) {
149
+ pending.push(target);
150
+ }
151
+ }
152
+ }
153
+ return [...emitted]
154
+ .map(target => path.relative(codexDir, target).split(path.sep).join("/"))
155
+ .sort();
156
+ }