Skip to content

Commit 3d685c0

Browse files
authored
Merge pull request #16 from yamalight/feature/engine-split
Engine split
2 parents 6e53dd9 + f426fc3 commit 3d685c0

File tree

123 files changed

+2592
-1525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2592
-1525
lines changed

.github/workflows/prerelease-lib.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Prerelease litlytics library
2+
3+
on:
4+
workflow_run:
5+
# Run after "Test and lint" workflow
6+
workflows: ['Test and lint']
7+
types:
8+
- completed # Only when it's completed
9+
branches:
10+
- main # Only run the publish workflow for pushes to main
11+
12+
jobs:
13+
publish-lib:
14+
environment: Github CI
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }} # Only proceed if the tests passed
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
# Check for changes in ./packages/litlytics
23+
- name: Check if changed
24+
id: changes
25+
run: |
26+
# Check if any files changed in the specified directory
27+
if git diff --quiet HEAD^ HEAD ./packages/litlytics; then
28+
echo "No changes in ./packages/litlytics. Skipping publish."
29+
echo "should_publish=false" >> $GITHUB_ENV
30+
else
31+
echo "Changes detected in ./packages/litlytics."
32+
echo "should_publish=true" >> $GITHUB_ENV
33+
34+
# Stop if no changes detected
35+
- name: Stop if no changes
36+
if: ${{ env.should_publish == 'false' }}
37+
run: exit 0
38+
39+
# install node (for npm utils)
40+
- name: Install node for npm checks
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: 22
44+
45+
# install bun
46+
- name: Install bun for deployment
47+
uses: oven-sh/setup-bun@v2
48+
with:
49+
bun-version: latest
50+
51+
# Install dependencies
52+
- name: Install dependencies
53+
working-directory: ./packages/litlytics
54+
run: bun install --frozen-lockfile
55+
56+
# Build package
57+
- name: Build package
58+
working-directory: ./packages/litlytics
59+
run: bun run build
60+
61+
# Determine @next version and update package.json
62+
- name: Determine @next version
63+
id: get_version
64+
working-directory: ./packages/litlytics
65+
run: |
66+
# Extract the current version from package.json
67+
# Fetch the latest @next version from npm
68+
current_version=$(node -pe "require('./package.json').version")
69+
latest_next_version=$(npm show litlytics@next version || $current_version)
70+
echo "Latest @next version: $latest_next_version"
71+
72+
# Bump the version by minor update and append `-next`
73+
# We now use bash for splitting the version
74+
major=$(echo "$latest_next_version" | cut -d'.' -f1)
75+
minor=$(echo "$latest_next_version" | cut -d'.' -f2)
76+
patch=$(echo "$latest_next_version" | cut -d'.' -f3)
77+
78+
next_patch=$((patch + 1))
79+
next_version="$major.$minor.$next_patch-next"
80+
81+
echo "Next version: $next_version"
82+
83+
# Update package.json with the new version
84+
npm version "$next_version" --no-git-tag-version
85+
86+
echo "version=$next_version" >> $GITHUB_ENV
87+
88+
# install and publish if local version is not the same as published
89+
- name: publish
90+
if: ${{ steps.versions.outputs.current != steps.versions.outputs.new }}
91+
working-directory: ./packages/litlytics
92+
run: bun publish --access public --tag next
93+
env:
94+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test-lint.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test and lint
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md' # Ignore changes to markdown files
7+
pull_request:
8+
paths-ignore:
9+
- '**/*.md' # Ignore changes to markdown files
10+
11+
jobs:
12+
test-lint:
13+
environment: Github CI
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install bun for deployment
23+
uses: oven-sh/setup-bun@v2
24+
with:
25+
bun-version: latest
26+
27+
# install deps
28+
- name: Install lib deps
29+
working-directory: ./packages/litlytics
30+
run: bun install --frozen-lockfile
31+
- name: Install app deps
32+
run: bun install --frozen-lockfile
33+
34+
# lib lint/check/test
35+
- name: Run lib typecheck
36+
working-directory: ./packages/litlytics
37+
run: bun run typecheck
38+
39+
- name: Run lib tests
40+
working-directory: ./packages/litlytics
41+
run: bun run test:ci
42+
43+
# main app lint/check/test
44+
- name: Run app eslint
45+
run: bun run lint
46+
47+
- name: Run app typecheck
48+
run: bun run typecheck
49+
50+
- name: Run app test
51+
run: bun run test:ci

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ node_modules
33
/.cache
44
/build
55
.env
6-
.env.local
6+
.env.local
7+
8+
# tests results
9+
coverage

app/components/markdown/Markdown.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, screen } from '@testing-library/react';
2-
import { expect, test } from 'bun:test';
2+
import { expect, test } from 'vitest';
33
import { CustomMarkdown } from './Markdown';
44

55
test('Renders basic markdown', () => {

app/components/pipeline/GeneratePipeline.tsx

+16-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from '@headlessui/react';
22
import { SparklesIcon } from '@heroicons/react/24/solid';
33
import clsx from 'clsx';
4-
import { useAtom, useAtomValue } from 'jotai';
54
import { useState } from 'react';
65
import { Button } from '~/components/catalyst/button';
76
import {
@@ -13,11 +12,7 @@ import {
1312
import { Field, FieldGroup, Label } from '~/components/catalyst/fieldset';
1413
import { Textarea } from '~/components/catalyst/textarea';
1514
import { Spinner } from '~/components/Spinner';
16-
import {
17-
litlyticsStore,
18-
pipelineAtom,
19-
pipelineStatusAtom,
20-
} from '~/store/store';
15+
import { useLitlytics } from '~/store/WithLitLytics';
2116
import { RefinePipeline } from './RefinePipeline';
2217

2318
const tabClass = clsx(
@@ -29,32 +24,20 @@ const tabClass = clsx(
2924
);
3025

3126
export default function GeneratePipeline() {
32-
const status = useAtomValue(pipelineStatusAtom);
33-
const litlytics = useAtomValue(litlyticsStore);
27+
const litlytics = useLitlytics();
3428
const [selectedTab, setSelectedTab] = useState(0);
3529
const [isOpen, setIsOpen] = useState(false);
3630
const [loading, setLoading] = useState(false);
37-
const [pipeline, setPipeline] = useAtom(pipelineAtom);
3831
const [error, setError] = useState<Error>();
3932

4033
const runPlan = async () => {
41-
if (!pipeline.pipelineDescription?.length) {
42-
return;
43-
}
44-
4534
try {
4635
setLoading(true);
4736
setError(undefined);
4837

4938
// generate plan from LLM
50-
const plan = await litlytics.generatePipeline({
51-
description: pipeline.pipelineDescription,
52-
});
39+
await litlytics.generatePipeline();
5340

54-
setPipeline({
55-
...pipeline,
56-
pipelinePlan: plan ?? '',
57-
});
5841
setLoading(false);
5942
setSelectedTab(1);
6043
} catch (err) {
@@ -66,9 +49,9 @@ export default function GeneratePipeline() {
6649
const closeDialog = () => {
6750
if (
6851
loading ||
69-
status.status === 'refine' ||
70-
status.status === 'step' ||
71-
status.status === 'sourcing'
52+
litlytics.pipelineStatus.status === 'refine' ||
53+
litlytics.pipelineStatus.status === 'step' ||
54+
litlytics.pipelineStatus.status === 'sourcing'
7255
) {
7356
return;
7457
}
@@ -81,7 +64,10 @@ export default function GeneratePipeline() {
8164
title="Generate pipeline"
8265
outline
8366
onClick={() => setIsOpen(true)}
84-
disabled={status.status === 'sourcing' || status.status === 'step'}
67+
disabled={
68+
litlytics.pipelineStatus.status === 'sourcing' ||
69+
litlytics.pipelineStatus.status === 'step'
70+
}
8571
className="border-sky-500 dark:border-sky-500"
8672
>
8773
<SparklesIcon aria-hidden="true" className="h-5 w-5 fill-sky-500" />{' '}
@@ -97,7 +83,7 @@ export default function GeneratePipeline() {
9783
<TabGroup selectedIndex={selectedTab} onChange={setSelectedTab}>
9884
<TabList className="flex gap-4">
9985
<Tab className={tabClass}>Plan</Tab>
100-
{Boolean(pipeline.pipelinePlan?.length) && (
86+
{Boolean(litlytics.pipeline.pipelinePlan?.length) && (
10187
<Tab className={tabClass}>Refine plan</Tab>
10288
)}
10389
</TabList>
@@ -110,13 +96,12 @@ export default function GeneratePipeline() {
11096
rows={5}
11197
name="task"
11298
placeholder="Task description"
113-
value={pipeline.pipelineDescription}
114-
onChange={(e) =>
115-
setPipeline((p) => ({
116-
...p,
99+
value={litlytics.pipeline.pipelineDescription}
100+
onChange={(e) => {
101+
litlytics.setPipeline({
117102
pipelineDescription: e.target.value,
118-
}))
119-
}
103+
});
104+
}}
120105
autoFocus
121106
disabled={loading}
122107
/>

app/components/pipeline/PipelineBuilder.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import { useAtomValue } from 'jotai';
2-
import { pipelineAtom } from '~/store/store';
1+
import { useLitlytics } from '~/store/WithLitLytics';
32
import { Background } from '../Background';
4-
import { OutputNode } from './nodes/OutputNode';
5-
import { SourceNode } from './nodes/SourceNode';
3+
import { OutputNode } from './nodes/output/OutputNode';
4+
import { SourceNode } from './nodes/source/SourceNode';
65
import { StepNode } from './nodes/StepNode';
76

87
export function PipelineBuilder() {
9-
const pipeline = useAtomValue(pipelineAtom);
8+
const litlytics = useLitlytics();
109

1110
return (
1211
<Background>
1312
<SourceNode />
14-
{pipeline.steps
13+
{litlytics.pipeline.steps
1514
.sort((a, b) => (a.connectsTo.includes(b.id) ? -1 : 1))
1615
.map((step) => (
1716
<StepNode data={step} key={step.id} />

0 commit comments

Comments
 (0)