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 @@ -145,7 +145,7 @@ Directory API services can be deployed either using the `Taskfile` or directly v
This will start the necessary components such as storage and API services.

```bash
task server:start
DIRECTORY_SERVER_OASF_API_VALIDATION_SCHEMA_URL="https://schema.oasf.outshift.com/" task server:start
```

### Using Helm chart
Expand Down
39 changes: 38 additions & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,43 @@ Verify record signatures.
dirctl verify record.json signature.sig --key public.key
```

#### `dirctl validate [<file>] [flags]`
Validate OASF record JSON from a file or stdin.

This command validates OASF record JSON against the OASF schema. The JSON can be
provided as a file path or piped from stdin (e.g., from `dirctl pull`).

You must specify either `--url` for API-based validation or `--disable-api` for
embedded schema validation.

**Examples:**
```bash
# Validate a file using embedded schemas (no API calls)
dirctl validate record.json --disable-api

# Validate a file with API-based validation
dirctl validate record.json --url https://schema.oasf.outshift.com

# Validate a file with non-strict mode (more permissive, only works with --url)
dirctl validate record.json --url https://schema.oasf.outshift.com --disable-strict

# Validate JSON piped from stdin
cat record.json | dirctl validate --disable-api

# Validate a record pulled from directory
dirctl pull <cid> --output json | dirctl validate --disable-api

# Validate all records in a directory (using shell scripting)
for cid in $(dirctl search --output jsonl | jq -r '.record_cid'); do
dirctl pull "$cid" | dirctl validate --disable-api
done
```

**Flags:**
- `--url <url>` - OASF schema URL for API-based validation (required if --disable-api is not specified)
- `--disable-api` - Disable API-based validation (use embedded schemas instead, required if --url is not specified)
- `--disable-strict` - Disable strict validation mode (more permissive validation, only works with --url)

### 📥 **Import Operations**

Import records from external registries into DIR. Supports automated batch imports from various registry types.
Expand Down Expand Up @@ -698,7 +735,7 @@ The CLI follows a clear service-based organization:
- **Storage**: Direct record management (`push`, `pull`, `delete`, `info`)
- **Routing**: Network announcement and discovery (`routing publish`, `routing list`, `routing search`)
- **Search**: General content search (`search`)
- **Security**: Signing and verification (`sign`, `verify`)
- **Security**: Signing, verification, and validation (`sign`, `verify`, `validate`)
- **Import**: External registry imports (`import`)
- **Sync**: Peer synchronization (`sync`)

Expand Down
2 changes: 2 additions & 0 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/agntcy/dir/cli/cmd/search"
"github.com/agntcy/dir/cli/cmd/sign"
"github.com/agntcy/dir/cli/cmd/sync"
"github.com/agntcy/dir/cli/cmd/validate"
"github.com/agntcy/dir/cli/cmd/verify"
"github.com/agntcy/dir/cli/cmd/version"
ctxUtils "github.com/agntcy/dir/cli/util/context"
Expand Down Expand Up @@ -61,6 +62,7 @@ func init() {
// initialize.Command, // REMOVED: Initialize functionality
sign.Command,
verify.Command,
validate.Command,
// storage commands
info.Command,
pull.Command,
Expand Down
23 changes: 23 additions & 0 deletions cli/cmd/validate/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0

package validate

var opts = &options{}

type options struct {
DisableAPI bool
DisableStrict bool
SchemaURL string
}

func init() {
flags := Command.Flags()

flags.BoolVar(&opts.DisableAPI, "disable-api", false,
"Disable API-based validation (use embedded schemas instead, required if --url is not specified)")
flags.BoolVar(&opts.DisableStrict, "disable-strict", false,
"Disable strict validation mode (more permissive validation, only works with --url)")
flags.StringVar(&opts.SchemaURL, "url", "",
"OASF schema URL for API-based validation (required if --disable-api is not specified)")
}
63 changes: 63 additions & 0 deletions cli/cmd/validate/testdata/record_invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "directory.agntcy.org/example/research-assistant-v4",
"version": "v4.0.0",
"schema_version": "0.8.0",
"description": "AI research assistant for data analysis and problem solving.",
"authors": [
"AGNTCY Contributors"
],
"created_at": "2025-03-19T17:06:37Z",
"annotations": {
"key": "value"
},
"skills": [
{
"id": 10201876
},
{
"name": "natural_language_processing/analytical_reasoning/problem_solving",
"id": 10702
}
],
"locators": [
{
"type": "docker_image",
"url": "https://ghcr.io/agntcy/research-assistant"
}
],
"domains": [
{
"id": 301,
"name": "life_science/biotechnology"
}
],
"modules": [
{
"name": "core/llm/model",
"id": 10201,
"data": {
"models": [
{
"provider": "openai",
"model": "gpt-4",
"api_base": "https://api.openai.com/v1",
"env_vars": [
{
"name": "OPENAI_API_KEY",
"description": "OpenAI API key for authentication",
"required": true
},
{
"name": "OPENAI_ORG_ID",
"description": "OpenAI organization ID",
"required": false,
"default_value": ""
}
]
}
]
}
}
],
"previous_record_cid": "bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku"
}
64 changes: 64 additions & 0 deletions cli/cmd/validate/testdata/record_valid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "directory.agntcy.org/example/research-assistant-v4",
"version": "v4.0.0",
"schema_version": "0.8.0",
"description": "AI research assistant for data analysis and problem solving.",
"authors": [
"AGNTCY Contributors"
],
"created_at": "2025-03-19T17:06:37Z",
"annotations": {
"key": "value"
},
"skills": [
{
"name": "natural_language_processing/natural_language_generation/text_completion",
"id": 10201
},
{
"name": "natural_language_processing/analytical_reasoning/problem_solving",
"id": 10702
}
],
"locators": [
{
"type": "docker_image",
"url": "https://ghcr.io/agntcy/research-assistant"
}
],
"domains": [
{
"id": 301,
"name": "life_science/biotechnology"
}
],
"modules": [
{
"name": "core/llm/model",
"id": 10201,
"data": {
"models": [
{
"provider": "openai",
"model": "gpt-4",
"api_base": "https://api.openai.com/v1",
"env_vars": [
{
"name": "OPENAI_API_KEY",
"description": "OpenAI API key for authentication",
"required": true
},
{
"name": "OPENAI_ORG_ID",
"description": "OpenAI organization ID",
"required": false,
"default_value": ""
}
]
}
]
}
}
],
"previous_record_cid": "bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku"
}
45 changes: 45 additions & 0 deletions cli/cmd/validate/testdata/record_valid_for_non_strict.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "directory.agntcy.org/example/research-assistant-v4",
"version": "v4.0.0",
"schema_version": "0.8.0",
"description": "AI research assistant for data analysis and problem solving.",
"authors": [
"AGNTCY Contributors"
],
"created_at": "2025-03-19T17:06:37Z",
"annotations": {
"key": "value"
},
"skills": [
{
"name": "natural_language_processing/natural_language_generation/text_completion",
"id": 10201
},
{
"name": "natural_language_processing/analytical_reasoning/problem_solving",
"id": 10702
}
],
"locators": [
{
"type": "docker_image",
"url": "https://ghcr.io/agntcy/research-assistant"
}
],
"domains": [
{
"id": 0,
"name": "base_domain"
}
],
"modules": [
{
"name": "license",
"data": {
"header": "Copyright (c) 2025 Cisco and/or its affiliates.",
"license": "Apache-2.0"
}
}
],
"previous_record_cid": "bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku"
}
45 changes: 45 additions & 0 deletions cli/cmd/validate/testdata/record_valid_for_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "directory.agntcy.org/example/research-assistant-v4",
"version": "v4.0.0",
"schema_version": "0.8.0",
"description": "AI research assistant for data analysis and problem solving.",
"authors": [
"AGNTCY Contributors"
],
"created_at": "2025-03-19T17:06:37Z",
"annotations": {
"key": "value"
},
"skills": [
{
"name": "natural_language_processing/natural_language_generation/text_completion",
"id": 10201
},
{
"name": "natural_language_processing/analytical_reasoning/problem_solving",
"id": 10702
}
],
"locators": [
{
"type": "docker_image",
"url": "https://ghcr.io/agntcy/research-assistant"
}
],
"domains": [
{
"id": 301,
"name": "life_science/biotechnology"
}
],
"modules": [
{
"name": "license",
"data": {
"header": "Copyright (c) 2025 Cisco and/or its affiliates.",
"license": "Apache-2.0"
}
}
],
"previous_record_cid": "asdf"
}
Loading
Loading