Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Reduce APort integration time from hours to minutes.
| Tool | Description | Status | Maintainer |
|------|-------------|--------|------------|
| [APort CLI](tools/cli/) | `npx create-aport-integration` scaffolding tool | ✅ Active | Community |
| [VS Code Extension](tools/vscode-extension/) | Policy development with IntelliSense | 🚧 In Progress | Community |
| [VS Code Extension](tools/vscode-extension/) | Snippets, syntax highlighting, and IntelliSense for APort policy development | ✅ Active | Community |
| [Postman Collection](tools/postman-collection/) | Complete API testing collection | ✅ Active | Community |

### 🌉 **Protocol Bridges & Standards**
Expand Down
6 changes: 6 additions & 0 deletions tools/vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/**
src/**
tests/**
examples/**
*.log
tsconfig.json
63 changes: 63 additions & 0 deletions tools/vscode-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# APort Developer Tools for VS Code

VS Code extension template for APort policy and passport development. It adds snippets, syntax highlighting, and IntelliSense helpers for common APort integration files.

## Features

- APort policy language mode for `.aport-policy` files and `APortfile`
- APort-specific syntax highlighting injected into JSON policy and passport files
- Syntax highlighting for policy pack IDs, agent IDs, capabilities, and common APort keys
- JSON schema validation for policy and passport fixtures
- Completion items for APort policy keys, sample policy packs, and common capabilities
- JavaScript, TypeScript, JSON, JSONC, and YAML snippets for APort integrations
- `APort: Open Documentation` command from the command palette

## Local development

```bash
cd tools/vscode-extension
npm install
npm run compile
npm test
```

Launch the extension from VS Code with `Run Extension`, then open one of the files in `examples/` to verify completions and schema validation.

## Snippets

| Language | Prefix | Description |
| --- | --- | --- |
| JavaScript | `aport-verify` | Create an APort verification request |
| JavaScript | `aport-express` | Protect an Express route with APort middleware |
| TypeScript | `aport-next-middleware` | Add APort verification to Next.js middleware |
| JSON/JSONC/APort Policy | `aport-policy` | Create an APort policy fixture |
| JSON/JSONC/APort Policy | `aport-passport` | Create an APort passport fixture |
| YAML | `aport-action` | Add an APort verify step to GitHub Actions |

## File patterns

The extension contributes JSON schema validation for:

- `*.aport.json`
- `*.aport-policy.json`
- `aport.policy.json`
- `*.aport-passport.json`
- `aport-passport.json`
- `aport.passport.json`

## Example

```json
{
"policy_pack": "finance.payment.refund.v1",
"agent_id": "agt_inst_refund_bot_123",
"verification_level": "github",
"context": {
"amount": 50,
"currency": "USD"
},
"limits": {
"refund_amount_max_per_tx": 100
}
}
```
25 changes: 25 additions & 0 deletions tools/vscode-extension/examples/nextjs-middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NextResponse, type NextRequest } from "next/server";
import { createAPortMiddleware } from "@aporthq/nextjs-middleware";

const verifyAgent = createAPortMiddleware({
policyPack: "finance.payment.refund.v1",
agentIdHeader: "x-agent-id",
apiKey: process.env.APORT_API_KEY
});

export async function middleware(request: NextRequest) {
const verification = await verifyAgent(request);

if (!verification.allowed) {
return NextResponse.json(
{ error: verification.reason ?? "APort verification failed" },
{ status: 403 }
);
}

return NextResponse.next();
}

export const config = {
matcher: ["/api/refunds/:path*"]
};
18 changes: 18 additions & 0 deletions tools/vscode-extension/examples/passport.aport-passport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"agent_id": "agt_inst_refund_bot_123",
"name": "Refund Bot",
"description": "Handles customer refund requests with APort verification.",
"verification_level": "github",
"capabilities": [
{
"name": "refund:create",
"description": "Create refund requests",
"limits": {
"refund_amount_max_per_tx": 100
}
}
],
"metadata": {
"framework": "APort VS Code Extension"
}
}
14 changes: 14 additions & 0 deletions tools/vscode-extension/examples/refund-policy.aport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"policy_pack": "finance.payment.refund.v1",
"agent_id": "agt_inst_refund_bot_123",
"verification_level": "github",
"context": {
"amount": 50,
"currency": "USD",
"order_id": "ord_123"
},
"limits": {
"refund_amount_max_per_tx": 100,
"refunds_per_day": 20
}
}
62 changes: 62 additions & 0 deletions tools/vscode-extension/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"comments": {
"lineComment": "//",
"blockComment": [
"/*",
"*/"
]
},
"brackets": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
]
],
"autoClosingPairs": [
{
"open": "{",
"close": "}"
},
{
"open": "[",
"close": "]"
},
{
"open": "(",
"close": ")"
},
{
"open": "\"",
"close": "\"",
"notIn": [
"string"
]
}
],
"surroundingPairs": [
[
"{",
"}"
],
[
"[",
"]"
],
[
"(",
")"
],
[
"\"",
"\""
]
]
}
159 changes: 159 additions & 0 deletions tools/vscode-extension/out/extension.js

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

1 change: 1 addition & 0 deletions tools/vscode-extension/out/extension.js.map

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

Loading