monomind 1.18.13 → 1.19.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/.claude/agents/core/researcher.md +29 -24
- package/.claude/agents/github/code-review-swarm.md +1 -1
- package/.claude/agents/github/github-modes.md +1 -1
- package/.claude/agents/github/issue-tracker.md +1 -1
- package/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/.claude/agents/github/pr-manager.md +1 -1
- package/.claude/agents/github/project-board-sync.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/github/repo-architect.md +1 -1
- package/.claude/agents/github/swarm-issue.md +1 -1
- package/.claude/agents/github/swarm-pr.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +1 -1
- package/.claude/agents/github/workflow-automation.md +1 -1
- package/.claude/agents/goal/goal-planner.md +1 -1
- package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/.claude/agents/testing/production-validator.md +8 -7
- package/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/.claude/commands/mastermind/_repeat.md +22 -3
- package/.claude/commands/mastermind/architect.md +1 -1
- package/.claude/commands/mastermind/autodev.md +1 -1
- package/.claude/commands/mastermind/build.md +1 -1
- package/.claude/commands/mastermind/code-review.md +5 -5
- package/.claude/commands/mastermind/debug.md +1 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/idea.md +1 -1
- package/.claude/commands/mastermind/improve.md +1 -1
- package/.claude/commands/mastermind/okf-export.md +14 -0
- package/.claude/commands/mastermind/okf-import.md +15 -0
- package/.claude/commands/mastermind/plan.md +1 -1
- package/.claude/commands/mastermind/research.md +1 -1
- package/.claude/commands/mastermind/review.md +12 -1
- package/.claude/commands/mastermind/runorg.md +1 -1
- package/.claude/commands/mastermind/taskdev.md +1 -1
- package/.claude/commands/mastermind/tdd.md +1 -1
- package/.claude/commands/mastermind/verify.md +1 -1
- package/.claude/helpers/graphify-freshen.cjs +16 -20
- package/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/.claude/helpers/hook-handler.cjs +89 -5
- package/.claude/helpers/intelligence.cjs +164 -15
- package/.claude/helpers/learning-service.mjs +1 -0
- package/.claude/helpers/mastermind-activate.cjs +33 -51
- package/.claude/helpers/monolean-activate.cjs +13 -3
- package/.claude/helpers/monolean-propagate.cjs +7 -3
- package/.claude/helpers/router.cjs +47 -9
- package/.claude/helpers/utils/monograph.cjs +37 -20
- package/.claude/settings.json +0 -20
- package/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/.claude/skills/mastermind-skills/architect.md +5 -6
- package/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/.claude/skills/mastermind-skills/review.md +25 -11
- package/.claude/skills/mastermind-skills/techport.md +37 -3
- package/.claude/skills/monodesign/document.md +9 -6
- package/.claude/skills/monodesign/extract.md +1 -1
- package/.claude/skills/monodesign/reference/document.md +1 -1
- package/.claude/skills/monodesign/reference/live.md +1 -1
- package/.claude/skills/monolean/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/@monomind/cli/.claude/agents/core/researcher.md +29 -24
- package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/github-modes.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/issue-tracker.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/pr-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/release-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/repo-architect.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/sync-coordinator.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +1 -1
- package/packages/@monomind/cli/.claude/agents/goal/goal-planner.md +1 -1
- package/packages/@monomind/cli/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/packages/@monomind/cli/.claude/agents/testing/production-validator.md +8 -7
- package/packages/@monomind/cli/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +22 -3
- package/packages/@monomind/cli/.claude/commands/mastermind/architect.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/autodev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/build.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/code-review.md +5 -5
- package/packages/@monomind/cli/.claude/commands/mastermind/debug.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/help.md +2 -2
- package/packages/@monomind/cli/.claude/commands/mastermind/idea.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/improve.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-export.md +14 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-import.md +15 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/plan.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/research.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/review.md +12 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/taskdev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/tdd.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/verify.md +1 -1
- package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +16 -20
- package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +89 -5
- package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +164 -15
- package/packages/@monomind/cli/.claude/helpers/learning-service.mjs +1 -0
- package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +33 -51
- package/packages/@monomind/cli/.claude/helpers/monolean-activate.cjs +13 -3
- package/packages/@monomind/cli/.claude/helpers/monolean-propagate.cjs +7 -3
- package/packages/@monomind/cli/.claude/helpers/router.cjs +47 -9
- package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +37 -20
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/architect.md +5 -6
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/review.md +25 -11
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/techport.md +37 -3
- package/packages/@monomind/cli/.claude/skills/monodesign/document.md +9 -6
- package/packages/@monomind/cli/.claude/skills/monodesign/extract.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/document.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/live.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monolean/SKILL.md +1 -1
- package/packages/@monomind/cli/bin/mcp-server.js +11 -1
- package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +1 -59
- package/packages/@monomind/cli/dist/src/commands/agent.js +2 -3
- package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/browse-action.js +94 -2
- package/packages/@monomind/cli/dist/src/commands/completions.js +11 -56
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +2 -116
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +2 -5
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +8 -7
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.js +0 -307
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -12
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +3 -51
- package/packages/@monomind/cli/dist/src/commands/index.js +36 -184
- package/packages/@monomind/cli/dist/src/commands/init-wizard.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/mcp.js +32 -4
- package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +1 -118
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +5 -171
- package/packages/@monomind/cli/dist/src/commands/memory.js +3 -6
- package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/commands/neural-core.js +145 -6
- package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural-registry.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +6 -6
- package/packages/@monomind/cli/dist/src/commands/performance.js +68 -58
- package/packages/@monomind/cli/dist/src/commands/providers.js +2 -131
- package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/commands/security-misc.js +69 -45
- package/packages/@monomind/cli/dist/src/commands/security.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/session.js +1 -285
- package/packages/@monomind/cli/dist/src/commands/start.js +2 -41
- package/packages/@monomind/cli/dist/src/commands/status.js +18 -29
- package/packages/@monomind/cli/dist/src/commands/swarm.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/task.js +2 -49
- package/packages/@monomind/cli/dist/src/commands/workflow.js +2 -104
- package/packages/@monomind/cli/dist/src/index.js +7 -0
- package/packages/@monomind/cli/dist/src/init/executor.js +3 -14
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -22
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +0 -1
- package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/init/types.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-client.js +0 -6
- package/packages/@monomind/cli/dist/src/mcp-server.js +16 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +0 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +5 -9
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +25 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +45 -159
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +1 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +24 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +452 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +4 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +28 -54
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +5 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.d.ts +7 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.js +7 -257
- package/packages/@monomind/cli/dist/src/memory/intelligence.d.ts +7 -8
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +15 -16
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +37 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.d.ts +3 -21
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +13 -80
- package/packages/@monomind/cli/dist/src/suggest.js +0 -5
- package/packages/@monomind/cli/package.json +1 -1
- package/packages/@monomind/guidance/README.md +49 -1153
- package/packages/@monomind/guidance/package.json +1 -74
- package/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/dist/src/commands/deployment.d.ts +0 -10
- package/packages/@monomind/cli/dist/src/commands/deployment.js +0 -706
|
@@ -1,706 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Deployment Command
|
|
3
|
-
* Deployment management, environments, rollbacks
|
|
4
|
-
*
|
|
5
|
-
* github.com/monoes/monomind
|
|
6
|
-
*/
|
|
7
|
-
import { output } from '../output.js';
|
|
8
|
-
import * as fs from 'fs';
|
|
9
|
-
import * as path from 'path';
|
|
10
|
-
// ============================================
|
|
11
|
-
// State Helpers
|
|
12
|
-
// ============================================
|
|
13
|
-
function getStateDir(cwd) {
|
|
14
|
-
return path.join(cwd, '.monomind');
|
|
15
|
-
}
|
|
16
|
-
function getStatePath(cwd) {
|
|
17
|
-
return path.join(getStateDir(cwd), 'deployments.json');
|
|
18
|
-
}
|
|
19
|
-
function emptyState() {
|
|
20
|
-
return { environments: {}, history: [], activeDeployment: undefined };
|
|
21
|
-
}
|
|
22
|
-
const MAX_DEPLOYMENT_STATE_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
23
|
-
// Input length caps to prevent DoS via unbounded strings stored to disk
|
|
24
|
-
const MAX_ENV_NAME_LEN = 128;
|
|
25
|
-
const MAX_VERSION_LEN = 64;
|
|
26
|
-
const MAX_DESCRIPTION_LEN = 1024;
|
|
27
|
-
const MAX_URL_LEN = 2048;
|
|
28
|
-
const MAX_ENV_TYPE_LEN = 64;
|
|
29
|
-
const MAX_HISTORY_LIMIT = 1000;
|
|
30
|
-
const MAX_LOGS_LIMIT = 1000;
|
|
31
|
-
function loadDeploymentState(cwd) {
|
|
32
|
-
const filePath = getStatePath(cwd);
|
|
33
|
-
if (!fs.existsSync(filePath)) {
|
|
34
|
-
return emptyState();
|
|
35
|
-
}
|
|
36
|
-
if (fs.statSync(filePath).size > MAX_DEPLOYMENT_STATE_BYTES) {
|
|
37
|
-
return emptyState();
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
41
|
-
const parsed = JSON.parse(raw);
|
|
42
|
-
// Strip proto-pollution keys before casting
|
|
43
|
-
const DANGEROUS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
44
|
-
if (parsed !== null && typeof parsed === 'object') {
|
|
45
|
-
for (const k of DANGEROUS) {
|
|
46
|
-
if (Object.prototype.hasOwnProperty.call(parsed, k))
|
|
47
|
-
delete parsed[k];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return parsed;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return emptyState();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const MAX_DEPLOYMENT_HISTORY = 1000;
|
|
57
|
-
function saveDeploymentState(cwd, state) {
|
|
58
|
-
// Cap history to prevent unbounded file growth
|
|
59
|
-
if (state.history.length > MAX_DEPLOYMENT_HISTORY) {
|
|
60
|
-
state.history = state.history.slice(-MAX_DEPLOYMENT_HISTORY);
|
|
61
|
-
}
|
|
62
|
-
const dir = getStateDir(cwd);
|
|
63
|
-
if (!fs.existsSync(dir)) {
|
|
64
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
const filePath = getStatePath(cwd);
|
|
67
|
-
const tmpPath = filePath + '.tmp';
|
|
68
|
-
fs.writeFileSync(tmpPath, JSON.stringify(state, null, 2), 'utf-8');
|
|
69
|
-
fs.renameSync(tmpPath, filePath);
|
|
70
|
-
}
|
|
71
|
-
function generateId() {
|
|
72
|
-
const ts = Date.now().toString(36);
|
|
73
|
-
const rand = Math.random().toString(36).slice(2, 8);
|
|
74
|
-
return `dep-${ts}-${rand}`;
|
|
75
|
-
}
|
|
76
|
-
function readProjectVersion(cwd) {
|
|
77
|
-
const pkgPath = path.join(cwd, 'package.json');
|
|
78
|
-
if (!fs.existsSync(pkgPath)) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
if (fs.statSync(pkgPath).size > 1024 * 1024) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
86
|
-
return pkg.version ?? null;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// ============================================
|
|
93
|
-
// Deploy subcommand
|
|
94
|
-
// ============================================
|
|
95
|
-
const deployCommand = {
|
|
96
|
-
name: 'deploy',
|
|
97
|
-
description: 'Deploy to target environment',
|
|
98
|
-
options: [
|
|
99
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Environment: dev, staging, prod', default: 'staging' },
|
|
100
|
-
{ name: 'version', short: 'v', type: 'string', description: 'Version to deploy' },
|
|
101
|
-
{ name: 'dry-run', short: 'd', type: 'boolean', description: 'Simulate deployment without changes' },
|
|
102
|
-
{ name: 'description', type: 'string', description: 'Deployment description' },
|
|
103
|
-
],
|
|
104
|
-
examples: [
|
|
105
|
-
{ command: 'monomind deployment deploy -e prod', description: 'Deploy to production' },
|
|
106
|
-
{ command: 'monomind deployment deploy --dry-run', description: 'Simulate deployment' },
|
|
107
|
-
],
|
|
108
|
-
action: async (ctx) => {
|
|
109
|
-
try {
|
|
110
|
-
const envName = String(ctx.flags['env'] || 'staging').slice(0, MAX_ENV_NAME_LEN);
|
|
111
|
-
const dryRun = Boolean(ctx.flags['dry-run']);
|
|
112
|
-
const description = ctx.flags['description'] ? String(ctx.flags['description']).slice(0, MAX_DESCRIPTION_LEN) : undefined;
|
|
113
|
-
let version = ctx.flags['version'] ? String(ctx.flags['version']).slice(0, MAX_VERSION_LEN) : null;
|
|
114
|
-
if (!version) {
|
|
115
|
-
version = readProjectVersion(ctx.cwd) || '0.0.0';
|
|
116
|
-
}
|
|
117
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
118
|
-
// Ensure environment exists; auto-create if it doesn't
|
|
119
|
-
if (!state.environments[envName]) {
|
|
120
|
-
state.environments[envName] = {
|
|
121
|
-
name: envName,
|
|
122
|
-
type: envName === 'prod' || envName === 'production' ? 'production' : envName === 'staging' ? 'staging' : 'local',
|
|
123
|
-
createdAt: new Date().toISOString(),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const record = {
|
|
127
|
-
id: generateId(),
|
|
128
|
-
environment: envName,
|
|
129
|
-
version,
|
|
130
|
-
status: 'deployed',
|
|
131
|
-
timestamp: new Date().toISOString(),
|
|
132
|
-
description,
|
|
133
|
-
};
|
|
134
|
-
if (dryRun) {
|
|
135
|
-
output.writeln();
|
|
136
|
-
output.printInfo('Dry run - no changes will be made');
|
|
137
|
-
output.writeln();
|
|
138
|
-
output.writeln(output.bold('Deployment Preview'));
|
|
139
|
-
output.printTable({
|
|
140
|
-
columns: [
|
|
141
|
-
{ key: 'field', header: 'Field' },
|
|
142
|
-
{ key: 'value', header: 'Value' },
|
|
143
|
-
],
|
|
144
|
-
data: [
|
|
145
|
-
{ field: 'ID', value: record.id },
|
|
146
|
-
{ field: 'Environment', value: envName },
|
|
147
|
-
{ field: 'Version', value: version },
|
|
148
|
-
{ field: 'Status', value: 'deployed (dry-run)' },
|
|
149
|
-
{ field: 'Description', value: description || '-' },
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
return { success: true };
|
|
153
|
-
}
|
|
154
|
-
state.history.push(record);
|
|
155
|
-
state.activeDeployment = record.id;
|
|
156
|
-
saveDeploymentState(ctx.cwd, state);
|
|
157
|
-
output.writeln();
|
|
158
|
-
output.printSuccess(`Deployed version ${version} to ${envName}`);
|
|
159
|
-
output.writeln();
|
|
160
|
-
output.printTable({
|
|
161
|
-
columns: [
|
|
162
|
-
{ key: 'field', header: 'Field' },
|
|
163
|
-
{ key: 'value', header: 'Value' },
|
|
164
|
-
],
|
|
165
|
-
data: [
|
|
166
|
-
{ field: 'ID', value: record.id },
|
|
167
|
-
{ field: 'Environment', value: envName },
|
|
168
|
-
{ field: 'Version', value: version },
|
|
169
|
-
{ field: 'Status', value: record.status },
|
|
170
|
-
{ field: 'Timestamp', value: record.timestamp },
|
|
171
|
-
{ field: 'Description', value: description || '-' },
|
|
172
|
-
],
|
|
173
|
-
});
|
|
174
|
-
return { success: true, data: record };
|
|
175
|
-
}
|
|
176
|
-
catch (err) {
|
|
177
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
178
|
-
output.printError('Deploy failed', msg);
|
|
179
|
-
return { success: false, exitCode: 1 };
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
// ============================================
|
|
184
|
-
// Status subcommand
|
|
185
|
-
// ============================================
|
|
186
|
-
const statusCommand = {
|
|
187
|
-
name: 'status',
|
|
188
|
-
description: 'Check deployment status across environments',
|
|
189
|
-
options: [
|
|
190
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Specific environment to check' },
|
|
191
|
-
],
|
|
192
|
-
examples: [
|
|
193
|
-
{ command: 'monomind deployment status', description: 'Show all environments' },
|
|
194
|
-
{ command: 'monomind deployment status -e prod', description: 'Check production' },
|
|
195
|
-
],
|
|
196
|
-
action: async (ctx) => {
|
|
197
|
-
try {
|
|
198
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
199
|
-
const filterEnv = ctx.flags['env'] ? String(ctx.flags['env']).slice(0, MAX_ENV_NAME_LEN) : null;
|
|
200
|
-
output.writeln();
|
|
201
|
-
output.writeln(output.bold('Deployment Status'));
|
|
202
|
-
output.writeln();
|
|
203
|
-
// Active deployment
|
|
204
|
-
if (state.activeDeployment) {
|
|
205
|
-
const active = state.history.find(r => r.id === state.activeDeployment);
|
|
206
|
-
if (active) {
|
|
207
|
-
output.printInfo(`Active deployment: ${active.id} (v${active.version} on ${active.environment})`);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
output.writeln(output.dim('No active deployment'));
|
|
212
|
-
}
|
|
213
|
-
// Environments table
|
|
214
|
-
const envEntries = Object.values(state.environments);
|
|
215
|
-
if (filterEnv) {
|
|
216
|
-
const env = state.environments[filterEnv];
|
|
217
|
-
if (!env) {
|
|
218
|
-
output.printWarning(`Environment '${filterEnv}' not found`);
|
|
219
|
-
return { success: true };
|
|
220
|
-
}
|
|
221
|
-
output.writeln();
|
|
222
|
-
output.writeln(output.bold('Environment'));
|
|
223
|
-
output.printTable({
|
|
224
|
-
columns: [
|
|
225
|
-
{ key: 'name', header: 'Name' },
|
|
226
|
-
{ key: 'type', header: 'Type' },
|
|
227
|
-
{ key: 'url', header: 'URL' },
|
|
228
|
-
{ key: 'createdAt', header: 'Created' },
|
|
229
|
-
],
|
|
230
|
-
data: [{ name: env.name, type: env.type, url: env.url || '-', createdAt: env.createdAt }],
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
else if (envEntries.length > 0) {
|
|
234
|
-
output.writeln();
|
|
235
|
-
output.writeln(output.bold('Environments'));
|
|
236
|
-
output.printTable({
|
|
237
|
-
columns: [
|
|
238
|
-
{ key: 'name', header: 'Name' },
|
|
239
|
-
{ key: 'type', header: 'Type' },
|
|
240
|
-
{ key: 'url', header: 'URL' },
|
|
241
|
-
{ key: 'createdAt', header: 'Created' },
|
|
242
|
-
],
|
|
243
|
-
data: envEntries.map(e => ({ name: e.name, type: e.type, url: e.url || '-', createdAt: e.createdAt })),
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
output.writeln(output.dim('No environments configured'));
|
|
248
|
-
}
|
|
249
|
-
// Recent history (last 5)
|
|
250
|
-
let recent = [...state.history].reverse();
|
|
251
|
-
if (filterEnv) {
|
|
252
|
-
recent = recent.filter(r => r.environment === filterEnv);
|
|
253
|
-
}
|
|
254
|
-
recent = recent.slice(0, 5);
|
|
255
|
-
if (recent.length > 0) {
|
|
256
|
-
output.writeln();
|
|
257
|
-
output.writeln(output.bold('Recent Deployments'));
|
|
258
|
-
output.printTable({
|
|
259
|
-
columns: [
|
|
260
|
-
{ key: 'id', header: 'ID' },
|
|
261
|
-
{ key: 'environment', header: 'Env' },
|
|
262
|
-
{ key: 'version', header: 'Version' },
|
|
263
|
-
{ key: 'status', header: 'Status' },
|
|
264
|
-
{ key: 'timestamp', header: 'Time' },
|
|
265
|
-
],
|
|
266
|
-
data: recent.map(r => ({ ...r })),
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return { success: true };
|
|
270
|
-
}
|
|
271
|
-
catch (err) {
|
|
272
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
273
|
-
output.printError('Status check failed', msg);
|
|
274
|
-
return { success: false, exitCode: 1 };
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
};
|
|
278
|
-
// ============================================
|
|
279
|
-
// Rollback subcommand
|
|
280
|
-
// ============================================
|
|
281
|
-
const rollbackCommand = {
|
|
282
|
-
name: 'rollback',
|
|
283
|
-
description: 'Rollback to previous deployment',
|
|
284
|
-
options: [
|
|
285
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Environment to rollback', required: true },
|
|
286
|
-
{ name: 'version', short: 'v', type: 'string', description: 'Specific version to rollback to' },
|
|
287
|
-
{ name: 'steps', short: 's', type: 'number', description: 'Number of versions to rollback', default: '1' },
|
|
288
|
-
],
|
|
289
|
-
examples: [
|
|
290
|
-
{ command: 'monomind deployment rollback -e prod', description: 'Rollback production' },
|
|
291
|
-
{ command: 'monomind deployment rollback -e prod -v V1.0.0', description: 'Rollback to specific version' },
|
|
292
|
-
],
|
|
293
|
-
action: async (ctx) => {
|
|
294
|
-
try {
|
|
295
|
-
const envName = String(ctx.flags['env'] || '').slice(0, MAX_ENV_NAME_LEN);
|
|
296
|
-
if (!envName) {
|
|
297
|
-
output.printError('Environment is required', 'Use --env or -e to specify');
|
|
298
|
-
return { success: false, exitCode: 1 };
|
|
299
|
-
}
|
|
300
|
-
const targetVersion = ctx.flags['version'] ? String(ctx.flags['version']).slice(0, MAX_VERSION_LEN) : null;
|
|
301
|
-
const steps = Math.min(Math.max(parseInt(ctx.flags.steps || '1', 10), 1), 100);
|
|
302
|
-
if (steps > 1) {
|
|
303
|
-
output.printWarning(`Multi-step rollback (--steps ${steps}) is not yet implemented. Rolling back 1 step only.`);
|
|
304
|
-
}
|
|
305
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
306
|
-
// Find deployments for this environment in reverse chronological order
|
|
307
|
-
const envHistory = state.history
|
|
308
|
-
.filter(r => r.environment === envName && r.status === 'deployed')
|
|
309
|
-
.reverse();
|
|
310
|
-
if (envHistory.length < 2 && !targetVersion) {
|
|
311
|
-
output.printWarning('No previous deployment to rollback to');
|
|
312
|
-
return { success: false, exitCode: 1 };
|
|
313
|
-
}
|
|
314
|
-
let rollbackTo;
|
|
315
|
-
if (targetVersion) {
|
|
316
|
-
rollbackTo = envHistory.find(r => r.version === targetVersion);
|
|
317
|
-
if (!rollbackTo) {
|
|
318
|
-
output.printError(`Version '${targetVersion}' not found in deployment history for '${envName}'`);
|
|
319
|
-
return { success: false, exitCode: 1 };
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
// Rollback to the deployment before the most recent one
|
|
324
|
-
rollbackTo = envHistory[1];
|
|
325
|
-
}
|
|
326
|
-
// Mark current active deployment for this env as rolled-back
|
|
327
|
-
const current = envHistory[0];
|
|
328
|
-
if (current) {
|
|
329
|
-
const idx = state.history.findIndex(r => r.id === current.id);
|
|
330
|
-
if (idx >= 0) {
|
|
331
|
-
state.history[idx].status = 'rolled-back';
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
// Create a new record for the rollback
|
|
335
|
-
const record = {
|
|
336
|
-
id: generateId(),
|
|
337
|
-
environment: envName,
|
|
338
|
-
version: rollbackTo.version,
|
|
339
|
-
status: 'deployed',
|
|
340
|
-
timestamp: new Date().toISOString(),
|
|
341
|
-
description: `Rollback from ${current?.version || 'unknown'} to ${rollbackTo.version}`,
|
|
342
|
-
};
|
|
343
|
-
state.history.push(record);
|
|
344
|
-
state.activeDeployment = record.id;
|
|
345
|
-
saveDeploymentState(ctx.cwd, state);
|
|
346
|
-
output.writeln();
|
|
347
|
-
output.printSuccess(`Rolled back ${envName} to version ${rollbackTo.version}`);
|
|
348
|
-
output.writeln();
|
|
349
|
-
output.printTable({
|
|
350
|
-
columns: [
|
|
351
|
-
{ key: 'field', header: 'Field' },
|
|
352
|
-
{ key: 'value', header: 'Value' },
|
|
353
|
-
],
|
|
354
|
-
data: [
|
|
355
|
-
{ field: 'Rollback ID', value: record.id },
|
|
356
|
-
{ field: 'Environment', value: envName },
|
|
357
|
-
{ field: 'From Version', value: current?.version || 'unknown' },
|
|
358
|
-
{ field: 'To Version', value: rollbackTo.version },
|
|
359
|
-
{ field: 'Timestamp', value: record.timestamp },
|
|
360
|
-
],
|
|
361
|
-
});
|
|
362
|
-
return { success: true, data: record };
|
|
363
|
-
}
|
|
364
|
-
catch (err) {
|
|
365
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
366
|
-
output.printError('Rollback failed', msg);
|
|
367
|
-
return { success: false, exitCode: 1 };
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
};
|
|
371
|
-
// ============================================
|
|
372
|
-
// History subcommand (logs)
|
|
373
|
-
// ============================================
|
|
374
|
-
const historyCommand = {
|
|
375
|
-
name: 'history',
|
|
376
|
-
description: 'View deployment history',
|
|
377
|
-
options: [
|
|
378
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Filter by environment' },
|
|
379
|
-
{ name: 'limit', short: 'l', type: 'number', description: 'Number of entries', default: '10' },
|
|
380
|
-
],
|
|
381
|
-
examples: [
|
|
382
|
-
{ command: 'monomind deployment history', description: 'Show all history' },
|
|
383
|
-
{ command: 'monomind deployment history -e prod', description: 'Production history' },
|
|
384
|
-
],
|
|
385
|
-
action: async (ctx) => {
|
|
386
|
-
try {
|
|
387
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
388
|
-
const filterEnv = ctx.flags['env'] ? String(ctx.flags['env']).slice(0, MAX_ENV_NAME_LEN) : null;
|
|
389
|
-
const limit = Math.min(Math.max(Number(ctx.flags['limit']) || 10, 1), MAX_HISTORY_LIMIT);
|
|
390
|
-
let records = [...state.history].reverse();
|
|
391
|
-
if (filterEnv) {
|
|
392
|
-
records = records.filter(r => r.environment === filterEnv);
|
|
393
|
-
}
|
|
394
|
-
records = records.slice(0, limit);
|
|
395
|
-
output.writeln();
|
|
396
|
-
output.writeln(output.bold('Deployment History'));
|
|
397
|
-
if (filterEnv) {
|
|
398
|
-
output.writeln(output.dim(`Filtered by environment: ${filterEnv}`));
|
|
399
|
-
}
|
|
400
|
-
output.writeln();
|
|
401
|
-
if (records.length === 0) {
|
|
402
|
-
output.writeln(output.dim('No deployment history found'));
|
|
403
|
-
return { success: true };
|
|
404
|
-
}
|
|
405
|
-
output.printTable({
|
|
406
|
-
columns: [
|
|
407
|
-
{ key: 'id', header: 'ID' },
|
|
408
|
-
{ key: 'environment', header: 'Env' },
|
|
409
|
-
{ key: 'version', header: 'Version' },
|
|
410
|
-
{ key: 'status', header: 'Status' },
|
|
411
|
-
{ key: 'timestamp', header: 'Time' },
|
|
412
|
-
{ key: 'description', header: 'Description' },
|
|
413
|
-
],
|
|
414
|
-
data: records.map(r => ({
|
|
415
|
-
...r,
|
|
416
|
-
description: r.description || '-',
|
|
417
|
-
})),
|
|
418
|
-
});
|
|
419
|
-
output.writeln();
|
|
420
|
-
output.writeln(output.dim(`Showing ${records.length} of ${state.history.length} total records`));
|
|
421
|
-
return { success: true };
|
|
422
|
-
}
|
|
423
|
-
catch (err) {
|
|
424
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
425
|
-
output.printError('Failed to load history', msg);
|
|
426
|
-
return { success: false, exitCode: 1 };
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
// ============================================
|
|
431
|
-
// Environments subcommand
|
|
432
|
-
// ============================================
|
|
433
|
-
const environmentsCommand = {
|
|
434
|
-
name: 'environments',
|
|
435
|
-
description: 'Manage deployment environments',
|
|
436
|
-
aliases: ['envs'],
|
|
437
|
-
options: [
|
|
438
|
-
{ name: 'action', short: 'a', type: 'string', description: 'Action: list, add, remove', default: 'list' },
|
|
439
|
-
{ name: 'name', short: 'n', type: 'string', description: 'Environment name' },
|
|
440
|
-
{ name: 'type', short: 't', type: 'string', description: 'Environment type: local, staging, production', default: 'local' },
|
|
441
|
-
{ name: 'url', short: 'u', type: 'string', description: 'Environment URL' },
|
|
442
|
-
],
|
|
443
|
-
examples: [
|
|
444
|
-
{ command: 'monomind deployment environments', description: 'List environments' },
|
|
445
|
-
{ command: 'monomind deployment envs -a add -n preview -t staging', description: 'Add environment' },
|
|
446
|
-
{ command: 'monomind deployment envs -a remove -n preview', description: 'Remove environment' },
|
|
447
|
-
],
|
|
448
|
-
action: async (ctx) => {
|
|
449
|
-
try {
|
|
450
|
-
const action = String(ctx.flags['action'] || 'list');
|
|
451
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
452
|
-
if (action === 'list') {
|
|
453
|
-
const envs = Object.values(state.environments);
|
|
454
|
-
output.writeln();
|
|
455
|
-
output.writeln(output.bold('Deployment Environments'));
|
|
456
|
-
output.writeln();
|
|
457
|
-
if (envs.length === 0) {
|
|
458
|
-
output.writeln(output.dim('No environments configured. Use --action add to create one.'));
|
|
459
|
-
return { success: true };
|
|
460
|
-
}
|
|
461
|
-
output.printTable({
|
|
462
|
-
columns: [
|
|
463
|
-
{ key: 'name', header: 'Name' },
|
|
464
|
-
{ key: 'type', header: 'Type' },
|
|
465
|
-
{ key: 'url', header: 'URL' },
|
|
466
|
-
{ key: 'createdAt', header: 'Created' },
|
|
467
|
-
],
|
|
468
|
-
data: envs.map(e => ({ name: e.name, type: e.type, url: e.url || '-', createdAt: e.createdAt })),
|
|
469
|
-
});
|
|
470
|
-
return { success: true };
|
|
471
|
-
}
|
|
472
|
-
if (action === 'add') {
|
|
473
|
-
const name = ctx.flags['name'] ? String(ctx.flags['name']).slice(0, MAX_ENV_NAME_LEN) : null;
|
|
474
|
-
if (!name) {
|
|
475
|
-
output.printError('Environment name is required', 'Use --name or -n to specify');
|
|
476
|
-
return { success: false, exitCode: 1 };
|
|
477
|
-
}
|
|
478
|
-
if (state.environments[name]) {
|
|
479
|
-
output.printWarning(`Environment '${name}' already exists`);
|
|
480
|
-
return { success: false, exitCode: 1 };
|
|
481
|
-
}
|
|
482
|
-
const envType = String(ctx.flags['type'] || 'local').slice(0, MAX_ENV_TYPE_LEN);
|
|
483
|
-
const url = ctx.flags['url'] ? String(ctx.flags['url']).slice(0, MAX_URL_LEN) : undefined;
|
|
484
|
-
state.environments[name] = {
|
|
485
|
-
name,
|
|
486
|
-
type: envType,
|
|
487
|
-
url,
|
|
488
|
-
createdAt: new Date().toISOString(),
|
|
489
|
-
};
|
|
490
|
-
saveDeploymentState(ctx.cwd, state);
|
|
491
|
-
output.writeln();
|
|
492
|
-
output.printSuccess(`Added environment '${name}' (${envType})`);
|
|
493
|
-
if (url) {
|
|
494
|
-
output.writeln(output.dim(` URL: ${url}`));
|
|
495
|
-
}
|
|
496
|
-
return { success: true };
|
|
497
|
-
}
|
|
498
|
-
if (action === 'remove') {
|
|
499
|
-
const name = ctx.flags['name'] ? String(ctx.flags['name']).slice(0, MAX_ENV_NAME_LEN) : null;
|
|
500
|
-
if (!name) {
|
|
501
|
-
output.printError('Environment name is required', 'Use --name or -n to specify');
|
|
502
|
-
return { success: false, exitCode: 1 };
|
|
503
|
-
}
|
|
504
|
-
if (!state.environments[name]) {
|
|
505
|
-
output.printWarning(`Environment '${name}' not found`);
|
|
506
|
-
return { success: false, exitCode: 1 };
|
|
507
|
-
}
|
|
508
|
-
delete state.environments[name];
|
|
509
|
-
saveDeploymentState(ctx.cwd, state);
|
|
510
|
-
output.writeln();
|
|
511
|
-
output.printSuccess(`Removed environment '${name}'`);
|
|
512
|
-
return { success: true };
|
|
513
|
-
}
|
|
514
|
-
output.printError(`Unknown action '${action}'`, 'Valid actions: list, add, remove');
|
|
515
|
-
return { success: false, exitCode: 1 };
|
|
516
|
-
}
|
|
517
|
-
catch (err) {
|
|
518
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
519
|
-
output.printError('Environments command failed', msg);
|
|
520
|
-
return { success: false, exitCode: 1 };
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
};
|
|
524
|
-
// ============================================
|
|
525
|
-
// Logs subcommand
|
|
526
|
-
// ============================================
|
|
527
|
-
const logsCommand = {
|
|
528
|
-
name: 'logs',
|
|
529
|
-
description: 'View deployment logs',
|
|
530
|
-
options: [
|
|
531
|
-
{ name: 'deployment', short: 'd', type: 'string', description: 'Deployment ID' },
|
|
532
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Environment' },
|
|
533
|
-
{ name: 'lines', short: 'n', type: 'number', description: 'Number of lines', default: '50' },
|
|
534
|
-
],
|
|
535
|
-
examples: [
|
|
536
|
-
{ command: 'monomind deployment logs -e prod', description: 'View production logs' },
|
|
537
|
-
{ command: 'monomind deployment logs -d dep-123', description: 'View specific deployment' },
|
|
538
|
-
],
|
|
539
|
-
action: async (ctx) => {
|
|
540
|
-
try {
|
|
541
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
542
|
-
const filterEnv = ctx.flags['env'] ? String(ctx.flags['env']).slice(0, MAX_ENV_NAME_LEN) : null;
|
|
543
|
-
const deploymentId = ctx.flags['deployment'] ? String(ctx.flags['deployment']).slice(0, 64) : null;
|
|
544
|
-
const limit = Math.min(Math.max(Number(ctx.flags['lines']) || 50, 1), MAX_LOGS_LIMIT);
|
|
545
|
-
output.writeln();
|
|
546
|
-
output.writeln(output.bold('Deployment Logs'));
|
|
547
|
-
output.writeln();
|
|
548
|
-
let records = [...state.history].reverse();
|
|
549
|
-
if (deploymentId) {
|
|
550
|
-
records = records.filter(r => r.id === deploymentId);
|
|
551
|
-
if (records.length === 0) {
|
|
552
|
-
output.printWarning(`Deployment '${deploymentId}' not found`);
|
|
553
|
-
return { success: false, exitCode: 1 };
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
if (filterEnv) {
|
|
557
|
-
records = records.filter(r => r.environment === filterEnv);
|
|
558
|
-
}
|
|
559
|
-
records = records.slice(0, limit);
|
|
560
|
-
if (records.length === 0) {
|
|
561
|
-
output.writeln(output.dim('No deployment logs found'));
|
|
562
|
-
return { success: true };
|
|
563
|
-
}
|
|
564
|
-
output.printTable({
|
|
565
|
-
columns: [
|
|
566
|
-
{ key: 'id', header: 'ID' },
|
|
567
|
-
{ key: 'environment', header: 'Env' },
|
|
568
|
-
{ key: 'version', header: 'Version' },
|
|
569
|
-
{ key: 'status', header: 'Status' },
|
|
570
|
-
{ key: 'timestamp', header: 'Time' },
|
|
571
|
-
{ key: 'description', header: 'Description' },
|
|
572
|
-
],
|
|
573
|
-
data: records.map(r => ({
|
|
574
|
-
...r,
|
|
575
|
-
description: r.description || '-',
|
|
576
|
-
})),
|
|
577
|
-
});
|
|
578
|
-
output.writeln();
|
|
579
|
-
output.writeln(output.dim(`${records.length} entries shown`));
|
|
580
|
-
return { success: true };
|
|
581
|
-
}
|
|
582
|
-
catch (err) {
|
|
583
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
584
|
-
output.printError('Failed to load logs', msg);
|
|
585
|
-
return { success: false, exitCode: 1 };
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
};
|
|
589
|
-
// ============================================
|
|
590
|
-
// Release subcommand
|
|
591
|
-
// ============================================
|
|
592
|
-
const releaseCommand = {
|
|
593
|
-
name: 'release',
|
|
594
|
-
description: 'Create a new release deployment',
|
|
595
|
-
options: [
|
|
596
|
-
{ name: 'version', short: 'v', type: 'string', description: 'Release version' },
|
|
597
|
-
{ name: 'env', short: 'e', type: 'string', description: 'Target environment', default: 'production' },
|
|
598
|
-
{ name: 'description', short: 'd', type: 'string', description: 'Release description' },
|
|
599
|
-
],
|
|
600
|
-
examples: [
|
|
601
|
-
{ command: 'monomind deployment release -v 3.5.0', description: 'Release version 3.5.0' },
|
|
602
|
-
{ command: 'monomind deployment release -v 3.5.0 -d "Major update"', description: 'Release with description' },
|
|
603
|
-
],
|
|
604
|
-
action: async (ctx) => {
|
|
605
|
-
try {
|
|
606
|
-
const envName = String(ctx.flags['env'] || 'production').slice(0, MAX_ENV_NAME_LEN);
|
|
607
|
-
const description = ctx.flags['description'] ? String(ctx.flags['description']).slice(0, MAX_DESCRIPTION_LEN) : undefined;
|
|
608
|
-
let version = ctx.flags['version'] ? String(ctx.flags['version']).slice(0, MAX_VERSION_LEN) : null;
|
|
609
|
-
if (!version) {
|
|
610
|
-
const pkgVersion = readProjectVersion(ctx.cwd);
|
|
611
|
-
if (!pkgVersion) {
|
|
612
|
-
output.printError('Version is required', 'Use --version or -v, or ensure package.json has a version field');
|
|
613
|
-
return { success: false, exitCode: 1 };
|
|
614
|
-
}
|
|
615
|
-
version = pkgVersion;
|
|
616
|
-
}
|
|
617
|
-
const state = loadDeploymentState(ctx.cwd);
|
|
618
|
-
// Ensure environment exists
|
|
619
|
-
if (!state.environments[envName]) {
|
|
620
|
-
state.environments[envName] = {
|
|
621
|
-
name: envName,
|
|
622
|
-
type: envName === 'prod' || envName === 'production' ? 'production' : 'staging',
|
|
623
|
-
createdAt: new Date().toISOString(),
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
const record = {
|
|
627
|
-
id: generateId(),
|
|
628
|
-
environment: envName,
|
|
629
|
-
version,
|
|
630
|
-
status: 'deployed',
|
|
631
|
-
timestamp: new Date().toISOString(),
|
|
632
|
-
description: description || `Release ${version}`,
|
|
633
|
-
};
|
|
634
|
-
state.history.push(record);
|
|
635
|
-
state.activeDeployment = record.id;
|
|
636
|
-
saveDeploymentState(ctx.cwd, state);
|
|
637
|
-
output.writeln();
|
|
638
|
-
output.printSuccess(`Released version ${version} to ${envName}`);
|
|
639
|
-
output.writeln();
|
|
640
|
-
output.printTable({
|
|
641
|
-
columns: [
|
|
642
|
-
{ key: 'field', header: 'Field' },
|
|
643
|
-
{ key: 'value', header: 'Value' },
|
|
644
|
-
],
|
|
645
|
-
data: [
|
|
646
|
-
{ field: 'Release ID', value: record.id },
|
|
647
|
-
{ field: 'Environment', value: envName },
|
|
648
|
-
{ field: 'Version', value: version },
|
|
649
|
-
{ field: 'Status', value: record.status },
|
|
650
|
-
{ field: 'Timestamp', value: record.timestamp },
|
|
651
|
-
{ field: 'Description', value: record.description || '-' },
|
|
652
|
-
],
|
|
653
|
-
});
|
|
654
|
-
return { success: true, data: record };
|
|
655
|
-
}
|
|
656
|
-
catch (err) {
|
|
657
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
658
|
-
output.printError('Release failed', msg);
|
|
659
|
-
return { success: false, exitCode: 1 };
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
};
|
|
663
|
-
// ============================================
|
|
664
|
-
// Main deployment command
|
|
665
|
-
// ============================================
|
|
666
|
-
export const deploymentCommand = {
|
|
667
|
-
name: 'deployment',
|
|
668
|
-
description: 'Deployment management, environments, rollbacks',
|
|
669
|
-
aliases: ['deploy'],
|
|
670
|
-
subcommands: [deployCommand, statusCommand, rollbackCommand, historyCommand, environmentsCommand, logsCommand, releaseCommand],
|
|
671
|
-
examples: [
|
|
672
|
-
{ command: 'monomind deployment deploy -e prod', description: 'Deploy to production' },
|
|
673
|
-
{ command: 'monomind deployment status', description: 'Check all environments' },
|
|
674
|
-
{ command: 'monomind deployment rollback -e prod', description: 'Rollback production' },
|
|
675
|
-
{ command: 'monomind deployment release -v 3.5.0', description: 'Create a release' },
|
|
676
|
-
],
|
|
677
|
-
action: async () => {
|
|
678
|
-
output.writeln();
|
|
679
|
-
output.writeln(output.bold('MonoMind Deployment'));
|
|
680
|
-
output.writeln(output.dim('Multi-environment deployment management'));
|
|
681
|
-
output.writeln();
|
|
682
|
-
output.writeln('Subcommands:');
|
|
683
|
-
output.printList([
|
|
684
|
-
'deploy - Deploy to target environment',
|
|
685
|
-
'status - Check deployment status',
|
|
686
|
-
'rollback - Rollback to previous version',
|
|
687
|
-
'history - View deployment history',
|
|
688
|
-
'environments - Manage deployment environments',
|
|
689
|
-
'logs - View deployment logs',
|
|
690
|
-
'release - Create a new release',
|
|
691
|
-
]);
|
|
692
|
-
output.writeln();
|
|
693
|
-
output.writeln('Features:');
|
|
694
|
-
output.printList([
|
|
695
|
-
'Zero-downtime rolling deployments',
|
|
696
|
-
'Automatic rollback on failure',
|
|
697
|
-
'Environment-specific configurations',
|
|
698
|
-
'Deployment previews for PRs',
|
|
699
|
-
]);
|
|
700
|
-
output.writeln();
|
|
701
|
-
output.writeln(output.dim('github.com/monoes/monomind'));
|
|
702
|
-
return { success: true };
|
|
703
|
-
},
|
|
704
|
-
};
|
|
705
|
-
export default deploymentCommand;
|
|
706
|
-
//# sourceMappingURL=deployment.js.map
|