@l4yercak3/cli 1.3.1 → 2.0.0-alpha.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.
- package/README.md +10 -220
- package/dist/api/client.d.ts +12 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +37 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/platform.d.ts +161 -0
- package/dist/api/platform.d.ts.map +1 -0
- package/dist/api/platform.js +70 -0
- package/dist/api/platform.js.map +1 -0
- package/dist/bin/sevenlayers.d.ts +3 -0
- package/dist/bin/sevenlayers.d.ts.map +1 -0
- package/dist/bin/sevenlayers.js +198 -0
- package/dist/bin/sevenlayers.js.map +1 -0
- package/dist/commands/agent/catalog.d.ts +5 -0
- package/dist/commands/agent/catalog.d.ts.map +1 -0
- package/dist/commands/agent/catalog.js +142 -0
- package/dist/commands/agent/catalog.js.map +1 -0
- package/dist/commands/agent/drift.d.ts +5 -0
- package/dist/commands/agent/drift.d.ts.map +1 -0
- package/dist/commands/agent/drift.js +113 -0
- package/dist/commands/agent/drift.js.map +1 -0
- package/dist/commands/agent/init.d.ts +5 -0
- package/dist/commands/agent/init.d.ts.map +1 -0
- package/dist/commands/agent/init.js +75 -0
- package/dist/commands/agent/init.js.map +1 -0
- package/dist/commands/agent/permissions.d.ts +5 -0
- package/dist/commands/agent/permissions.d.ts.map +1 -0
- package/dist/commands/agent/permissions.js +88 -0
- package/dist/commands/agent/permissions.js.map +1 -0
- package/dist/commands/agent/runner.d.ts +14 -0
- package/dist/commands/agent/runner.d.ts.map +1 -0
- package/dist/commands/agent/runner.js +59 -0
- package/dist/commands/agent/runner.js.map +1 -0
- package/dist/commands/agent/shared.d.ts +13 -0
- package/dist/commands/agent/shared.d.ts.map +1 -0
- package/dist/commands/agent/shared.js +31 -0
- package/dist/commands/agent/shared.js.map +1 -0
- package/dist/commands/agent/template.d.ts +5 -0
- package/dist/commands/agent/template.d.ts.map +1 -0
- package/dist/commands/agent/template.js +104 -0
- package/dist/commands/agent/template.js.map +1 -0
- package/dist/commands/app/connect.d.ts +7 -0
- package/dist/commands/app/connect.d.ts.map +1 -0
- package/dist/commands/app/connect.js +12 -0
- package/dist/commands/app/connect.js.map +1 -0
- package/dist/commands/app/init.d.ts +7 -0
- package/dist/commands/app/init.d.ts.map +1 -0
- package/dist/commands/app/init.js +12 -0
- package/dist/commands/app/init.js.map +1 -0
- package/dist/commands/app/link.d.ts +3 -0
- package/dist/commands/app/link.d.ts.map +1 -0
- package/dist/commands/app/link.js +92 -0
- package/dist/commands/app/link.js.map +1 -0
- package/dist/commands/app/pages.d.ts +15 -0
- package/dist/commands/app/pages.d.ts.map +1 -0
- package/dist/commands/app/pages.js +180 -0
- package/dist/commands/app/pages.js.map +1 -0
- package/dist/commands/app/register.d.ts +3 -0
- package/dist/commands/app/register.d.ts.map +1 -0
- package/dist/commands/app/register.js +120 -0
- package/dist/commands/app/register.js.map +1 -0
- package/dist/commands/app/remote.d.ts +14 -0
- package/dist/commands/app/remote.d.ts.map +1 -0
- package/dist/commands/app/remote.js +44 -0
- package/dist/commands/app/remote.js.map +1 -0
- package/dist/commands/app/setup.d.ts +3 -0
- package/dist/commands/app/setup.d.ts.map +1 -0
- package/dist/commands/app/setup.js +299 -0
- package/dist/commands/app/setup.js.map +1 -0
- package/dist/commands/app/shared.d.ts +9 -0
- package/dist/commands/app/shared.d.ts.map +1 -0
- package/dist/commands/app/shared.js +122 -0
- package/dist/commands/app/shared.js.map +1 -0
- package/dist/commands/app/sync.d.ts +7 -0
- package/dist/commands/app/sync.d.ts.map +1 -0
- package/dist/commands/app/sync.js +107 -0
- package/dist/commands/app/sync.js.map +1 -0
- package/dist/commands/booking/check.d.ts +3 -0
- package/dist/commands/booking/check.d.ts.map +1 -0
- package/dist/commands/booking/check.js +68 -0
- package/dist/commands/booking/check.js.map +1 -0
- package/dist/commands/booking/setup.d.ts +3 -0
- package/dist/commands/booking/setup.d.ts.map +1 -0
- package/dist/commands/booking/setup.js +95 -0
- package/dist/commands/booking/setup.js.map +1 -0
- package/dist/commands/booking/shared.d.ts +31 -0
- package/dist/commands/booking/shared.d.ts.map +1 -0
- package/dist/commands/booking/shared.js +112 -0
- package/dist/commands/booking/shared.js.map +1 -0
- package/dist/commands/booking/smoke.d.ts +3 -0
- package/dist/commands/booking/smoke.d.ts.map +1 -0
- package/dist/commands/booking/smoke.js +101 -0
- package/dist/commands/booking/smoke.js.map +1 -0
- package/dist/commands/cms/bind.d.ts +3 -0
- package/dist/commands/cms/bind.d.ts.map +1 -0
- package/dist/commands/cms/bind.js +212 -0
- package/dist/commands/cms/bind.js.map +1 -0
- package/dist/commands/cms/content.d.ts +40 -0
- package/dist/commands/cms/content.d.ts.map +1 -0
- package/dist/commands/cms/content.js +169 -0
- package/dist/commands/cms/content.js.map +1 -0
- package/dist/commands/cms/doctor.d.ts +3 -0
- package/dist/commands/cms/doctor.d.ts.map +1 -0
- package/dist/commands/cms/doctor.js +69 -0
- package/dist/commands/cms/doctor.js.map +1 -0
- package/dist/commands/cms/migrate.d.ts +3 -0
- package/dist/commands/cms/migrate.d.ts.map +1 -0
- package/dist/commands/cms/migrate.js +78 -0
- package/dist/commands/cms/migrate.js.map +1 -0
- package/dist/commands/cms/registry.d.ts +3 -0
- package/dist/commands/cms/registry.d.ts.map +1 -0
- package/dist/commands/cms/registry.js +161 -0
- package/dist/commands/cms/registry.js.map +1 -0
- package/dist/commands/cms/seed.d.ts +3 -0
- package/dist/commands/cms/seed.d.ts.map +1 -0
- package/dist/commands/cms/seed.js +102 -0
- package/dist/commands/cms/seed.js.map +1 -0
- package/dist/commands/cms/shared.d.ts +22 -0
- package/dist/commands/cms/shared.d.ts.map +1 -0
- package/dist/commands/cms/shared.js +82 -0
- package/dist/commands/cms/shared.js.map +1 -0
- package/dist/commands/doctor/target.d.ts +3 -0
- package/dist/commands/doctor/target.d.ts.map +1 -0
- package/dist/commands/doctor/target.js +46 -0
- package/dist/commands/doctor/target.js.map +1 -0
- package/dist/commands/env/list.d.ts +3 -0
- package/dist/commands/env/list.d.ts.map +1 -0
- package/dist/commands/env/list.js +28 -0
- package/dist/commands/env/list.js.map +1 -0
- package/dist/commands/env/set.d.ts +3 -0
- package/dist/commands/env/set.d.ts.map +1 -0
- package/dist/commands/env/set.js +36 -0
- package/dist/commands/env/set.js.map +1 -0
- package/dist/commands/env/use.d.ts +3 -0
- package/dist/commands/env/use.d.ts.map +1 -0
- package/dist/commands/env/use.js +15 -0
- package/dist/commands/env/use.js.map +1 -0
- package/dist/commands/legacy/connect.d.ts +3 -0
- package/dist/commands/legacy/connect.d.ts.map +1 -0
- package/dist/commands/legacy/connect.js +8 -0
- package/dist/commands/legacy/connect.js.map +1 -0
- package/dist/commands/legacy/pages.d.ts +3 -0
- package/dist/commands/legacy/pages.d.ts.map +1 -0
- package/dist/commands/legacy/pages.js +16 -0
- package/dist/commands/legacy/pages.js.map +1 -0
- package/dist/commands/legacy/spread.d.ts +3 -0
- package/dist/commands/legacy/spread.d.ts.map +1 -0
- package/dist/commands/legacy/spread.js +8 -0
- package/dist/commands/legacy/spread.js.map +1 -0
- package/dist/commands/legacy/sync.d.ts +3 -0
- package/dist/commands/legacy/sync.d.ts.map +1 -0
- package/dist/commands/legacy/sync.js +8 -0
- package/dist/commands/legacy/sync.js.map +1 -0
- package/dist/config/env-diff.d.ts +10 -0
- package/dist/config/env-diff.d.ts.map +1 -0
- package/dist/config/env-diff.js +24 -0
- package/dist/config/env-diff.js.map +1 -0
- package/dist/config/env-parser.d.ts +20 -0
- package/dist/config/env-parser.d.ts.map +1 -0
- package/dist/config/env-parser.js +70 -0
- package/dist/config/env-parser.js.map +1 -0
- package/dist/config/env-writer.d.ts +22 -0
- package/dist/config/env-writer.d.ts.map +1 -0
- package/dist/config/env-writer.js +172 -0
- package/dist/config/env-writer.js.map +1 -0
- package/dist/config/profile-store.d.ts +29 -0
- package/dist/config/profile-store.d.ts.map +1 -0
- package/dist/config/profile-store.js +257 -0
- package/dist/config/profile-store.js.map +1 -0
- package/dist/core/args.d.ts +11 -0
- package/dist/core/args.d.ts.map +1 -0
- package/dist/core/args.js +106 -0
- package/dist/core/args.js.map +1 -0
- package/dist/core/colors.d.ts +6 -0
- package/dist/core/colors.d.ts.map +1 -0
- package/dist/core/colors.js +29 -0
- package/dist/core/colors.js.map +1 -0
- package/dist/safety/target-guard.d.ts +16 -0
- package/dist/safety/target-guard.d.ts.map +1 -0
- package/dist/safety/target-guard.js +55 -0
- package/dist/safety/target-guard.js.map +1 -0
- package/dist/testing/booking-smoke.d.ts +17 -0
- package/dist/testing/booking-smoke.d.ts.map +1 -0
- package/dist/testing/booking-smoke.js +43 -0
- package/dist/testing/booking-smoke.js.map +1 -0
- package/dist/tests/agent-commands.test.d.ts +2 -0
- package/dist/tests/agent-commands.test.d.ts.map +1 -0
- package/dist/tests/agent-commands.test.js +180 -0
- package/dist/tests/agent-commands.test.js.map +1 -0
- package/dist/tests/agent-governance.test.d.ts +2 -0
- package/dist/tests/agent-governance.test.d.ts.map +1 -0
- package/dist/tests/agent-governance.test.js +233 -0
- package/dist/tests/agent-governance.test.js.map +1 -0
- package/dist/tests/app-commands.test.d.ts +2 -0
- package/dist/tests/app-commands.test.d.ts.map +1 -0
- package/dist/tests/app-commands.test.js +462 -0
- package/dist/tests/app-commands.test.js.map +1 -0
- package/dist/tests/booking-commands.test.d.ts +2 -0
- package/dist/tests/booking-commands.test.d.ts.map +1 -0
- package/dist/tests/booking-commands.test.js +204 -0
- package/dist/tests/booking-commands.test.js.map +1 -0
- package/dist/tests/booking-smoke.test.d.ts +2 -0
- package/dist/tests/booking-smoke.test.d.ts.map +1 -0
- package/dist/tests/booking-smoke.test.js +183 -0
- package/dist/tests/booking-smoke.test.js.map +1 -0
- package/dist/tests/cms-commands.test.d.ts +2 -0
- package/dist/tests/cms-commands.test.d.ts.map +1 -0
- package/dist/tests/cms-commands.test.js +254 -0
- package/dist/tests/cms-commands.test.js.map +1 -0
- package/dist/tests/cms-ops.test.d.ts +2 -0
- package/dist/tests/cms-ops.test.d.ts.map +1 -0
- package/dist/tests/cms-ops.test.js +125 -0
- package/dist/tests/cms-ops.test.js.map +1 -0
- package/dist/tests/env-writer.test.d.ts +2 -0
- package/dist/tests/env-writer.test.d.ts.map +1 -0
- package/dist/tests/env-writer.test.js +90 -0
- package/dist/tests/env-writer.test.js.map +1 -0
- package/dist/tests/profile-store.test.d.ts +2 -0
- package/dist/tests/profile-store.test.d.ts.map +1 -0
- package/dist/tests/profile-store.test.js +88 -0
- package/dist/tests/profile-store.test.js.map +1 -0
- package/dist/tests/target-guard.test.d.ts +2 -0
- package/dist/tests/target-guard.test.d.ts.map +1 -0
- package/dist/tests/target-guard.test.js +132 -0
- package/dist/tests/target-guard.test.js.map +1 -0
- package/dist/ui/logo.d.ts +2 -0
- package/dist/ui/logo.d.ts.map +1 -0
- package/dist/ui/logo.js +22 -0
- package/dist/ui/logo.js.map +1 -0
- package/package.json +17 -53
- package/.claude/settings.local.json +0 -36
- package/.cursor/rules.md +0 -203
- package/.eslintrc.js +0 -31
- package/CLAUDE.md +0 -100
- package/bin/cli.js +0 -116
- package/docs/ADDING_FRAMEWORK_DETECTORS.md +0 -391
- package/docs/ADDING_NEW_PROJECT_TYPE.md +0 -156
- package/docs/ARCHITECTURE_RELATIONSHIPS.md +0 -411
- package/docs/CLI_AUTHENTICATION.md +0 -214
- package/docs/CLI_PAGE_DETECTION_REQUIREMENTS.md +0 -519
- package/docs/CRM-PIPELINES-SEQUENCES-SPEC.md +0 -429
- package/docs/DETECTOR_ARCHITECTURE.md +0 -326
- package/docs/DEVELOPMENT.md +0 -194
- package/docs/IMPLEMENTATION_PHASES.md +0 -468
- package/docs/INTEGRATION_PATHS_ARCHITECTURE.md +0 -1543
- package/docs/OAUTH_CLARIFICATION.md +0 -258
- package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +0 -211
- package/docs/PHASE_0_PROGRESS.md +0 -120
- package/docs/PHASE_1_COMPLETE.md +0 -366
- package/docs/PHASE_SUMMARY.md +0 -149
- package/docs/PLAN.md +0 -511
- package/docs/README.md +0 -56
- package/docs/STRIPE_INTEGRATION.md +0 -447
- package/docs/SUMMARY.md +0 -230
- package/docs/UPDATED_PLAN.md +0 -447
- package/docs/mcp_server/MCP_EXTENSION_GUIDE.md +0 -1313
- package/docs/mcp_server/MCP_SERVER_ARCHITECTURE.md +0 -1481
- package/docs/mcp_server/applicationOntology.ts +0 -817
- package/docs/mcp_server/cliApplications.ts +0 -639
- package/docs/mcp_server/crmOntology.ts +0 -1063
- package/docs/mcp_server/eventOntology.ts +0 -1183
- package/docs/mcp_server/formsOntology.ts +0 -1401
- package/docs/mcp_server/ontologySchemas.ts +0 -185
- package/docs/mcp_server/schema.ts +0 -250
- package/docs/microsass_production_machine/CLI_API_REFERENCE.md +0 -1197
- package/docs/microsass_production_machine/CLI_PRODUCT_VISION.md +0 -676
- package/docs/microsass_production_machine/CLI_REQUIREMENTS.md +0 -606
- package/docs/microsass_production_machine/CONNECTED_APPLICATIONS_SPEC.md +0 -390
- package/docs/microsass_production_machine/IMPLEMENTATION_ROADMAP.md +0 -725
- package/docs/microsass_production_machine/OBJECT_MAPPINGS.md +0 -808
- package/docs/microsass_production_machine/REFERENCE_IMPLEMENTATION.md +0 -532
- package/src/api/backend-client.js +0 -449
- package/src/commands/api-keys.js +0 -119
- package/src/commands/connect.js +0 -243
- package/src/commands/login.js +0 -332
- package/src/commands/logout.js +0 -30
- package/src/commands/mcp-server.js +0 -85
- package/src/commands/mcp-setup.js +0 -686
- package/src/commands/pages.js +0 -317
- package/src/commands/scaffold.js +0 -409
- package/src/commands/spread.js +0 -861
- package/src/commands/status.js +0 -62
- package/src/commands/sync.js +0 -169
- package/src/commands/upgrade.js +0 -48
- package/src/config/config-manager.js +0 -206
- package/src/detectors/api-client-detector.js +0 -85
- package/src/detectors/base-detector.js +0 -77
- package/src/detectors/database-detector.js +0 -245
- package/src/detectors/expo-detector.js +0 -166
- package/src/detectors/github-detector.js +0 -74
- package/src/detectors/index.js +0 -106
- package/src/detectors/mapping-suggestor.js +0 -119
- package/src/detectors/model-detector.js +0 -318
- package/src/detectors/nextjs-detector.js +0 -139
- package/src/detectors/oauth-detector.js +0 -122
- package/src/detectors/page-detector.js +0 -480
- package/src/detectors/registry.js +0 -121
- package/src/generators/api-client-generator.js +0 -223
- package/src/generators/api-only/client.js +0 -683
- package/src/generators/api-only/index.js +0 -96
- package/src/generators/api-only/types.js +0 -618
- package/src/generators/api-only/webhooks.js +0 -377
- package/src/generators/env-generator.js +0 -191
- package/src/generators/expo-auth-generator.js +0 -1009
- package/src/generators/gitignore-generator.js +0 -92
- package/src/generators/index.js +0 -166
- package/src/generators/manifest-generator.js +0 -154
- package/src/generators/mcp-guide-generator.js +0 -256
- package/src/generators/nextauth-generator.js +0 -247
- package/src/generators/oauth-guide-generator.js +0 -277
- package/src/generators/quickstart/components/index.js +0 -1699
- package/src/generators/quickstart/components-mobile/index.js +0 -1440
- package/src/generators/quickstart/database/convex.js +0 -1257
- package/src/generators/quickstart/database/index.js +0 -34
- package/src/generators/quickstart/database/supabase.js +0 -1132
- package/src/generators/quickstart/hooks/index.js +0 -1065
- package/src/generators/quickstart/index.js +0 -191
- package/src/generators/quickstart/pages/index.js +0 -1466
- package/src/generators/quickstart/screens/index.js +0 -1498
- package/src/logo.js +0 -116
- package/src/mcp/auth.js +0 -127
- package/src/mcp/registry/domains/applications.js +0 -516
- package/src/mcp/registry/domains/benefits.js +0 -798
- package/src/mcp/registry/domains/codegen.js +0 -894
- package/src/mcp/registry/domains/core.js +0 -324
- package/src/mcp/registry/domains/crm.js +0 -591
- package/src/mcp/registry/domains/events.js +0 -649
- package/src/mcp/registry/domains/forms.js +0 -696
- package/src/mcp/registry/index.js +0 -164
- package/src/mcp/server.js +0 -116
- package/src/utils/file-utils.js +0 -117
- package/src/utils/init-helpers.js +0 -243
- package/src/utils/prompt-utils.js +0 -195
- package/templates/CLAUDE.md +0 -86
- package/tests/api-client-detector.test.js +0 -214
- package/tests/api-client-generator.test.js +0 -176
- package/tests/backend-client.test.js +0 -640
- package/tests/base-detector.test.js +0 -101
- package/tests/commands/login.test.js +0 -143
- package/tests/commands/logout.test.js +0 -84
- package/tests/commands/status.test.js +0 -167
- package/tests/config-manager.test.js +0 -321
- package/tests/database-detector.test.js +0 -221
- package/tests/detector-index.test.js +0 -209
- package/tests/detector-registry.test.js +0 -93
- package/tests/env-generator.test.js +0 -278
- package/tests/expo-detector.test.js +0 -263
- package/tests/file-utils.test.js +0 -194
- package/tests/generators-index.test.js +0 -454
- package/tests/github-detector.test.js +0 -145
- package/tests/gitignore-generator.test.js +0 -109
- package/tests/logo.test.js +0 -96
- package/tests/nextauth-generator.test.js +0 -255
- package/tests/nextjs-detector.test.js +0 -235
- package/tests/oauth-detector.test.js +0 -264
- package/tests/oauth-guide-generator.test.js +0 -273
- package/tests/page-detector.test.js +0 -371
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tool Registry
|
|
3
|
-
*
|
|
4
|
-
* Central registry for all MCP tools organized by domain.
|
|
5
|
-
* Handles tool discovery, filtering by auth context, and execution.
|
|
6
|
-
*
|
|
7
|
-
* @module mcp/registry
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { requireAuth, hasPermission } = require('../auth');
|
|
11
|
-
|
|
12
|
-
// Import tool domains
|
|
13
|
-
const coreDomain = require('./domains/core');
|
|
14
|
-
const crmDomain = require('./domains/crm');
|
|
15
|
-
const eventsDomain = require('./domains/events');
|
|
16
|
-
const formsDomain = require('./domains/forms');
|
|
17
|
-
const codegenDomain = require('./domains/codegen');
|
|
18
|
-
const applicationsDomain = require('./domains/applications');
|
|
19
|
-
const benefitsDomain = require('./domains/benefits');
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} ToolDefinition
|
|
23
|
-
* @property {string} name - Tool name (e.g., 'l4yercak3_get_capabilities')
|
|
24
|
-
* @property {string} description - Human-readable description
|
|
25
|
-
* @property {Object} inputSchema - JSON Schema for tool parameters
|
|
26
|
-
* @property {Function} handler - Async function(params, authContext) => result
|
|
27
|
-
* @property {boolean} requiresAuth - Whether auth is required
|
|
28
|
-
* @property {string[]} [requiredPermissions] - Permissions needed to use this tool
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {Object} ToolDomain
|
|
33
|
-
* @property {string} name - Domain name (e.g., 'crm')
|
|
34
|
-
* @property {string} description - Domain description
|
|
35
|
-
* @property {ToolDefinition[]} tools - Tools in this domain
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* All registered tool domains
|
|
40
|
-
* @type {ToolDomain[]}
|
|
41
|
-
*/
|
|
42
|
-
const toolDomains = [
|
|
43
|
-
coreDomain,
|
|
44
|
-
applicationsDomain,
|
|
45
|
-
crmDomain,
|
|
46
|
-
eventsDomain,
|
|
47
|
-
formsDomain,
|
|
48
|
-
benefitsDomain,
|
|
49
|
-
codegenDomain,
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Get all available tools for the current auth context
|
|
54
|
-
*
|
|
55
|
-
* @param {Object|null} authContext - Current auth context
|
|
56
|
-
* @returns {ToolDefinition[]} Available tools
|
|
57
|
-
*/
|
|
58
|
-
function getAvailableTools(authContext) {
|
|
59
|
-
const tools = [];
|
|
60
|
-
|
|
61
|
-
for (const domain of toolDomains) {
|
|
62
|
-
for (const tool of domain.tools) {
|
|
63
|
-
// Include if no auth required
|
|
64
|
-
if (!tool.requiresAuth) {
|
|
65
|
-
tools.push(tool);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Skip if auth required but not authenticated
|
|
70
|
-
if (!authContext) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Check required permissions
|
|
75
|
-
if (tool.requiredPermissions && tool.requiredPermissions.length > 0) {
|
|
76
|
-
const hasAllPermissions = tool.requiredPermissions.every(perm =>
|
|
77
|
-
hasPermission(authContext, perm)
|
|
78
|
-
);
|
|
79
|
-
if (!hasAllPermissions) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
tools.push(tool);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return tools;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Find a tool by name
|
|
93
|
-
*
|
|
94
|
-
* @param {string} name - Tool name
|
|
95
|
-
* @returns {ToolDefinition|null}
|
|
96
|
-
*/
|
|
97
|
-
function findTool(name) {
|
|
98
|
-
for (const domain of toolDomains) {
|
|
99
|
-
const tool = domain.tools.find(t => t.name === name);
|
|
100
|
-
if (tool) {
|
|
101
|
-
return tool;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Execute a tool
|
|
109
|
-
*
|
|
110
|
-
* @param {string} name - Tool name
|
|
111
|
-
* @param {Object} params - Tool parameters
|
|
112
|
-
* @param {Object|null} authContext - Current auth context
|
|
113
|
-
* @returns {Promise<any>} Tool result
|
|
114
|
-
*/
|
|
115
|
-
async function executeTool(name, params, authContext) {
|
|
116
|
-
const tool = findTool(name);
|
|
117
|
-
|
|
118
|
-
if (!tool) {
|
|
119
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Check auth requirements
|
|
123
|
-
if (tool.requiresAuth) {
|
|
124
|
-
requireAuth(authContext);
|
|
125
|
-
|
|
126
|
-
// Check permissions
|
|
127
|
-
if (tool.requiredPermissions && tool.requiredPermissions.length > 0) {
|
|
128
|
-
for (const perm of tool.requiredPermissions) {
|
|
129
|
-
if (!hasPermission(authContext, perm)) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
`Permission denied: ${perm} required for tool ${name}`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Execute the tool
|
|
139
|
-
try {
|
|
140
|
-
return await tool.handler(params, authContext);
|
|
141
|
-
} catch (error) {
|
|
142
|
-
// Re-throw with context
|
|
143
|
-
const enhancedError = new Error(`Tool ${name} failed: ${error.message}`);
|
|
144
|
-
enhancedError.toolName = name;
|
|
145
|
-
enhancedError.originalError = error;
|
|
146
|
-
throw enhancedError;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get all domains (for documentation/discovery)
|
|
152
|
-
*
|
|
153
|
-
* @returns {ToolDomain[]}
|
|
154
|
-
*/
|
|
155
|
-
function getDomains() {
|
|
156
|
-
return toolDomains;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
module.exports = {
|
|
160
|
-
getAvailableTools,
|
|
161
|
-
findTool,
|
|
162
|
-
executeTool,
|
|
163
|
-
getDomains,
|
|
164
|
-
};
|
package/src/mcp/server.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* L4YERCAK3 MCP Server
|
|
3
|
-
*
|
|
4
|
-
* Exposes L4YERCAK3 backend capabilities to Claude Code via MCP protocol.
|
|
5
|
-
* This allows Claude Code to discover and use L4YERCAK3 features to help
|
|
6
|
-
* users integrate their projects.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* - Users add via: claude mcp add l4yercak3 -- npx l4yercak3 mcp-server
|
|
10
|
-
* - Reads auth from ~/.l4yercak3/config.json (created by l4yercak3 login)
|
|
11
|
-
*
|
|
12
|
-
* @module mcp/server
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
16
|
-
const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
17
|
-
const {
|
|
18
|
-
CallToolRequestSchema,
|
|
19
|
-
ListToolsRequestSchema,
|
|
20
|
-
} = require('@modelcontextprotocol/sdk/types.js');
|
|
21
|
-
|
|
22
|
-
const { getAuthContext } = require('./auth');
|
|
23
|
-
const { getAvailableTools, executeTool } = require('./registry');
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create and configure the MCP server
|
|
27
|
-
*/
|
|
28
|
-
function createServer() {
|
|
29
|
-
const server = new Server(
|
|
30
|
-
{
|
|
31
|
-
name: 'l4yercak3',
|
|
32
|
-
version: require('../../package.json').version,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
capabilities: {
|
|
36
|
-
tools: {},
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// Handle ListTools request
|
|
42
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
43
|
-
const authContext = await getAuthContext();
|
|
44
|
-
const tools = getAvailableTools(authContext);
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
tools: tools.map(tool => ({
|
|
48
|
-
name: tool.name,
|
|
49
|
-
description: tool.description,
|
|
50
|
-
inputSchema: tool.inputSchema,
|
|
51
|
-
})),
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Handle CallTool request
|
|
56
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
57
|
-
const { name, arguments: args } = request.params;
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const authContext = await getAuthContext();
|
|
61
|
-
const result = await executeTool(name, args || {}, authContext);
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
content: [
|
|
65
|
-
{
|
|
66
|
-
type: 'text',
|
|
67
|
-
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
} catch (error) {
|
|
72
|
-
return {
|
|
73
|
-
content: [
|
|
74
|
-
{
|
|
75
|
-
type: 'text',
|
|
76
|
-
text: `Error: ${error.message}`,
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
isError: true,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return server;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Start the MCP server
|
|
89
|
-
*/
|
|
90
|
-
async function startServer() {
|
|
91
|
-
const server = createServer();
|
|
92
|
-
const transport = new StdioServerTransport();
|
|
93
|
-
|
|
94
|
-
await server.connect(transport);
|
|
95
|
-
|
|
96
|
-
// Log startup to stderr (stdout is used for MCP protocol)
|
|
97
|
-
console.error('[L4YERCAK3 MCP] Server started');
|
|
98
|
-
|
|
99
|
-
// Handle graceful shutdown
|
|
100
|
-
process.on('SIGINT', async () => {
|
|
101
|
-
console.error('[L4YERCAK3 MCP] Shutting down...');
|
|
102
|
-
await server.close();
|
|
103
|
-
process.exit(0);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
process.on('SIGTERM', async () => {
|
|
107
|
-
console.error('[L4YERCAK3 MCP] Shutting down...');
|
|
108
|
-
await server.close();
|
|
109
|
-
process.exit(0);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
module.exports = {
|
|
114
|
-
createServer,
|
|
115
|
-
startServer,
|
|
116
|
-
};
|
package/src/utils/file-utils.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File Utilities
|
|
3
|
-
* Helper functions for safe file operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const crypto = require('crypto');
|
|
9
|
-
const inquirer = require('inquirer');
|
|
10
|
-
const chalk = require('chalk');
|
|
11
|
-
|
|
12
|
-
const GENERATED_HEADER = 'Auto-generated by @l4yercak3/cli';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Check if a file was generated by our CLI
|
|
16
|
-
*/
|
|
17
|
-
function isGeneratedFile(filePath) {
|
|
18
|
-
if (!fs.existsSync(filePath)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
24
|
-
// Check first 500 chars for our header
|
|
25
|
-
return content.substring(0, 500).includes(GENERATED_HEADER);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Check if file exists and prompt for action if needed
|
|
33
|
-
* Returns: 'write' | 'skip' | 'backup'
|
|
34
|
-
*/
|
|
35
|
-
async function checkFileOverwrite(filePath, options = {}) {
|
|
36
|
-
const { silent = false, defaultAction = 'prompt' } = options;
|
|
37
|
-
|
|
38
|
-
if (!fs.existsSync(filePath)) {
|
|
39
|
-
return 'write';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// If it's our generated file, safe to overwrite
|
|
43
|
-
if (isGeneratedFile(filePath)) {
|
|
44
|
-
if (!silent) {
|
|
45
|
-
console.log(chalk.gray(` Updating ${path.basename(filePath)} (previously generated)`));
|
|
46
|
-
}
|
|
47
|
-
return 'write';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// File exists and wasn't generated by us - prompt user
|
|
51
|
-
if (defaultAction === 'skip') {
|
|
52
|
-
return 'skip';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const relativePath = path.basename(filePath);
|
|
56
|
-
console.log(chalk.yellow(`\n ⚠️ ${relativePath} already exists and appears to be modified`));
|
|
57
|
-
|
|
58
|
-
const { action } = await inquirer.prompt([
|
|
59
|
-
{
|
|
60
|
-
type: 'list',
|
|
61
|
-
name: 'action',
|
|
62
|
-
message: `What would you like to do with ${relativePath}?`,
|
|
63
|
-
choices: [
|
|
64
|
-
{ name: 'Overwrite (replace with generated code)', value: 'write' },
|
|
65
|
-
{ name: 'Backup and overwrite (save old file as .backup)', value: 'backup' },
|
|
66
|
-
{ name: 'Skip (keep existing file)', value: 'skip' },
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
]);
|
|
70
|
-
|
|
71
|
-
return action;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Write file with optional backup
|
|
76
|
-
*/
|
|
77
|
-
function writeFileWithBackup(filePath, content, action) {
|
|
78
|
-
if (action === 'skip') {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (action === 'backup' && fs.existsSync(filePath)) {
|
|
83
|
-
const backupPath = `${filePath}.backup`;
|
|
84
|
-
fs.copyFileSync(filePath, backupPath);
|
|
85
|
-
console.log(chalk.gray(` Backed up to ${path.basename(backupPath)}`));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
89
|
-
return filePath;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Ensure directory exists
|
|
94
|
-
*/
|
|
95
|
-
function ensureDir(dirPath) {
|
|
96
|
-
if (!fs.existsSync(dirPath)) {
|
|
97
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Generate SHA256 hash of project path for identification
|
|
103
|
-
* This is used to identify returning projects when registering with backend
|
|
104
|
-
*/
|
|
105
|
-
function generateProjectPathHash(projectPath) {
|
|
106
|
-
const absolutePath = path.resolve(projectPath);
|
|
107
|
-
return crypto.createHash('sha256').update(absolutePath).digest('hex');
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
module.exports = {
|
|
111
|
-
GENERATED_HEADER,
|
|
112
|
-
isGeneratedFile,
|
|
113
|
-
checkFileOverwrite,
|
|
114
|
-
writeFileWithBackup,
|
|
115
|
-
ensureDir,
|
|
116
|
-
generateProjectPathHash,
|
|
117
|
-
};
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Init Helpers
|
|
3
|
-
* Shared helper functions for project initialization, connection, and sync commands
|
|
4
|
-
* Extracted from spread.js for reuse across connect.js, scaffold.js, sync.js
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { execSync } = require('child_process');
|
|
8
|
-
const inquirer = require('inquirer');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
|
-
const backendClient = require('../api/backend-client');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create an organization on the platform
|
|
14
|
-
* @param {string} orgName - Organization name
|
|
15
|
-
* @returns {Promise<{organizationId: string, organizationName: string}>}
|
|
16
|
-
*/
|
|
17
|
-
async function createOrganization(orgName) {
|
|
18
|
-
console.log(chalk.gray(` Creating organization "${orgName}"...`));
|
|
19
|
-
const newOrg = await backendClient.createOrganization(orgName);
|
|
20
|
-
const organizationId = newOrg.organizationId || newOrg.id || newOrg.data?.organizationId || newOrg.data?.id;
|
|
21
|
-
const organizationName = newOrg.name || orgName;
|
|
22
|
-
|
|
23
|
-
if (!organizationId) {
|
|
24
|
-
throw new Error('Organization ID not found in response. Please check backend API endpoint.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
console.log(chalk.green(` ✅ Organization created: ${organizationName}\n`));
|
|
28
|
-
return { organizationId, organizationName };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generate a new API key for an organization
|
|
33
|
-
* @param {string} organizationId
|
|
34
|
-
* @returns {Promise<string>} The API key
|
|
35
|
-
*/
|
|
36
|
-
async function generateNewApiKey(organizationId) {
|
|
37
|
-
console.log(chalk.gray(' Generating API key...'));
|
|
38
|
-
const apiKeyResponse = await backendClient.generateApiKey(
|
|
39
|
-
organizationId,
|
|
40
|
-
'CLI Generated Key',
|
|
41
|
-
['*']
|
|
42
|
-
);
|
|
43
|
-
const apiKey = apiKeyResponse.key || apiKeyResponse.apiKey || apiKeyResponse.data?.key || apiKeyResponse.data?.apiKey;
|
|
44
|
-
|
|
45
|
-
if (!apiKey) {
|
|
46
|
-
throw new Error('API key not found in response. Please check backend API endpoint.');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log(chalk.green(` ✅ API key generated\n`));
|
|
50
|
-
return apiKey;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Check if the project is a git repository
|
|
55
|
-
* @param {string} projectPath
|
|
56
|
-
* @returns {boolean}
|
|
57
|
-
*/
|
|
58
|
-
function isGitRepo(projectPath) {
|
|
59
|
-
try {
|
|
60
|
-
execSync('git rev-parse --is-inside-work-tree', {
|
|
61
|
-
cwd: projectPath,
|
|
62
|
-
stdio: 'pipe',
|
|
63
|
-
});
|
|
64
|
-
return true;
|
|
65
|
-
} catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get git status (uncommitted changes)
|
|
72
|
-
* @param {string} projectPath
|
|
73
|
-
* @returns {string}
|
|
74
|
-
*/
|
|
75
|
-
function getGitStatus(projectPath) {
|
|
76
|
-
try {
|
|
77
|
-
const status = execSync('git status --porcelain', {
|
|
78
|
-
cwd: projectPath,
|
|
79
|
-
encoding: 'utf8',
|
|
80
|
-
});
|
|
81
|
-
return status.trim();
|
|
82
|
-
} catch {
|
|
83
|
-
return '';
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Check for uncommitted changes and prompt user to commit first
|
|
89
|
-
* @param {string} projectPath
|
|
90
|
-
* @returns {Promise<boolean>} true if should proceed, false to abort
|
|
91
|
-
*/
|
|
92
|
-
async function checkGitStatusBeforeGeneration(projectPath) {
|
|
93
|
-
const debug = process.env.L4YERCAK3_DEBUG;
|
|
94
|
-
|
|
95
|
-
if (debug) {
|
|
96
|
-
console.log('\n[DEBUG] Git status check:');
|
|
97
|
-
console.log(` projectPath: "${projectPath}"`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (!isGitRepo(projectPath)) {
|
|
101
|
-
if (debug) console.log(' → Not a git repo, skipping check');
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const status = getGitStatus(projectPath);
|
|
106
|
-
|
|
107
|
-
if (debug) {
|
|
108
|
-
console.log(` → Git status: "${status.substring(0, 100)}${status.length > 100 ? '...' : ''}"`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!status) {
|
|
112
|
-
if (debug) console.log(' → No uncommitted changes, proceeding');
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const changes = status.split('\n').filter(line => line.trim());
|
|
117
|
-
const modifiedCount = changes.filter(line => line.startsWith(' M') || line.startsWith('M ')).length;
|
|
118
|
-
const untrackedCount = changes.filter(line => line.startsWith('??')).length;
|
|
119
|
-
const stagedCount = changes.filter(line => /^[MADRC]/.test(line)).length;
|
|
120
|
-
|
|
121
|
-
console.log(chalk.yellow(' ⚠️ Uncommitted changes detected\n'));
|
|
122
|
-
|
|
123
|
-
if (modifiedCount > 0) console.log(chalk.gray(` ${modifiedCount} modified file(s)`));
|
|
124
|
-
if (untrackedCount > 0) console.log(chalk.gray(` ${untrackedCount} untracked file(s)`));
|
|
125
|
-
if (stagedCount > 0) console.log(chalk.gray(` ${stagedCount} staged file(s)`));
|
|
126
|
-
|
|
127
|
-
console.log('');
|
|
128
|
-
console.log(chalk.gray(' We recommend committing your changes before generating'));
|
|
129
|
-
console.log(chalk.gray(' new files, so you can easily revert if needed.\n'));
|
|
130
|
-
|
|
131
|
-
const { action } = await inquirer.prompt([
|
|
132
|
-
{
|
|
133
|
-
type: 'list',
|
|
134
|
-
name: 'action',
|
|
135
|
-
message: 'How would you like to proceed?',
|
|
136
|
-
choices: [
|
|
137
|
-
{ name: 'Continue anyway - I\'ll handle it later', value: 'continue' },
|
|
138
|
-
{ name: 'Commit changes now - Create a checkpoint commit', value: 'commit' },
|
|
139
|
-
{ name: 'Abort - I\'ll commit manually first', value: 'abort' },
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
if (action === 'abort') {
|
|
145
|
-
console.log(chalk.gray('\n No worries! Run the command again after committing.\n'));
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (action === 'commit') {
|
|
150
|
-
try {
|
|
151
|
-
execSync('git add -A', { cwd: projectPath, stdio: 'pipe' });
|
|
152
|
-
const commitMessage = 'chore: checkpoint before L4YERCAK3 integration';
|
|
153
|
-
execSync(`git commit -m "${commitMessage}"`, { cwd: projectPath, stdio: 'pipe' });
|
|
154
|
-
|
|
155
|
-
console.log(chalk.green('\n ✅ Changes committed successfully'));
|
|
156
|
-
console.log(chalk.gray(` Message: "${commitMessage}"`));
|
|
157
|
-
console.log(chalk.gray(' You can revert with: git reset --soft HEAD~1\n'));
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.log(chalk.yellow('\n ⚠️ Could not create commit automatically'));
|
|
160
|
-
console.log(chalk.gray(` ${error.message}`));
|
|
161
|
-
console.log(chalk.gray(' Proceeding with file generation anyway...\n'));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Select or create an organization
|
|
170
|
-
* @returns {Promise<{organizationId: string, organizationName: string}>}
|
|
171
|
-
*/
|
|
172
|
-
async function selectOrganization(defaultName) {
|
|
173
|
-
const orgsResponse = await backendClient.getOrganizations();
|
|
174
|
-
const organizations = Array.isArray(orgsResponse)
|
|
175
|
-
? orgsResponse
|
|
176
|
-
: orgsResponse.organizations || orgsResponse.data || [];
|
|
177
|
-
|
|
178
|
-
if (organizations.length === 0) {
|
|
179
|
-
const { orgName } = await inquirer.prompt([
|
|
180
|
-
{
|
|
181
|
-
type: 'input',
|
|
182
|
-
name: 'orgName',
|
|
183
|
-
message: 'Organization name:',
|
|
184
|
-
default: defaultName || 'My Organization',
|
|
185
|
-
validate: (input) => input.trim().length > 0 || 'Organization name is required',
|
|
186
|
-
},
|
|
187
|
-
]);
|
|
188
|
-
return createOrganization(orgName);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const { orgChoice } = await inquirer.prompt([
|
|
192
|
-
{
|
|
193
|
-
type: 'list',
|
|
194
|
-
name: 'orgChoice',
|
|
195
|
-
message: 'Select organization:',
|
|
196
|
-
choices: [
|
|
197
|
-
...organizations.map(org => ({
|
|
198
|
-
name: `${org.name} (${org.id})`,
|
|
199
|
-
value: org.id,
|
|
200
|
-
})),
|
|
201
|
-
{ name: '➕ Create new organization', value: '__create__' },
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
]);
|
|
205
|
-
|
|
206
|
-
if (orgChoice === '__create__') {
|
|
207
|
-
const { orgName } = await inquirer.prompt([
|
|
208
|
-
{
|
|
209
|
-
type: 'input',
|
|
210
|
-
name: 'orgName',
|
|
211
|
-
message: 'Organization name:',
|
|
212
|
-
default: defaultName || 'My Organization',
|
|
213
|
-
validate: (input) => input.trim().length > 0 || 'Organization name is required',
|
|
214
|
-
},
|
|
215
|
-
]);
|
|
216
|
-
return createOrganization(orgName);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const selectedOrg = organizations.find(org => org.id === orgChoice);
|
|
220
|
-
console.log(chalk.green(` ✅ Selected organization: ${selectedOrg.name}\n`));
|
|
221
|
-
return { organizationId: orgChoice, organizationName: selectedOrg.name };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Require the user to be logged in, exit if not
|
|
226
|
-
*/
|
|
227
|
-
function requireAuth(configManager) {
|
|
228
|
-
if (!configManager.isLoggedIn()) {
|
|
229
|
-
console.log(chalk.yellow(' ⚠️ You must be logged in first'));
|
|
230
|
-
console.log(chalk.gray('\n Run "l4yercak3 login" to authenticate\n'));
|
|
231
|
-
process.exit(1);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
module.exports = {
|
|
236
|
-
createOrganization,
|
|
237
|
-
generateNewApiKey,
|
|
238
|
-
isGitRepo,
|
|
239
|
-
getGitStatus,
|
|
240
|
-
checkGitStatusBeforeGeneration,
|
|
241
|
-
selectOrganization,
|
|
242
|
-
requireAuth,
|
|
243
|
-
};
|