Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/debug/jtag/browser/generated.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Browser Structure Registry - Auto-generated
*
* Contains 11 daemons and 201 commands and 2 adapters and 28 widgets.
* Contains 11 daemons and 204 commands and 2 adapters and 28 widgets.
* Generated by scripts/generate-structure.ts - DO NOT EDIT MANUALLY
*/

Expand Down Expand Up @@ -146,6 +146,9 @@ import { WebFetchBrowserCommand } from './../commands/interface/web/fetch/browse
import { InterfaceWebmcpCallBrowserCommand } from './../commands/interface/webmcp/call/browser/InterfaceWebmcpCallBrowserCommand';
import { InterfaceWebmcpDiscoverBrowserCommand } from './../commands/interface/webmcp/discover/browser/InterfaceWebmcpDiscoverBrowserCommand';
import { ListBrowserCommand } from './../commands/list/browser/ListBrowserCommand';
import { LoggingDisableBrowserCommand } from './../commands/logging/disable/browser/LoggingDisableBrowserCommand';
import { LoggingEnableBrowserCommand } from './../commands/logging/enable/browser/LoggingEnableBrowserCommand';
import { LoggingStatusBrowserCommand } from './../commands/logging/status/browser/LoggingStatusBrowserCommand';
import { LogsConfigBrowserCommand } from './../commands/logs/config/browser/LogsConfigBrowserCommand';
import { LogsListBrowserCommand } from './../commands/logs/list/browser/LogsListBrowserCommand';
import { LogsReadBrowserCommand } from './../commands/logs/read/browser/LogsReadBrowserCommand';
Expand Down Expand Up @@ -958,6 +961,21 @@ export const BROWSER_COMMANDS: CommandEntry[] = [
className: 'ListBrowserCommand',
commandClass: ListBrowserCommand
},
{
name: 'logging/disable',
className: 'LoggingDisableBrowserCommand',
commandClass: LoggingDisableBrowserCommand
},
{
name: 'logging/enable',
className: 'LoggingEnableBrowserCommand',
commandClass: LoggingEnableBrowserCommand
},
{
name: 'logging/status',
className: 'LoggingStatusBrowserCommand',
commandClass: LoggingStatusBrowserCommand
},
{
name: 'logs/config',
className: 'LogsConfigBrowserCommand',
Expand Down
20 changes: 20 additions & 0 deletions src/debug/jtag/commands/logging/disable/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Development files
.eslintrc*
tsconfig*.json
vitest.config.ts

# Build artifacts
*.js.map
*.d.ts.map

# IDE
.vscode/
.idea/

# Logs
*.log
npm-debug.log*

# OS files
.DS_Store
Thumbs.db
166 changes: 166 additions & 0 deletions src/debug/jtag/commands/logging/disable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Logging Disable Command

Disable logging for a persona. Persists to .continuum/logging.json

## Table of Contents

- [Usage](#usage)
- [CLI Usage](#cli-usage)
- [Tool Usage](#tool-usage)
- [Parameters](#parameters)
- [Result](#result)
- [Examples](#examples)
- [Testing](#testing)
- [Unit Tests](#unit-tests)
- [Integration Tests](#integration-tests)
- [Getting Help](#getting-help)
- [Access Level](#access-level)
- [Implementation Notes](#implementation-notes)

## Usage

### CLI Usage

From the command line using the jtag CLI:

```bash
./jtag logging/disable --persona=<value>
```

### Tool Usage

From Persona tools or programmatic access using `Commands.execute()`:

```typescript
import { Commands } from '@system/core/shared/Commands';

const result = await Commands.execute('logging/disable', {
// your parameters here
});
```

## Parameters

- **persona** (required): `string` - Persona uniqueId to disable logging for (e.g., 'helper', 'codereview')
- **category** (optional): `string` - Specific category to disable. If not specified, disables all logging for the persona

## Result

Returns `LoggingDisableResult` with:

Returns CommandResult with:
- **persona**: `string` - The persona that was disabled
- **enabled**: `boolean` - Whether any logging remains enabled for this persona
- **categories**: `string[]` - Categories still enabled (empty if all disabled)
- **message**: `string` - Human-readable status message

## Examples

### Disable all logging for helper persona

```bash
./jtag logging/disable --persona=helper
```

**Expected result:**
{ persona: 'helper', enabled: false, categories: [], message: 'Disabled all logging for helper' }

### Disable only training logs

```bash
./jtag logging/disable --persona=helper --category=training
```

**Expected result:**
{ persona: 'helper', enabled: true, categories: ['cognition'], message: 'Disabled training logging for helper' }

## Getting Help

### Using the Help Tool

Get detailed usage information for this command:

**CLI:**
```bash
./jtag help logging/disable
```

**Tool:**
```typescript
// Use your help tool with command name 'logging/disable'
```

### Using the README Tool

Access this README programmatically:

**CLI:**
```bash
./jtag readme logging/disable
```

**Tool:**
```typescript
// Use your readme tool with command name 'logging/disable'
```

## Testing

### Unit Tests

Test command logic in isolation using mock dependencies:

```bash
# Run unit tests (no server required)
npx tsx commands/Logging Disable/test/unit/LoggingDisableCommand.test.ts
```

**What's tested:**
- Command structure and parameter validation
- Mock command execution patterns
- Required parameter validation (throws ValidationError)
- Optional parameter handling (sensible defaults)
- Performance requirements
- Assertion utility helpers

**TDD Workflow:**
1. Write/modify unit test first (test-driven development)
2. Run test, see it fail
3. Implement feature
4. Run test, see it pass
5. Refactor if needed

### Integration Tests

Test command with real client connections and system integration:

```bash
# Prerequisites: Server must be running
npm start # Wait 90+ seconds for deployment

# Run integration tests
npx tsx commands/Logging Disable/test/integration/LoggingDisableIntegration.test.ts
```

**What's tested:**
- Client connection to live system
- Real command execution via WebSocket
- ValidationError handling for missing params
- Optional parameter defaults
- Performance under load
- Various parameter combinations

**Best Practice:**
Run unit tests frequently during development (fast feedback). Run integration tests before committing (verify system integration).

## Access Level

**ai-safe** - Safe for AI personas to call autonomously

## Implementation Notes

- **Shared Logic**: Core business logic in `shared/LoggingDisableTypes.ts`
- **Browser**: Browser-specific implementation in `browser/LoggingDisableBrowserCommand.ts`
- **Server**: Server-specific implementation in `server/LoggingDisableServerCommand.ts`
- **Unit Tests**: Isolated testing in `test/unit/LoggingDisableCommand.test.ts`
- **Integration Tests**: System testing in `test/integration/LoggingDisableIntegration.test.ts`
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Logging Disable Command - Browser Implementation
*
* Disable logging for a persona. Persists to .continuum/logging.json
*/

import { CommandBase, type ICommandDaemon } from '@daemons/command-daemon/shared/CommandBase';
import type { JTAGContext } from '@system/core/types/JTAGTypes';
import type { LoggingDisableParams, LoggingDisableResult } from '../shared/LoggingDisableTypes';

export class LoggingDisableBrowserCommand extends CommandBase<LoggingDisableParams, LoggingDisableResult> {

constructor(context: JTAGContext, subpath: string, commander: ICommandDaemon) {
super('logging/disable', context, subpath, commander);
}

async execute(params: LoggingDisableParams): Promise<LoggingDisableResult> {
console.log('🌐 BROWSER: Delegating Logging Disable to server');
return await this.remoteExecute(params);
}
}
35 changes: 35 additions & 0 deletions src/debug/jtag/commands/logging/disable/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@jtag-commands/logging/disable",
"version": "1.0.0",
"description": "Disable logging for a persona. Persists to .continuum/logging.json",
"main": "server/LoggingDisableServerCommand.ts",
"types": "shared/LoggingDisableTypes.ts",
"scripts": {
"test": "npm run test:unit && npm run test:integration",
"test:unit": "npx vitest run test/unit/*.test.ts",
"test:integration": "npx tsx test/integration/LoggingDisableIntegration.test.ts",
"lint": "npx eslint **/*.ts",
"typecheck": "npx tsc --noEmit"
},
"peerDependencies": {
"@jtag/core": "*"
},
"files": [
"shared/**/*.ts",
"browser/**/*.ts",
"server/**/*.ts",
"test/**/*.ts",
"README.md"
],
"keywords": [
"jtag",
"command",
"logging/disable"
],
"license": "MIT",
"author": "",
"repository": {
"type": "git",
"url": ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Logging Disable Command - Server Implementation
*
* Disable logging for a persona. Persists to .continuum/logging.json
*/

import { CommandBase, type ICommandDaemon } from '@daemons/command-daemon/shared/CommandBase';
import type { JTAGContext } from '@system/core/types/JTAGTypes';
import { ValidationError } from '@system/core/types/ErrorTypes';
import type { LoggingDisableParams, LoggingDisableResult } from '../shared/LoggingDisableTypes';
import { createLoggingDisableResultFromParams } from '../shared/LoggingDisableTypes';
import { LoggingConfig, LOGGING_CATEGORIES } from '@system/core/logging/LoggingConfig';

export class LoggingDisableServerCommand extends CommandBase<LoggingDisableParams, LoggingDisableResult> {

constructor(context: JTAGContext, subpath: string, commander: ICommandDaemon) {
super('logging/disable', context, subpath, commander);
}

async execute(params: LoggingDisableParams): Promise<LoggingDisableResult> {
// Validate persona parameter
if (!params.persona || params.persona.trim() === '') {
throw new ValidationError(
'persona',
`Missing required parameter 'persona'. ` +
`Use: ./jtag logging/disable --persona=helper [--category=cognition]`
);
}

const persona = params.persona.trim();
const category = params.category?.trim();

// Disable logging
if (category) {
// Disable specific category
LoggingConfig.setEnabled(persona, category, false);
} else {
// Disable all logging for persona
LoggingConfig.setPersonaEnabled(persona, false);
}

// Get current state after update
const config = LoggingConfig.getConfig();
const normalizedId = persona.toLowerCase().replace(/\s+ai$/i, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
const personaConfig = config.personas[normalizedId];

// Determine remaining enabled categories
let categories: string[] = [];
let enabled = false;

if (personaConfig && personaConfig.enabled) {
enabled = true;
if (!personaConfig.categories || personaConfig.categories.length === 0) {
categories = Object.values(LOGGING_CATEGORIES);
} else if (personaConfig.categories.includes('*')) {
categories = Object.values(LOGGING_CATEGORIES);
} else {
categories = personaConfig.categories;
}
}

const message = category
? `Disabled ${category} logging for ${persona}`
: `Disabled all logging for ${persona}`;

return createLoggingDisableResultFromParams(params, {
success: true,
persona,
enabled,
categories,
message,
});
}
}
Loading
Loading