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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Alternatively, you can download it from the [JetBrains Marketplace](https://plug

Alternatively, you can install it from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=tangcent.one-ide).

## Skills

Install the `editor-context` skill to give terminal AI tools (claude, gemini-cli, kiro-cli, codex, etc.) access to your live IDE editor state:

```bash
npx skills add tangcent/one-IDE -g -y
```

See the [skills catalog](./skills/README.md) for details.

## Development

### Prerequisites
Expand Down
7 changes: 7 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
build/
*.log
.DS_Store
.env
coverage/
.idea/
79 changes: 79 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# one-ide-cli

CLI to access live IDE editor state published by the [One-IDE](https://github.com/tangcent/one-IDE) plugin.

When running AI tools in the terminal (Claude CLI, Codex, Kiro CLI, etc.), the tool has no direct access to the IDE. The One-IDE plugin (JetBrains / VS Code) continuously writes editor state to `~/.one-ide/cluster/state.json`. `one-ide-cli` reads that file and exposes the data as simple commands.

## Installation

```bash
npm install -g one-ide-cli
```

## Prerequisites

The [One-IDE plugin](https://github.com/tangcent/one-IDE) must be installed and active in at least one IDE (JetBrains or VS Code/fork).

## Commands

### Active project root

```bash
one-ide-cli active-project
# /Users/you/project
```

### Active file in a project

```bash
one-ide-cli active-file /Users/you/project
# /Users/you/project/src/main.ts
```

Returns the file currently focused in the IDE. Exits with an error if the given project path does not match the active project.

### Open files in a project

```bash
one-ide-cli opened-files /Users/you/project
```

```json
[
"/Users/you/project/src/main.ts",
"/Users/you/project/src/utils.ts",
"/Users/you/project/README.md"
]
```

### Active IDE name

```bash
one-ide-cli ide
# VSCode
```

### Help

```bash
one-ide-cli --help
```

## Using Editor Context in AI Prompts

```bash
# Pass active file to Claude CLI
PROJECT=$(one-ide-cli active-project)
ACTIVE=$(one-ide-cli active-file "$PROJECT")
claude "Review $ACTIVE for potential bugs."

# Pass all open files as context
PROJECT=$(one-ide-cli active-project)
FILES=$(one-ide-cli opened-files "$PROJECT")
claude "I have these files open: $FILES. Help me understand the overall structure."

# Kiro CLI
PROJECT=$(one-ide-cli active-project)
ACTIVE=$(one-ide-cli active-file "$PROJECT")
kiro "Review the file at $ACTIVE"
```
51 changes: 51 additions & 0 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "one-ide-cli",
"version": "1.0.0",
"description": "CLI to access live IDE editor state published by the One-IDE plugin",
"main": "build/index.js",
"type": "module",
"bin": {
"one-ide-cli": "build/index.js"
},
"files": [
"build",
"README.md",
"LICENSE"
],
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"start": "node build/index.js",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tangcent/one-IDE.git",
"directory": "cli"
},
"keywords": [
"one-ide",
"ide",
"editor",
"cli",
"cursor",
"vscode",
"jetbrains"
],
"author": "tangcent",
"license": "MIT",
"bugs": {
"url": "https://github.com/tangcent/one-IDE/issues"
},
"homepage": "https://github.com/tangcent/one-IDE/tree/main/cli#readme",
"devDependencies": {
"@types/node": "^22.0.0",
"typescript": "^5.5.0"
}
}
89 changes: 89 additions & 0 deletions cli/scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_ROOT" || exit 1

publish_npm() {
echo "🚀 Publishing to npmjs.com..."
npm publish --access public
}

publish_github() {
echo "🚀 Publishing to GitHub Packages..."

if ! npm whoami --registry=https://npm.pkg.github.com >/dev/null 2>&1; then
echo "⚠️ You are not logged in to GitHub Packages."
echo "📦 You need a GitHub Personal Access Token (classic) with:"
echo " ✅ write:packages"
echo " ✅ read:packages"
echo ""
echo "🔗 Create one here: https://github.com/settings/tokens/new?scopes=write:packages,read:packages&description=one-ide-cli%20Publish"
echo ""
read -p "Would you like to log in now? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
npm login --registry=https://npm.pkg.github.com || { echo "❌ Login failed."; exit 1; }
else
echo "❌ Authentication required. Run 'npm login --registry=https://npm.pkg.github.com' and try again."
exit 1
fi
fi

cp package.json package.json.bak

node -e "
const fs = require('fs');
const pkg = require('./package.json');
pkg.name = '@tangcent/one-ide-cli';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
"

cleanup() {
rm -f .npmrc
mv package.json.bak package.json
}
trap cleanup EXIT

npm publish --registry=https://npm.pkg.github.com

cleanup
trap - EXIT
}

TARGET=$1

if [ -z "$TARGET" ]; then
echo "Select registry to publish to:"
echo "1) All (GitHub & NPM)"
echo "2) NPM only (npmjs.com)"
echo "3) GitHub only (npm.pkg.github.com)"
read -p "Enter choice [1-3]: " choice
case $choice in
1) TARGET="all" ;;
2) TARGET="npm" ;;
3) TARGET="github" ;;
*) echo "❌ Invalid choice" && exit 1 ;;
esac
fi

echo "👉 Selected target: $TARGET"

case $TARGET in
npm) publish_npm ;;
github) publish_github ;;
all)
echo "📦 Publishing to ALL registries..."
publish_github && echo "✅ GitHub publish success." || echo "⚠️ GitHub publish failed. Continuing..."
publish_npm && echo "✅ npm publish success." || { echo "❌ npm publish failed."; exit 1; }
;;
*)
echo "❌ Invalid option: $TARGET"
echo "Usage: ./scripts/publish.sh [github|npm|all]"
exit 1
;;
esac

echo "🎉 Done!"
68 changes: 68 additions & 0 deletions cli/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_ROOT" || exit 1

CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"

IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
MAJOR=$(echo "${VERSION_PARTS[0]}" | grep -oE '^[0-9]+')
MINOR=$(echo "${VERSION_PARTS[1]}" | grep -oE '^[0-9]+')
PATCH=$(echo "${VERSION_PARTS[2]}" | grep -oE '^[0-9]+')

NEXT_PATCH="$MAJOR.$MINOR.$((PATCH + 1))"
NEXT_MINOR="$MAJOR.$((MINOR + 1)).0"
NEXT_MAJOR="$((MAJOR + 1)).0.0"

echo ""
echo "Select a new version to release:"
echo "1) Patch ($NEXT_PATCH)"
echo "2) Minor ($NEXT_MINOR)"
echo "3) Major ($NEXT_MAJOR)"
echo "4) Custom"
echo "5) Cancel"

read -p "Enter your choice [1-5]: " CHOICE

NEW_VERSION=""
case $CHOICE in
1) NEW_VERSION="$NEXT_PATCH" ;;
2) NEW_VERSION="$NEXT_MINOR" ;;
3) NEW_VERSION="$NEXT_MAJOR" ;;
4)
read -p "Enter custom version: " NEW_VERSION
[ -z "$NEW_VERSION" ] && echo "Version cannot be empty." && exit 1
;;
5) echo "Release cancelled." && exit 0 ;;
*) echo "Invalid choice." && exit 1 ;;
esac

echo ""
echo "You are about to release version: $NEW_VERSION"
read -p "Are you sure? (y/N) " CONFIRM
[[ ! "$CONFIRM" =~ ^([yY][eE][sS]|[yY])$ ]] && echo "Cancelled." && exit 0

echo ""
echo "Updating version to $NEW_VERSION..."
npm version "$NEW_VERSION" --git-tag-version=false || exit 1

echo "Building project..."
npm run build || { echo "Build failed. Aborting release."; exit 1; }

echo ""
echo "Publishing to npm..."
npm publish --access public || { echo "Publish failed."; exit 1; }

echo ""
echo "Successfully published version $NEW_VERSION!"

read -p "Do you want to create a git tag and push? (y/N) " GIT_TAG
if [[ "$GIT_TAG" =~ ^([yY][eE][sS]|[yY])$ ]]; then
git add package.json package-lock.json
git commit -m "chore(cli): release $NEW_VERSION"
git tag "cli/v$NEW_VERSION"
git push && git push --tags
fi
22 changes: 22 additions & 0 deletions cli/src/help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as os from 'os';
import * as path from 'path';

const STATE_FILE = path.join(os.homedir(), '.one-ide', 'cluster', 'state.json');

export function printHelp(): void {
console.log(`
one-ide-cli — access live IDE editor state from the terminal

State file: ${STATE_FILE}

Commands:
context <project-path> Full editor context (active project, file, selection, open files, file text)
active-project Print the workspace root of the active project
active-file <project-path> Print the active file in the given project
opened-files <project-path> Print all open files in the given project (JSON array)
ide Print the active IDE name (e.g. VSCode, IntelliJ IDEA)

Options:
--help, -h Show this help
`.trim());
}
Loading
Loading