Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9d9c5d1
feat(gemini): add native extension support and unified prompts
StoyanD Dec 18, 2025
4ed7faa
update the gemini doc to onboard user smoothly
StoyanD Dec 21, 2025
7f8abeb
chore(openspec): archive gemini extension support change
StoyanD Dec 21, 2025
001f285
Merge branch 'main' into gemini-extension
StoyanD Dec 22, 2025
3318ed4
Merge branch 'main' into gemini-extension
StoyanD Jan 6, 2026
2c3ca61
Merge branch 'main' into gemini-extension
StoyanD Jan 9, 2026
85ac417
feat(openspec): add proposal for MCP server and .openspec migration
StoyanD Jan 9, 2026
6785450
feat: implement mcp server and directory migration
StoyanD Jan 9, 2026
80f74e8
docs: update tasks status
StoyanD Jan 9, 2026
4e6b92e
test: update init tests to expect .openspec directory
StoyanD Jan 12, 2026
31adee9
feat: complete mcp tools implementation and archive change
StoyanD Jan 12, 2026
230a0d5
separate logic into core spec
StoyanD Jan 12, 2026
4a5c901
fix(archive): handle errors gracefully and add spec update prompt
StoyanD Jan 12, 2026
12fae4c
feat(release): sync gemini-extension.json version with package.json
StoyanD Jan 12, 2026
84ebe16
docs: add MCP JSON configuration snippet to README
StoyanD Jan 12, 2026
77a5b0b
feat(mcp): refactor core logic and expand MCP server tools
StoyanD Jan 12, 2026
4eb0ba5
feat(mcp): complete MCP toolset parity
StoyanD Jan 12, 2026
3bdf7cc
docs(openspec): archive refactor-core-isolation and update add-mcp-te…
StoyanD Jan 12, 2026
d068620
feat(core): refactor change logic and add MCP tests
StoyanD Jan 12, 2026
ad63aad
fix(lint): resolve restricted imports and ts-expect-error descriptions
StoyanD Jan 12, 2026
d4563c8
fix(mcp): resolve type errors in tools.ts
StoyanD Jan 12, 2026
b447e4d
refactor(mcp): decouple SpecCommand from mcp tools
StoyanD Jan 12, 2026
f1e2e96
archiving proposal
StoyanD Jan 12, 2026
a0958c5
chore: resolve merge conflicts and preserve CLI/MCP/Core separation r…
StoyanD Jan 12, 2026
1dd5ecc
test: fix regressions in update.test.ts after merge resolution
StoyanD Jan 12, 2026
95ed23b
feat: migrate to .openspec/ directory and implement security hardening
StoyanD Jan 13, 2026
6e5150d
chore: update gemini extension to use direct mcp entry point
StoyanD Jan 13, 2026
afe3507
chore: use ${extensionPath} for MCP server resolution in gemini-exten…
StoyanD Jan 13, 2026
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ jobs:
- name: Lint
run: pnpm lint

- name: Check extension version sync
run: node scripts/check-extension-version.mjs

- name: Check for build artifacts
run: |
if [ ! -d "dist" ]; then
Expand All @@ -156,6 +159,9 @@ jobs:
exit 1
fi

- name: Verify MCP server help
run: node bin/openspec.js serve --help

validate-changesets:
name: Validate Changesets
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
with:
title: 'chore(release): version packages'
createGithubReleases: true
version: pnpm run ci:version
# Use CI-specific release script: relies on version PR having been merged
# so package.json already contains the bumped version.
publish: pnpm run release:ci
Expand Down
141 changes: 141 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# OpenSpec Extension for Gemini CLI

OpenSpec is an AI-native system for spec-driven development. It helps developers and AI agents maintain a shared understanding of project requirements and technical designs through a structured workflow.

This extension provides native integration via the Model Context Protocol (MCP), enabling a **zero-install workflow** where agents can manage OpenSpec without requiring the global `openspec` npm package.

## MCP Capabilities

### Tools
- `openspec_init`: Initialize or extend OpenSpec in the current project.
- `openspec_update`: Refresh instruction files and slash commands.
- `openspec_view`: Get dashboard data for specs and changes.
- `openspec_create_change`: Scaffold a new OpenSpec change directory.
- `openspec_list_changes`: List active change proposals.
- `openspec_list_specs`: List current specifications.
- `openspec_show_change`: Show details of a change (JSON/Markdown).
- `openspec_show_spec`: Show details of a specification (JSON/Markdown).
- `openspec_validate_change`: Validate a change proposal against schema rules.
- `openspec_archive_change`: Archive a completed change and update main specs.

### Resources
- `openspec://changes/{name}/proposal`: Access the proposal.md content.
- `openspec://changes/{name}/tasks`: Access the tasks.md content.
- `openspec://specs/{id}`: Access the spec.md content for a capability.

### Prompts
- `openspec_proposal`: Context and steps for scaffolding a new change.
- `openspec_apply`: Instructions for implementing an approved change.
- `openspec_archive`: Workflow for archiving a completed change.

## Zero-Install Usage

If you have this extension added to your Gemini CLI, you can start using OpenSpec immediately in any directory by asking:

> "Initialize OpenSpec in this project"

The agent will use `openspec_init` to scaffold the necessary files. No local or global installation of `@fission-ai/openspec` is required for AI-driven workflows.

## Prerequisites

This extension requires the Gemini CLI. The OpenSpec MCP server is bundled with the extension.

**Auto-Initialization Instruction**:
When the user starts a session or tries to use OpenSpec:
1. **Check for CLI**: Run `openspec --version`.
- If found, use `openspec` for all commands.
- If missing, prefer using the bundled MCP server tools or fall back to `npx` (or `pnpm dlx`):
```bash
npx "@fission-ai/openspec"
```
- Inform the user if a global installation is recommended for performance, but do not perform it automatically.
2. **Check for Slash Commands**: Verify if `.gemini/commands/openspec/` exists and contains `proposal.toml`, `apply.toml`, and `archive.toml`.
- If missing, **automatically generate them** using the logic defined in the "Maintenance: Slash Command Synchronization" section below.
- Inform the user: "OpenSpec slash commands have been generated. You may need to restart the CLI to see them."
3. **Check for Project Initialization**: Verify if the `.openspec/` directory exists in the project root (or legacy `openspec/`).
- If missing, automatically run `openspec init` to scaffold the project structure.
4. **Populate Project Context**:
- **Trigger**: When `openspec init` completes and suggests "Populate your project context", you MUST perform this immediately.
- **Action**: Read `.openspec/project.md`, analyze project config (`package.json`, etc.), and fill in the details. **Do not** ask the user to do this manually.

## Core Mandates for Gemini Agents

- **Specs are Truth**: Always read `.openspec/specs/` to understand the current state of a capability.
- **Changes are Proposals**: All modifications to behavior or requirements MUST start as a proposal in `.openspec/changes/`.
- **Minimize Confirmations**: Do not ask for permission for low-risk read operations or standard project scaffolding if the user's intent is clear. Assume consent for actions explicitly requested.
- **Three-Stage Workflow**:
1. **Stage 1: Creating Changes**: Scaffold `proposal.md`, `tasks.md`, and spec deltas. Validate with `openspec validate <id> --strict`.
2. **Stage 2: Implementing Changes**: Follow `tasks.md` sequentially.
3. **Stage 3: Archiving Changes**: Move completed changes to `archive/` using `openspec archive <id>`.

## Essential CLI Commands

When working in an OpenSpec-enabled project, you can use these commands:

- `openspec list`: Show active changes.
- `openspec list --specs`: Show existing capabilities.
- `openspec show <id>`: View details of a change or spec.
- `openspec validate <id>`: Validate a change against the project's specs.
- `openspec init`: Initialize OpenSpec in a new project.
- `openspec update`: Update instruction files (like `AGENTS.md`).

## Directory Structure

- `.openspec/project.md`: Project-specific conventions and tech stack.
- `.openspec/specs/`: Current requirements and scenarios (the "truth").
- `.openspec/changes/`: Pending proposals and implementation tasks.

## Writing Specs

Requirements must be normative (SHALL/MUST). Every requirement MUST have at least one scenario using the following format:

```markdown
#### Scenario: Name
- **WHEN** action or condition
- **THEN** expected result
```

For more detailed instructions, refer to `.openspec/AGENTS.md`.

## Maintenance: Slash Command Synchronization

The slash commands for this extension (`.gemini/commands/openspec/*.toml`) are generated artifacts. The single source of truth for their content is `src/core/templates/prompts.ts`.

**Instruction**: When `src/core/templates/prompts.ts` is modified, or when asked to "update slash commands", you MUST regenerate the TOML files in `.gemini/commands/openspec/` using the following logic:

1. **Read** `src/core/templates/prompts.ts` to extract the exported constants.
2. **Construct** the prompt body for each command by joining the relevant constants with `\n\n`:
- **proposal**: `PROPOSAL_GUARDRAILS` + `PROPOSAL_STEPS` + `PROPOSAL_REFERENCES`
- **apply**: `BASE_GUARDRAILS` + `APPLY_STEPS` + `APPLY_REFERENCES`
- **archive**: `BASE_GUARDRAILS` + `ARCHIVE_STEPS` + `ARCHIVE_REFERENCES`
3. **Generate** the TOML files with the following structure (preserving the `<!-- OPENSPEC:START -->` markers inside the prompt string):

**File**: `.gemini/commands/openspec/proposal.toml`
```toml
description = "Scaffold a new OpenSpec change and validate strictly."
prompt = """
<!-- OPENSPEC:START -->
{PROPOSAL_BODY}
<!-- OPENSPEC:END -->
"""
```

**File**: `.gemini/commands/openspec/apply.toml`
```toml
description = "Implement an approved OpenSpec change and keep tasks in sync."
prompt = """
<!-- OPENSPEC:START -->
{APPLY_BODY}
<!-- OPENSPEC:END -->
"""
```

**File**: `.gemini/commands/openspec/archive.toml`
```toml
description = "Archive a deployed OpenSpec change and update specs."
prompt = """
<!-- OPENSPEC:START -->
{ARCHIVE_BODY}
<!-- OPENSPEC:END -->
"""
```
65 changes: 50 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Key outcomes:
## How OpenSpec compares (at a glance)

- **Lightweight**: simple workflow, no API keys, minimal setup.
- **Brownfield-first**: works great beyond 0→1. OpenSpec separates the source of truth from proposals: `openspec/specs/` (current truth) and `openspec/changes/` (proposed updates). This keeps diffs explicit and manageable across features.
- **Brownfield-first**: works great beyond 0→1. OpenSpec separates the source of truth from proposals: `.openspec/specs/` (current truth) and `.openspec/changes/` (proposed updates). This keeps diffs explicit and manageable across features.
- **Change tracking**: proposals, tasks, and spec deltas live together; archiving merges the approved updates back into specs.
- **Compared to spec-kit & Kiro**: those shine for brand-new features (0→1). OpenSpec also excels when modifying existing behavior (1→n), especially when updates span multiple specs.

Expand Down Expand Up @@ -85,7 +85,28 @@ See the full comparison in [How OpenSpec Compares](#how-openspec-compares).
4. Archive the change to merge the approved updates back into the source-of-truth specs.
```

## Getting Started
## Integration Modes

OpenSpec supports two primary integration modes for AI agents:

1. **Native MCP (Recommended)**: Use OpenSpec as an MCP server (e.g., via the Gemini CLI extension). This enables a **zero-install workflow** where agents can manage OpenSpec without requiring the npm package to be installed in the environment. Add it to your MCP host (like Claude Desktop) using this snippet:

```json
{
"mcpServers": {
"openspec": {
"command": "npx",
"args": ["-y", "@fission-ai/openspec@latest", "serve"]
}
}
}
```

2. **CLI Wrapper**: Agents call the `openspec` command-line tool directly. This requires the `@fission-ai/openspec` package to be installed globally or locally.

---

## 🚀 Quick Start

### Supported AI Tools

Expand All @@ -108,7 +129,7 @@ These tools have built-in OpenSpec commands. Select the OpenSpec integration whe
| **Crush** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.crush/commands/openspec/`) |
| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| **Factory Droid** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.factory/commands/`) |
| **Gemini CLI** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.gemini/commands/openspec/`) |
| **Gemini CLI** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (Native Extension available) |
| **GitHub Copilot** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.github/prompts/`) |
| **iFlow (iflow-cli)** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.iflow/commands/`) |
| **Kilo Code** | `/openspec-proposal.md`, `/openspec-apply.md`, `/openspec-archive.md` (`.kilocode/workflows/`) |
Expand All @@ -133,6 +154,20 @@ These tools automatically read workflow instructions from `openspec/AGENTS.md`.

</details>

### Gemini CLI Extension (Native)

OpenSpec is available as a native extension for the [Gemini CLI](https://geminicli.com). This provides deep contextual awareness and native slash commands without manual configuration.

**Install the extension:**
```bash
gemini extensions install https://github.com/Fission-AI/OpenSpec
```

**Benefits:**
- **Zero Configuration**: Automatically sets up `/openspec` slash commands.
- **Native Context**: Gemini becomes "OpenSpec-aware" instantly.
- **Auto-Maintenance**: The agent can self-repair its command definitions from the source of truth.

### Install & Initialize

#### Prerequisites
Expand Down Expand Up @@ -164,7 +199,7 @@ openspec init
**What happens during initialization:**
- You'll be prompted to pick any natively supported AI tools (Claude Code, CodeBuddy, Cursor, OpenCode, Qoder,etc.); other assistants always rely on the shared `AGENTS.md` stub
- OpenSpec automatically configures slash commands for the tools you choose and always writes a managed `AGENTS.md` hand-off at the project root
- A new `openspec/` directory structure is created in your project
- A new `.openspec/` directory structure is created in your project (with backward compatibility for legacy `openspec/` folders)

**After setup:**
- Primary AI tools can trigger `/openspec` workflows without additional configuration
Expand All @@ -178,10 +213,10 @@ After `openspec init` completes, you'll receive a suggested prompt to help popul

```text
Populate your project context:
"Please read openspec/project.md and help me fill it out with details about my project, tech stack, and conventions"
"Please read .openspec/project.md and help me fill it out with details about my project, tech stack, and conventions"
```

Use `openspec/project.md` to define project-level conventions, standards, architectural patterns, and other guidelines that should be followed across all changes.
Use `.openspec/project.md` to define project-level conventions, standards, architectural patterns, and other guidelines that should be followed across all changes.

### Create Your First Change

Expand All @@ -195,7 +230,7 @@ You: Create an OpenSpec change proposal for adding profile search filters by rol
(Shortcut for tools with slash commands: /openspec:proposal Add profile search filters)

AI: I'll create an OpenSpec change proposal for profile filters.
*Scaffolds openspec/changes/add-profile-filters/ with proposal.md, tasks.md, spec deltas.*
*Scaffolds .openspec/changes/add-profile-filters/ with proposal.md, tasks.md, spec deltas.*
```

#### 2. Verify & Review
Expand All @@ -214,7 +249,7 @@ Iterate on the specifications until they match your needs:
You: Can you add acceptance criteria for the role and team filters?

AI: I'll update the spec delta with scenarios for role and team filters.
*Edits openspec/changes/add-profile-filters/specs/profile/spec.md and tasks.md.*
*Edits .openspec/changes/add-profile-filters/specs/profile/spec.md and tasks.md.*
```

#### 4. Implement the Change
Expand All @@ -225,7 +260,7 @@ You: The specs look good. Let's implement this change.
(Shortcut for tools with slash commands: /openspec:apply add-profile-filters)

AI: I'll work through the tasks in the add-profile-filters change.
*Implements tasks from openspec/changes/add-profile-filters/tasks.md*
*Implements tasks from .openspec/changes/add-profile-filters/tasks.md*
*Marks tasks complete: Task 1.1 ✓, Task 1.2 ✓, Task 2.1 ✓...*
```

Expand Down Expand Up @@ -265,7 +300,7 @@ openspec archive <change> [--yes|-y] # Move a completed change into archive/ (
When you ask your AI assistant to "add two-factor authentication", it creates:

```
openspec/
.openspec/
├── specs/
│ └── auth/
│ └── spec.md # Current auth spec (if exists)
Expand All @@ -279,7 +314,7 @@ openspec/
└── spec.md # Delta showing additions
```

### AI-Generated Spec (created in `openspec/specs/auth/spec.md`):
### AI-Generated Spec (created in `.openspec/specs/auth/spec.md`):

```markdown
# Auth Specification
Expand All @@ -296,7 +331,7 @@ The system SHALL issue a JWT on successful login.
- THEN a JWT is returned
```

### AI-Generated Change Delta (created in `openspec/changes/add-2fa/specs/auth/spec.md`):
### AI-Generated Change Delta (created in `.openspec/changes/add-2fa/specs/auth/spec.md`):

```markdown
# Delta for Auth
Expand All @@ -310,7 +345,7 @@ The system MUST require a second factor during login.
- THEN an OTP challenge is required
```

### AI-Generated Tasks (created in `openspec/changes/add-2fa/tasks.md`):
### AI-Generated Tasks (created in `.openspec/changes/add-2fa/tasks.md`):

```markdown
## 1. Database Setup
Expand Down Expand Up @@ -347,10 +382,10 @@ Deltas are "patches" that show how specs change:
## How OpenSpec Compares

### vs. spec-kit
OpenSpec’s two-folder model (`openspec/specs/` for the current truth, `openspec/changes/` for proposed updates) keeps state and diffs separate. This scales when you modify existing features or touch multiple specs. spec-kit is strong for greenfield/0→1 but provides less structure for cross-spec updates and evolving features.
OpenSpec’s two-folder model (`.openspec/specs/` for the current truth, `.openspec/changes/` for proposed updates) keeps state and diffs separate. This scales when you modify existing features or touch multiple specs. spec-kit is strong for greenfield/0→1 but provides less structure for cross-spec updates and evolving features.

### vs. Kiro.dev
OpenSpec groups every change for a feature in one folder (`openspec/changes/feature-name/`), making it easy to track related specs, tasks, and designs together. Kiro spreads updates across multiple spec folders, which can make feature tracking harder.
OpenSpec groups every change for a feature in one folder (`.openspec/changes/feature-name/`), making it easy to track related specs, tasks, and designs together. Kiro spreads updates across multiple spec folders, which can make feature tracking harder.

### vs. No Specs
Without specs, AI coding assistants generate code from vague prompts, often missing requirements or adding unwanted features. OpenSpec brings predictability by agreeing on the desired behavior before any code is written.
Expand Down
13 changes: 13 additions & 0 deletions gemini-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "openspec",
"version": "0.19.0",
"contextFileName": "GEMINI.md",
"mcpServers": {
"openspec": {
"command": "node",
"args": [
"${extensionPath}/dist/mcp/index.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Add Gemini CLI Extension Support

## Why
Integrating with Gemini CLI makes agents “OpenSpec-aware” by default, reducing setup friction and improving correctness via project-specific context.

## What Changes
- Add `gemini-extension.json` extension manifest (non-breaking).
- Add `GEMINI.md` Gemini-focused usage/context doc (non-breaking).
- Extract shared prompts into `src/core/templates/prompts.ts` (non-breaking).
- Add native Gemini slash commands under `.gemini/commands/openspec/` (non-breaking).

## Impact
- **Specs**: N/A (no spec schema changes).
- **Code**: New extension metadata + prompt source-of-truth; Gemini CLI users get a first-class onboarding path.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## ADDED Requirements
### Requirement: Slash Command Safety
All generated slash command templates SHALL include safety guardrails.

#### Scenario: CLI Availability Check
- **WHEN** generating slash commands for any tool
- **THEN** the template SHALL include an instruction to verify the `openspec` CLI is installed and available in the environment
- **AND** guide the user to install it via `npm install -g @fission-ai/openspec` if missing
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [x] Create `gemini-extension.json` in the project root @file:gemini-extension.json
- [x] Create `GEMINI.md` in the project root with OpenSpec context @file:GEMINI.md
- [x] Extract slash command prompts to a shared location for unified usage across agents
- [x] Configure `GEMINI.md` to auto-generate slash commands from shared prompts
- [x] Document CLI installation prerequisites in `GEMINI.md` and shared prompts
- [x] Add maintenance instructions to `GEMINI.md` for syncing slash commands from `prompts.ts`
- [x] Update `README.md` with Gemini CLI Extension installation and benefits
- [x] Verify the extension can be linked locally using `gemini extensions link .` (Manual verification)
Loading
Loading