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/) | Policy development with validation, snippets, and IntelliSense | ✅ Active | Community |
| [Postman Collection](tools/postman-collection/) | Complete API testing collection | ✅ Active | Community |

### 🌉 **Protocol Bridges & Standards**
Expand Down
7 changes: 7 additions & 0 deletions tools/vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/**
src/test/**
out/test/**
node_modules/**
*.tgz
*.vsix
coverage/**
69 changes: 69 additions & 0 deletions tools/vscode-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# APort Policy Tools for VS Code

VS Code extension for authoring APort policy packs.

## Features

- Syntax highlighting for `.aport-policy`, `.aport-policy.json`, `.aport-policy.yaml`, and `.aport-policy.yml`.
- JSON schema validation for `*.aport-policy.json` and `.github/aport-policy.json`.
- Completion suggestions for common policy fields.
- Snippets for policy packs and individual rules.
- Validation command for JSON and simple YAML policy files.
- Sample policy generation command.

## Commands

| Command | Description |
| --- | --- |
| `APort: Validate Policy Pack` | Validates the active APort policy file and reports diagnostics. |
| `APort: Insert Sample Policy Pack` | Inserts a starter policy pack using the configured default policy id. |

## Configuration

```json
{
"aportPolicy.defaultPolicyId": "code.repository.merge.v1",
"aportPolicy.validateOnSave": true
}
```

## Example Policy

```json
{
"policy": {
"id": "code.repository.merge.v1",
"version": "1.0.0",
"description": "Require APort verification before repository changes"
},
"rules": [
{
"id": "require-repository-capability",
"effect": "allow",
"condition": "agent.capabilities.includes('repo.merge')",
"reason": "Agent must have repository merge capability"
}
],
"limits": {
"max_files_changed": 25
}
}
```

## Development

```bash
npm install
npm test
npm run check
```

## Package Layout

```text
src/extension.ts VS Code activation, commands, completions, diagnostics
src/policyValidator.ts Policy parser and validator
schemas/ JSON schema for APort policy packs
snippets/ VS Code snippets
syntaxes/ TextMate grammar
```
27 changes: 27 additions & 0 deletions tools/vscode-extension/examples/refund-policy.aport-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"policy": {
"id": "finance.payment.refund.v1",
"version": "1.0.0",
"description": "Allow refund actions only for verified agents with refund capability"
},
"rules": [
{
"id": "require-refund-capability",
"effect": "allow",
"condition": "agent.capabilities.includes('payments.refund')",
"reason": "Agent must have refund capability"
},
{
"id": "deny-large-refunds",
"effect": "deny",
"condition": "context.amount > limits.max_refund_amount",
"reason": "Refund amount exceeds policy limit"
}
],
"limits": {
"max_refund_amount": 500
},
"metadata": {
"owner": "finance"
}
}
20 changes: 20 additions & 0 deletions tools/vscode-extension/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"comments": {
"lineComment": "#"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "\"", "close": "\"" }
],
"surroundingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "\"", "close": "\"" }
]
}
59 changes: 59 additions & 0 deletions tools/vscode-extension/package-lock.json

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

109 changes: 109 additions & 0 deletions tools/vscode-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"name": "aport-policy-tools",
"displayName": "APort Policy Tools",
"description": "Syntax highlighting, validation, snippets, and IntelliSense for APort policy packs.",
"version": "0.1.0",
"publisher": "aport-community",
"license": "MIT",
"engines": {
"vscode": "^1.90.0"
},
"categories": [
"Programming Languages",
"Linters",
"Snippets"
],
"keywords": [
"aport",
"policy",
"agent",
"validation",
"intellisense"
],
"activationEvents": [
"onLanguage:aport-policy",
"onCommand:aportPolicy.validate",
"onCommand:aportPolicy.insertSamplePolicy"
],
"main": "./out/extension.js",
"scripts": {
"compile": "tsc -p ./",
"test": "npm run compile && node --test out/test/*.test.js",
"check": "npm run compile && node --check out/extension.js && node --check out/policyValidator.js"
},
"contributes": {
"commands": [
{
"command": "aportPolicy.validate",
"title": "APort: Validate Policy Pack"
},
{
"command": "aportPolicy.insertSamplePolicy",
"title": "APort: Insert Sample Policy Pack"
}
],
"configuration": {
"title": "APort Policy Tools",
"properties": {
"aportPolicy.defaultPolicyId": {
"type": "string",
"default": "code.repository.merge.v1",
"description": "Default policy id used by snippets and sample policy generation."
},
"aportPolicy.validateOnSave": {
"type": "boolean",
"default": true,
"description": "Run policy validation when an APort policy document is saved."
}
}
},
"jsonValidation": [
{
"fileMatch": [
"*.aport-policy.json",
".github/aport-policy.json"
],
"url": "./schemas/aport-policy.schema.json"
}
],
"languages": [
{
"id": "aport-policy",
"aliases": [
"APort Policy",
"aport-policy"
],
"extensions": [
".aport-policy",
".aport-policy.json",
".aport-policy.yaml",
".aport-policy.yml"
],
"filenames": [
"aport-policy.json",
"aport-policy.yaml",
"aport-policy.yml"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "aport-policy",
"scopeName": "source.aport-policy",
"path": "./syntaxes/aport-policy.tmLanguage.json"
}
],
"snippets": [
{
"language": "aport-policy",
"path": "./snippets/aport-policy.json"
}
]
},
"devDependencies": {
"@types/node": "^20.14.10",
"@types/vscode": "1.90.0",
"typescript": "^5.5.4"
}
}
62 changes: 62 additions & 0 deletions tools/vscode-extension/schemas/aport-policy.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://aport.io/schemas/aport-policy.schema.json",
"title": "APort Policy Pack",
"type": "object",
"required": ["policy", "rules"],
"additionalProperties": true,
"properties": {
"policy": {
"type": "object",
"required": ["id", "version"],
"additionalProperties": true,
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z]+(\\.[a-z0-9_-]+)+\\.v[0-9]+$",
"description": "Stable policy pack id, such as code.repository.merge.v1."
},
"version": {
"type": "string",
"description": "Policy pack version."
},
"description": {
"type": "string"
}
}
},
"rules": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["id", "effect", "condition"],
"additionalProperties": true,
"properties": {
"id": {
"type": "string"
},
"effect": {
"type": "string",
"enum": ["allow", "deny"]
},
"condition": {
"type": "string"
},
"reason": {
"type": "string"
}
}
}
},
"limits": {
"type": "object",
"additionalProperties": {
"type": ["number", "string", "boolean"]
}
},
"metadata": {
"type": "object"
}
}
}
Loading