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
23 changes: 17 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: Publish package

on:
push:
workflow_run:
workflows:
- CI
types:
- completed
branches:
- main
workflow_dispatch:
Expand All @@ -10,13 +14,17 @@ permissions:
contents: read

concurrency:
group: publish-${{ github.workflow }}-${{ github.ref }}
group: publish-${{ github.workflow }}-${{ github.event.workflow_run.head_sha || github.ref }}
cancel-in-progress: false

jobs:
publish-main:
name: Publish main release to npm
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
if: >-
${{ github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
environment:
name: npm
Expand All @@ -28,6 +36,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}

- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
Expand All @@ -51,6 +60,8 @@ jobs:
- name: Select the release version
id: release
shell: bash
env:
SOURCE_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
set -euo pipefail

Expand All @@ -69,8 +80,8 @@ jobs:
candidate_parent="$(git rev-parse "${candidate_commit}^" 2>/dev/null || true)"
candidate_subject="$(git log -1 --format=%s "${candidate_commit}")"

if [[ "${candidate_commit}" == "${GITHUB_SHA}" ]] || \
[[ "${candidate_parent}" == "${GITHUB_SHA}" && \
if [[ "${candidate_commit}" == "${SOURCE_SHA}" ]] || \
[[ "${candidate_parent}" == "${SOURCE_SHA}" && \
"${candidate_subject}" == "chore(release): ${candidate_tag} [skip ci]" ]]; then
release_tag="${candidate_tag}"
release_commit="${candidate_commit}"
Expand Down Expand Up @@ -98,7 +109,7 @@ jobs:

if git show-ref --verify --quiet "refs/tags/${release_tag}"; then
tag_commit="$(git rev-list -n 1 "${release_tag}")"
echo "${release_tag} already belongs to ${tag_commit}, not ${GITHUB_SHA}." >&2
echo "${release_tag} already belongs to ${tag_commit}, not ${SOURCE_SHA}." >&2
exit 1
fi

Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ pnpm test

## Releases

Maintainers should follow the [release guide](docs/releasing.md). Every merge to
`main` automatically selects the next package version, verifies the artifact,
publishes it, and creates the matching tag and GitHub Release. Do not bump normal
beta versions or create GitHub Releases manually.
Maintainers should follow the [release guide](docs/releasing.md). After a merge
to `main` passes the complete main CI matrix, it automatically selects the next
package version, verifies and publishes the artifact, and creates the matching
tag and GitHub Release. Do not bump normal beta versions or create GitHub
Releases manually.

## Licensing

Expand Down
19 changes: 14 additions & 5 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Parallax uses two release paths in

| Branch | Trigger | npm dist-tag | Purpose |
| ------------- | ------------------------ | ------------ | --------------------- |
| `main` | Every push or PR merge | `next` | Public beta releases |
| `main` | Successful main CI run | `next` | Public beta releases |
| `development` | Manual workflow dispatch | `dev` | Development snapshots |

Daily work belongs on `development`. Promote tested work to `main` with a pull
Expand All @@ -25,8 +25,10 @@ GitHub Actions must be allowed to create the generated release commit.

## Automatic releases from `main`

Every new `main` push must either complete a release or fail visibly. A main run
no longer succeeds by silently skipping an already-published version.
Every new `main` push runs the complete CI matrix first. The publish workflow is
triggered only after that exact main commit passes CI; a failed or cancelled CI
run cannot publish an npm package. Once started, the release must complete or
fail visibly instead of silently skipping an already-published version.

The version in `package.json` selects the release line:

Expand Down Expand Up @@ -71,8 +73,9 @@ git push origin development
```

Open a pull request from `development` to `main`, wait for CI, review it, and
merge it. The resulting main push automatically creates the next npm release.
No manual version-bump commit is needed for a normal beta.
merge it. The merge runs CI again on the exact main commit. Its successful
completion automatically triggers the next npm release. No manual version-bump
commit is needed for a normal beta.

Follow the release live:

Expand Down Expand Up @@ -140,6 +143,12 @@ npx --yes @singularitycolabs/parallax@dev --version

## Failure handling

### Main CI fails

The publish workflow does not start, so no version, tag, or npm package is
created. Fix the validation failure on `development`, wait for its CI to pass,
and promote the correction to `main`.

### Verification fails

No tag or npm package is created. Fix the source on `development`, promote it to
Expand Down
10 changes: 2 additions & 8 deletions src/cli/tui/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import { Box, Text, useApp, useInput } from 'ink';
import type { ApprovalDecision, PermissionMode, RuntimeEvent } from '../../protocol/index.ts';
import {
applyModelSelection,
MissingApiKeyError,
type Agent,
} from '../../app/index.ts';
import { applyModelSelection, MissingApiKeyError, type Agent } from '../../app/index.ts';
import {
getProvider,
listProviders,
Expand Down Expand Up @@ -166,9 +162,7 @@ export function App(props: AppProps): React.ReactElement {
if (err instanceof MissingApiKeyError) {
// No key on this path — offer the dialog to enter one, preset to the
// provider the user asked for.
pushSystem(
`${sel.provider} needs an API key. Opening /model to configure it…`,
);
pushSystem(`${sel.provider} needs an API key. Opening /model to configure it…`);
openDialog(sel.provider);
return;
}
Expand Down
24 changes: 7 additions & 17 deletions src/cli/tui/components/ModelDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export function ModelDialog({
: undefined;
const presetNeedsKey = preset !== undefined && !hasKey(preset.id);

const [step, setStep] = useState<Step>(
preset ? (presetNeedsKey ? 'key' : 'model') : 'provider',
);
const [step, setStep] = useState<Step>(preset ? (presetNeedsKey ? 'key' : 'model') : 'provider');
const [filter, setFilter] = useState('');
const [selected, setSelected] = useState(0);
const [providerId, setProviderId] = useState(preset?.id ?? '');
Expand All @@ -103,7 +101,9 @@ export function ModelDialog({
const [hint, setHint] = useState('');
// The model chosen while we detour through the key step (its default when we
// jumped straight to key entry for a preset provider).
const [pendingModel, setPendingModel] = useState(presetNeedsKey ? (preset?.defaultModel ?? '') : '');
const [pendingModel, setPendingModel] = useState(
presetNeedsKey ? (preset?.defaultModel ?? '') : '',
);

const provider = useMemo(
() => providers.find((p) => p.id === providerId),
Expand All @@ -121,8 +121,7 @@ export function ModelDialog({
}, [provider, filter]);
// On an OpenAI-/Anthropic-wire provider any model id is valid on the wire, so a
// non-matching filter becomes an explicit "use what I typed" row.
const allowCustomModel =
filter.trim() !== '' && !modelRows.some((m) => m === filter.trim());
const allowCustomModel = filter.trim() !== '' && !modelRows.some((m) => m === filter.trim());

const resetList = (): void => {
setFilter('');
Expand Down Expand Up @@ -261,12 +260,7 @@ export function ModelDialog({
</Box>

{step === 'provider' ? (
<ProviderList
theme={theme}
rows={providerRows}
selected={selected}
hasKey={hasKey}
/>
<ProviderList theme={theme} rows={providerRows} selected={selected} hasKey={hasKey} />
) : (
<ModelList
theme={theme}
Expand Down Expand Up @@ -316,11 +310,7 @@ function ProviderList({
const active = idx === selected;
const keyed = hasKey(p.id);
const statusGlyph = !p.supported ? '·' : keyed ? glyphs.check : glyphs.cross;
const statusColor = !p.supported
? theme.subtle
: keyed
? theme.success
: theme.warning;
const statusColor = !p.supported ? theme.subtle : keyed ? theme.success : theme.warning;
return (
<Box key={p.id}>
<Text color={active ? theme.accent : theme.subtle}>{active ? '❯ ' : ' '}</Text>
Expand Down
7 changes: 1 addition & 6 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ export {
credentialsPath,
localConfigPaths,
} from './paths.ts';
export {
loadCredentials,
getCredential,
saveCredential,
type Credentials,
} from './credentials.ts';
export { loadCredentials, getCredential, saveCredential, type Credentials } from './credentials.ts';
export {
PROVIDERS,
BASE_PROVIDERS,
Expand Down