@exchanet/enet 1.0.4 → 1.0.7

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.
@@ -0,0 +1,136 @@
1
+ # METHOD REFLEX — Agent Instructions
2
+ > Universal Modular Architecture · v1.0.0 · @exchanet
3
+
4
+ ---
5
+
6
+ ## YOUR PRIMARY DIRECTIVE / TU DIRECTIVA PRINCIPAL
7
+
8
+ You are building a modular application using Method REFLEX. Every module you create must be self-describing via a `manifest.json` file. The manifest is written **before any code**. The system reads manifests to automatically generate the Admin Panel, dashboard, and settings UI. You never manually wire backend logic to the Admin Panel — the manifest does it.
9
+
10
+ Estás construyendo una aplicación modular usando Method REFLEX. Cada módulo que crees debe ser auto-descriptivo a través de un archivo `manifest.json`. El manifest se escribe **antes de cualquier código**. El sistema lee los manifests para generar automáticamente el Panel Admin, dashboard y UI de configuración. Nunca cablearás manualmente la lógica backend al Panel Admin — el manifest lo hace.
11
+
12
+ **If a module has no manifest, it does not exist.**
13
+ **Si un módulo no tiene manifest, no existe.**
14
+
15
+ ---
16
+
17
+ ## ABSOLUTE RULES / REGLAS ABSOLUTAS
18
+
19
+ 1. **No manifest = module does not exist.** Core rejects modules without valid `manifest.json`.
20
+ 2. **Manifest before code.** Complete manifest before any handler, model, or component.
21
+ 3. **Zero hardcoded configuration.** Every configurable value lives in `manifest.settings`, read via `context.settings.get("key")`.
22
+ 4. **Core has no business logic.** Domain logic lives in modules only.
23
+ 5. **Admin Panel is a renderer.** Never code it to show a specific module — modules declare capabilities, Admin Panel renders them.
24
+ 6. **A module is complete only when the Admin Panel reflects it correctly.**
25
+ 7. **Removing a module folder requires zero code changes elsewhere.**
26
+
27
+ ---
28
+
29
+ ## WORKFLOW / FLUJO DE TRABAJO
30
+
31
+ ### Starting a new project / Nuevo proyecto:
32
+ 1. Ask for spectech if not provided (stack, database, deploy target)
33
+ 2. Declare the architecture you will build
34
+ 3. **Wait for confirmation before writing any code**
35
+ 4. Build Core → Manifest schema → Modules → Admin Panel
36
+
37
+ ### Adding a module / Añadir un módulo:
38
+ 1. Write complete `manifest.json` (all settings + capabilities + hooks)
39
+ 2. Validate against `manifest.schema.json`
40
+ 3. Implement all handlers referenced in manifest
41
+ 4. Place in modules directory (Core discovers automatically)
42
+ 5. Boot system and verify module appears in Admin Panel
43
+ 6. Build custom UI components only if manifest declares a `component` field
44
+
45
+ ### When you cannot complete a manifest / Cuando no puedes completar un manifest:
46
+
47
+ **STOP. Ask the user:**
48
+
49
+ ```
50
+ "I cannot complete the manifest for [module name] because I don't understand
51
+ [specific aspect]. Before I continue, I need you to clarify: [specific question]"
52
+
53
+ "No puedo completar el manifest de [nombre del módulo] porque no entiendo
54
+ [aspecto específico]. Antes de continuar, necesito que aclares: [pregunta específica]"
55
+ ```
56
+
57
+ Do not proceed. Do not create a partial manifest. Do not make assumptions. Wait.
58
+ No continúes. No crees un manifest parcial. No hagas suposiciones. Espera.
59
+
60
+ ---
61
+
62
+ ## MANIFEST FORMAT / FORMATO DEL MANIFEST
63
+
64
+ ```json
65
+ {
66
+ "id": "module-id",
67
+ "name": "Human Name",
68
+ "version": "1.0.0",
69
+ "type": "functional",
70
+ "section": "admin-section",
71
+ "dependencies": [],
72
+ "hooks": { "event.name": "ClassName.method" },
73
+ "settings": {
74
+ "key": {
75
+ "type": "integer|string|boolean|select",
76
+ "label": "Label",
77
+ "default": null,
78
+ "ui": "slider|toggle|text|select"
79
+ }
80
+ },
81
+ "capabilities": [
82
+ { "type": "view", "label": "Label", "data": "ClassName.method" },
83
+ { "type": "action", "label": "Label", "handler": "ClassName.method", "dangerous": false },
84
+ { "type": "metric", "label": "Label", "data": "ClassName.method" },
85
+ { "type": "widget", "label": "Label", "data": "ClassName.method", "component": "ComponentName" }
86
+ ]
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ## WHAT THE CORE MUST IMPLEMENT / QUÉ DEBE IMPLEMENTAR EL CORE
93
+
94
+ - Module discovery — scan modules dir for valid manifests
95
+ - Manifest validation — reject invalid manifests with clear errors (never silent)
96
+ - Dependency resolution — boot in correct order
97
+ - Handler registry — map `ClassName.method` references to implementations
98
+ - Hook system — dispatch events to declared handlers
99
+ - Settings store — persistent, namespaced by module ID, initialized from defaults
100
+ - REFLEX engine — read all manifests, build Admin nav, dashboard, settings schemas
101
+ - Admin API — standard endpoints (same in every project, every stack)
102
+
103
+ ```
104
+ GET /api/admin/manifest-registry
105
+ GET /api/admin/navigation
106
+ GET /api/admin/settings/:moduleId
107
+ POST /api/admin/settings/:moduleId
108
+ GET /api/admin/dashboard
109
+ POST /api/admin/action/:moduleId/:actionId
110
+ GET /api/admin/health
111
+ ```
112
+
113
+ **The Core has ZERO business logic. / El Core tiene CERO lógica de negocio.**
114
+
115
+ ---
116
+
117
+ ## COMPLETION CHECKLIST / CHECKLIST DE COMPLETITUD
118
+
119
+ Before marking any module complete / Antes de marcar cualquier módulo como completo:
120
+
121
+ - [ ] `manifest.json` valid / válido
122
+ - [ ] All declared handlers implemented / Todos los handlers declarados implementados
123
+ - [ ] Zero hardcoded values — all settings use `context.settings.get()` / Cero hardcoded
124
+ - [ ] Module appears in Admin Panel navigation / El módulo aparece en la navegación del Panel Admin
125
+ - [ ] All views render with data / Todas las vistas renderizan con datos
126
+ - [ ] All actions execute correctly / Todas las acciones ejecutan correctamente
127
+ - [ ] Dangerous actions show confirmation dialog / Las acciones peligrosas muestran diálogo
128
+ - [ ] All metrics show in dashboard / Todas las métricas aparecen en el dashboard
129
+ - [ ] All settings render and save correctly / Todos los settings renderizan y guardan
130
+ - [ ] Adding this module required zero Core changes / Añadir el módulo requirió cero cambios en el Core
131
+ - [ ] Removing module folder removes it completely from Admin Panel / Eliminar la carpeta lo elimina del Panel Admin
132
+
133
+ ---
134
+
135
+ *For full documentation / Para documentación completa: `METHOD.md`*
136
+ *Method REFLEX v1.0.0 · @exchanet · MIT*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exchanet/enet",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "enet — exchanet methods manager. Install, scaffold and manage AI coding methods.",
5
5
  "bin": {
6
6
  "enet": "src/index.js"
@@ -2,11 +2,11 @@ import chalk from 'chalk'
2
2
  import ora from 'ora'
3
3
  import fs from 'fs-extra'
4
4
  import path from 'path'
5
- import { detectAgent, getInstallPath, AGENTS } from '../utils/agent-detector.js'
6
- import { getMethod } from '../utils/registry.js'
7
- import { fetchFromGitHub } from '../utils/registry.js'
5
+ import { detectSystemAgents, getInstallPath, AGENTS } from '../utils/agent-detector.js'
6
+ import { getMethod, fetchFromGitHub } from '../utils/registry.js'
8
7
 
9
8
  export async function installCommand(methodId, options) {
9
+ // Load method from registry
10
10
  const spinner = ora('Fetching registry...').start()
11
11
  const method = await getMethod(methodId).catch(() => null)
12
12
  spinner.stop()
@@ -17,40 +17,92 @@ export async function installCommand(methodId, options) {
17
17
  process.exit(1)
18
18
  }
19
19
 
20
- // Detect or force agent
21
- let agent
20
+ // Determine target agents
21
+ let targetAgents = []
22
+
22
23
  if (options.agent) {
24
+ // --agent flag: install for a specific agent only
23
25
  if (!AGENTS[options.agent]) {
24
26
  console.log(chalk.red(` ✗ Unknown agent: "${options.agent}"`))
25
- console.log(chalk.dim(` Valid: cursor, windsurf, copilot, generic\n`))
27
+ console.log(chalk.dim(` Valid: ${Object.keys(AGENTS).filter(k => k !== 'generic').join(', ')}\n`))
26
28
  process.exit(1)
27
29
  }
28
- agent = { key: options.agent, ...AGENTS[options.agent] }
30
+ targetAgents = [{ key: options.agent, ...AGENTS[options.agent] }]
31
+
29
32
  } else {
30
- agent = await detectAgent()
33
+ // Detect all agents installed on the system
34
+ const detected = await detectSystemAgents()
35
+
36
+ if (detected.length === 0) {
37
+ console.log(chalk.yellow(' ⚠ No AI agents detected on this system.'))
38
+ console.log(chalk.dim(` Use ${chalk.white('--agent <name>')} to force an agent.`))
39
+ console.log(chalk.dim(` Valid: cursor, windsurf, antigravity, claudecode, copilot, generic\n`))
40
+ process.exit(1)
41
+ }
42
+
43
+ if (detected.length === 1 || options.global) {
44
+ // Only one detected, or --global flag: install for all without asking
45
+ targetAgents = detected
46
+ } else {
47
+ // Multiple agents detected: ask the user
48
+ console.log(chalk.white(`\n Detected ${detected.length} agents on this system:\n`))
49
+ detected.forEach((a, i) => console.log(chalk.dim(` [${i + 1}] ${a.name}`)))
50
+ console.log(chalk.dim(` [${detected.length + 1}] All of the above\n`))
51
+
52
+ const { createInterface } = await import('readline')
53
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
54
+ const answer = await new Promise(resolve => {
55
+ rl.question(chalk.white(' Install for which agent(s)? '), resolve)
56
+ })
57
+ rl.close()
58
+
59
+ const choice = parseInt(answer.trim())
60
+ if (choice === detected.length + 1) {
61
+ targetAgents = detected
62
+ } else if (choice >= 1 && choice <= detected.length) {
63
+ targetAgents = [detected[choice - 1]]
64
+ } else {
65
+ console.log(chalk.red('\n Invalid choice. Cancelled.\n'))
66
+ process.exit(1)
67
+ }
68
+ }
31
69
  }
32
70
 
33
- console.log(chalk.dim(` Method : ${chalk.white(method.name)}`))
34
- console.log(chalk.dim(` Agent : ${chalk.white(agent.name)}${options.agent ? '' : chalk.dim(' (auto-detected)')}`))
35
- console.log(chalk.dim(` Source : ${chalk.white(`github.com/${method.repo}`)}\n`))
71
+ console.log()
36
72
 
37
- const fetchSpinner = ora(`Fetching adapter...`).start()
73
+ // Install for each target agent
74
+ let schemaInstalled = false
75
+ for (const agent of targetAgents) {
76
+ await installForAgent(method, agent, options, schemaInstalled)
77
+ schemaInstalled = true // only install schema once
78
+ }
79
+
80
+ printHints(methodId)
81
+ }
82
+
83
+ async function installForAgent(method, agent, options, skipExtras = false) {
84
+ const isGlobal = options.global || false
85
+ const adapterKey = method.adapters[agent.key] ? agent.key : 'generic'
86
+ const adapterPath = method.adapters[adapterKey]
87
+
88
+ if (isGlobal && !agent.globalInstallDir) {
89
+ console.log(chalk.yellow(` ⚠ ${agent.name} does not support global install — skipping`))
90
+ return
91
+ }
92
+
93
+ const spinner = ora(`Installing for ${agent.name}${isGlobal ? ' (global)' : ''}...`).start()
38
94
 
39
95
  try {
40
- const adapterPath = method.adapters[agent.key] ?? method.adapters.generic
41
96
  const content = await fetchFromGitHub(method.repo, adapterPath)
42
-
43
- const installPath = options.global
44
- ? path.join(process.env.HOME || process.env.USERPROFILE, '.enet', `${methodId}.md`)
45
- : getInstallPath(agent, methodId)
97
+ const installPath = getInstallPath(agent, method.id, { global: isGlobal })
46
98
 
47
99
  await fs.ensureDir(path.dirname(installPath))
48
100
 
49
- // Windsurf appends, others overwrite
101
+ // Windsurf global appends to global_rules.md
50
102
  if (agent.key === 'windsurf' && await fs.pathExists(installPath)) {
51
103
  const existing = await fs.readFile(installPath, 'utf8')
52
104
  if (existing.includes(method.name)) {
53
- fetchSpinner.warn(chalk.yellow(`${method.name} already installed`))
105
+ spinner.warn(chalk.yellow(`${agent.name} already installed`))
54
106
  return
55
107
  }
56
108
  await fs.appendFile(installPath, `\n\n---\n\n${content}`)
@@ -58,32 +110,29 @@ export async function installCommand(methodId, options) {
58
110
  await fs.writeFile(installPath, content)
59
111
  }
60
112
 
61
- fetchSpinner.succeed(chalk.green(`${method.name} installed`))
62
- console.log(chalk.dim(` → ${path.relative(process.cwd(), installPath)}`))
113
+ spinner.succeed(chalk.green(`${agent.name} installed`))
114
+ console.log(chalk.dim(` → ${installPath}`))
63
115
  console.log(chalk.dim(` ${agent.configNote}\n`))
64
116
 
65
- // Download extras (e.g. manifest.schema.json for modular-design)
66
- if (method.extras) {
67
- for (const [key, filePath] of Object.entries(method.extras)) {
68
- const extraSpinner = ora(`Fetching ${key}...`).start()
69
- try {
70
- const extraContent = await fetchFromGitHub(method.repo, filePath)
71
- const extraOut = path.join(process.cwd(), path.basename(filePath))
72
- await fs.writeFile(extraOut, extraContent)
73
- extraSpinner.succeed(chalk.dim(`${key} → ${path.basename(filePath)}`))
74
- } catch {
75
- extraSpinner.warn(chalk.dim(`${key} not available (non-critical)`))
76
- }
117
+ } catch (err) {
118
+ spinner.fail(chalk.red(`${agent.name} — ${err.message}`))
119
+ return
120
+ }
121
+
122
+ // Download extras (schema, etc.) once
123
+ if (!skipExtras && method.extras) {
124
+ for (const [key, filePath] of Object.entries(method.extras)) {
125
+ const extraSpinner = ora(`Fetching ${key}...`).start()
126
+ try {
127
+ const extraContent = await fetchFromGitHub(method.repo, filePath)
128
+ const extraOut = path.join(process.cwd(), path.basename(filePath))
129
+ await fs.writeFile(extraOut, extraContent)
130
+ extraSpinner.succeed(chalk.dim(`${key} → ${path.basename(filePath)}`))
131
+ } catch {
132
+ extraSpinner.warn(chalk.dim(`${key} not available (non-critical)`))
77
133
  }
78
- console.log()
79
134
  }
80
-
81
- printHints(methodId)
82
-
83
- } catch (err) {
84
- fetchSpinner.fail(chalk.red(`Failed: ${err.message}`))
85
- console.log(chalk.dim(' Check your internet connection and try again.\n'))
86
- process.exit(1)
135
+ console.log()
87
136
  }
88
137
  }
89
138
 
@@ -95,7 +144,7 @@ function printHints(methodId) {
95
144
  console.log(chalk.dim(` 3. Agent builds Core → modules → Admin Panel`))
96
145
  console.log()
97
146
  console.log(chalk.dim(` ${chalk.white('enet new module <name>')} scaffold your first module`))
98
- console.log(chalk.dim(` ${chalk.white('enet validate')} check manifests at any time\n`))
147
+ console.log(chalk.dim(` ${chalk.white('enet validate')} check manifests at any time\n`))
99
148
  }
100
149
  if (methodId === 'pdca-t') {
101
150
  console.log(chalk.dim(` PDCA-T adds quality validation to your workflow.`))
@@ -1,70 +1,127 @@
1
1
  import fs from 'fs-extra'
2
2
  import path from 'path'
3
+ import os from 'os'
4
+
5
+ const HOME = os.homedir()
3
6
 
4
7
  export const AGENTS = {
5
8
  cursor: {
6
9
  name: 'Cursor',
7
- signals: ['.cursor'],
8
- installDir: '.cursor/rules',
10
+ systemSignals: [
11
+ path.join(HOME, '.cursor')
12
+ ],
13
+ projectSignals: ['.cursor/rules', '.cursor'],
14
+ projectInstallDir: '.cursor/rules',
15
+ globalInstallDir: path.join(HOME, '.cursor', 'rules'),
9
16
  filename: 'enet-{id}.md',
10
17
  configNote: 'Rule auto-applies to all files (alwaysApply: true)'
11
18
  },
12
19
  windsurf: {
13
20
  name: 'Windsurf',
14
- signals: ['.windsurfrules', '.windsurf'],
15
- installDir: '.',
21
+ systemSignals: [
22
+ path.join(HOME, '.codeium', 'windsurf')
23
+ ],
24
+ projectSignals: ['.windsurfrules', '.windsurf'],
25
+ projectInstallDir: '.',
26
+ globalInstallDir: path.join(HOME, '.codeium', 'windsurf', 'memories'),
27
+ globalFilename: 'global_rules.md',
16
28
  filename: '.windsurfrules',
17
- configNote: 'Appended to .windsurfrules'
18
- },
19
- copilot: {
20
- name: 'GitHub Copilot',
21
- signals: ['.github/copilot-instructions.md', '.github'],
22
- installDir: '.github',
23
- filename: 'copilot-instructions.md',
24
- configNote: 'Written to .github/copilot-instructions.md'
29
+ configNote: 'Appended to global_rules.md'
25
30
  },
26
31
  antigravity: {
27
32
  name: 'Antigravity (Google)',
28
- signals: ['.agent/rules', '.agent'],
29
- installDir: '.agent/rules',
33
+ systemSignals: [
34
+ path.join(HOME, '.gemini', 'antigravity')
35
+ ],
36
+ projectSignals: ['.agent/rules', '.agent'],
37
+ projectInstallDir: '.agent/rules',
38
+ globalInstallDir: path.join(HOME, '.gemini', 'antigravity', 'skills', 'method-modular-design'),
39
+ globalFilename: 'SKILL.md',
30
40
  filename: 'enet-{id}.md',
31
- configNote: 'Rule saved to .agent/rules/ — set activation to Always On in Antigravity'
41
+ configNote: 'Skill saved — set activation to Always On in Antigravity'
32
42
  },
33
43
  claudecode: {
34
44
  name: 'Claude Code',
35
- signals: ['CLAUDE.md', '.claude'],
36
- installDir: '.',
45
+ systemSignals: [
46
+ path.join(HOME, '.claude')
47
+ ],
48
+ projectSignals: ['CLAUDE.md', '.claude'],
49
+ projectInstallDir: '.',
50
+ globalInstallDir: path.join(HOME, '.claude'),
51
+ globalFilename: 'CLAUDE.md',
37
52
  filename: 'CLAUDE.md',
38
- configNote: 'Written to CLAUDE.md — Claude Code reads this file automatically'
53
+ configNote: 'Written to ~/.claude/CLAUDE.md — Claude Code reads this automatically'
54
+ },
55
+ copilot: {
56
+ name: 'GitHub Copilot',
57
+ systemSignals: [],
58
+ projectSignals: ['.github/copilot-instructions.md'],
59
+ projectInstallDir: '.github',
60
+ globalInstallDir: null,
61
+ filename: 'copilot-instructions.md',
62
+ configNote: 'Written to .github/copilot-instructions.md'
39
63
  },
40
64
  generic: {
41
65
  name: 'Generic Agent',
42
- signals: [],
43
- installDir: '.enet',
66
+ systemSignals: [],
67
+ projectSignals: [],
68
+ projectInstallDir: '.enet',
69
+ globalInstallDir: null,
44
70
  filename: '{id}.md',
45
71
  configNote: 'Saved to .enet/ — paste contents into your agent\'s context'
46
72
  }
47
73
  }
48
74
 
49
75
  /**
50
- * Detects which AI agent is active in the current project.
76
+ * Detects ALL agents installed on the system by checking known global paths.
51
77
  */
52
- export async function detectAgent(cwd = process.cwd()) {
78
+ export async function detectSystemAgents() {
79
+ const found = []
53
80
  for (const [key, agent] of Object.entries(AGENTS)) {
54
81
  if (key === 'generic') continue
55
- for (const signal of agent.signals) {
82
+ for (const signal of agent.systemSignals) {
83
+ if (await fs.pathExists(signal)) {
84
+ found.push({ key, ...agent })
85
+ break
86
+ }
87
+ }
88
+ }
89
+ return found
90
+ }
91
+
92
+ /**
93
+ * Detects ALL agents present in the current project.
94
+ */
95
+ export async function detectProjectAgents(cwd = process.cwd()) {
96
+ const found = []
97
+ for (const [key, agent] of Object.entries(AGENTS)) {
98
+ if (key === 'generic') continue
99
+ for (const signal of agent.projectSignals) {
56
100
  if (await fs.pathExists(path.join(cwd, signal))) {
57
- return { key, ...agent }
101
+ found.push({ key, ...agent })
102
+ break
58
103
  }
59
104
  }
60
105
  }
61
- return { key: 'generic', ...AGENTS.generic }
106
+ return found
62
107
  }
63
108
 
64
109
  /**
65
- * Returns the full install path for a method adapter.
110
+ * Returns the first detected agent (legacy, used by status/doctor).
66
111
  */
67
- export function getInstallPath(agent, methodId, cwd = process.cwd()) {
112
+ export async function detectAgent(cwd = process.cwd()) {
113
+ const agents = await detectProjectAgents(cwd)
114
+ return agents[0] ?? { key: 'generic', ...AGENTS.generic }
115
+ }
116
+
117
+ /**
118
+ * Returns the install path for a method adapter.
119
+ */
120
+ export function getInstallPath(agent, methodId, { global = false, cwd = process.cwd() } = {}) {
121
+ if (global) {
122
+ const filename = agent.globalFilename ?? agent.filename.replace('{id}', methodId)
123
+ return path.join(agent.globalInstallDir, filename)
124
+ }
68
125
  const filename = agent.filename.replace('{id}', methodId)
69
- return path.join(cwd, agent.installDir, filename)
126
+ return path.join(cwd, agent.projectInstallDir, filename)
70
127
  }