nurosys-agents 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.agent/INSTRUCTIONS.md +82 -0
  2. package/.agent/README.md +483 -0
  3. package/.agent/backend/skills/architect/SKILL.md +436 -0
  4. package/.agent/backend/skills/auth-and-permissions/SKILL.md +168 -0
  5. package/.agent/backend/skills/brainstorm/SKILL.md +127 -0
  6. package/.agent/backend/skills/code-reviewer/SKILL.md +324 -0
  7. package/.agent/backend/skills/create-blueprint/SKILL.md +650 -0
  8. package/.agent/backend/skills/debug-issue/SKILL.md +53 -0
  9. package/.agent/backend/skills/explore-codebase/SKILL.md +45 -0
  10. package/.agent/backend/skills/quick-execute/SKILL.md +99 -0
  11. package/.agent/backend/skills/refactor-safely/SKILL.md +46 -0
  12. package/.agent/backend/skills/security-assessment/SKILL.md +174 -0
  13. package/.agent/backend/workflows/module-runner.claude.md +226 -0
  14. package/.agent/backend/workflows/module-runner.codex.md +155 -0
  15. package/.agent/backend/workflows/module-runner.cursor.md +212 -0
  16. package/.agent/frontend/skills/architect/SKILL.md +644 -0
  17. package/.agent/frontend/skills/auth-and-permissions/SKILL.md +43 -0
  18. package/.agent/frontend/skills/create-blueprint/SKILL.md +635 -0
  19. package/.agent/frontend/skills/debug-issue/SKILL.md +28 -0
  20. package/.agent/frontend/skills/explore-codebase/SKILL.md +29 -0
  21. package/.agent/frontend/skills/feature-workflow/SKILL.md +61 -0
  22. package/.agent/frontend/skills/react-quality-review/SKILL.md +126 -0
  23. package/.agent/frontend/skills/react-quality-review/examples.md +24 -0
  24. package/.agent/frontend/skills/react-quality-review/rules/_sections.md +26 -0
  25. package/.agent/frontend/skills/react-quality-review/rules/_template.md +28 -0
  26. package/.agent/frontend/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  27. package/.agent/frontend/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  28. package/.agent/frontend/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  29. package/.agent/frontend/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  30. package/.agent/frontend/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  31. package/.agent/frontend/skills/react-quality-review/rules/rendering-activity.md +26 -0
  32. package/.agent/frontend/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  33. package/.agent/frontend/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  34. package/.agent/frontend/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  35. package/.agent/frontend/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  36. package/.agent/frontend/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  37. package/.agent/frontend/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  38. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  39. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  40. package/.agent/frontend/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  41. package/.agent/frontend/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  42. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  43. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo.md +44 -0
  44. package/.agent/frontend/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  45. package/.agent/frontend/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  46. package/.agent/frontend/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  47. package/.agent/frontend/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  48. package/.agent/frontend/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  49. package/.agent/frontend/skills/refactor-safely/SKILL.md +29 -0
  50. package/.agent/frontend/skills/vuexy-component-guide/SKILL.md +369 -0
  51. package/.agent/frontend/skills/vuexy-component-guide/examples.md +662 -0
  52. package/.agent/frontend/skills/vuexy-component-guide/reference.md +1036 -0
  53. package/.agent/frontend/workflows/build-feature-react.workflow.md +82 -0
  54. package/.agent/frontend/workflows/feature-module-runner.md +101 -0
  55. package/.agent/monolith/skills/architect/SKILL.md +648 -0
  56. package/.agent/monolith/skills/auth-and-permissions/SKILL.md +43 -0
  57. package/.agent/monolith/skills/code-reviewer/SKILL.md +281 -0
  58. package/.agent/monolith/skills/create-blueprint/SKILL.md +635 -0
  59. package/.agent/monolith/skills/debug-issue/SKILL.md +28 -0
  60. package/.agent/monolith/skills/explore-codebase/SKILL.md +29 -0
  61. package/.agent/monolith/skills/feature-workflow/SKILL.md +61 -0
  62. package/.agent/monolith/skills/react-quality-review/SKILL.md +126 -0
  63. package/.agent/monolith/skills/react-quality-review/examples.md +24 -0
  64. package/.agent/monolith/skills/react-quality-review/rules/_sections.md +26 -0
  65. package/.agent/monolith/skills/react-quality-review/rules/_template.md +28 -0
  66. package/.agent/monolith/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  67. package/.agent/monolith/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  68. package/.agent/monolith/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  69. package/.agent/monolith/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  70. package/.agent/monolith/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  71. package/.agent/monolith/skills/react-quality-review/rules/rendering-activity.md +26 -0
  72. package/.agent/monolith/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  73. package/.agent/monolith/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  74. package/.agent/monolith/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  75. package/.agent/monolith/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  76. package/.agent/monolith/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  77. package/.agent/monolith/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  78. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  79. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  80. package/.agent/monolith/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  81. package/.agent/monolith/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  82. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  83. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo.md +44 -0
  84. package/.agent/monolith/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  85. package/.agent/monolith/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  86. package/.agent/monolith/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  87. package/.agent/monolith/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  88. package/.agent/monolith/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  89. package/.agent/monolith/skills/refactor-safely/SKILL.md +29 -0
  90. package/.agent/monolith/skills/vuexy-component-guide/SKILL.md +369 -0
  91. package/.agent/monolith/skills/vuexy-component-guide/examples.md +662 -0
  92. package/.agent/monolith/skills/vuexy-component-guide/reference.md +1036 -0
  93. package/.agent/monolith/workflows/add-new-api-feature-module.md +63 -0
  94. package/.agent/monolith/workflows/backend-quality-review.md +27 -0
  95. package/.agent/monolith/workflows/build-feature-backend.workflow.md +91 -0
  96. package/.agent/monolith/workflows/build-feature-react.workflow.md +82 -0
  97. package/.agent/monolith/workflows/feature-module-runner.md +97 -0
  98. package/.agent/templates/FEATURE_PLAN.md +42 -0
  99. package/.agent/templates/MODULE.md +45 -0
  100. package/.agent/templates/REVIEW_REPORT.md +44 -0
  101. package/.agent/templates/SECURITY_REPORT.md +70 -0
  102. package/.agent/templates/TEST_PLAN.md +49 -0
  103. package/README.md +131 -0
  104. package/package.json +42 -0
  105. package/scripts/setup-rules.js +224 -0
  106. package/scripts/setup.js +518 -0
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # nurosys-agents
2
+
3
+ Portable backend AI agent skills for **Claude Code**, **Cursor**, and **Codex**. One install, drop into any backend project, and you get a coherent end-to-end developer journey: brainstorm → plan → architect → autonomously build.
4
+
5
+ Built on **[Serena](https://github.com/oraios/serena)** for symbol-level code intelligence (replaces the older `code-review-graph` peer dependency).
6
+
7
+ > **v2.0 note:** This package was previously published as `nurosys-agent-skills`. It has been renamed to `nurosys-agents` with a refreshed skill set and Serena as the MCP. See "Migrating from v1.x" below if you're upgrading.
8
+
9
+ ---
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install --save-dev nurosys-agents
15
+ npm exec nurosys-agent-setup
16
+ ```
17
+
18
+ The setup wizard detects your stack (backend / frontend / monolith) and asks which IDE(s) you use, then wires everything: skills, MCP, project-memory rules, IDE-specific module-runner.
19
+
20
+ Serena runs via `uvx`. If you don't have it: https://docs.astral.sh/uv/getting-started/installation/
21
+
22
+ ---
23
+
24
+ ## The end-to-end journey
25
+
26
+ ```
27
+ 1. /create-blueprint all → bootstrap project-memory/
28
+ 2. /brainstorm <problem> → explore 3-5 approaches
29
+ 3. /architect <chosen approach> → plan modules + approval gate (NEVER writes code)
30
+ 4. /module-runner <feature-dir> → autonomous build, review, security, commit per module
31
+ ```
32
+
33
+ Plus on-demand utilities:
34
+
35
+ - `/quick-execute <small task>` — fast execution, no plan gate
36
+ - `/code-reviewer` — review the current branch
37
+ - `/security-assessment [diff|full|path:X]` — standalone security audit
38
+ - `/explore-codebase` / `/refactor-safely` / `/debug-issue` — Serena-powered navigation tools
39
+
40
+ ---
41
+
42
+ ## Skills
43
+
44
+ | Skill | Purpose |
45
+ |---|---|
46
+ | `/create-blueprint` | Bootstrap `project-memory/` artifacts from your codebase (constitution, auth-model, repo-map, architecture, models, quality-playbook, core-memory). **Run first** on a new project. |
47
+ | `/brainstorm` | Explore 3-5 distinct approaches to a problem. No code, no files written. |
48
+ | `/architect` | **Pure planner.** Reads project-memory, consults `/auth-and-permissions` and `/security-assessment` as read-only sub-agents, writes a module-wise plan + per-module prompts. **Never writes code.** Hard approval gate before module prompts are generated. |
49
+ | `/module-runner` | The autonomous executor. For each planned module: spawns sub-agents for implement → build/test → code review → fixes → security audit → fixes → commit → push. Main agent stays clean. IDE-specific variants: Claude Code (Task tool), Cursor (subagents), Codex (foreground fallback). |
50
+ | `/code-reviewer` | Full constitution-aligned review. Standalone writes `documentation/reports/REVIEW_REPORT_*.md`; sub-agent mode returns JSON for `/module-runner`. |
51
+ | `/security-assessment` | Auth, input, injection, deps, data-exposure, crypto/secrets audit. Standalone writes `documentation/reports/SECURITY_ASSESSMENT_*.md`; sub-agent mode returns JSON. |
52
+ | `/auth-and-permissions` | Generic auth review, fully driven by `project-memory/auth-model.md` (no hardcoded framework names). Used by `/code-reviewer` for auth-heavy reviews and by `/architect` to draft auth approach during planning. |
53
+ | `/quick-execute` | Fast execution for small tasks. Hard guardrail STOPs and recommends `/architect` if scope exceeds 3 files or touches auth / data-model / public-API / dependencies. |
54
+ | `/explore-codebase` | Symbol-level navigation (Serena). |
55
+ | `/refactor-safely` | Bounded-blast-radius refactors via Serena's symbolic edit tools (`rename_symbol`, `replace_symbol_body`, `safe_delete_symbol`). |
56
+ | `/debug-issue` | Stack-trace-driven debugging with Serena. |
57
+
58
+ ---
59
+
60
+ ## What gets created in your project
61
+
62
+ ### Claude Code
63
+
64
+ | Path | Purpose |
65
+ |---|---|
66
+ | `.claude/skills/<name>/` | Skill directories (symlinks into the package) |
67
+ | `.claude/agents/module-runner.md` | Claude-variant module-runner |
68
+ | `.mcp.json` | Serena MCP registration (Claude Code) |
69
+ | `CLAUDE.md`, `AGENTS.md` | Project instructions (symlinked to package `INSTRUCTIONS.md`) |
70
+
71
+ ### Cursor
72
+
73
+ | Path | Purpose |
74
+ |---|---|
75
+ | `.cursor/mcp.json` | Serena MCP registration |
76
+ | `.cursor/rules/serena.mdc` | Always-apply rule: use Serena before grep/read |
77
+ | `.cursor/rules/<skill>.mdc` | One description-triggered rule per skill |
78
+ | `.cursor/subagents/<name>.md` | 6 subagent wrappers used by Cursor-variant `/module-runner` |
79
+
80
+ ### Codex
81
+
82
+ | Path | Purpose |
83
+ |---|---|
84
+ | `AGENTS.md` | Project instructions (shared with Claude Code) |
85
+ | `.codex/rules/default.rules` | Starlark exec policy: allows `npm`, `git`, `node`, `uvx` |
86
+ | `.codex/workflows/module-runner.md` | Codex-variant module-runner (foreground fallback) |
87
+ | `~/.codex/config.toml` | User-level Serena MCP config |
88
+
89
+ ### Project-memory wiring (all IDEs)
90
+
91
+ Run `npm exec nurosys-setup-rules` after `/create-blueprint all` to wire `project-memory/*.md` into IDE rule systems.
92
+
93
+ ---
94
+
95
+ ## Migrating from v1.x (`nurosys-agent-skills`)
96
+
97
+ If you have v1.x installed:
98
+
99
+ 1. `npm uninstall nurosys-agent-skills`
100
+ 2. `npm install --save-dev nurosys-agents`
101
+ 3. `npm exec nurosys-agent-setup` (re-runs setup with new package layout)
102
+ 4. Optional cleanup of old artifacts:
103
+ - `rm scripts/run-feature-modules.sh` (replaced by `/module-runner` skill)
104
+ - Remove `code-review-graph` from MCP configs if present (Serena replaces it)
105
+
106
+ The major changes in v2:
107
+ - **Renamed**: `nurosys-agent-skills` → `nurosys-agents`
108
+ - **Serena replaces code-review-graph** as the MCP
109
+ - **`/architect` never writes code** — its only outputs are planning documents
110
+ - **`/module-runner` replaces `feature-module-runner`** — IDE-native sub-agent orchestration (Task tool / Cursor subagents) instead of a shell script
111
+ - **New skills**: `/brainstorm`, `/quick-execute`, `/security-assessment`
112
+ - **`/auth-and-permissions` is fully generic** — driven entirely by `project-memory/auth-model.md`
113
+ - **Deleted workflows**: `build-feature-backend.workflow.md`, `backend-quality-review.md`, `add-new-api-feature-module.md`, `feature-module-runner.md` (their content absorbed into `/module-runner` or moved to per-project `project-memory/architecture.md`)
114
+
115
+ ---
116
+
117
+ ## Stack support
118
+
119
+ | Stack | Status |
120
+ |---|---|
121
+ | Backend (NestJS / Express / Fastify / Koa) | āœ… First-class (v2.0) |
122
+ | Frontend (React / Next / Vue / Vite) | ā³ Carried over from v1; not yet refreshed for v2 architecture |
123
+ | Monolith | ā³ Same as frontend |
124
+
125
+ Backend is the focus of v2.0. Frontend and monolith updates will follow.
126
+
127
+ ---
128
+
129
+ ## License
130
+
131
+ MIT
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "nurosys-agents",
3
+ "version": "2.0.0",
4
+ "description": "Portable backend agent skills (architect, code-reviewer, security-assessment, auth-and-permissions, brainstorm, quick-execute, create-blueprint) plus a multi-IDE module-runner. Built on Serena for symbolic code analysis. Works with Claude Code, Cursor, and Codex.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://gitlab.com/nurosys/nurosys-agents.git"
8
+ },
9
+ "homepage": "https://gitlab.com/nurosys/nurosys-agents#readme",
10
+ "bugs": {
11
+ "url": "https://gitlab.com/nurosys/nurosys-agents/-/issues"
12
+ },
13
+ "keywords": [
14
+ "claude",
15
+ "agents",
16
+ "skills",
17
+ "code-review",
18
+ "architecture",
19
+ "ai-development",
20
+ "cursor",
21
+ "codex",
22
+ "openai",
23
+ "llm"
24
+ ],
25
+ "author": "Nurosys",
26
+ "license": "MIT",
27
+ "files": [
28
+ ".agent/",
29
+ "scripts/"
30
+ ],
31
+ "bin": {
32
+ "nurosys-agent-setup": "scripts/setup.js",
33
+ "nurosys-setup-rules": "scripts/setup-rules.js"
34
+ },
35
+ "scripts": {
36
+ "setup": "node scripts/setup.js",
37
+ "setup-rules": "node scripts/setup-rules.js"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ }
42
+ }
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Writes MDC rule files from project-memory/ into IDE rule directories.
5
+ *
6
+ * - Cursor → .cursor/rules/<name>.mdc (real files with MDC frontmatter + @file reference)
7
+ * - Antigravity → .agents/rules/<name>.md (symlinks, detected when .agents/ exists)
8
+ *
9
+ * Cursor MDC files contain proper YAML frontmatter so Cursor knows when to apply each rule.
10
+ * The body uses an @filename reference so the live project-memory content is sourced at
11
+ * context-injection time — project-memory files are never inlined here.
12
+ *
13
+ * Usage:
14
+ * node scripts/setup-rules.js # from project root
15
+ * npm exec nurosys-setup-rules # via package bin
16
+ */
17
+
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ const projectRoot = process.cwd();
22
+ const projectMemory = path.join(projectRoot, 'project-memory');
23
+
24
+ // Maps project-memory filename → rule config per IDE
25
+ const RULE_MAP = [
26
+ {
27
+ source: 'constitution.md',
28
+ cursorTarget: 'constitution.mdc',
29
+ antigravityTarget: 'constitution.md',
30
+ description: 'Non-negotiable project rules and coding standards',
31
+ alwaysApply: true,
32
+ },
33
+ {
34
+ source: 'architecture.md',
35
+ cursorTarget: 'architecture.mdc',
36
+ antigravityTarget: 'architecture.md',
37
+ description: 'System architecture, module topology, and data flow',
38
+ alwaysApply: true,
39
+ },
40
+ {
41
+ source: 'repo-map.md',
42
+ cursorTarget: 'repo-map.mdc',
43
+ antigravityTarget: 'repo-map.md',
44
+ description: 'Repository module layout, naming conventions, and reusable components',
45
+ alwaysApply: true,
46
+ },
47
+ {
48
+ source: 'auth-model.md',
49
+ cursorTarget: 'auth-model.mdc',
50
+ antigravityTarget: 'auth-model.md',
51
+ description: 'Auth model, JWT flow, guard chain, RBAC, and tenant scoping',
52
+ globs: ['src/auth/**', 'src/core/auth/**'],
53
+ alwaysApply: false,
54
+ },
55
+ {
56
+ source: 'models.md',
57
+ cursorTarget: 'models.mdc',
58
+ antigravityTarget: 'models.md',
59
+ description: 'Domain model inventory and entity definitions',
60
+ globs: ['src/**/*.model.ts', 'src/**/*.entity.ts'],
61
+ alwaysApply: false,
62
+ },
63
+ {
64
+ source: 'quality-playbook.md',
65
+ cursorTarget: 'quality-playbook.mdc',
66
+ antigravityTarget: 'quality-playbook.md',
67
+ description: 'Code quality patterns, anti-patterns, and preferred fixes for this project',
68
+ alwaysApply: false,
69
+ },
70
+ {
71
+ source: 'core-memory.md',
72
+ cursorTarget: 'core-memory.mdc',
73
+ antigravityTarget: 'core-memory.md',
74
+ description: 'Project history, design decisions, and completed modules',
75
+ alwaysApply: false,
76
+ },
77
+ ];
78
+
79
+ function isSymlink(p) {
80
+ try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; }
81
+ }
82
+
83
+ function buildMdcContent(entry) {
84
+ const lines = ['---'];
85
+ lines.push(`description: "${entry.description}"`);
86
+ if (entry.globs && entry.globs.length) {
87
+ lines.push(`globs: [${entry.globs.map(g => `"${g}"`).join(', ')}]`);
88
+ }
89
+ lines.push(`alwaysApply: ${entry.alwaysApply}`);
90
+ lines.push('---');
91
+ lines.push('');
92
+ lines.push(`@project-memory/${entry.source}`);
93
+ return lines.join('\n') + '\n';
94
+ }
95
+
96
+ function writeCursorRules(rulesDir) {
97
+ let created = 0, updated = 0, skipped = 0, missing = 0;
98
+
99
+ fs.mkdirSync(rulesDir, { recursive: true });
100
+
101
+ for (const entry of RULE_MAP) {
102
+ const sourcePath = path.join(projectMemory, entry.source);
103
+ const targetPath = path.join(rulesDir, entry.cursorTarget);
104
+
105
+ if (!fs.existsSync(sourcePath)) {
106
+ console.log(` āš ļø Skipped ${entry.cursorTarget}: project-memory/${entry.source} not found`);
107
+ missing++;
108
+ continue;
109
+ }
110
+
111
+ const content = buildMdcContent(entry);
112
+
113
+ if (fs.existsSync(targetPath) && !isSymlink(targetPath)) {
114
+ const existing = fs.readFileSync(targetPath, 'utf8');
115
+ if (existing === content) {
116
+ console.log(` āœ… ${entry.cursorTarget} (already up to date)`);
117
+ skipped++;
118
+ continue;
119
+ }
120
+ fs.writeFileSync(targetPath, content);
121
+ console.log(` šŸ”„ ${entry.cursorTarget} (updated frontmatter)`);
122
+ updated++;
123
+ continue;
124
+ }
125
+
126
+ // Remove stale symlink if present
127
+ if (isSymlink(targetPath)) fs.unlinkSync(targetPath);
128
+
129
+ fs.writeFileSync(targetPath, content);
130
+ console.log(` āœ… ${entry.cursorTarget} → @project-memory/${entry.source}`);
131
+ created++;
132
+ }
133
+
134
+ return { created, updated, skipped, missing };
135
+ }
136
+
137
+ function wireAntigravityRules(rulesDir) {
138
+ let created = 0, skipped = 0, missing = 0;
139
+
140
+ fs.mkdirSync(rulesDir, { recursive: true });
141
+
142
+ for (const entry of RULE_MAP) {
143
+ const sourcePath = path.join(projectMemory, entry.source);
144
+ const targetPath = path.join(rulesDir, entry.antigravityTarget);
145
+
146
+ if (!fs.existsSync(sourcePath)) {
147
+ console.log(` āš ļø Skipped ${entry.antigravityTarget}: project-memory/${entry.source} not found`);
148
+ missing++;
149
+ continue;
150
+ }
151
+
152
+ if (isSymlink(targetPath)) {
153
+ console.log(` āœ… ${entry.antigravityTarget} (already linked)`);
154
+ skipped++;
155
+ continue;
156
+ }
157
+
158
+ if (fs.existsSync(targetPath)) {
159
+ console.log(` āš ļø ${entry.antigravityTarget} exists as a real file — skipping`);
160
+ skipped++;
161
+ continue;
162
+ }
163
+
164
+ fs.symlinkSync(path.relative(rulesDir, sourcePath), targetPath);
165
+ console.log(` āœ… ${entry.antigravityTarget} → project-memory/${entry.source}`);
166
+ created++;
167
+ }
168
+
169
+ return { created, skipped, missing };
170
+ }
171
+
172
+ function runSetupRules() {
173
+ console.log('\n── Project-memory rules ──────────────────────────────────────');
174
+
175
+ if (!fs.existsSync(projectMemory)) {
176
+ console.log(' āš ļø project-memory/ not found — skipping rules.');
177
+ console.log(' Run /create-blueprint all, then re-run nurosys-agent-setup.');
178
+ return;
179
+ }
180
+
181
+ let ran = false;
182
+
183
+ // Cursor — .cursor/rules/*.mdc (real files with MDC frontmatter)
184
+ if (fs.existsSync(path.join(projectRoot, '.cursor'))) {
185
+ console.log('\n Cursor (.cursor/rules/*.mdc)');
186
+ const { created, updated, skipped, missing } = writeCursorRules(
187
+ path.join(projectRoot, '.cursor', 'rules')
188
+ );
189
+ console.log(` ${created} created, ${updated} updated, ${skipped} already set, ${missing} missing source`);
190
+ ran = true;
191
+ }
192
+
193
+ // Antigravity — .agents/rules/*.md (symlinks)
194
+ if (fs.existsSync(path.join(projectRoot, '.agents'))) {
195
+ console.log('\n .agents/rules (symlinks from project-memory/)');
196
+ const { created, skipped, missing } = wireAntigravityRules(
197
+ path.join(projectRoot, '.agents', 'rules')
198
+ );
199
+ console.log(` ${created} created, ${skipped} already set, ${missing} missing source`);
200
+ ran = true;
201
+ }
202
+
203
+ // Codex — .codex/rules/ uses Starlark execution policy, not markdown context files.
204
+ // Project-memory context is already available via AGENTS.md (created by nurosys-agent-setup).
205
+ if (fs.existsSync(path.join(projectRoot, '.codex'))) {
206
+ console.log('\n Codex (.codex/rules/): Starlark execution policy only — project-memory wired via AGENTS.md.');
207
+ ran = true;
208
+ }
209
+
210
+ if (!ran) return;
211
+
212
+ const totalMissing = RULE_MAP.filter(e => !fs.existsSync(path.join(projectMemory, e.source))).length;
213
+ if (totalMissing > 0) {
214
+ console.log(`\n ā„¹ļø ${totalMissing} project-memory files not yet generated.`);
215
+ console.log(' Run /create-blueprint all to generate them.');
216
+ }
217
+ }
218
+
219
+ if (require.main === module) {
220
+ console.log('šŸ”§ Setting up IDE rules from project-memory/\n');
221
+ runSetupRules();
222
+ }
223
+
224
+ module.exports = { runSetupRules };