Files
openwork/services/openwork-share/server/_lib/package-openwork-files.test.ts
Jan c8c0ec9de0 fix/share inline success rail (#837)
* feat: enhance share functionality with new config support and improved UI elements

- Updated test command in package.json to include new test file.
- Added support for 'config' tone in share-bundle-page.js.
- Refactored share-home-client.js to improve handling of pasted content and state management.
- Introduced share-home-state.js for managing preview items and summary cards.
- Added tests for new share-home-state functions.
- Enhanced package-openwork-files.js to recognize and process config files.
- Updated UI styles for share components, including new configurations and improved layout.
- Added new CSS classes for config items and share actions.

* remove drop files

* skills area

* refactor: update ShareHomeClient component and styles for improved layout and item display

- Enhanced the rendering of included items in ShareHomeClient with a new layout.
- Removed redundant code for included items display.
- Updated CSS styles for .included-section, .included-list, and .included-item to improve alignment and spacing.
- Adjusted grid layout for input methods and share cards for better responsiveness.

* feat: implement syntax highlighting and enhance item examples in ShareHomeClient

- Added syntax highlighting functionality for JSON and Markdown content in ShareHomeClient.
- Introduced example fields for preview items in share-home-state.js to provide better context.
- Updated the layout and styles for the carbon preview component to improve user experience.
- Refactored the included items display to use buttons for better interaction and accessibility.

* feat: add syntax highlighting and improve layout for ShareHomeClient

- Implemented syntax highlighting for JSON and Markdown content in ShareHomeClient.
- Updated example names in share-home-state.js for clarity.
- Enhanced the layout and styles of the carbon preview component for better user experience.
- Adjusted CSS for improved responsiveness and visual appeal of share components.

* feat: enhance ShareHomeClient with example selection and improved item display

- Added state management for active examples in ShareHomeClient to allow users to select and preview example contents.
- Updated the rendering of included items to visually indicate active and dimmed states for better user interaction.
- Enhanced CSS styles for included items to reflect active and dimmed states, improving overall user experience.

* refactor: remove deprecated ShareHomeClient and share-home-state components

- Deleted the ShareHomeClient and share-home-state files as part of a cleanup process.
- Removed associated tests and unused functions to streamline the codebase.
- Updated styles in globals.css to reflect the removal of these components.

* feat: implement ShareHomeClient with TypeScript support and enhanced functionality

- Introduced ShareHomeClient component with TypeScript for improved type safety and maintainability.
- Added state management for file uploads and previews, enhancing user interaction.
- Created share-home-state for managing preview items and feedback.
- Updated package.json to include new TypeScript dependencies and adjusted test commands.
- Added tsconfig.json for TypeScript configuration and improved project structure.
- Enhanced styles in globals.css for better UI presentation and responsiveness.
- Removed outdated test files to streamline the codebase.

* refactor: update ShareHomeClient layout and enhance carbon preview component

- Reorganized the layout of the ShareHomeClient component to improve user experience.
- Updated the carbon preview component with a new footer for better content display.
- Adjusted CSS styles for grid layout and carbon window to enhance responsiveness and visual appeal.
- Removed outdated paste metadata display for a cleaner interface.

* refactor: update ShareHomeClient paste state management and improve styles

- Introduced a constant for default paste state to streamline state management in ShareHomeClient.
- Updated paste state messages for clarity and consistency across different scenarios.
- Enhanced CSS styles in globals.css for better visual presentation, including adjustments to background colors and element padding.

* feat: add baseline example and improve paste handling in ShareHomeClient

- Introduced a baseline example for skill input to guide users in the ShareHomeClient component.
- Enhanced paste handling to display the baseline example when no input is provided.
- Updated CSS styles for the status bar and highlighted paste area to reflect the new baseline state and improve visual clarity.

* feat: enhance ShareHomeClient with updated file sharing prompts and improved styles

- Updated selection label to provide clearer feedback on file readiness for sharing.
- Improved drop zone instructions for better user guidance on file uploads.
- Adjusted CSS styles for drop zones and icons to enhance visual appeal and user interaction.
- Refined layout and spacing for a more polished user experience.

* feat: enhance ShareHomeClient with improved copy functionality and updated styles

- Introduced a timer for copy state management to provide user feedback on link copying.
- Updated the layout of the share link section for better visual clarity and interaction.
- Enhanced CSS styles for share link actions and buttons to improve user experience and responsiveness.

* refactor: reorganize ShareHomeClient layout and enhance CSS styles

- Updated the layout of the ShareHomeClient component for improved visual clarity and user interaction.
- Enhanced CSS styles in globals.css for better alignment and responsiveness of share actions and status indicators.
- Removed unnecessary grid row definitions to streamline the layout structure.

* feat: add settings configuration and update CSS styles for improved layout

- Introduced a new settings.local.json file to manage permissions for web fetching.
- Updated CSS styles in globals.css to enhance layout responsiveness and visual consistency, including adjustments to alignment and background colors for severity indicators.

* feat: implement OpenWork Share service with API endpoints and UI components

- Added new service for OpenWork Share, including API routes for health checks, bundle management, and package handling.
- Introduced UI components for displaying shareable bundles and navigation.
- Implemented responsive design elements and improved user interaction through enhanced layouts and styles.
- Updated TypeScript configuration and package dependencies to support new features.
- Enhanced error handling and response management for API interactions.

* clean

* feat: enhance OpenWork Share service with Playwright integration and updated styles

- Added Playwright configuration for end-to-end testing of the OpenWork Share service.
- Updated package.json to include new test scripts for Playwright.
- Enhanced layout component with new font imports for improved typography.
- Refined global CSS styles for better font handling and visual consistency across components.
- Introduced new utility classes for improved styling and responsiveness.

* feat: enhance ShareHomeClient with placeholder item handling and updated styles

- Introduced a new function to build placeholder items based on pasted content and selected entries.
- Updated the component's state management to improve handling of examples and file previews.
- Refined CSS styles for better alignment and visual consistency, including adjustments to the preview filename display and layout responsiveness.
- Added a new JSON file to track test results for improved testing feedback.

* refactor: simplify package status handling and update button state logic in ShareHomeClient

- Removed unnecessary parameters from getPackageStatus function to streamline its usage.
- Updated button disabled state logic to improve clarity and functionality during publishing.
- Enhanced overall code readability by reducing complexity in state management.

* feat: enhance ShareHomeClient with improved selection and preview handling

- Introduced new utility functions for generating selection labels and preview filenames to streamline display logic.
- Updated selection label logic for clearer user feedback on file readiness for sharing.
- Enhanced preview filename display to reflect selected entries and pasted content more accurately.
- Refined CSS styles for better layout and visual consistency in publish actions and results.

* playwright not needed

* fix: update routing types and remove package-lock.json

- Changed the import path for routing types in next-env.d.ts to align with the latest Next.js structure.
- Removed package-lock.json as it is no longer needed for dependency management.

* added ts tests

* removed claude and added it to gitignore

* docs: add openwork-share PR screenshots

---------

Co-authored-by: jcllobet <jcllobet@users.noreply.github.com>
2026-03-11 13:40:32 -07:00

179 lines
5.0 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { packageOpenworkFiles } from "./package-openwork-files.ts";
test("packageOpenworkFiles creates a single skill bundle from skill markdown", () => {
const result = packageOpenworkFiles({
files: [
{
path: ".opencode/skills/sales-inbound/SKILL.md",
content: `---
name: sales-inbound
description: Handle inbound sales leads.
trigger: crm
version: 1.2.0
---
# Sales Inbound
Route fresh leads and qualify them.`,
},
],
});
assert.equal(result.bundleType, "skill");
assert.equal(result.bundle.type, "skill");
assert.equal(result.bundle.name, "sales-inbound");
assert.equal(result.bundle.trigger, "crm");
assert.equal(result.summary.skills, 1);
assert.equal(result.items[0]?.kind, "Skill");
});
test("packageOpenworkFiles builds a workspace profile with agents and MCP config", () => {
const result = packageOpenworkFiles({
files: [
{
path: ".opencode/agents/sales-inbound.md",
content: `---
description: Handles inbound sales work.
mode: subagent
model: openai/gpt-5.4
version: 1.2.0
---
You qualify leads and route follow-up.`,
},
{
path: "opencode.jsonc",
content: `{
// Project config should survive alongside typed entries
"model": "openai/gpt-5.4",
"mcp": {
"crm-sync": {
"type": "remote",
"url": "https://crm.example.com/mcp"
}
}
}`,
},
],
});
assert.equal(result.bundleType, "workspace-profile");
assert.equal(result.bundle.type, "workspace-profile");
assert.equal(result.summary.agents, 1);
assert.equal(result.summary.mcpServers, 1);
assert.equal(result.summary.configs, 1);
const workspace = result.bundle.workspace as Record<string, Record<string, Record<string, unknown>>>;
assert.deepEqual(Object.keys(workspace.opencode.agent), ["sales-inbound"]);
assert.deepEqual(Object.keys(workspace.opencode.mcp), ["crm-sync"]);
assert.equal(workspace.opencode.model, "openai/gpt-5.4");
});
test("packageOpenworkFiles redacts secret-looking values and adds a warning", () => {
const result = packageOpenworkFiles({
files: [
{
path: "opencode.json",
content: JSON.stringify({
mcp: {
crm: {
type: "remote",
headers: {
Authorization: "Bearer real-secret-token",
},
},
},
}),
},
],
});
assert.ok(result.warnings.some((w) => /[Rr]edacted/.test(w)));
});
test("packageOpenworkFiles infers AGENTS.md as agent markdown", () => {
const result = packageOpenworkFiles({
files: [
{
path: "AGENTS.md",
content: `# Revenue Agent
## Agent overview
This agent handles inbound revenue operations.
The agent coordinates follow-up and handoff.`,
},
],
});
assert.equal(result.bundleType, "workspace-profile");
assert.equal(result.summary.agents, 1);
assert.equal(result.items[0]?.kind, "Agent");
});
test("packageOpenworkFiles accepts mcp_config.json by filename as MCP config", () => {
const result = packageOpenworkFiles({
files: [
{
path: "mcp_config.json",
content: JSON.stringify({
type: "remote",
url: "https://mcp.example.com",
}),
},
],
});
assert.equal(result.bundleType, "workspace-profile");
assert.equal(result.summary.mcpServers, 1);
assert.equal(result.items[0]?.kind, "MCP");
});
test("packageOpenworkFiles accepts opencode-shaped jsonc from a generic filename", () => {
const result = packageOpenworkFiles({
files: [
{
path: "workspace-config.jsonc",
content: `{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"autoupdate": true,
"server": {
"port": 4096
}
}`,
},
],
});
assert.equal(result.bundleType, "workspace-profile");
assert.equal(result.summary.configs, 1);
const workspace = result.bundle.workspace as Record<string, Record<string, unknown>>;
assert.equal(workspace.opencode.model, "anthropic/claude-sonnet-4-5");
assert.equal(result.items[0]?.kind, "Config");
assert.equal(result.items[0]?.meta, "OpenCode config");
});
test("packageOpenworkFiles falls back to generic config for unknown json objects", () => {
const result = packageOpenworkFiles({
files: [
{
path: "settings.json",
content: JSON.stringify({
featureFlags: {
experimentalShare: true,
},
}),
},
],
});
assert.equal(result.bundleType, "workspace-profile");
assert.equal(result.summary.configs, 1);
const workspace = result.bundle.workspace as Record<string, Record<string, Record<string, unknown>>>;
assert.equal(workspace.config.settings.featureFlags.experimentalShare, true);
assert.equal(result.items[0]?.kind, "Config");
assert.equal(result.items[0]?.meta, "Config file");
});