principles-disciple 1.39.0 → 1.41.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/esbuild.config.js CHANGED
@@ -25,6 +25,7 @@ function copyRecursive(src, dest) {
25
25
 
26
26
  async function bundlePlugin() {
27
27
  try {
28
+ // 1. Build the main bundle for OpenClaw
28
29
  await build({
29
30
  entryPoints: ['src/index.ts'],
30
31
  outfile: 'dist/bundle.js',
@@ -44,7 +45,35 @@ async function bundlePlugin() {
44
45
  metafile: true,
45
46
  });
46
47
 
47
- console.log('Bundle created: dist/bundle.js');
48
+ console.log('Main bundle created: dist/bundle.js');
49
+
50
+ // 2. Build core tools for CLI usage (bootstrap-rules, etc)
51
+ // We keep these separate and un-minified for easier debugging and CLI importing
52
+ await build({
53
+ entryPoints: {
54
+ 'core/bootstrap-rules': 'src/core/bootstrap-rules.ts',
55
+ 'core/principle-tree-ledger': 'src/core/principle-tree-ledger.ts',
56
+ 'core/principle-training-state': 'src/core/principle-training-state.ts',
57
+ 'core/principle-compiler/index': 'src/core/principle-compiler/index.ts',
58
+ 'core/trajectory/index': 'src/core/trajectory.ts',
59
+ },
60
+ outdir: 'dist',
61
+ bundle: true,
62
+ platform: 'node',
63
+ target: 'node20',
64
+ format: 'esm',
65
+ outbase: 'src',
66
+ external: [
67
+ 'openclaw',
68
+ '@openclaw/sdk',
69
+ '@openclaw/plugin-kit',
70
+ 'better-sqlite3',
71
+ ],
72
+ sourcemap: false,
73
+ minify: false,
74
+ });
75
+
76
+ console.log('Core CLI tools built in dist/core/');
48
77
 
49
78
  const staticFiles = ['templates', 'openclaw.plugin.json'];
50
79
  const distDir = 'dist';
@@ -65,9 +94,9 @@ async function bundlePlugin() {
65
94
  console.log(`Copied: ${file} -> dist/${file}`);
66
95
  }
67
96
 
68
- console.log('\nPlugin bundle ready for distribution.');
97
+ console.log('\nPlugin build ready for distribution.');
69
98
  } catch (error) {
70
- console.error('Bundle failed:', error);
99
+ console.error('Build failed:', error);
71
100
  process.exit(1);
72
101
  }
73
102
  }
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
5
- "version": "1.39.0",
5
+ "version": "1.41.0",
6
6
  "skills": [
7
7
  "./skills"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.js",
@@ -30,13 +30,14 @@
30
30
  "build:web": "node scripts/build-web.mjs",
31
31
  "build:bundle": "node esbuild.config.js && node scripts/build-web.mjs",
32
32
  "build:production": "node esbuild.config.js --production && node scripts/build-web.mjs --production && node scripts/verify-build.mjs",
33
- "test": "vitest run --project=unit",
34
- "test:unit": "vitest run --project=unit",
35
- "test:integration": "vitest run --project=integration",
36
- "test:coverage": "vitest run --project=unit --coverage",
33
+ "test": "vitest run",
34
+ "test:unit": "vitest run tests/core tests/service tests/hooks tests/commands tests/utils tests/scripts --exclude tests/commands/evolver.test.ts",
35
+ "test:integration": "vitest run tests/integration/",
36
+ "test:coverage": "vitest run --coverage",
37
37
  "test:all": "vitest run",
38
38
  "lint": "eslint src/",
39
39
  "bootstrap-rules": "node scripts/bootstrap-rules.mjs",
40
+ "compile-principles": "node scripts/compile-principles.mjs",
40
41
  "validate-live-path": "tsx scripts/validate-live-path.ts"
41
42
  },
42
43
  "devDependencies": {
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Principle Compiler CLI
5
+ *
6
+ * Compiles eligible principles (those derived from pain events) into
7
+ * auto-generated rules via the PrincipleCompiler pipeline.
8
+ *
9
+ * Usage:
10
+ * npm run compile-principles
11
+ * WORKSPACE_DIR=/path/to/workspace npm run compile-principles
12
+ * node scripts/compile-principles.mjs /path/to/workspace
13
+ */
14
+
15
+ import { join, dirname } from 'path';
16
+ import { fileURLToPath } from 'url';
17
+
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = dirname(__filename);
20
+
21
+ // Resolve workspace directory: CLI arg > env var > default
22
+ const WORKSPACE_DIR = process.argv[2]
23
+ || process.env.WORKSPACE_DIR
24
+ || join(process.env.HOME, '.openclaw', 'workspace-main');
25
+
26
+ const STATE_DIR = join(WORKSPACE_DIR, '.state');
27
+
28
+ async function run() {
29
+ console.log('Principle Compiler CLI');
30
+ console.log(` Workspace: ${WORKSPACE_DIR}`);
31
+ console.log(` State dir: ${STATE_DIR}`);
32
+
33
+ let compilerModule, trajectoryModule;
34
+
35
+ try {
36
+ compilerModule = await import('../dist/core/principle-compiler/index.js');
37
+ } catch {
38
+ console.error('PrincipleCompiler module not found in dist/. Build first: node esbuild.config.js');
39
+ process.exit(1);
40
+ }
41
+
42
+ try {
43
+ trajectoryModule = await import('../dist/core/trajectory/index.js');
44
+ } catch {
45
+ console.error('TrajectoryDatabase module not found in dist/. Build first: node esbuild.config.js');
46
+ process.exit(1);
47
+ }
48
+
49
+ const { PrincipleCompiler } = compilerModule;
50
+ const { TrajectoryDatabase } = trajectoryModule;
51
+
52
+ let trajectory;
53
+ try {
54
+ trajectory = new TrajectoryDatabase({ workspaceDir: WORKSPACE_DIR });
55
+ } catch (err) {
56
+ console.error(`Failed to open trajectory database: ${err.message}`);
57
+ process.exit(1);
58
+ }
59
+
60
+ try {
61
+ const compiler = new PrincipleCompiler(STATE_DIR, trajectory);
62
+
63
+ console.log('\nCompiling eligible principles...');
64
+ const results = compiler.compileAll();
65
+
66
+ const succeeded = results.filter(r => r.success);
67
+ const failed = results.filter(r => !r.success);
68
+
69
+ console.log(`\nResults: ${succeeded.length} succeeded, ${failed.length} failed`);
70
+
71
+ for (const r of succeeded) {
72
+ console.log(` + ${r.principleId} -> rule ${r.ruleId} (impl: ${r.implementationId})`);
73
+ }
74
+
75
+ for (const r of failed) {
76
+ console.log(` x ${r.principleId}: ${r.reason}`);
77
+ }
78
+
79
+ if (results.length === 0) {
80
+ console.log(' No eligible principles found for compilation.');
81
+ }
82
+
83
+ if (failed.length > 0) {
84
+ process.exitCode = 1;
85
+ }
86
+ } finally {
87
+ trajectory.dispose();
88
+ }
89
+ }
90
+
91
+ run().catch((err) => {
92
+ console.error(`Fatal: ${err.message}`);
93
+ process.exit(1);
94
+ });