# PCode Dependency Installation Guide - Linux (LLM Prompt)

## Purpose

This document provides unified dependency checking and installation guidance for AI/LLM systems. LLMs should guide users through dependency checking and installation based on the content provided in this document.

## Check Workflow

1. Confirm the current Linux distribution and architecture satisfy the package requirements.
2. Check the Node.js version: Run `node --version`
3. Check the OpenSpec version: Run `openspec --version`

## Installation Guide

### Node.js Installation

Install Node.js from the official distribution channel:

```bash
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
    NODE_ARCH="x64"
elif [ "$ARCH" = "aarch64" ]; then
    NODE_ARCH="arm64"
else
    echo "Unsupported architecture: $ARCH"
    exit 1
fi

curl -fsSL https://nodejs.org/dist/vcurrent-version/node-vcurrent-version-linux-${NODE_ARCH}.tar.xz -o /tmp/node.tar.xz
mkdir -p ~/.local
rm -rf ~/.local/node-current
mkdir -p ~/.local/node-current
tar -xJf /tmp/node.tar.xz -C ~/.local/node-current --strip-components=1
rm /tmp/node.tar.xz
export PATH="$HOME/.local/node-current/bin:$PATH"
echo 'export PATH="$HOME/.local/node-current/bin:$PATH"' >> ~/.bashrc
```

Verify installation: `node --version`

### OpenSpec Installation

OpenSpec installs with the package manager bundled in Node.js, so no standalone npm prerequisite is required.

```bash
npm install @fission-ai/openspec@minimum-version -g
```

Verify installation: `openspec --version`

## Dependency Requirements

The following dependency version requirements are pre-populated in this prompt and ready to use:

### node
- 最低版本: 20.11.0
- 推荐版本: 24.12.0
- 安装提示: Install from https://nodejs.org/ or use nvm
- 描述: Node.js runtime

### openspec
- 最低版本: 1.0.0
- 最高版本: 2.0.0
- 描述: OpenSpec proposal management system

### system
- 描述: System requirements for Hagicode platform



## Troubleshooting

### Version Mismatch

Use the version requirements listed in this prompt and upgrade or downgrade according to each dependency's installHint.

**Node.js version mismatch**:
```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install recommended-version
nvm use recommended-version
```

**OpenSpec version mismatch**:
```bash
npm install @fission-ai/openspec@minimum-version -g
```

### Network Issues

- Node.js: Official nodejs.org distribution
- OpenSpec: Official npmjs.org registry through the bundled package manager

### Permission Issues

```bash
sudo npm install @fission-ai/openspec@minimum-version -g
```

## Verification Checklist

After completing installation, run the following commands to verify all dependencies:

```bash
uname -m
node --version
openspec --version
```

## Execution Boundary (Mandatory)

- The only required action after installation is dependency status checking.
- Do not attempt to start any service.
- Do not perform extra initialization tasks.
- Do not trigger post-install workflows unrelated to dependency checks.
- In non-interactive mode, do not ask interactive questions; use deterministic defaults and record assumptions in the output.
- The final output must be: installation completed + dependency check results.

## Output Installation Result Report

**Important**: After completing all dependency checks and installations, you must output a clear table report to the user summarizing the status of all dependencies.

Report format:

```markdown
## Dependency Installation Result Report

| Dependency | Status | Current Value | Requirement | Notes |
|------------|--------|---------------|-------------|-------|
| System Compatibility | ✓ Confirmed | Linux x64 | Matches package requirements | |
| Node.js | ✓ Installed | 24.12.0 | >= 20.11.0 | |
| OpenSpec | ✓ Installed | 1.0.5 | 1.0.0 - < 2.0.0 | |

## Summary
- Required dependencies: 3/3 satisfied ✓
```

**Notes**:
- **Status**: Use "✓ Installed", "✗ Not Installed", "⚠ Version Mismatch"
- **Current Value**: Actual system information or version obtained from the verification commands
- **Requirement**: Requirement listed in this prompt
- **Notes**: Any follow-up action or compatibility note

After outputting the report, if there are uninstalled or version-mismatched dependencies, provide specific installation or upgrade recommendations.

## Important Notes

1. **Version Numbers**: Version information in this guide is pre-populated in the dependency section of this prompt
2. **Package Management**: OpenSpec uses the package manager bundled with Node.js, so no standalone npm prerequisite is needed
