@cnrai/pave 0.3.32 → 0.3.34

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.
Files changed (83) hide show
  1. package/MARKETPLACE.md +406 -0
  2. package/README.md +218 -21
  3. package/build-binary.js +591 -0
  4. package/build-npm.js +537 -0
  5. package/build.js +230 -0
  6. package/check-binary.js +26 -0
  7. package/deploy.sh +95 -0
  8. package/index.js +5775 -0
  9. package/lib/agent-registry.js +1037 -0
  10. package/lib/args-parser.js +837 -0
  11. package/lib/blessed-widget-patched.js +93 -0
  12. package/lib/cli-markdown.js +590 -0
  13. package/lib/compaction.js +153 -0
  14. package/lib/duration.js +94 -0
  15. package/lib/hash.js +22 -0
  16. package/lib/marketplace.js +866 -0
  17. package/lib/memory-config.js +166 -0
  18. package/lib/skill-manager.js +891 -0
  19. package/lib/soul.js +31 -0
  20. package/lib/tool-output-formatter.js +180 -0
  21. package/package.json +35 -33
  22. package/start-pave.sh +149 -0
  23. package/status.js +271 -0
  24. package/test/abort-stream.test.js +445 -0
  25. package/test/agent-auto-compaction.test.js +552 -0
  26. package/test/agent-comm-abort.test.js +95 -0
  27. package/test/agent-comm.test.js +598 -0
  28. package/test/agent-inbox.test.js +576 -0
  29. package/test/agent-init.test.js +264 -0
  30. package/test/agent-interrupt.test.js +314 -0
  31. package/test/agent-lifecycle.test.js +520 -0
  32. package/test/agent-log-files.test.js +349 -0
  33. package/test/agent-mode.manual-test.js +392 -0
  34. package/test/agent-parsing.test.js +228 -0
  35. package/test/agent-post-stream-idle.test.js +762 -0
  36. package/test/agent-registry.test.js +359 -0
  37. package/test/agent-rm.test.js +442 -0
  38. package/test/agent-spawn.test.js +933 -0
  39. package/test/agent-status-api.test.js +624 -0
  40. package/test/agent-update.test.js +435 -0
  41. package/test/args-parser.test.js +391 -0
  42. package/test/auto-compaction-chat.manual-test.js +227 -0
  43. package/test/auto-compaction.test.js +941 -0
  44. package/test/build-config.test.js +120 -0
  45. package/test/build-npm.test.js +388 -0
  46. package/test/chat-command.test.js +137 -0
  47. package/test/chat-leading-lines.test.js +159 -0
  48. package/test/config-flag.test.js +272 -0
  49. package/test/cursor-drift.test.js +135 -0
  50. package/test/debug-require.js +23 -0
  51. package/test/dir-migration.test.js +323 -0
  52. package/test/duration.test.js +229 -0
  53. package/test/ghostty-term.test.js +202 -0
  54. package/test/http500-backoff.test.js +854 -0
  55. package/test/integration.test.js +86 -0
  56. package/test/memory-guard-env.test.js +220 -0
  57. package/test/pr233-fixes.test.js +259 -0
  58. package/test/run-agent-init.js +297 -0
  59. package/test/run-all.js +64 -0
  60. package/test/run-config-flag.js +159 -0
  61. package/test/run-cursor-drift.js +82 -0
  62. package/test/run-session-path.js +154 -0
  63. package/test/run-tests.js +643 -0
  64. package/test/sandbox-redirect.test.js +202 -0
  65. package/test/session-path.test.js +132 -0
  66. package/test/shebang-strip.test.js +241 -0
  67. package/test/soul-reinject.test.js +1027 -0
  68. package/test/soul-reread.test.js +281 -0
  69. package/test/tool-output-formatter.test.js +486 -0
  70. package/test/tool-output-gating.test.js +143 -0
  71. package/test/tool-states.test.js +167 -0
  72. package/test/tools-flag.test.js +65 -0
  73. package/test/tui-attach.test.js +1255 -0
  74. package/test/tui-compaction.test.js +354 -0
  75. package/test/tui-wrap.test.js +568 -0
  76. package/test-binary.js +52 -0
  77. package/test-binary2.js +36 -0
  78. package/LICENSE +0 -21
  79. package/pave.js +0 -2
  80. package/sandbox/SandboxRunner.js +0 -1
  81. package/sandbox/pave-run.js +0 -2
  82. package/sandbox/permission.js +0 -1
  83. package/sandbox/utils/yaml.js +0 -1
package/status.js ADDED
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PAVE Project Status - Display project overview and health check
4
+ */
5
+
6
+ const path = require('path');
7
+ const fs = require('fs');
8
+ const { execSync } = require('child_process');
9
+
10
+ function _log(message, type = 'INFO') {
11
+ const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
12
+ const prefix = `[${timestamp}] [${type}]`;
13
+ console.log(`${prefix} ${message}`);
14
+ }
15
+
16
+ function checkFileExists(filePath) {
17
+ return fs.existsSync(filePath);
18
+ }
19
+
20
+ function getFileSize(filePath) {
21
+ try {
22
+ const stats = fs.statSync(filePath);
23
+ return (stats.size / 1024).toFixed(1) + ' KB';
24
+ } catch (e) {
25
+ return 'Unknown';
26
+ }
27
+ }
28
+
29
+ function runCommand(command, options = {}) {
30
+ try {
31
+ const output = execSync(command, {
32
+ encoding: 'utf8',
33
+ timeout: 5000,
34
+ ...options,
35
+ });
36
+ return output.trim();
37
+ } catch (e) {
38
+ return null;
39
+ }
40
+ }
41
+
42
+ function checkProjectStatus() {
43
+ console.log('='.repeat(70));
44
+ console.log('PAVE PROJECT STATUS');
45
+ console.log('='.repeat(70));
46
+
47
+ const projectRoot = path.join(__dirname, '..');
48
+ const paveRoot = __dirname;
49
+ const opencodeLiteRoot = path.join(projectRoot, 'opencode-lite');
50
+
51
+ console.log('\\n📁 PROJECT STRUCTURE:');
52
+ console.log(` Project root: ${projectRoot}`);
53
+ console.log(` PAVE package: ${paveRoot}`);
54
+ console.log(` OpenCode-Lite: ${opencodeLiteRoot}`);
55
+
56
+ // Check core files
57
+ console.log('\\n📄 CORE FILES:');
58
+ const coreFiles = [
59
+ { name: 'PAVE Main', path: path.join(paveRoot, 'index.js') },
60
+ { name: 'PAVE Build Script', path: path.join(paveRoot, 'build.js') },
61
+ { name: 'PAVE Test Suite', path: path.join(paveRoot, 'test-tools.js') },
62
+ { name: 'OpenCode-Lite Server', path: path.join(opencodeLiteRoot, 'src/index.js') },
63
+ { name: 'OpenCode-Lite Tools', path: path.join(opencodeLiteRoot, 'src/tools/index.js') },
64
+ { name: 'Fetch Tool', path: path.join(opencodeLiteRoot, 'src/tools/fetch.js') },
65
+ ];
66
+
67
+ for (const file of coreFiles) {
68
+ const exists = checkFileExists(file.path);
69
+ const size = exists ? getFileSize(file.path) : 'Missing';
70
+ const status = exists ? '✅' : '❌';
71
+ console.log(` ${status} ${file.name}: ${size}`);
72
+ }
73
+
74
+ // Check build artifacts
75
+ console.log('\\n🏗️ BUILD STATUS:');
76
+ const distPath = path.join(paveRoot, 'dist');
77
+ const bundlePath = path.join(distPath, 'pave.js');
78
+
79
+ if (checkFileExists(distPath)) {
80
+ console.log(' ✅ Dist directory exists');
81
+ if (checkFileExists(bundlePath)) {
82
+ console.log(` ✅ Bundle exists: ${getFileSize(bundlePath)}`);
83
+
84
+ // Check if bundle is executable
85
+ try {
86
+ const stats = fs.statSync(bundlePath);
87
+ const isExecutable = (stats.mode & 0o111) !== 0;
88
+ console.log(` ${isExecutable ? '✅' : '❌'} Bundle is executable`);
89
+ } catch (e) {
90
+ console.log(' ❌ Cannot check bundle permissions');
91
+ }
92
+ } else {
93
+ console.log(' ❌ Bundle missing - run npm run build');
94
+ }
95
+ } else {
96
+ console.log(' ❌ Dist directory missing - run npm run build');
97
+ }
98
+
99
+ // Check dependencies
100
+ console.log('\\n📦 DEPENDENCIES:');
101
+ const packagePath = path.join(paveRoot, 'package.json');
102
+ if (checkFileExists(packagePath)) {
103
+ console.log(' ✅ Package.json exists');
104
+
105
+ try {
106
+ const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
107
+ console.log(` 📝 Version: ${pkg.version}`);
108
+ console.log(` 📝 Node requirement: ${pkg.engines?.node || 'Not specified'}`);
109
+
110
+ const depCount = Object.keys(pkg.dependencies || {}).length;
111
+ const devDepCount = Object.keys(pkg.devDependencies || {}).length;
112
+ console.log(` 📝 Dependencies: ${depCount} production, ${devDepCount} development`);
113
+
114
+ // Check if node_modules exists for development dependencies
115
+ if (devDepCount > 0) {
116
+ const nodeModulesPath = path.join(paveRoot, 'node_modules');
117
+ if (checkFileExists(nodeModulesPath)) {
118
+ console.log(' ✅ node_modules installed');
119
+ } else {
120
+ console.log(' ❌ node_modules missing - run npm install');
121
+ }
122
+ }
123
+ } catch (e) {
124
+ console.log(' ❌ Cannot parse package.json');
125
+ }
126
+ } else {
127
+ console.log(' ❌ Package.json missing');
128
+ }
129
+
130
+ // Check OpenCode-Lite tools
131
+ console.log('\\n🔧 OPENCODE-LITE TOOLS:');
132
+ try {
133
+ const toolsPath = path.join(opencodeLiteRoot, 'src/tools/index.js');
134
+ if (checkFileExists(toolsPath)) {
135
+ // Try to load tools
136
+ delete require.cache[require.resolve(toolsPath)];
137
+ const { getTools } = require(toolsPath);
138
+ const tools = getTools();
139
+
140
+ console.log(` ✅ Tools system working: ${tools.length} tools available`);
141
+
142
+ const toolNames = tools.map((t) => t.function.name);
143
+ console.log(` 📝 Available tools: ${toolNames.join(', ')}`);
144
+
145
+ // Check for fetch tool specifically
146
+ if (toolNames.includes('fetch')) {
147
+ console.log(' ✅ Fetch tool available (replaces wget/curl)');
148
+ } else {
149
+ console.log(' ❌ Fetch tool missing');
150
+ }
151
+ } else {
152
+ console.log(' ❌ Tools system missing');
153
+ }
154
+ } catch (e) {
155
+ console.log(' ❌ Tools system error: ' + e.message);
156
+ }
157
+
158
+ // Check Git status
159
+ console.log('\\n📚 GIT STATUS:');
160
+ const gitBranch = runCommand('git branch --show-current', { cwd: projectRoot });
161
+ const gitStatus = runCommand('git status --porcelain', { cwd: projectRoot });
162
+
163
+ if (gitBranch) {
164
+ console.log(` ✅ Git repository: branch '${gitBranch}'`);
165
+
166
+ if (gitStatus) {
167
+ const lines = gitStatus.split('\\n').filter((l) => l.trim());
168
+ console.log(` 📝 Uncommitted changes: ${lines.length} files`);
169
+ if (lines.length <= 5) {
170
+ lines.forEach((line) => console.log(` ${line}`));
171
+ } else {
172
+ lines.slice(0, 3).forEach((line) => console.log(` ${line}`));
173
+ console.log(` ... and ${lines.length - 3} more files`);
174
+ }
175
+ } else {
176
+ console.log(' ✅ Working directory clean');
177
+ }
178
+
179
+ const lastCommit = runCommand('git log -1 --pretty=format:"%h - %an: %s (%cr)"', { cwd: projectRoot });
180
+ if (lastCommit) {
181
+ console.log(` 📝 Last commit: ${lastCommit}`);
182
+ }
183
+ } else {
184
+ console.log(' ❌ Not a Git repository or Git not available');
185
+ }
186
+
187
+ // System information
188
+ console.log('\\n💻 SYSTEM INFO:');
189
+ console.log(` 📝 Node.js: ${process.version}`);
190
+ console.log(` 📝 Platform: ${process.platform} ${process.arch}`);
191
+ console.log(` 📝 Working directory: ${process.cwd()}`);
192
+
193
+ const memoryUsage = process.memoryUsage();
194
+ console.log(` 📝 Memory usage: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)}MB heap`);
195
+
196
+ // Check if running on iSH
197
+ const isISH = process.platform === 'linux' &&
198
+ (process.env.TERM_PROGRAM === 'iSH' ||
199
+ checkFileExists('/etc/alpine-release'));
200
+
201
+ if (isISH) {
202
+ console.log(' 🏔️ Running on iSH (iOS Alpine Linux)');
203
+ }
204
+
205
+ // Quick functionality test
206
+ console.log('\\n🧪 QUICK TESTS:');
207
+
208
+ try {
209
+ // Test argument parsing
210
+ const { parseArgs } = require(path.join(paveRoot, 'lib/args-parser'));
211
+ const _testArgs = parseArgs(['--help']);
212
+ console.log(' ✅ CLI argument parsing works');
213
+ } catch (e) {
214
+ console.log(' ❌ CLI argument parsing failed: ' + e.message);
215
+ }
216
+
217
+ try {
218
+ // Test memory configuration
219
+ const { applyMemoryConfig: _applyMemoryConfig } = require(path.join(paveRoot, 'lib/memory-config'));
220
+ console.log(' ✅ Memory configuration system works');
221
+ } catch (e) {
222
+ console.log(' ❌ Memory configuration failed: ' + e.message);
223
+ }
224
+
225
+ console.log('\\n' + '='.repeat(70));
226
+ console.log('STATUS SUMMARY');
227
+ console.log('='.repeat(70));
228
+
229
+ // Count checks
230
+ let passed = 0;
231
+ let total = 0;
232
+
233
+ // This is a simple heuristic - in a real implementation, we'd track each check
234
+ const hasMainFiles = checkFileExists(path.join(paveRoot, 'index.js'));
235
+ const hasBuild = checkFileExists(path.join(distPath, 'pave.js'));
236
+ const hasTools = checkFileExists(path.join(opencodeLiteRoot, 'src/tools/index.js'));
237
+ const hasPackage = checkFileExists(packagePath);
238
+
239
+ total = 4;
240
+ if (hasMainFiles) passed++;
241
+ if (hasBuild) passed++;
242
+ if (hasTools) passed++;
243
+ if (hasPackage) passed++;
244
+
245
+ console.log(`\\n📊 Health Check: ${passed}/${total} core components OK`);
246
+
247
+ if (passed === total) {
248
+ console.log('\\n🎉 PAVE PROJECT STATUS: HEALTHY');
249
+ console.log('\\n✨ Ready to use:');
250
+ console.log(' • npm start - Run PAVE');
251
+ console.log(' • npm run start:ish - Run with iSH optimizations');
252
+ console.log(' • npm test - Run tool tests');
253
+ console.log(' • npm run build - Create distribution');
254
+ } else {
255
+ console.log('\\n⚠️ PAVE PROJECT STATUS: NEEDS ATTENTION');
256
+ console.log('\\n🔧 Suggested fixes:');
257
+ if (!hasMainFiles) console.log(' • Restore missing core files');
258
+ if (!hasBuild) console.log(' • Run: npm run build');
259
+ if (!hasTools) console.log(' • Check OpenCode-Lite installation');
260
+ if (!hasPackage) console.log(' • Restore package.json');
261
+ }
262
+
263
+ console.log('');
264
+ }
265
+
266
+ // Run status check
267
+ if (require.main === module) {
268
+ checkProjectStatus();
269
+ }
270
+
271
+ module.exports = { checkProjectStatus };