@massa-ai/codex-plugin 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.codex-plugin/plugin.json +30 -0
  2. package/README.md +96 -0
  3. package/agents/massa-ai-architecture-specialist.toml +64 -0
  4. package/agents/massa-ai-audit-specialist.toml +80 -0
  5. package/agents/massa-ai-builder.toml +66 -0
  6. package/agents/massa-ai-context-curator.toml +66 -0
  7. package/agents/massa-ai-documentation-agent.toml +64 -0
  8. package/agents/massa-ai-furps-analyst.toml +70 -0
  9. package/agents/massa-ai-investigator.toml +67 -0
  10. package/agents/massa-ai-mobile-specialist.toml +81 -0
  11. package/agents/massa-ai-navigator.toml +74 -0
  12. package/agents/massa-ai-plan-critic.toml +89 -0
  13. package/agents/massa-ai-planner.toml +64 -0
  14. package/agents/massa-ai-requirements-analyst.toml +63 -0
  15. package/agents/massa-ai-reviewer.toml +65 -0
  16. package/agents/massa-ai-test-engineer.toml +65 -0
  17. package/agents/massa-ai-verification-agent.toml +64 -0
  18. package/hooks/hooks.json +52 -0
  19. package/hooks/massa-ai-hook +298 -0
  20. package/install.sh +475 -0
  21. package/package.json +30 -0
  22. package/skills/agents/architecture-specialist/SKILL.md +69 -0
  23. package/skills/agents/audit-specialist/SKILL.md +85 -0
  24. package/skills/agents/builder/SKILL.md +71 -0
  25. package/skills/agents/context-curator/SKILL.md +71 -0
  26. package/skills/agents/documentation-agent/SKILL.md +69 -0
  27. package/skills/agents/furps-analyst/SKILL.md +74 -0
  28. package/skills/agents/investigator/SKILL.md +72 -0
  29. package/skills/agents/mobile-specialist/SKILL.md +86 -0
  30. package/skills/agents/navigator/SKILL.md +79 -0
  31. package/skills/agents/plan-critic/SKILL.md +93 -0
  32. package/skills/agents/planner/SKILL.md +69 -0
  33. package/skills/agents/requirements-analyst/SKILL.md +68 -0
  34. package/skills/agents/reviewer/SKILL.md +70 -0
  35. package/skills/agents/test-engineer/SKILL.md +70 -0
  36. package/skills/agents/verification-agent/SKILL.md +69 -0
  37. package/skills/def.md +17 -0
  38. package/skills/find.md +19 -0
  39. package/skills/graph.md +16 -0
  40. package/skills/index.md +19 -0
  41. package/skills/map.md +24 -0
  42. package/skills/massa-ai/SKILL.md +315 -0
  43. package/skills/massa-ai/personas/README.md +35 -0
  44. package/skills/massa-ai/personas/ai-native-nodejs-cli-architect.md +76 -0
  45. package/skills/massa-ai/personas/catalog.json +157 -0
  46. package/skills/massa-ai/personas/context-skill-harness-engineer-architect.md +74 -0
  47. package/skills/massa-ai/personas/product-manager.md +67 -0
  48. package/skills/massa-ai/personas/senior-mobile-engineer.md +74 -0
  49. package/skills/massa-ai/personas/senior-mobile-qa-automation-engineer.md +75 -0
  50. package/skills/massa-ai/references/adr-authoring.md +189 -0
  51. package/skills/massa-ai/references/agent-orchestration.md +221 -0
  52. package/skills/massa-ai/references/architecture-coupling-lens.md +239 -0
  53. package/skills/massa-ai/references/architecture-deepening-lens.md +136 -0
  54. package/skills/massa-ai/references/architecture-domain-lens.md +186 -0
  55. package/skills/massa-ai/references/architecture-lenses.md +108 -0
  56. package/skills/massa-ai/references/audit-report-io.md +459 -0
  57. package/skills/massa-ai/references/audit-scope.md +103 -0
  58. package/skills/massa-ai/references/code-annotation.md +111 -0
  59. package/skills/massa-ai/references/codebase-investigation.md +96 -0
  60. package/skills/massa-ai/references/context-firewall.md +62 -0
  61. package/skills/massa-ai/references/conversation-feedback.md +104 -0
  62. package/skills/massa-ai/references/debug-diagnosis-loop.md +140 -0
  63. package/skills/massa-ai/references/decision-engine.md +73 -0
  64. package/skills/massa-ai/references/evidence-gate.md +53 -0
  65. package/skills/massa-ai/references/furps/analyst-role.md +49 -0
  66. package/skills/massa-ai/references/furps/checklist.md +92 -0
  67. package/skills/massa-ai/references/furps/intake.md +104 -0
  68. package/skills/massa-ai/references/furps/report-contract.md +140 -0
  69. package/skills/massa-ai/references/hook-enforcement.md +137 -0
  70. package/skills/massa-ai/references/implementation-delivery.md +101 -0
  71. package/skills/massa-ai/references/installation.md +110 -0
  72. package/skills/massa-ai/references/lessons.md +119 -0
  73. package/skills/massa-ai/references/maestro/artifacts-reports.md +69 -0
  74. package/skills/massa-ai/references/maestro/cli-device.md +65 -0
  75. package/skills/massa-ai/references/maestro/cloud.md +67 -0
  76. package/skills/massa-ai/references/maestro/config-env-output.md +76 -0
  77. package/skills/massa-ai/references/maestro/fact-ledger.md +71 -0
  78. package/skills/massa-ai/references/maestro/js-scripting.md +70 -0
  79. package/skills/massa-ai/references/maestro/mcp.md +59 -0
  80. package/skills/massa-ai/references/maestro/patterns.md +96 -0
  81. package/skills/massa-ai/references/maestro/selectors.md +91 -0
  82. package/skills/massa-ai/references/maestro/workspace-execution.md +81 -0
  83. package/skills/massa-ai/references/maestro/yaml-commands.md +203 -0
  84. package/skills/massa-ai/references/maestro.md +47 -0
  85. package/skills/massa-ai/references/mcp-tools.md +296 -0
  86. package/skills/massa-ai/references/memory-policy.md +103 -0
  87. package/skills/massa-ai/references/mobile-context.md +113 -0
  88. package/skills/massa-ai/references/mobile-diagnosis.md +106 -0
  89. package/skills/massa-ai/references/mobile-figma-matcher/ATTRIBUTION.md +5 -0
  90. package/skills/massa-ai/references/mobile-figma-matcher/android-compose.md +13 -0
  91. package/skills/massa-ai/references/mobile-figma-matcher/android-views.md +13 -0
  92. package/skills/massa-ai/references/mobile-figma-matcher/core.md +117 -0
  93. package/skills/massa-ai/references/mobile-figma-matcher/ios-swiftui.md +12 -0
  94. package/skills/massa-ai/references/mobile-figma-matcher/ios-uikit.md +12 -0
  95. package/skills/massa-ai/references/mobile-figma-matcher/kmp-compose-multiplatform.md +14 -0
  96. package/skills/massa-ai/references/mobile-figma-matcher/repository-detection.md +77 -0
  97. package/skills/massa-ai/references/naming-standards.md +47 -0
  98. package/skills/massa-ai/references/pr-task-fix.md +80 -0
  99. package/skills/massa-ai/references/project-context.md +76 -0
  100. package/skills/massa-ai/references/rfc/ATTRIBUTION.md +5 -0
  101. package/skills/massa-ai/references/rfc/discovery-and-sizing.md +120 -0
  102. package/skills/massa-ai/references/rfc/document-contract.md +85 -0
  103. package/skills/massa-ai/references/rfc/quality-and-lifecycle.md +101 -0
  104. package/skills/massa-ai/references/root-cause-scripts.md +97 -0
  105. package/skills/massa-ai/references/spec-driven/artifact-store.md +98 -0
  106. package/skills/massa-ai/references/spec-driven/code-analysis.md +119 -0
  107. package/skills/massa-ai/references/spec-driven/coding-principles.md +80 -0
  108. package/skills/massa-ai/references/spec-driven/context-limits.md +64 -0
  109. package/skills/massa-ai/references/spec-driven/design.md +257 -0
  110. package/skills/massa-ai/references/spec-driven/discuss.md +182 -0
  111. package/skills/massa-ai/references/spec-driven/execute.md +471 -0
  112. package/skills/massa-ai/references/spec-driven/lessons.md +5 -0
  113. package/skills/massa-ai/references/spec-driven/memory.md +214 -0
  114. package/skills/massa-ai/references/spec-driven/specify.md +283 -0
  115. package/skills/massa-ai/references/spec-driven/sub-agents.md +151 -0
  116. package/skills/massa-ai/references/spec-driven/tasks.md +494 -0
  117. package/skills/massa-ai/references/spec-driven/validate.md +397 -0
  118. package/skills/massa-ai/references/subagent-design.md +132 -0
  119. package/skills/massa-ai/references/synapse-policy.md +160 -0
  120. package/skills/massa-ai/references/tdd/calibrated-examples.md +54 -0
  121. package/skills/massa-ai/references/tdd/discovery-and-sizing.md +83 -0
  122. package/skills/massa-ai/references/tdd/document-contract.md +136 -0
  123. package/skills/massa-ai/references/tdd/quality-and-lifecycle.md +83 -0
  124. package/skills/massa-ai/references/the-fool/cognitive-bias-inventory.md +103 -0
  125. package/skills/massa-ai/references/the-fool/dialectic-synthesis.md +170 -0
  126. package/skills/massa-ai/references/the-fool/evidence-audit.md +202 -0
  127. package/skills/massa-ai/references/the-fool/mode-selection-guide.md +113 -0
  128. package/skills/massa-ai/references/the-fool/pre-mortem-analysis.md +200 -0
  129. package/skills/massa-ai/references/the-fool/red-team-adversarial.md +206 -0
  130. package/skills/massa-ai/references/the-fool/socratic-questioning.md +153 -0
  131. package/skills/massa-ai/references/ticket/atlassian-fix.md +130 -0
  132. package/skills/massa-ai/references/ticket/intake-and-sources.md +65 -0
  133. package/skills/massa-ai/references/ticket/templates-and-quality.md +129 -0
  134. package/skills/massa-ai/references/verification-ladder.md +62 -0
  135. package/skills/massa-ai/scripts/lessons.py +590 -0
  136. package/skills/massa-ai/workflows/adr.md +33 -0
  137. package/skills/massa-ai/workflows/architecture/architecture-audit.md +125 -0
  138. package/skills/massa-ai/workflows/architecture/architecture-fix.md +110 -0
  139. package/skills/massa-ai/workflows/bugs/bugs-audit.md +113 -0
  140. package/skills/massa-ai/workflows/bugs/bugs-fix.md +97 -0
  141. package/skills/massa-ai/workflows/code-quality/code-quality-audit.md +154 -0
  142. package/skills/massa-ai/workflows/code-quality/code-quality-fix.md +99 -0
  143. package/skills/massa-ai/workflows/commit.md +61 -0
  144. package/skills/massa-ai/workflows/debug.md +86 -0
  145. package/skills/massa-ai/workflows/design.md +54 -0
  146. package/skills/massa-ai/workflows/exploration.md +119 -0
  147. package/skills/massa-ai/workflows/feature.md +52 -0
  148. package/skills/massa-ai/workflows/general.md +46 -0
  149. package/skills/massa-ai/workflows/implementation/implementation-audit.md +87 -0
  150. package/skills/massa-ai/workflows/implementation/implementation-fix.md +90 -0
  151. package/skills/massa-ai/workflows/long-session.md +44 -0
  152. package/skills/massa-ai/workflows/maestro/maestro-audit.md +56 -0
  153. package/skills/massa-ai/workflows/maestro/maestro-fix.md +74 -0
  154. package/skills/massa-ai/workflows/maestro/maestro.md +68 -0
  155. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-audit.md +68 -0
  156. package/skills/massa-ai/workflows/mobile-figma/mobile-figma-fix.md +74 -0
  157. package/skills/massa-ai/workflows/onboarding.md +23 -0
  158. package/skills/massa-ai/workflows/refactor.md +47 -0
  159. package/skills/massa-ai/workflows/refinement/furps-refinement.md +81 -0
  160. package/skills/massa-ai/workflows/requirements/requirements-audit.md +114 -0
  161. package/skills/massa-ai/workflows/requirements/requirements-fix.md +93 -0
  162. package/skills/massa-ai/workflows/rfc.md +55 -0
  163. package/skills/massa-ai/workflows/security/security-audit.md +113 -0
  164. package/skills/massa-ai/workflows/security/security-fix.md +97 -0
  165. package/skills/massa-ai/workflows/spec-driven.md +217 -0
  166. package/skills/massa-ai/workflows/tdd.md +71 -0
  167. package/skills/massa-ai/workflows/tests/tests-audit.md +114 -0
  168. package/skills/massa-ai/workflows/tests/tests-fix.md +96 -0
  169. package/skills/massa-ai/workflows/the-fool.md +82 -0
  170. package/skills/massa-ai/workflows/ticket.md +42 -0
  171. package/skills/persona-router/SKILL.md +158 -0
  172. package/skills/status.md +15 -0
package/install.sh ADDED
@@ -0,0 +1,475 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # massa-ai Codex plugin installer
4
+ #
5
+ # Copies the plugin bundle (manifest, skills, hooks.json, binary symlink) into
6
+ # the user's or project's Codex config directory and merges the 6 massa-ai hook
7
+ # events into ~/.codex/hooks.json (or ./.codex/hooks.json) using an
8
+ # array-append merge that preserves existing user hooks.
9
+ #
10
+ # MCP registration is delegated to scripts/install-agents.sh, the single writer
11
+ # of host MCP config. This installer no longer ships a plugin-local .mcp.json.
12
+ #
13
+ # Complementary to the marketplace route, NOT a duplicate of it. Installing via
14
+ # `codex plugin add massa-ai@massa-ai` gives Codex the skills and the /plugins
15
+ # entry; it CANNOT give it hooks, because a Codex plugin manifest has no hooks
16
+ # key (none of the 203 manifests shipped by the bundled/curated/runtime
17
+ # marketplaces declares one). Hooks reach Codex only through ~/.codex/hooks.json,
18
+ # which this script writes. So there is no double-fire to guard against here —
19
+ # unlike apps/claude-plugin/install.sh, whose plugin does ship hooks/hooks.json.
20
+ #
21
+ # Idempotent: re-running is a no-op when owned entries already present.
22
+ # Uninstall removes only ownership-marked entries + the plugin directory.
23
+ #
24
+ # Usage:
25
+ # apps/codex-plugin/install.sh # install at user scope (~/.codex)
26
+ # apps/codex-plugin/install.sh --user # (same)
27
+ # apps/codex-plugin/install.sh --project # install at project scope (./.codex)
28
+ # apps/codex-plugin/install.sh --uninstall # remove owned entries + plugin dir
29
+ # apps/codex-plugin/install.sh -h|--help # show this help
30
+
31
+ set -euo pipefail
32
+
33
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
35
+ CLAUDE_PLUGIN_BIN="$REPO_ROOT/apps/claude-plugin/hooks/massa-ai-hook.ts"
36
+
37
+ SCOPE="user"
38
+ UNINSTALL=0
39
+ DRY_RUN=0
40
+
41
+ for arg in "$@"; do
42
+ case "$arg" in
43
+ --user) SCOPE="user" ;;
44
+ --project) SCOPE="project" ;;
45
+ --uninstall) UNINSTALL=1 ;;
46
+ --quiet) MASSA_AI_VERBOSE=0 ;;
47
+ --verbose) MASSA_AI_VERBOSE=1 ;;
48
+ --dry-run) DRY_RUN=1; MASSA_AI_VERBOSE=1 ;;
49
+ -h|--help)
50
+ sed -n '2,/^$/p' "$0" | sed 's/^# \{0,1\}//'
51
+ exit 0
52
+ ;;
53
+ *) echo "Unknown flag: $arg" >&2; exit 2 ;;
54
+ esac
55
+ done
56
+
57
+ # Banner
58
+ source "$SCRIPT_DIR/../../scripts/banner.sh"
59
+ massa_ai_banner
60
+
61
+ # Resolve target base dir
62
+ if [[ "$SCOPE" == "project" ]]; then
63
+ CODEX_DIR="$(pwd)/.codex"
64
+ else
65
+ CODEX_DIR="$HOME/.codex"
66
+ fi
67
+ PLUGIN_DIR="$CODEX_DIR/plugins/massa-ai"
68
+ HOOKS_JSON="$CODEX_DIR/hooks.json"
69
+ AGENTS_DIR="$CODEX_DIR/agents"
70
+
71
+ # Array-append merge (F5 mitigation): for each of the 6 events, append the
72
+ # massa-ai hook entry to the event's array if no entry with
73
+ # _massaAiOwned: true already exists. Backup before first write. Uses node
74
+ # (preferred) or bun for safe JSON manipulation — bash cannot do JSON safely.
75
+ #
76
+ # Entry shape is Codex's matcher-group form — an outer object whose "hooks" is
77
+ # an ARRAY of { type, command }:
78
+ # { "hooks": [{ "type": "command", "command": "<bin> <sub>" }],
79
+ # "_massaAiOwned": true }
80
+ # Codex addresses hook state as "<file>:<event>:<group>:<hook>", so a flat entry
81
+ # (type/command at the top level, no inner array) has no ":<hook>" index, is
82
+ # never enumerated, and never appears in /hooks. Releases before this one wrote
83
+ # the flat form; the install path migrates them (see MIGRATION below).
84
+ merge_hooks_json() {
85
+ local file="$1"
86
+ local mode="$2" # "install" or "uninstall"
87
+ local ts
88
+ ts="$(date +%Y%m%d%H%M%S)"
89
+
90
+ local runner=""
91
+ if command -v node &>/dev/null; then
92
+ runner="node"
93
+ elif command -v bun &>/dev/null; then
94
+ runner="bun"
95
+ else
96
+ echo "Error: node or bun required to merge hooks.json (JSON manipulation)" >&2
97
+ exit 3
98
+ fi
99
+
100
+ "$runner" - "$file" "$mode" "$ts" "$PLUGIN_DIR" <<'NODE'
101
+ const fs = require("fs");
102
+ const path = require("path");
103
+
104
+ const file = process.argv[2];
105
+ const mode = process.argv[3];
106
+ const ts = process.argv[4];
107
+ const pluginDir = process.argv[5];
108
+
109
+ const EVENTS = [
110
+ ["SessionStart", "session-start"],
111
+ ["UserPromptSubmit", "user-prompt-submit"],
112
+ ["PreToolUse", "pre-tool-use"],
113
+ ["PostToolUse", "post-tool-use"],
114
+ ["PreCompact", "pre-compact"],
115
+ ["Stop", "stop"],
116
+ ];
117
+
118
+ let cfg = {};
119
+ let existed = false;
120
+ try {
121
+ const raw = fs.readFileSync(file, "utf8");
122
+ if (raw.trim()) {
123
+ cfg = JSON.parse(raw);
124
+ existed = true;
125
+ }
126
+ } catch (e) {
127
+ if (e.code === "ENOENT") {
128
+ // no file — start empty
129
+ } else {
130
+ throw e;
131
+ }
132
+ }
133
+
134
+ // Ensure nested hooks object exists (Codex schema requires this structure)
135
+ if (typeof cfg.hooks !== "object" || cfg.hooks === null) {
136
+ cfg.hooks = {};
137
+ }
138
+
139
+ function isOwned(e) {
140
+ return Boolean(e) && e._massaAiOwned === true;
141
+ }
142
+
143
+ // A correctly-shaped owned entry is a matcher group: its "hooks" is an array.
144
+ // Anything owned that fails this is a pre-fix flat entry Codex cannot enumerate.
145
+ function isOwnedMatcherGroup(e) {
146
+ return isOwned(e) && Array.isArray(e.hooks);
147
+ }
148
+
149
+ function hasOwned(arr) {
150
+ return Array.isArray(arr) && arr.some(isOwnedMatcherGroup);
151
+ }
152
+
153
+ if (mode === "uninstall") {
154
+ // Remove owned entries from nested location + perform flat→nested migration
155
+ const hooks = cfg.hooks;
156
+
157
+ // First, remove owned entries from the correct nested location
158
+ for (const [evt] of EVENTS) {
159
+ if (Array.isArray(hooks[evt])) {
160
+ hooks[evt] = hooks[evt].filter((e) => !(e && e._massaAiOwned === true));
161
+ if (hooks[evt].length === 0) delete hooks[evt];
162
+ }
163
+ }
164
+
165
+ // Clean up if hooks object is now empty
166
+ if (Object.keys(hooks).length === 0) delete cfg.hooks;
167
+ } else {
168
+ // install: backup before first write if file existed
169
+ if (existed) {
170
+ const bak = `${file}.massa-ai.bak-${ts}`;
171
+ fs.copyFileSync(file, bak);
172
+ }
173
+
174
+ // Migration: check for broken flat-key entries at top level that should be removed
175
+ for (const [evt] of EVENTS) {
176
+ if (Array.isArray(cfg[evt])) {
177
+ const ownedEntries = cfg[evt].filter((e) => e && e._massaAiOwned === true);
178
+ // Only remove if ALL entries are owned (user entries are never marked)
179
+ if (ownedEntries.length > 0 && ownedEntries.length === cfg[evt].length) {
180
+ delete cfg[evt];
181
+ }
182
+ }
183
+ }
184
+
185
+ // MIGRATION: drop owned entries written in the pre-fix flat shape. They are
186
+ // invisible to Codex, so leaving them would both keep /hooks empty and make
187
+ // hasOwned() below treat the event as already wired. Only owned entries are
188
+ // touched — user entries are never marked.
189
+ for (const [evt] of EVENTS) {
190
+ if (Array.isArray(cfg.hooks[evt])) {
191
+ cfg.hooks[evt] = cfg.hooks[evt].filter(
192
+ (e) => !(isOwned(e) && !isOwnedMatcherGroup(e)),
193
+ );
194
+ }
195
+ }
196
+
197
+ // Now write to the correct nested location
198
+ for (const [evt, sub] of EVENTS) {
199
+ if (!Array.isArray(cfg.hooks[evt])) cfg.hooks[evt] = [];
200
+ if (!hasOwned(cfg.hooks[evt])) {
201
+ cfg.hooks[evt].push({
202
+ hooks: [
203
+ {
204
+ type: "command",
205
+ command: `${pluginDir}/hooks/massa-ai-hook ${sub}`,
206
+ },
207
+ ],
208
+ _massaAiOwned: true,
209
+ });
210
+ }
211
+ }
212
+ }
213
+
214
+ fs.mkdirSync(path.dirname(file), { recursive: true });
215
+ fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + "\n");
216
+ NODE
217
+ }
218
+
219
+ # ── Skills bundling (PDO-08, 09 / D3 two-writer ownership) ──────────────────
220
+ # scripts/install-skills.sh remains the single writer once it has already
221
+ # claimed this platform (skillsOwner: "repo" in the shared install-state.json).
222
+ # This plugin installs its bundled massa-ai/persona-router skills into the
223
+ # SAME harness skills directory ($CODEX_DIR/skills — NOT $PLUGIN_DIR/skills,
224
+ # which is Codex's own marketplace-plugin skill cache, a separate mechanism)
225
+ # only when that has not happened, mirroring the MCP single-writer precedent
226
+ # (test-mcp-single-writer.sh). A repo checkout's own --apply always takes
227
+ # precedence over a prior plugin install — see install-skills.sh.
228
+ HARNESS_STATE_FILE="$HOME/.config/massa-ai/install-state.json"
229
+ HARNESS_SKILLS_DIR="$CODEX_DIR/skills"
230
+ HARNESS_HOST="codex"
231
+
232
+ harness_skills_owner() {
233
+ local runner="$1"
234
+ "$runner" - "$HARNESS_STATE_FILE" "$HARNESS_HOST" <<'NODE'
235
+ const fs = require("fs");
236
+ const [, , file, host] = process.argv;
237
+ try {
238
+ const data = JSON.parse(fs.readFileSync(file, "utf8"));
239
+ const rec = data && data.platforms && data.platforms[host];
240
+ process.stdout.write(rec && rec.skillsOwner === "repo" ? "repo" : "none");
241
+ } catch {
242
+ process.stdout.write("none");
243
+ }
244
+ NODE
245
+ }
246
+
247
+ install_bundled_skills() {
248
+ local runner=""
249
+ if command -v node &>/dev/null; then runner="node"
250
+ elif command -v bun &>/dev/null; then runner="bun"
251
+ else
252
+ echo " ⚠ node or bun required to install bundled skills — skipping" >&2
253
+ return 0
254
+ fi
255
+
256
+ if [[ "$(harness_skills_owner "$runner")" == "repo" ]]; then
257
+ vecho " ↷ skills already installed by scripts/install-skills.sh (repo-owned) — skipping bundled copy"
258
+ return 0
259
+ fi
260
+
261
+ local installed=0 name src dest
262
+ for name in massa-ai persona-router; do
263
+ src="$SCRIPT_DIR/skills/$name"
264
+ [[ -d "$src" ]] || continue
265
+ dest="$HARNESS_SKILLS_DIR/$name"
266
+ if [[ -e "$dest" && ! -d "$dest" ]]; then
267
+ echo " ⚠ $dest exists and is not a directory — skipping" >&2
268
+ continue
269
+ fi
270
+ mkdir -p "$HARNESS_SKILLS_DIR"
271
+ rm -rf "$dest"
272
+ cp -R "$src" "$dest"
273
+ installed=$((installed + 1))
274
+ done
275
+ vecho " + ${installed} harness skills installed to $HARNESS_SKILLS_DIR (plugin-owned)"
276
+
277
+ "$runner" - "$HARNESS_STATE_FILE" "$HARNESS_HOST" "$CODEX_DIR" <<'NODE'
278
+ const fs = require("fs");
279
+ const path = require("path");
280
+ const [, , file, host, root] = process.argv;
281
+ let data = { version: 2, platforms: {} };
282
+ try {
283
+ const existing = JSON.parse(fs.readFileSync(file, "utf8"));
284
+ if (existing && typeof existing === "object" && !Array.isArray(existing)) data = existing;
285
+ } catch { /* fresh */ }
286
+ if (typeof data.platforms !== "object" || data.platforms === null || Array.isArray(data.platforms)) {
287
+ data.platforms = {};
288
+ }
289
+ data.version = 2;
290
+ data.platforms[host] = { root, skillsOwner: "plugin", skills: ["massa-ai", "persona-router"] };
291
+ fs.mkdirSync(path.dirname(file), { recursive: true });
292
+ fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
293
+ NODE
294
+ }
295
+
296
+ uninstall_bundled_skills() {
297
+ local runner=""
298
+ if command -v node &>/dev/null; then runner="node"
299
+ elif command -v bun &>/dev/null; then runner="bun"
300
+ else return 0
301
+ fi
302
+
303
+ local raw_owner
304
+ raw_owner="$("$runner" - "$HARNESS_STATE_FILE" "$HARNESS_HOST" <<'NODE'
305
+ const fs = require("fs");
306
+ const [, , file, host] = process.argv;
307
+ try {
308
+ const data = JSON.parse(fs.readFileSync(file, "utf8"));
309
+ const rec = data && data.platforms && data.platforms[host];
310
+ process.stdout.write(rec ? String(rec.skillsOwner) : "none");
311
+ } catch {
312
+ process.stdout.write("none");
313
+ }
314
+ NODE
315
+ )"
316
+ [[ "$raw_owner" == "plugin" ]] || return 0
317
+
318
+ local name
319
+ for name in massa-ai persona-router; do
320
+ rm -rf "$HARNESS_SKILLS_DIR/$name"
321
+ done
322
+ rmdir "$HARNESS_SKILLS_DIR" 2>/dev/null || true
323
+ echo " - removed plugin-owned harness skills from $HARNESS_SKILLS_DIR"
324
+
325
+ "$runner" - "$HARNESS_STATE_FILE" "$HARNESS_HOST" <<'NODE'
326
+ const fs = require("fs");
327
+ const [, , file, host] = process.argv;
328
+ try {
329
+ const data = JSON.parse(fs.readFileSync(file, "utf8"));
330
+ if (data && data.platforms && data.platforms[host] && data.platforms[host].skillsOwner === "plugin") {
331
+ delete data.platforms[host];
332
+ fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
333
+ }
334
+ } catch { /* nothing to clean up */ }
335
+ NODE
336
+ }
337
+
338
+ # ── Uninstall ───────────────────────────────────────────────────────────────
339
+ if [[ "$UNINSTALL" -eq 1 ]]; then
340
+ echo "Uninstalling massa-ai Codex plugin (scope: $SCOPE)..."
341
+ uninstall_bundled_skills
342
+ # Remove owned hook entries (preserves user hooks)
343
+ if [[ -f "$HOOKS_JSON" ]]; then
344
+ merge_hooks_json "$HOOKS_JSON" "uninstall"
345
+ echo " - removed massa-ai hook entries from $HOOKS_JSON"
346
+ fi
347
+ # Remove plugin directory
348
+ if [[ -d "$PLUGIN_DIR" ]]; then
349
+ rm -rf "$PLUGIN_DIR"
350
+ echo " - removed $PLUGIN_DIR"
351
+ fi
352
+ # Remove only ownership-marked agent TOML files (R3: shared agents dir, user
353
+ # agents preserved). Marker = "# massa-ai-owned" top comment.
354
+ if [[ -d "$AGENTS_DIR" ]]; then
355
+ removed=0
356
+ for f in "$AGENTS_DIR/"*.toml; do
357
+ [[ -f "$f" ]] || continue
358
+ if head -n1 "$f" | grep -q "^# massa-ai-owned$"; then
359
+ rm -f "$f"
360
+ removed=$((removed + 1))
361
+ fi
362
+ done
363
+ if [[ "$removed" -gt 0 ]]; then
364
+ echo " - removed ${removed} massa-ai-owned agent TOML files from $AGENTS_DIR/"
365
+ fi
366
+ fi
367
+ echo ""
368
+ echo "Done. User hooks and user agents preserved."
369
+ exit 0
370
+ fi
371
+
372
+ # ── Install ──────────────────────────────────────────────────────────────────
373
+ vecho "Installing massa-ai Codex plugin to: $PLUGIN_DIR"
374
+ mkdir -p "$PLUGIN_DIR/.codex-plugin" "$PLUGIN_DIR/skills" "$PLUGIN_DIR/hooks"
375
+
376
+ # Copy manifest
377
+ cp "$SCRIPT_DIR/.codex-plugin/plugin.json" "$PLUGIN_DIR/.codex-plugin/plugin.json"
378
+ vecho " + .codex-plugin/plugin.json"
379
+
380
+ # Copy skills
381
+ skill_count=0
382
+ for src in "$SCRIPT_DIR/skills/"*.md; do
383
+ name="$(basename "$src")"
384
+ cp "$src" "$PLUGIN_DIR/skills/$name"
385
+ vecho " + skills/$name"
386
+ skill_count=$((skill_count + 1))
387
+ done
388
+
389
+ # Copy hooks.json (the placeholder version — installer replaces paths)
390
+ cp "$SCRIPT_DIR/hooks/hooks.json" "$PLUGIN_DIR/hooks/hooks.json"
391
+ vecho " + hooks/hooks.json"
392
+
393
+ # Older installs shipped a plugin-local .mcp.json here. It was never a Codex
394
+ # read path, and MCP is now owned by scripts/install-agents.sh — drop the
395
+ # residue so upgraders converge on a single registration.
396
+ if [[ -f "$PLUGIN_DIR/.mcp.json" ]]; then
397
+ rm -f "$PLUGIN_DIR/.mcp.json"
398
+ # Not gated by --quiet: this deletes a file in the user's home, so it is a
399
+ # mutation notice rather than per-file chatter.
400
+ echo -e " - removed stale .mcp.json (MCP is now registered in ~/.codex/config.toml)"
401
+ fi
402
+
403
+ # Copy the real hooks/massa-ai-hook this plugin already ships (T14/PDO-14: a
404
+ # generated real file, no longer a symlink into apps/claude-plugin/ — that
405
+ # path does not exist in a registry tarball install, where $REPO_ROOT is not
406
+ # this monorepo. $CLAUDE_PLUGIN_BIN is kept only as a repo-checkout fallback.
407
+ if [[ -f "$SCRIPT_DIR/hooks/massa-ai-hook" ]]; then
408
+ cp "$SCRIPT_DIR/hooks/massa-ai-hook" "$PLUGIN_DIR/hooks/massa-ai-hook"
409
+ chmod +x "$PLUGIN_DIR/hooks/massa-ai-hook"
410
+ vecho " + hooks/massa-ai-hook"
411
+ elif [[ -f "$CLAUDE_PLUGIN_BIN" ]]; then
412
+ ln -sfn "$CLAUDE_PLUGIN_BIN" "$PLUGIN_DIR/hooks/massa-ai-hook"
413
+ vecho " + hooks/massa-ai-hook → $CLAUDE_PLUGIN_BIN"
414
+ else
415
+ echo " ⚠ Warning: no massa-ai-hook binary found" >&2
416
+ echo " Hooks will not fire until the binary is available." >&2
417
+ fi
418
+
419
+ # Merge hooks.json (array-append, backup, idempotent)
420
+ vecho ""
421
+ vecho "Merging hooks into $HOOKS_JSON..."
422
+ merge_hooks_json "$HOOKS_JSON" "install"
423
+ vecho " + 6 massa-ai hook events wired (array-append, user hooks preserved)"
424
+
425
+ # Write the generated subagent specialist TOML files to ~/.codex/agents/ (OUTSIDE the
426
+ # plugin dir — Codex custom agents load from the config-root agents/ dir, not
427
+ # the plugin dir). Each file carries a "# massa-ai-owned" top comment for
428
+ # scoped uninstall (R3: shared agents dir, user agents preserved).
429
+ mkdir -p "$AGENTS_DIR"
430
+ specialist_count=0
431
+ for src in "$SCRIPT_DIR/agents/"massa-ai-*.toml; do
432
+ [[ -f "$src" ]] || continue
433
+ name="$(basename "$src")"
434
+ cp "$src" "$AGENTS_DIR/$name"
435
+ vecho " + $name"
436
+ specialist_count=$((specialist_count + 1))
437
+ done
438
+ vecho " + ${specialist_count} subagent specialists (generated from skills/agents/*/SKILL.md)"
439
+
440
+ # Skills bundling (PDO-08, 09): install massa-ai/persona-router into the
441
+ # shared harness skills directory, unless scripts/install-skills.sh already
442
+ # owns it for this platform.
443
+ vecho ""
444
+ install_bundled_skills
445
+
446
+ # ── MCP registration (delegated) ─────────────────────────────────────────────
447
+ # scripts/install-agents.sh is the single writer of host MCP config. It writes
448
+ # [mcp_servers.massa-ai] into ~/.codex/config.toml at USER scope — a --project
449
+ # plugin install still registers MCP for the whole user.
450
+ vecho ""
451
+ vecho "Registering MCP server (user scope) via scripts/install-agents.sh..."
452
+ if [[ -f "$REPO_ROOT/scripts/install-agents.sh" ]]; then
453
+ # On success the delegated output is detail (usually "up to date"), so it is
454
+ # gated. On failure it is never gated: a silently-failed MCP registration is
455
+ # exactly the bug this change set exists to fix.
456
+ if agents_out="$(MASSA_AI_SUPPRESS_SPECIALIST_HINT=1 bash "$REPO_ROOT/scripts/install-agents.sh" --agent codex --yes 2>&1)"; then
457
+ vecho "$agents_out"
458
+ else
459
+ echo "$agents_out" >&2
460
+ echo " ⚠ MCP wiring failed — run: bash scripts/install-agents.sh --agent codex --yes" >&2
461
+ fi
462
+ else
463
+ echo " ⚠ scripts/install-agents.sh not found — register MCP with: bash scripts/install-agents.sh --agent codex --yes" >&2
464
+ fi
465
+
466
+ # Summary line in quiet mode
467
+ if [ "${MASSA_AI_VERBOSE:-0}" != "1" ]; then
468
+ ok "codex plugin installed (${skill_count} skills, ${specialist_count} specialists, 6 hooks)"
469
+ else
470
+ vecho ""
471
+ vecho "Done. Restart Codex to pick up the plugin."
472
+ vecho ""
473
+ vecho "⚠ Run /hooks in Codex to trust massa-ai hooks, or no observations will be captured."
474
+ vecho "💡 MCP is registered in ~/.codex/config.toml by scripts/install-agents.sh (single writer)."
475
+ fi
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@massa-ai/codex-plugin",
3
+ "version": "1.6.0",
4
+ "description": "massa-ai plugin for Codex — semantic code search, memory, and context compression",
5
+ "files": [
6
+ "agents",
7
+ "hooks",
8
+ "skills",
9
+ "install.sh",
10
+ "README.md",
11
+ ".codex-plugin/plugin.json"
12
+ ],
13
+ "author": "luizgmassa",
14
+ "keywords": [
15
+ "codex",
16
+ "plugin",
17
+ "massa-ai",
18
+ "semantic-search",
19
+ "code-search",
20
+ "memory",
21
+ "context-compression",
22
+ "ai",
23
+ "llm"
24
+ ],
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/luizgmassa/massa-ai"
29
+ }
30
+ }
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: architecture-specialist
3
+ description: Read-only architecture guidance agent. Evaluate architecture, suggest boundaries, recommend abstractions, evaluate trade-offs, and suggest modularization. Folds the existing domain-mapper, coupling-auditor, and deepening-architect roles into one specialist. Triggers when a workflow needs architectural guidance before or during design. Never implements or rewrites code.
4
+ license: MIT
5
+ metadata:
6
+ author: S1LV4, luizgmassa
7
+ version: "1.0.0"
8
+ model_hint: MiniMax M3
9
+ permission: read-only
10
+ ---
11
+
12
+ # Architecture Specialist Agent Skill
13
+
14
+ ## Mission
15
+ Provide architectural guidance by evaluating structure, suggesting boundaries, and weighing trade-offs.
16
+
17
+ ## Responsibilities
18
+ - Evaluate architecture (layering, boundaries, coupling, depth).
19
+ - Suggest module boundaries and seams.
20
+ - Recommend abstractions where duplication or volatility warrants them.
21
+ - Evaluate trade-offs between approaches.
22
+ - Suggest modularization for shallow or over-coupled modules.
23
+
24
+ ## Restrictions
25
+ - Never implement.
26
+ - Never rewrite code.
27
+ - Never spawn subagents and never load the `massa-ai` router; the dispatching workflow owns routing.
28
+
29
+ ## Inputs
30
+ - `scope`: the module, service, or area under evaluation.
31
+ - `inputs`: recalled facts, source pointers, existing architecture docs.
32
+ - `sensors`: static coupling/depth metrics when available.
33
+
34
+ ## Outputs
35
+ - Status: Complete | Partial | Blocked
36
+ - Scope: modules and boundaries evaluated
37
+ - Evidence: `path:line` pointers, coupling/depth metrics, source locations
38
+ - Findings: boundary suggestions, abstraction recommendations, trade-off analysis, modularization plan
39
+ - Risks and skipped checks
40
+ - Exact next step
41
+
42
+ ## Invocation
43
+ ### Use when
44
+ - A workflow needs architectural guidance before or during design.
45
+ - The work crosses module or service boundaries.
46
+ - The user asks for architecture evaluation, coupling analysis, or modularization.
47
+
48
+ ### Do not use when
49
+ - The work is a single-file fix with no architectural surface.
50
+ - The task needs a concrete implementation (route to builder).
51
+ - An audit-specific lens is needed (route to audit-specialist with `lens: architecture`).
52
+
53
+ ## massa-ai Integration
54
+ - Context Firewall: summarize source reads; return findings and metrics, not raw code.
55
+ - Verification Ladder: static (coupling, depth, boundary) checks; no behavioral changes.
56
+ - Massa-ai Memory: suggest durable architecture-decision memories only when a boundary or abstraction is recommended; main agent persists.
57
+ - Synapse: own ephemeral session when evaluation spans multiple modules with repeated searches.
58
+ - References: `references/architecture-lenses.md`, `references/architecture-domain-lens.md`, `references/architecture-coupling-lens.md`, `references/architecture-deepening-lens.md`.
59
+
60
+ ## Model Hint
61
+ MiniMax M3 (advisory). Fallback to the workflow's configured default model if unavailable.
62
+
63
+ ## Validation Sensors
64
+ - Every finding has a `path:line` or metric pointer.
65
+ - Trade-offs name at least two alternatives.
66
+ - Boundary suggestions reference concrete modules.
67
+
68
+ ## Memory Boundary
69
+ Suggest durable memories only when an architectural boundary or abstraction is recommended and accepted. The main agent persists. Do not persist one-off evaluation chatter.
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: audit-specialist
3
+ description: Configurable read-only audit agent. Execute specialized audits through six lenses — bugs, architecture, security, requirements, code-quality, performance — selected via the lens field in the capability packet. Triggers when a workflow needs a findings-only audit. Never modifies implementation.
4
+ license: MIT
5
+ metadata:
6
+ author: S1LV4, luizgmassa
7
+ version: "1.0.0"
8
+ model_hint: GLM-5.2
9
+ permission: read-only
10
+ ---
11
+
12
+ # Audit Specialist Agent Skill
13
+
14
+ ## Mission
15
+ Execute a specialized audit through one configurable lens and return findings-only output.
16
+
17
+ ## Responsibilities
18
+ - Execute the audit checklist for the selected lens.
19
+ - Tie every finding to a `path:line` source location.
20
+ - Rank findings by severity.
21
+ - Produce a findings report following the project audit-report format.
22
+
23
+ ## Restrictions
24
+ - Never modify implementation.
25
+ - One lens per dispatch; do not mix lenses in one run.
26
+ - Never spawn subagents and never load the `massa-ai` router; the dispatching workflow owns routing.
27
+
28
+ ## Lenses
29
+
30
+ The `lens` field in the capability packet selects the audit behavior:
31
+
32
+ | Lens | Focus | Per-lens references |
33
+ |---|---|---|
34
+ | `bugs` | Bug discovery: null paths, error handling, race conditions, logic errors | `workflows/bugs/bugs-audit.md` |
35
+ | `architecture` | DDD, boundaries, coupling, module depth, seams | `references/architecture-lenses.md`, `references/architecture-domain-lens.md`, `references/architecture-coupling-lens.md`, `references/architecture-deepening-lens.md` |
36
+ | `security` | Security, privacy, auth, validation, secret handling | `workflows/security/security-audit.md` |
37
+ | `requirements` | Requirements, spec, acceptance, scope alignment | `workflows/requirements/requirements-audit.md` |
38
+ | `code-quality` | SOLID, Clean Code, KISS, YAGNI, DRY, maintainability | `workflows/code-quality/code-quality-audit.md` |
39
+ | `performance` | Performance hotspots, allocation, latency, throughput | Domain-specific; no fixed reference |
40
+
41
+ All lenses share `references/audit-scope.md` (scope rules) and `references/audit-report-io.md` (report format).
42
+
43
+ ## Inputs
44
+ - `scope`: the target area, diff, or module to audit.
45
+ - `lens`: one of `bugs | architecture | security | requirements | code-quality | performance` (required).
46
+ - `inputs`: recalled facts, existing audit reports, source pointers.
47
+ - `sensors`: static checks available for the lens (lint, typecheck, security scanners).
48
+
49
+ ## Outputs
50
+ - Status: Complete | Partial | Blocked
51
+ - Scope: area audited + lens used
52
+ - Evidence: `path:line` pointers, static-check results, source locations
53
+ - Findings: ranked list (severity, location, problem, suggestion) in the project audit-report format
54
+ - Risks and skipped checks
55
+ - Exact next step
56
+
57
+ ## Invocation
58
+ ### Use when
59
+ - A workflow needs a findings-only audit of an implementation target.
60
+ - The user asks for a bug, architecture, security, requirements, code-quality, or performance audit.
61
+ - A high/critical finding needs independent verification.
62
+
63
+ ### Do not use when
64
+ - The task needs a fix (route to the matching `*-fix` workflow or builder).
65
+ - No concrete target exists to audit.
66
+ - The lens is ambiguous (ask the user to pick one).
67
+
68
+ ## massa-ai Integration
69
+ - Context Firewall: summarize the audit scope; return findings, not raw source dumps.
70
+ - Verification Ladder: static checks per lens; no behavioral changes (findings-only).
71
+ - Massa-ai Memory: suggest durable audit-pattern memories only when a lens reveals a recurring issue class; main agent persists.
72
+ - Synapse: own ephemeral session when the audit spans multiple modules with repeated searches.
73
+ - References: `references/audit-scope.md`, `references/audit-report-io.md`, plus the per-lens references above.
74
+
75
+ ## Model Hint
76
+ GLM-5.2 (advisory). Fallback to the workflow's configured default model if unavailable.
77
+
78
+ ## Validation Sensors
79
+ - Every finding has a `path:line` pointer.
80
+ - Findings follow the project audit-report format (`references/audit-report-io.md`).
81
+ - Severity is assigned per the lens rubric.
82
+ - No fix actions taken (findings-only).
83
+
84
+ ## Memory Boundary
85
+ Suggest durable memories only when a lens reveals a recurring issue class worth remembering. The main agent persists. Do not persist the audit report itself (it lives in `.specs/`).