@avesta-hq/prevention 0.6.0-pre.6 → 0.6.0-pre.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.
- package/bin/cli.js +1 -1
- package/bin/lib/init.js +1 -1
- package/package.json +5 -6
- package/bin/lib/test-local.js +0 -127
package/bin/cli.js
CHANGED
|
@@ -47,7 +47,7 @@ switch (command) {
|
|
|
47
47
|
require('./lib/init').serve();
|
|
48
48
|
break;
|
|
49
49
|
case 'test-local':
|
|
50
|
-
require('
|
|
50
|
+
require('../scripts/lib/test-local').testLocal(args[1]);
|
|
51
51
|
break;
|
|
52
52
|
case 'session-start':
|
|
53
53
|
require('./lib/session-start').sessionStart();
|
package/bin/lib/init.js
CHANGED
|
@@ -139,7 +139,7 @@ function serve() {
|
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const mcpServerPath = path.join(PACKAGE_ROOT, '
|
|
142
|
+
const mcpServerPath = path.join(PACKAGE_ROOT, 'package', 'mcp-server.ts');
|
|
143
143
|
if (fs.existsSync(mcpServerPath)) {
|
|
144
144
|
const { execFileSync } = require('child_process');
|
|
145
145
|
try { execFileSync('npx', ['tsx', mcpServerPath], { stdio: 'inherit' }); } catch (e) { process.exit(e.status || 1); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avesta-hq/prevention",
|
|
3
|
-
"version": "0.6.0-pre.
|
|
3
|
+
"version": "0.6.0-pre.7",
|
|
4
4
|
"description": "XP/CD development agent commands for Claude Code - achieve Elite DORA metrics through disciplined TDD and Continuous Delivery practices",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -30,13 +30,12 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc",
|
|
33
|
-
"dev": "tsx
|
|
33
|
+
"dev": "tsx package/mcp-server.ts",
|
|
34
34
|
"test": "jest",
|
|
35
|
-
"test:evals": "cd src/_deprecated/evals && python -m pytest test_cases/orchestrator/ -v",
|
|
36
35
|
"generate:catalog": "tsx scripts/generate-catalog-data.ts",
|
|
37
|
-
"prebuild
|
|
38
|
-
"build:binary": "
|
|
39
|
-
"build:all": "
|
|
36
|
+
"prebuild": "tsx scripts/generate-catalog-data.ts",
|
|
37
|
+
"build:binary": "pnpm prebuild && bun build package/mcp-server.ts --compile --outfile dist/prevention",
|
|
38
|
+
"build:all": "pnpm prebuild && bun build package/mcp-server.ts --compile --target=bun-linux-x64 --outfile dist/prevention-linux-x64 && bun build package/mcp-server.ts --compile --target=bun-darwin-arm64 --outfile dist/prevention-darwin-arm64 && bun build package/mcp-server.ts --compile --target=bun-darwin-x64 --outfile dist/prevention-darwin-x64"
|
|
40
39
|
},
|
|
41
40
|
"engines": {
|
|
42
41
|
"node": ">=18.0.0"
|
package/bin/lib/test-local.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Local Testing Setup
|
|
4
|
-
*
|
|
5
|
-
* Sets up a target project to use the local Prevention source code
|
|
6
|
-
* instead of the published npm package. Copies agents, commands,
|
|
7
|
-
* configures hooks, and points MCP server at local source.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* cd ~/Projects/my-test-project
|
|
11
|
-
* node ~/Projects/cd-agent/bin/lib/test-local.js
|
|
12
|
-
*
|
|
13
|
-
* Or via CLI:
|
|
14
|
-
* node ~/Projects/cd-agent/bin/cli.js test-local [target-dir]
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const fs = require('fs');
|
|
18
|
-
const path = require('path');
|
|
19
|
-
const { execSync } = require('child_process');
|
|
20
|
-
const { PACKAGE_ROOT, COMMANDS_DIR, AGENTS_DIR, AVESTA_DIR, copyDir, getVersion } = require('./utils');
|
|
21
|
-
const {
|
|
22
|
-
configureMcpServer,
|
|
23
|
-
configureSessionStartHook,
|
|
24
|
-
configureEnforcementHooks,
|
|
25
|
-
configurePermissions,
|
|
26
|
-
configureStatusLine,
|
|
27
|
-
ensureClaudeMdSection,
|
|
28
|
-
} = require('./settings');
|
|
29
|
-
|
|
30
|
-
function testLocal(targetDir) {
|
|
31
|
-
targetDir = targetDir || process.cwd();
|
|
32
|
-
const cdAgentRoot = PACKAGE_ROOT;
|
|
33
|
-
|
|
34
|
-
console.log(`\n Setting up local Prevention test environment...`);
|
|
35
|
-
console.log(` Source: ${cdAgentRoot}`);
|
|
36
|
-
console.log(` Target: ${targetDir}\n`);
|
|
37
|
-
|
|
38
|
-
// Step 1: Rebuild embedded assets
|
|
39
|
-
console.log(' [1/6] Rebuilding catalog + embedded assets...');
|
|
40
|
-
try {
|
|
41
|
-
execSync('pnpm run prebuild:assets', { cwd: cdAgentRoot, stdio: 'pipe' });
|
|
42
|
-
console.log(' ✓ Assets rebuilt');
|
|
43
|
-
} catch (e) {
|
|
44
|
-
console.error(' ✗ Asset rebuild failed:', e.message);
|
|
45
|
-
console.error(' Try running manually: cd ' + cdAgentRoot + ' && pnpm run prebuild:assets');
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Step 2: Copy agents + commands
|
|
50
|
-
console.log(' [2/6] Copying agents and commands...');
|
|
51
|
-
const claudeDir = path.join(targetDir, '.claude');
|
|
52
|
-
if (!fs.existsSync(claudeDir)) fs.mkdirSync(claudeDir, { recursive: true });
|
|
53
|
-
|
|
54
|
-
if (fs.existsSync(COMMANDS_DIR)) {
|
|
55
|
-
copyDir(COMMANDS_DIR, path.join(claudeDir, 'commands'));
|
|
56
|
-
}
|
|
57
|
-
if (fs.existsSync(AGENTS_DIR)) {
|
|
58
|
-
copyDir(AGENTS_DIR, path.join(claudeDir, 'agents'));
|
|
59
|
-
}
|
|
60
|
-
if (fs.existsSync(AVESTA_DIR)) {
|
|
61
|
-
copyDir(AVESTA_DIR, path.join(targetDir, '.avesta'));
|
|
62
|
-
}
|
|
63
|
-
const commandCount = fs.existsSync(COMMANDS_DIR) ? fs.readdirSync(COMMANDS_DIR).filter(f => f.endsWith('.md')).length : 0;
|
|
64
|
-
const agentCount = fs.existsSync(AGENTS_DIR) ? fs.readdirSync(AGENTS_DIR).filter(f => f.endsWith('.md')).length : 0;
|
|
65
|
-
console.log(` ✓ Copied ${commandCount} commands, ${agentCount} agents`);
|
|
66
|
-
|
|
67
|
-
// Step 3: Configure MCP servers (local source + remote content)
|
|
68
|
-
console.log(' [3/6] Configuring MCP servers (local source + remote content)...');
|
|
69
|
-
const mcpServerPath = path.join(cdAgentRoot, 'src', 'mcp-server.ts');
|
|
70
|
-
configureMcpServer(targetDir, null, { localSource: mcpServerPath });
|
|
71
|
-
console.log(` ✓ Local MCP server → npx tsx ${mcpServerPath}`);
|
|
72
|
-
const remoteUrl = process.env.AVESTA_MCP_URL || 'https://prevention-production.up.railway.app/mcp';
|
|
73
|
-
console.log(` ✓ Remote MCP server → ${remoteUrl}`);
|
|
74
|
-
|
|
75
|
-
// Step 4: Configure hooks (pointing at local CLI)
|
|
76
|
-
console.log(' [4/6] Configuring hooks...');
|
|
77
|
-
configureSessionStartHook(targetDir);
|
|
78
|
-
configureEnforcementHooks(targetDir);
|
|
79
|
-
configurePermissions(targetDir);
|
|
80
|
-
configureStatusLine(targetDir);
|
|
81
|
-
ensureClaudeMdSection(targetDir);
|
|
82
|
-
|
|
83
|
-
// Step 5: Write version
|
|
84
|
-
console.log(' [5/6] Writing version...');
|
|
85
|
-
const versionFile = path.join(targetDir, '.avesta', 'version.json');
|
|
86
|
-
const versionDir = path.dirname(versionFile);
|
|
87
|
-
if (!fs.existsSync(versionDir)) fs.mkdirSync(versionDir, { recursive: true });
|
|
88
|
-
fs.writeFileSync(versionFile, JSON.stringify({ version: getVersion(), updated_at: new Date().toISOString() }, null, 2));
|
|
89
|
-
console.log(` ✓ Version ${getVersion()}`);
|
|
90
|
-
|
|
91
|
-
// Step 6: Show result
|
|
92
|
-
console.log(' [6/6] Verifying setup...');
|
|
93
|
-
const settings = JSON.parse(fs.readFileSync(path.join(claudeDir, 'settings.json'), 'utf8'));
|
|
94
|
-
const hookTypes = Object.keys(settings.hooks || {});
|
|
95
|
-
console.log(` ✓ Hooks configured: ${hookTypes.join(', ')}`);
|
|
96
|
-
|
|
97
|
-
const mcpJsonPath = path.join(targetDir, '.mcp.json');
|
|
98
|
-
const mcpFinal = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf8'));
|
|
99
|
-
const mcpCmd = mcpFinal.mcpServers?.prevention?.command || '?';
|
|
100
|
-
const mcpArgs = (mcpFinal.mcpServers?.prevention?.args || []).join(' ');
|
|
101
|
-
console.log(` ✓ Local MCP: ${mcpCmd} ${mcpArgs}`);
|
|
102
|
-
const remoteEntry = mcpFinal.mcpServers?.['prevention-content'];
|
|
103
|
-
console.log(` ✓ Remote MCP: ${remoteEntry?.url || 'not configured'}`);
|
|
104
|
-
|
|
105
|
-
console.log(`
|
|
106
|
-
✅ Local test environment ready! (v${getVersion()})
|
|
107
|
-
|
|
108
|
-
Changes from source at ${cdAgentRoot} are active.
|
|
109
|
-
No npm publish needed — MCP server runs from source via tsx.
|
|
110
|
-
|
|
111
|
-
To test:
|
|
112
|
-
1. Open Claude Code in ${targetDir}
|
|
113
|
-
2. Run avesta login to authenticate (connects remote content server)
|
|
114
|
-
3. Run /avesta-init backend (or frontend)
|
|
115
|
-
4. Test skill enforcement: /avesta-red should block writes until skills loaded
|
|
116
|
-
5. Test gate enforcement: git commit should be blocked without review gate
|
|
117
|
-
|
|
118
|
-
To revert to published version:
|
|
119
|
-
node ${path.join(cdAgentRoot, 'bin', 'cli.js')} update
|
|
120
|
-
`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (require.main === module) {
|
|
124
|
-
testLocal(process.argv[2]);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = { testLocal };
|