Skip to content

Commit

Permalink
Fixed svelte check and wiki ts test
Browse files Browse the repository at this point in the history
  • Loading branch information
Acumen-Desktop committed Feb 13, 2025
1 parent f8fe186 commit 5a956e8
Show file tree
Hide file tree
Showing 22 changed files with 1,629 additions and 510 deletions.
134 changes: 134 additions & 0 deletions acumen/_goose/feature_docs/svelte-check/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Check your code with svelte-check

Provides CLI diagnostics checks for:

- Unused CSS
- Svelte A11y hints
- JavaScript/TypeScript compiler errors

Requires Node 16 or later.

### Usage:

#### Local / in your project

Installation:

`npm i svelte-check --save-dev`

Package.json:

```json
{
// ...
"scripts": {
"svelte-check": "svelte-check"
// ...
},
// ...
"devDependencies": {
"svelte-check": "..."
// ...
}
}
```

Usage:

`npm run svelte-check`

#### Global (not recommended)

Installation:

`npm i svelte-check svelte -g`

Usage:

1. Go to folder where to start checking
2. `svelte-check`

### Args:

| Flag | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--workspace <path>` | Path to your workspace. All subdirectories except node_modules and those listed in `--ignore` are checked |
| `--output <human\|human-verbose\|machine\|machine-verbose>` |
| `--watch` | Will not exit after one pass but keep watching files for changes and rerun diagnostics |
| `--preserveWatchOutput` | Do not clear the screen in watch mode |
| `--tsconfig <path>` | Pass a path to a tsconfig or jsconfig file. The path can be relative to the workspace path or absolute. Doing this means that only files matched by the files/include/exclude pattern of the config file are diagnosed. It also means that errors from TypeScript and JavaScript files are reported. If not given, will do an upwards traversal looking for the next jsconfig/tsconfig.json |
| `--no-tsconfig` | Use this if you only want to check the Svelte files found in the current directory and below and ignore any JS/TS files (they will not be type-checked) |
| `--ignore <path1,path2>` | Only has an effect when used in conjunction with `--no-tsconfig`. Files/folders to ignore - relative to workspace root, comma-separated, inside quotes. Example: `--ignore "dist,build"`. When used in conjunction with `--tsconfig`, this will only have effect on the files watched, not on the files that are diagnosed, which is then determined by the `tsconfig.json` |
| `--fail-on-warnings` | Will also exit with error code when there are warnings |
| `--compiler-warnings <code1:error\|ignore,code2:error\|ignore>` | A list of Svelte compiler warning codes. Each entry defines whether that warning should be ignored or treated as an error. Warnings are comma-separated, between warning code and error level is a colon; all inside quotes. Example: `--compiler-warnings "css-unused-selector:ignore,unused-export-let:error"` |
| `--diagnostic-sources <js,svelte,css>` | A list of diagnostic sources which should run diagnostics on your code. Possible values are `js` (includes TS), `svelte`, `css`. Comma-separated, inside quotes. By default all are active. Example: `--diagnostic-sources "js,svelte"` |
| `--threshold <error\|warning>` | Filters the diagnostics to display. `error` will output only errors while `warning` will output warnings and errors. |

### FAQ

#### Why is there no option to only check specific files (for example only staged files)?

`svelte-check` needs to know the whole project to do valid checks. Imagine you alter a component property `export let foo` to `export let bar`, but you don't update any of the component usages. They all have errors now but you would not catch them if you only run checks on changed files.

### More docs, preprocessor setup and troubleshooting

[See here](/docs/README.md).

### Machine-Readable Output

Setting the `--output` to `machine` or `machine-verbose` will format output in a way that is easier to read
by machines, e.g. inside CI pipelines, for code quality checks, etc.

Each row corresponds to a new record. Rows are made up of columns that are separated by a
single space character. The first column of every row contains a timestamp in milliseconds
which can be used for monitoring purposes. The second column gives us the "row type", based
on which the number and types of subsequent columns may differ.

The first row is of type `START` and contains the workspace folder (wrapped in quotes).

###### Example:

```
1590680325583 START "/home/user/language-tools/packages/language-server/test/plugins/typescript/testfiles"
```

Any number of `ERROR` or `WARNING` records may follow. Their structure is identical and depends on the output argoument.

If the argument is `machine` it will tell us the filename, the starting line and column numbers, and the error message. The filename is relative to the workspace directory. The filename and the message are both wrapped in quotes.

###### Example:

```
1590680326283 ERROR "codeactions.svelte" 1:16 "Cannot find module 'blubb' or its corresponding type declarations."
1590680326778 WARNING "imported-file.svelte" 0:37 "Component has unused export property 'prop'. If it is for external reference only, please consider using `export const prop`"
```

If the argument is `machine-verbose` it will tell us the filename, the starting line and column numbers, the ending line and column numbers, the error message, the code of diagnostic, the human-friendly description of the code and the human-friendly source of the diagnostic (eg. svelte/typescript). The filename is relative to the workspace directory. Each diagnostic is represented as an [ndjson](https://en.wikipedia.org/wiki/JSON_streaming#Newline-Delimited_JSON) line prefixed by the timestamp of the log.

###### Example:

```
1590680326283 {"type":"ERROR","fn":"codeaction.svelte","start":{"line":1,"character":16},"end":{"line":1,"character":23},"message":"Cannot find module 'blubb' or its corresponding type declarations.","code":2307,"source":"js"}
1590680326778 {"type":"WARNING","filename":"imported-file.svelte","start":{"line":0,"character":37},"end":{"line":0,"character":51},"message":"Component has unused export property 'prop'. If it is for external reference only, please consider using `export
const prop`","code":"unused-export-let","source":"svelte"}
```

The output concludes with a `COMPLETED` message that summarizes total numbers of files, errors and warnings that were encountered during the check.

###### Example:

```
1590680326807 COMPLETED 20 FILES 21 ERRORS 1 WARNINGS 3 FILES_WITH_PROBLEMS
```

If the application experiences a runtime error, this error will appear as a `FAILURE` record.

###### Example:

```
1590680328921 FAILURE "Connection closed"
```

### Credits

- Vue's [VTI](https://github.com/vuejs/vetur/tree/master/vti) which laid the foundation for `svelte-check`
71 changes: 71 additions & 0 deletions acumen/features/api-endpoints/api-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# API Client Implementation

## Core Endpoints

### Agent Management
```typescript
POST /agent
Headers: { 'X-Secret-Key': string }
Body: { provider: string, model: string }
```

### Configuration
```typescript
POST /configs/providers
Headers: { 'X-Secret-Key': string }
Body: { providers: string[] }

POST /configs/store
DELETE /configs/delete
```

### AI Interaction
```typescript
POST /ask
Headers: { 'X-Secret-Key': string }
Body: { prompt: string }

POST /reply (SSE)
Headers: { 'X-Secret-Key': string }
Body: ChatRequest
```

## Implementation Requirements

### Authentication
- Secret key from electron app config
- Include in all API requests
- Error handling for auth failures

### SSE Handling
- Server-sent events for streaming
- Proper event parsing
- Error and completion handling

### TypeScript Types
```typescript
interface ApiConfig {
baseUrl: string;
secretKey: string;
}

interface ApiResponse<T> {
data?: T;
error?: string;
}
```

## Usage Example
```typescript
// Create API client
const api = new ApiClient({
baseUrl: getApiUrl(),
secretKey: getSecretKey()
});

// Make authenticated request
const response = await api.post('/agent', {
provider: 'google',
model: 'gemini-pro'
});
```
37 changes: 37 additions & 0 deletions acumen/features/svelte-electron-ui/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Svelte-Electron Architecture Overview

## Core Components

### 1. Backend (Rust)
- `goose-server`: HTTP server with AppState management
- `goose-cli`: Command-line interface
- `goose`: Core AI agent library

### 2. Frontend (Svelte + Electron)
- Based on React implementation in `ui/desktop`
- Uses shadcn-svelte for UI components
- Communicates with backend via HTTP/SSE

## Key Architectural Points

### State Management
- Backend: Thread-safe AppState using Arc<Mutex>
- Frontend: Svelte stores (replacing React contexts)
- API authentication via secret key

### Communication Flow
1. Electron main process starts goose-server
2. Svelte UI makes authenticated API calls
3. Server-sent events for streaming responses

### File Organization
- `/src/lib` - Svelte components
- `/src/routes` - Page components
- `/src/stores` - State management
- `/src/api` - Backend communication

## Migration Strategy
1. Port core functionality first
2. Match React behavior exactly
3. Add Svelte-specific improvements
4. Maintain feature parity
79 changes: 79 additions & 0 deletions acumen/features/svelte-electron-ui/component-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Component Migration Guide

## Component Structure

### React to Svelte Mapping
```
React Svelte
----------------------------------------
/components /src/lib/components
/ui /ui
/settings /settings
/chat /chat
App.tsx App.svelte
ChatWindow.tsx ChatWindow.svelte
```

## Key Differences

### 1. Props and Events
```typescript
// React
interface Props {
onSubmit: (value: string) => void;
disabled?: boolean;
}

// Svelte
<script lang="ts">
export let onSubmit: (value: string) => void;
export let disabled = false;
</script>
```

### 2. State Management
```typescript
// React
const [value, setValue] = useState('');

// Svelte
let value = '';
$: console.log(value); // Reactive
```

### 3. Effects
```typescript
// React
useEffect(() => {
// Side effect
return () => cleanup();
}, [deps]);

// Svelte
onMount(() => {
// Side effect
return () => cleanup();
});
```

## Migration Steps

1. Core Components First
- ChatWindow
- Settings
- Provider/Model selection

2. UI Components
- Port shadcn components
- Maintain styling
- Keep component small

3. Features
- One feature at a time
- Test thoroughly
- Document differences

4. State Management
- Convert contexts to stores
- Use reactive statements
- Keep state minimal
Loading

0 comments on commit 5a956e8

Please sign in to comment.