feat(core): Add permission-controlled Deno execution, configurable script server port, improved downloader, dependency bumps and test updates

This commit is contained in:
2025-12-02 11:27:35 +00:00
parent 01dd40e599
commit fb0bfed4ab
20 changed files with 7919 additions and 3613 deletions

1
.serena/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/cache

View File

@@ -0,0 +1,47 @@
# Code Style and Conventions
## Naming Conventions
- **Interfaces**: Prefix with `I` (e.g., `IDenoRelease`, `IAsset`)
- **Types**: Prefix with `T` (not heavily used in this codebase)
- **Classes**: PascalCase (e.g., `SmartDeno`, `DenoDownloader`)
- **Files**: Lowercase, hyphenated (e.g., `classes.smartdeno.ts`, `classes.denodownloader.ts`)
- **Methods/Properties**: camelCase
## File Organization
- **Source**: `ts/` directory
- **Tests**: `test/` directory
- **Compiled Output**: `dist_ts/` (excluded from git)
- **Temporary Files**: `.nogit/` directory (excluded from git)
## File Naming Patterns
- Classes: `classes.<name>.ts` (e.g., `classes.smartdeno.ts`)
- Entry point: `index.ts`
- Plugin/dependency imports: `plugins.ts`
- Path configurations: `paths.ts`
## Import Patterns
1. **All module dependencies** imported in `ts/plugins.ts`
2. **References use full path**: `plugins.moduleName.className()`
3. **Local imports** use `.js` extension (for ESM compatibility)
Example from plugins.ts:
```typescript
import * as smartfile from '@push.rocks/smartfile';
export { smartfile };
```
Usage:
```typescript
import * as plugins from './plugins.js';
plugins.smartfile.fs.writeFile(...);
```
## Class Patterns
- Private properties for internal state
- Public async methods for API
- Dependency injection where appropriate
- JSDoc comments for public methods
## Module Resolution
- Always use `.js` extension in imports (even for `.ts` files)
- This is required for ESM compatibility with NodeNext resolution

View File

@@ -0,0 +1,63 @@
# Codebase Structure
## Directory Layout
```
smartdeno/
├── ts/ # Source code
│ ├── index.ts # Main entry point (exports SmartDeno)
│ ├── plugins.ts # Dependency imports
│ ├── paths.ts # Path configurations
│ ├── classes.smartdeno.ts # Main SmartDeno class
│ ├── classes.denodownloader.ts # Deno download logic
│ ├── classes.scriptserver.ts # Script execution server
│ ├── classes.denoexecution.ts # Script execution wrapper
│ └── 00_commitinfo_data.ts # Commit metadata
├── test/ # Test files
│ └── test.ts # Main test suite
├── dist_ts/ # Compiled output (gitignored)
├── .nogit/ # Temporary/debug files (gitignored)
├── assets/ # Static assets
├── .gitea/ # Gitea-specific configs
├── .vscode/ # VS Code settings
├── .claude/ # Claude Code settings
├── .serena/ # Serena agent settings
├── package.json # Package manifest
├── tsconfig.json # TypeScript config
├── npmextra.json # Extended npm metadata
├── readme.md # Main documentation
└── readme.hints.md # Development hints (currently empty)
```
## Core Classes
### SmartDeno (ts/classes.smartdeno.ts)
Main orchestrator class with methods:
- `start(options)` - Initialize and download Deno if needed
- `stop()` - Cleanup resources
- `executeScript(scriptArg)` - Execute a Deno script
### DenoDownloader (ts/classes.denodownloader.ts)
Handles Deno binary download:
- Fetches latest Deno release from GitHub
- Platform detection (Linux, macOS, Windows)
- Architecture detection (x64, arm64)
- Downloads and extracts Deno binary
### ScriptServer (ts/classes.scriptserver.ts)
Internal server for script execution
### DenoExecution (ts/classes.denoexecution.ts)
Wraps individual script execution
## Entry Point Flow
1. User imports from `@push.rocks/smartdeno`
2. `index.ts` exports `SmartDeno` class
3. User creates instance: `new SmartDeno()`
4. User calls `await smartDeno.start()` to initialize
5. User calls `await smartDeno.executeScript(code)` to run Deno code
## Dependencies Pattern
All external dependencies are:
1. Imported in `plugins.ts`
2. Exported as namespace
3. Used with full path (e.g., `plugins.smartfile.fs.readFile()`)

View File

@@ -0,0 +1,20 @@
# Project Overview
## Purpose
**@push.rocks/smartdeno** is a Node.js module that enables running Deno scripts from within Node.js environments. It provides functionality for:
- Automatically downloading Deno if not available in the system
- Executing Deno scripts from Node.js
- Running a script server for ephemeral execution
- Cross-platform support (Linux, macOS, Windows)
## Key Features
- Seamless integration of Deno into Node.js workflows
- Automatic Deno version management and downloading
- Script execution via internal server
- Support for both local and system-wide Deno installations
## Business Context
- Owned and maintained by Task Venture Capital GmbH
- MIT License (with trademark restrictions)
- Published as `@push.rocks/smartdeno` on npm
- Repository hosted at https://code.foss.global/push.rocks/smartdeno

View File

@@ -0,0 +1,89 @@
# Suggested Commands
## Package Management
```bash
# Install dependencies
pnpm install
# Add runtime dependency
pnpm install --save <package>
# Add dev dependency
pnpm install --save-dev <package>
```
## Development Commands
### Building
```bash
# Build the project (compiles TypeScript)
pnpm build
# Equivalent to: tsbuild --web --allowimplicitany
# Type check without building
tsbuild check ts/**/* --skiplibcheck # For source files
```
### Testing
```bash
# Run all tests
pnpm test
# Equivalent to: tstest test/ --web
# Run specific test file
tstest test/test.ts --verbose
# Run test with log file output
tstest test/test.ts --verbose --logfile .nogit/testlogs/test.log
```
### Documentation
```bash
# Build documentation
pnpm buildDocs
# Equivalent to: tsdoc
```
### Running TypeScript Files
```bash
# tsx is available globally for direct execution
tsx path/to/file.ts
```
## Git Commands
```bash
# Check status
git status
# Stage and commit (use small, focused commits)
git add <files>
git commit -m "description"
# Move files (preserves history)
git mv old-path new-path
```
## System Commands (Linux)
- `ls` - List directory contents
- `cd` - Change directory
- `grep` - Search text
- `find` - Find files
- `cat` - Display file contents
- `kill <PID>` - Kill specific process (NEVER use `killall node`)
## Port Management
```bash
# Find process on port
lsof -i :80
lsof -i :443
# Kill specific PID
kill <PID>
# Wait between server restarts
sleep 10
```
## Debug Scripts
- Store debug scripts in `.nogit/debug/`
- Run with: `tsx .nogit/debug/script-name.ts`

View File

@@ -0,0 +1,86 @@
# Task Completion Checklist
## After Code Changes
### 1. Type Checking
```bash
# Check source files
pnpm build
# Check test files
tsbuild check test/**/* --skiplibcheck
```
### 2. Testing
```bash
# Run all tests
pnpm test
# Or run specific test
tstest test/test.ts --verbose
```
### 3. Linting/Formatting
- No explicit linter/formatter configured in package.json
- Follow existing code style patterns
### 4. Documentation
```bash
# Update documentation if public API changed
pnpm buildDocs
```
## Before Committing
### 1. Verify Changes
```bash
git status
git diff
```
### 2. Stage Files
```bash
git add <files>
```
### 3. Commit with Clear Message
```bash
git commit -m "Brief description of single focused change"
```
### Commit Best Practices
- **Small, focused commits** with single clear purpose
- **Descriptive messages** explaining "what" and "why"
- **Avoid mixing** different change types in one commit
- **Use git mv** for file operations to preserve history
## Testing Requirements
### Test File Naming
- `*.both.ts` - Browser and Node tests
- `*.node.ts` - Node-only tests
- `*.browser.ts` - Browser-only tests
### Test File Requirements
- Import `expect`, `expectAsync`, `tap` from `@push.rocks/tapbundle`
- Import TypeScript files directly (never compiled JS)
- **MUST end with**: `export default tap.start()` or `tap.start()`
- Place stubs ONLY in test files, never in production code
## Common Issues
### Missing tsrun
```bash
# If you get "tsrun: command not found"
pnpm install --save-dev @git.zone/tsrun
```
### Server Management
- **Before reading logs**: Wait 20 seconds for complete log writes
- **When killing servers**: Find specific PID, never `killall node`
- **Between restarts**: Wait 10 seconds
## Documentation Updates
- Update `readme.md` if public API changes
- Consider updating `readme.hints.md` for development findings
- Store plans in `readme.plan.md` if needed

View File

@@ -0,0 +1,35 @@
# Tech Stack
## Language & Runtime
- **TypeScript** (ES2022 target)
- **Node.js** (ES Modules, NodeNext module resolution)
- Experimental decorators enabled
## Package Manager
- **pnpm** exclusively (never npm or yarn)
## Key Dependencies
### Runtime Dependencies
- `@api.global/typedserver` - Typed server functionality
- `@push.rocks/lik` - Core utilities
- `@push.rocks/smartarchive` - Archive handling (for Deno zip extraction)
- `@push.rocks/smartfile` - File system operations
- `@push.rocks/smartpath` - Path utilities
- `@push.rocks/smartshell` - Shell command execution
- `@push.rocks/smartunique` - Unique ID generation
### Dev Dependencies
- `@git.zone/tsbuild` - TypeScript building
- `@git.zone/tsbundle` - Bundling
- `@git.zone/tsrun` - Running TypeScript
- `@git.zone/tstest` - Testing framework
- `@push.rocks/tapbundle` - TAP testing utilities
## Build Configuration
- **Module System**: ES Modules (type: "module")
- **Module Resolution**: NodeNext
- **Verbatim Module Syntax**: Enabled
- **Experimental Decorators**: Enabled
- **Use Define for Class Fields**: False
- **Browser Target**: Latest Chrome version

67
.serena/project.yml Normal file
View File

@@ -0,0 +1,67 @@
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
# * For C, use cpp
# * For JavaScript, use typescript
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: typescript
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed) on 2025-04-07
ignored_paths: []
# whether the project is in read-only mode
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
# Added on 2025-04-18
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
# * `create_text_file`: Creates/overwrites a file in the project directory.
# * `delete_lines`: Deletes a range of lines within a file.
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
# * `execute_shell_command`: Executes a shell command.
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
# * `initial_instructions`: Gets the initial instructions for the current project.
# Should only be used in settings where the system prompt cannot be set,
# e.g. in clients you have no control over, like Claude Desktop.
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
# * `insert_at_line`: Inserts content at a given line in a file.
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
# * `list_memories`: Lists memories in Serena's project-specific memory store.
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
# * `read_file`: Reads a file within the project directory.
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
# * `remove_project`: Removes a project from the Serena configuration.
# * `replace_lines`: Replaces a range of lines within a file with new content.
# * `replace_symbol_body`: Replaces the full definition of a symbol.
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
# * `search_for_pattern`: Performs a search for a pattern in the project.
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
# * `switch_modes`: Activates modes by providing a list of their names
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
excluded_tools: []
# initial prompt for the project. It will always be given to the LLM upon activating the project
# (contrary to the memories, which are loaded on demand).
initial_prompt: ""
project_name: "smartdeno"