@aigis-ai/cli 1.0.3 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +53 -0
- package/README.md +58 -188
- package/SKILL.md +20 -55
- package/aigis-ai-cli-2.0.1.tgz +0 -0
- package/bin/aigis.js +446 -59
- package/content/index/audit-scan.md +21 -207
- package/content/index/auto-verify-rules.json +439 -0
- package/content/index/context-rules.json +90 -0
- package/content/resolvers/triggers.json +229 -0
- package/content/{implement → skills/areas}/audit-logging.md +5 -0
- package/content/skills/areas/fallback-patterns.md +200 -0
- package/content/skills/areas/input-validation.md +380 -0
- package/content/skills/areas/pii-handling.md +189 -0
- package/content/skills/areas/rate-limiting.md +246 -0
- package/content/skills/core.md +62 -0
- package/content/skills/infrastructure/logging.md +202 -0
- package/content/skills/infrastructure/rate-limiting.md +169 -0
- package/content/skills/infrastructure/secrets.md +167 -0
- package/content/skills/workflows/fastapi-llm.md +86 -0
- package/docs/resolvers.md +114 -0
- package/lib/auto-verify.js +378 -0
- package/lib/build.js +629 -0
- package/lib/checksum.js +39 -0
- package/lib/fetch.js +164 -9
- package/lib/init.js +141 -93
- package/lib/keywords.js +92 -130
- package/lib/special-recognizers.js +370 -0
- package/package.json +1 -1
- package/scripts/baseline-cursorrules.snapshot.txt +30 -0
- package/scripts/bootstrap-step-6-bench.js +85 -0
- package/scripts/check-content-sync.js +91 -0
- package/scripts/triggers.schema.json +50 -0
- package/scripts/validate-triggers.js +176 -0
- package/content/implement/fallback-patterns.md +0 -190
- package/content/implement/input-validation.md +0 -212
- package/content/implement/pii-handling.md +0 -207
- package/content/implement/rate-limiting.md +0 -217
- /package/content/{implement → skills/areas}/bias-monitoring.md +0 -0
- /package/content/{implement → skills/areas}/confidence-scoring.md +0 -0
- /package/content/{implement → skills/areas}/data-integrity.md +0 -0
- /package/content/{implement → skills/areas}/explainability.md +0 -0
- /package/content/{implement → skills/areas}/human-oversight.md +0 -0
- /package/content/{implement → skills/areas}/monitoring.md +0 -0
- /package/content/{implement → skills/areas}/output-sanitization.md +0 -0
- /package/content/{implement → skills/areas}/prompt-security.md +0 -0
- /package/content/{implement → skills/areas}/rag-security.md +0 -0
- /package/content/{implement → skills/areas}/supply-chain.md +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: infra-secrets
|
|
3
|
+
title: Secrets management infrastructure (env-var baseline + vault integration patterns)
|
|
4
|
+
controls:
|
|
5
|
+
owasp: [LLM02, LLM05]
|
|
6
|
+
nist: [MAP-2.3, MEASURE-2.7]
|
|
7
|
+
iso42001: [Clause-8.3]
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Several area procedures (`pii-handling`, `supply-chain`, the `rate-limiting` infra file's Redis URL) require secrets — API keys, database credentials, connection strings — to live outside source code. This file shows the two infrastructure shapes that satisfy that requirement: an environment-variable baseline for new projects, and integration patterns for projects that already have a secrets manager. Pick one. Then return to the procedure that sent you here.
|
|
11
|
+
|
|
12
|
+
This is content, not a scaffold. Aigis does not write files for you. Copy the snippets you need; adapt them to your project.
|
|
13
|
+
|
|
14
|
+
## Starting from scratch (you have no secrets manager yet)
|
|
15
|
+
|
|
16
|
+
If you are building a new project and don't have a vault, the minimum acceptable baseline is environment variables loaded from a `.env` file in development and from your platform's secret store in production. Hard-coded secrets in source files are not acceptable at any stage — the supply-chain procedure will flag them.
|
|
17
|
+
|
|
18
|
+
### Required dependency
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
python-dotenv>=1.0 # loads .env into os.environ; pin per your supply-chain procedure
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### `.env.example` convention
|
|
25
|
+
|
|
26
|
+
Commit `.env.example` with placeholder values. Add `.env` to `.gitignore`. Every key in `.env.example` must be present in `.env` for the app to start.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
# .env.example
|
|
30
|
+
ANTHROPIC_API_KEY=sk-ant-REPLACE_ME
|
|
31
|
+
OPENAI_API_KEY=sk-REPLACE_ME
|
|
32
|
+
DATABASE_URL=postgresql://user:REPLACE_ME@localhost:5432/dbname
|
|
33
|
+
REDIS_URL=redis://localhost:6379/0
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
# .gitignore
|
|
38
|
+
.env
|
|
39
|
+
.env.local
|
|
40
|
+
.env.*.local
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Do not deploy `.env` to production. Production secrets come from your platform's secret store (Vault, AWS Secrets Manager, GCP Secret Manager, or the wrappers below). The `.env` file exists only for local development; a `.env` in a container image or a production deploy is a leak.
|
|
44
|
+
|
|
45
|
+
### Loading code
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import os
|
|
49
|
+
from dotenv import load_dotenv
|
|
50
|
+
|
|
51
|
+
load_dotenv() # no-op in production if .env is absent
|
|
52
|
+
|
|
53
|
+
def require(name: str) -> str:
|
|
54
|
+
value = os.getenv(name)
|
|
55
|
+
if not value or value.endswith("REPLACE_ME"):
|
|
56
|
+
raise RuntimeError(f"Missing required secret: {name}")
|
|
57
|
+
return value
|
|
58
|
+
|
|
59
|
+
ANTHROPIC_API_KEY = require("ANTHROPIC_API_KEY")
|
|
60
|
+
DATABASE_URL = require("DATABASE_URL")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The `require` helper fails fast at startup rather than at first use. A missing API key should crash the process on boot, not surface as a 500 the first time a user hits the LLM endpoint.
|
|
64
|
+
|
|
65
|
+
### Verifying the setup
|
|
66
|
+
|
|
67
|
+
Before wiring secrets into application code, confirm loading works and that no secret leaks into logs:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
print("ANTHROPIC_API_KEY loaded:", bool(os.getenv("ANTHROPIC_API_KEY")))
|
|
71
|
+
# Never print the value itself, even in development scripts.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If this prints `False`, fix the `.env` location or `load_dotenv()` call before continuing.
|
|
75
|
+
|
|
76
|
+
## Integrate with existing infrastructure
|
|
77
|
+
|
|
78
|
+
If you already have a secrets manager, adapt rather than introduce a second source of truth. Common cases below; pick the closest match.
|
|
79
|
+
|
|
80
|
+
### HashiCorp Vault
|
|
81
|
+
|
|
82
|
+
Read secrets at process start, populate `os.environ`, and let the rest of the app use the env-var pattern above:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import hvac, os
|
|
86
|
+
|
|
87
|
+
client = hvac.Client(url=os.environ["VAULT_ADDR"], token=os.environ["VAULT_TOKEN"])
|
|
88
|
+
secrets = client.secrets.kv.v2.read_secret_version(path="myapp/prod")["data"]["data"]
|
|
89
|
+
for key, value in secrets.items():
|
|
90
|
+
os.environ.setdefault(key, value)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use AppRole or Kubernetes auth in production; static `VAULT_TOKEN` is for local development only.
|
|
94
|
+
|
|
95
|
+
### AWS Secrets Manager
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import boto3, json, os
|
|
99
|
+
|
|
100
|
+
client = boto3.client("secretsmanager", region_name=os.environ["AWS_REGION"])
|
|
101
|
+
secret = json.loads(client.get_secret_value(SecretId="myapp/prod")["SecretString"])
|
|
102
|
+
for key, value in secret.items():
|
|
103
|
+
os.environ.setdefault(key, value)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Grant the application's IAM role `secretsmanager:GetSecretValue` on a single secret ARN, not `*`. Rotate via the built-in rotation Lambda, not by hand.
|
|
107
|
+
|
|
108
|
+
### GCP Secret Manager
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from google.cloud import secretmanager
|
|
112
|
+
import os
|
|
113
|
+
|
|
114
|
+
client = secretmanager.SecretManagerServiceClient()
|
|
115
|
+
def fetch(name: str) -> str:
|
|
116
|
+
path = f"projects/{os.environ['GCP_PROJECT']}/secrets/{name}/versions/latest"
|
|
117
|
+
return client.access_secret_version(name=path).payload.data.decode()
|
|
118
|
+
|
|
119
|
+
os.environ["ANTHROPIC_API_KEY"] = fetch("anthropic-api-key")
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Bind the service account to `roles/secretmanager.secretAccessor` on each secret, not at the project level.
|
|
123
|
+
|
|
124
|
+
### Doppler / 1Password / Infisical
|
|
125
|
+
|
|
126
|
+
These tools inject secrets as environment variables at process start via a CLI wrapper:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
doppler run -- python app.py
|
|
130
|
+
op run --env-file=.env -- python app.py
|
|
131
|
+
infisical run -- python app.py
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Your application code does not change — it still reads `os.environ`. The wrapper handles fetch, decryption, and injection. Appropriate when you want centralized rotation without code changes.
|
|
135
|
+
|
|
136
|
+
These are developer-experience tools — good for smaller teams and centralized rotation. For regulated environments (SOC 2, HIPAA, FedRAMP), prefer the managed services above.
|
|
137
|
+
|
|
138
|
+
## Production considerations
|
|
139
|
+
|
|
140
|
+
Things to think about before deploying. None of these are blockers for the procedure that sent you here, but all of them affect whether your secret hygiene survives contact with a real environment.
|
|
141
|
+
|
|
142
|
+
### Rotation
|
|
143
|
+
|
|
144
|
+
Every secret should have a known rotation cadence. API keys: at least every 90 days, immediately on suspected compromise. Database credentials: managed by the secrets manager's rotation feature where available. Document the rotation procedure next to the secret definition; an undocumented secret is an unrotated secret.
|
|
145
|
+
|
|
146
|
+
For secrets that cannot rotate without downtime (primary database credentials on a live system), use dual-credential patterns — provision the new credential alongside the old, shift traffic, then revoke the old.
|
|
147
|
+
|
|
148
|
+
### Access control
|
|
149
|
+
|
|
150
|
+
Grant read access to specific secrets, not to the whole vault. Use separate credentials for development, staging, and production — a leaked dev key should not unlock prod. Audit access logs from your secrets manager; unexplained reads are an incident.
|
|
151
|
+
|
|
152
|
+
### Logging hygiene
|
|
153
|
+
|
|
154
|
+
Secrets must never appear in logs, error messages, stack traces, or telemetry. The `audit-logging` area procedure covers redaction patterns. At minimum, scrub `Authorization` headers, `*_KEY`, `*_SECRET`, `*_TOKEN`, `*_PASSWORD`, and connection strings before any log emit.
|
|
155
|
+
|
|
156
|
+
### Build-time vs runtime
|
|
157
|
+
|
|
158
|
+
Do not bake secrets into container images, build artifacts, or CI caches. Inject at runtime via the patterns above. A secret in a Docker layer is permanently exposed even after you "remove" it — image layers are append-only.
|
|
159
|
+
|
|
160
|
+
## After this file
|
|
161
|
+
|
|
162
|
+
Return to the area procedure that sent you here (`pii-handling`, `supply-chain`, or `rate-limiting`). The procedure's secret-handling checkpoint is satisfied once your application reads secrets from environment variables (or a managed source above) and your repository contains no hard-coded credentials.
|
|
163
|
+
|
|
164
|
+
## Related infrastructure
|
|
165
|
+
|
|
166
|
+
- `aigis infra logging` — redaction patterns to keep secrets out of log output.
|
|
167
|
+
- `aigis infra rate-limiting` — where the Redis connection string this file scopes for you actually gets used.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workflow-fastapi-llm
|
|
3
|
+
description: Canonical 8-file layout for a FastAPI service that calls an LLM API. Run after `aigis classify` returned a Python/FastAPI system. Maps each governance area to a specific module so wiring is consistent across runs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow: FastAPI + LLM
|
|
7
|
+
|
|
8
|
+
This workflow is for: a FastAPI HTTP service that calls a hosted LLM (Anthropic, OpenAI) on user input. If your project is something else (Express, Next.js, agentic loop, RAG service), this workflow does not apply — see `aigis workflow --list` for available workflows.
|
|
9
|
+
|
|
10
|
+
## Canonical file layout
|
|
11
|
+
|
|
12
|
+
Build into exactly these 8 files.
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
app/
|
|
16
|
+
├── main.py # FastAPI routes + minimal orchestration only
|
|
17
|
+
├── input_validation.py # length limits, sanitize, 3-category injection detection
|
|
18
|
+
├── pii.py # PII_PATTERNS + redact_pii (5 required classes)
|
|
19
|
+
├── rate_limit.py # Redis-backed limiter + token budget + Retry-After
|
|
20
|
+
├── fallback.py # 3-state circuit breaker + per-request kill switch + safe response
|
|
21
|
+
├── audit.py # trace IDs, structured logs, decision records, fairness fields
|
|
22
|
+
├── monitoring.py # metrics, drift, incident logging, user feedback endpoint
|
|
23
|
+
└── response.py # response shaping: confidence metadata, explanation, output sanitization
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Plus at the project root: `requirements.txt` with pinned `==` versions, `tests/` with at least one smoke test, `docker-compose.yml` (Redis dependency for `rate_limit.py`).
|
|
27
|
+
|
|
28
|
+
## Area-to-file mapping
|
|
29
|
+
|
|
30
|
+
| Aigis area (run `aigis get <id>` for the procedure) | Lives in |
|
|
31
|
+
|---|---|
|
|
32
|
+
| input-validation | `app/input_validation.py` |
|
|
33
|
+
| pii-handling | `app/pii.py` |
|
|
34
|
+
| rate-limiting | `app/rate_limit.py` |
|
|
35
|
+
| fallback-patterns | `app/fallback.py` |
|
|
36
|
+
| audit-logging | `app/audit.py` |
|
|
37
|
+
| bias-monitoring | `app/audit.py` (fairness fields are part of structured logs) |
|
|
38
|
+
| monitoring | `app/monitoring.py` |
|
|
39
|
+
| confidence-scoring | `app/response.py` |
|
|
40
|
+
| explainability | `app/response.py` |
|
|
41
|
+
| output-sanitization | `app/response.py` |
|
|
42
|
+
| human-oversight | `app/main.py` (decision gate + override surface + action allowlist) |
|
|
43
|
+
| prompt-security | `app/main.py` (`SYSTEM_PROMPT` constant + leakage detection) |
|
|
44
|
+
| supply-chain | `requirements.txt` (pinned versions) + `app/main.py` (`MODEL_VERSION` constant) |
|
|
45
|
+
|
|
46
|
+
If `main.py`'s responsibilities grow past routes + minimal orchestration, pull human-oversight into `app/human_oversight.py` and/or prompt-security into `app/prompt_security.py`. Don't invent other splits — variance hurts maintainability.
|
|
47
|
+
|
|
48
|
+
## Wiring contracts (cross-file invariants)
|
|
49
|
+
|
|
50
|
+
These are the wiring rules the area-skill verification checkpoints check for. Get them right at build time.
|
|
51
|
+
|
|
52
|
+
1. **`redact_pii` from `pii.py` is called in two places:**
|
|
53
|
+
- `main.py`, on user input, before passing to the LLM client
|
|
54
|
+
- `audit.py`, on input/output before structured-log emission
|
|
55
|
+
2. **`call_llm_safely` from `fallback.py` wraps every LLM client call.** Every `client.messages.create` / `client.chat.completions.create` site routes through it. There must be exactly one LLM call site in `main.py` (or in a dedicated `app/llm.py` if you split for clarity); other modules invoke it through the safe wrapper.
|
|
56
|
+
3. **`ai_system_enabled()` from `fallback.py` is called inside the request handler in `main.py`, on every request.** Not at module load. Not via `@lru_cache`. Not stored on a `settings = Settings()` module-level singleton.
|
|
57
|
+
4. **The injection guard from `input_validation.py` blocks before the LLM call.** Raises `HTTPException(400)` on detection; the LLM call must come AFTER the guard, never before, never in parallel.
|
|
58
|
+
5. **`enforce_rate_limit` and `enforce_token_budget` from `rate_limit.py` run in the handler before any sanitize/LLM work.** Cheaper to reject than to sanitize-then-reject.
|
|
59
|
+
6. **`set_trace_id` middleware from `audit.py` runs on every request.** All log emissions and the `X-Trace-Id` response header use the contextvar.
|
|
60
|
+
7. **`response.py` shapes the outgoing payload from a parsed model result.** It receives the validated assessment dict and returns the JSON body the client gets — confidence metadata, explanation, sanitized fields, framing. `main.py` calls it at the end of the request handler; `response.py` does not call the LLM and does not log.
|
|
61
|
+
|
|
62
|
+
## Order of implementation
|
|
63
|
+
|
|
64
|
+
Recommended order (each step ships independently, tests pass at every step):
|
|
65
|
+
|
|
66
|
+
1. `app/main.py` skeleton with `POST /api/assess-claim` (or your route), `GET /healthz`, no LLM call yet.
|
|
67
|
+
2. `app/input_validation.py` — `aigis get input-validation` and follow the procedure.
|
|
68
|
+
3. `app/pii.py` — `aigis get pii-handling` and follow the procedure.
|
|
69
|
+
4. `app/fallback.py` — `aigis get fallback-patterns` and follow the procedure.
|
|
70
|
+
5. `app/rate_limit.py` — `aigis get rate-limiting` and follow the procedure.
|
|
71
|
+
6. Wire the LLM call in `main.py`, routing through `call_llm_safely`.
|
|
72
|
+
7. `app/audit.py` — `aigis get audit-logging` and `aigis get bias-monitoring`.
|
|
73
|
+
8. `app/monitoring.py` — `aigis get monitoring`.
|
|
74
|
+
9. `app/response.py` — `aigis get confidence-scoring`, `aigis get explainability`, `aigis get output-sanitization`. Wire it into `main.py` as the last step before returning.
|
|
75
|
+
10. Human-oversight + prompt-security work in `main.py` — `aigis get human-oversight`, `aigis get prompt-security`.
|
|
76
|
+
11. `requirements.txt` and `tests/` — `aigis get supply-chain`.
|
|
77
|
+
|
|
78
|
+
## Verification per file
|
|
79
|
+
|
|
80
|
+
After building each file, run `aigis verify <area> --auto .`. The scanner returns PASS/FAIL/OVERCLAIM/JUDGMENT for that area's deterministic checks. Fix any FAIL or OVERCLAIM before moving to the next file.
|
|
81
|
+
|
|
82
|
+
## If your existing codebase uses a different layout
|
|
83
|
+
|
|
84
|
+
Map each responsibility above to your existing modules. The wiring contracts (the numbered list) stay the same — the file names don't. For example, if your codebase already has `services/text_processing.py` for text cleanup, the input-validation procedure can live there; the contract that "an injection guard runs before the LLM call" is what matters, not which file holds it.
|
|
85
|
+
|
|
86
|
+
If the mapping is non-trivial, document it in `docs/aigis-mapping.md` so future contributors and `aigis verify --auto` reviewers can find your modules.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Resolvers
|
|
2
|
+
|
|
3
|
+
Aigis's resolver translates natural-language project descriptions into the trait set classify uses to recommend governance areas. The same source — `content/resolvers/triggers.json` — is consumed by both the CLI (when you run `aigis classify "<description>"`) and embedded in the IDE rules file by `aigis init` (so coding agents apply the same rules in-IDE).
|
|
4
|
+
|
|
5
|
+
## The two tiers
|
|
6
|
+
|
|
7
|
+
**High-confidence:** the phrase implies the listed traits in essentially every realistic project where it appears. There is no plausible counterexample. Auto-applied — no user prompt.
|
|
8
|
+
|
|
9
|
+
**Low-confidence:** the phrase implies the listed traits only some of the time. There is a realistic project where the phrase appears WITHOUT the trait applying. Requires a confirmation prompt (`yes / no / unsure`); applied only on `yes`.
|
|
10
|
+
|
|
11
|
+
## Decision rule for new entries
|
|
12
|
+
|
|
13
|
+
If you can describe a real project where the phrase appears but the trait does not apply, the entry is low-confidence. When in doubt, low-confidence — false-positive auto-application is worse than an extra confirmation prompt.
|
|
14
|
+
|
|
15
|
+
## How the resolver is consumed
|
|
16
|
+
|
|
17
|
+
**CLI flow:**
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
aigis classify "<plain English description>"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The CLI reads `triggers.json`, scans the description for phrases, and emits:
|
|
24
|
+
|
|
25
|
+
- `high_confidence_matches` — phrases that fired with their traits (auto-applied)
|
|
26
|
+
- `low_confidence_suggestions` — phrases that need confirmation
|
|
27
|
+
- `final_traits` — the resolved trait set after confirmations
|
|
28
|
+
|
|
29
|
+
In a TTY, the CLI prompts interactively for each low-confidence suggestion. With `--json`, with `--confirm <ids>`, with `--reject <ids>`, or in a non-TTY environment (CI, piped), no prompt is shown and low-confidence defaults to rejected unless explicitly confirmed.
|
|
30
|
+
|
|
31
|
+
**Agent flow:**
|
|
32
|
+
|
|
33
|
+
`aigis init <ide>` embeds a checksum-guarded markdown table into the IDE rules file (.cursorrules / SKILL.md / etc.). The agent reads the table inline alongside the user's chat message and applies the same matching rules — auto-apply for high-confidence, ask the user for low-confidence.
|
|
34
|
+
|
|
35
|
+
Both consumers see the exact same table because both load from `triggers.json`. The block in the rules file carries a SHA-256 of the canonical JSON content; running `aigis init` again confirms the block is up to date or surfaces a mismatch.
|
|
36
|
+
|
|
37
|
+
## Schema
|
|
38
|
+
|
|
39
|
+
```jsonc
|
|
40
|
+
{
|
|
41
|
+
"version": "1.0",
|
|
42
|
+
"tier_rule": "<the tier rule, inline>",
|
|
43
|
+
"high_confidence": {
|
|
44
|
+
"<phrase>": {
|
|
45
|
+
"traits": ["<trait>", ...],
|
|
46
|
+
"confidence": "high",
|
|
47
|
+
"notes": "<one-line maintainer note>",
|
|
48
|
+
"context_filter": ["web", "agentic"] // OPTIONAL
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"low_confidence": {
|
|
52
|
+
"<phrase>": {
|
|
53
|
+
"traits": ["<trait>", ...],
|
|
54
|
+
"confidence": "low",
|
|
55
|
+
"confirmation_prompt": "<question ending in '(yes / no / unsure)'>",
|
|
56
|
+
"notes": "<one-line maintainer note>",
|
|
57
|
+
"context_filter": ["web"] // OPTIONAL
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Required fields are enforced by `scripts/validate-triggers.js` (run automatically on PRs touching this file via `.github/workflows/triggers-validation.yml`).
|
|
64
|
+
|
|
65
|
+
- `version`: `N.N` string. Bumped on schema changes, not on entry additions.
|
|
66
|
+
- `tier_rule`: prose, inline at the top so the JSON is self-documenting.
|
|
67
|
+
- `confidence`: redundant with the tier grouping but kept inline so future reorganizations don't restructure entries.
|
|
68
|
+
- `context_filter`: reserved for `aigis get --context` integration; safe to omit.
|
|
69
|
+
- Phrase keys must be sorted case-insensitively within each tier.
|
|
70
|
+
|
|
71
|
+
## Matching semantics
|
|
72
|
+
|
|
73
|
+
- Case-insensitive substring match against the input description.
|
|
74
|
+
- Multi-word phrases match contiguously.
|
|
75
|
+
- A phrase that appears only inside a longer word does match (e.g., "RAG" matches "RAGgedy"; this is acceptable for the v1.0 ruleset). Submit a high-precision boundary-aware mapping if it bites in practice.
|
|
76
|
+
|
|
77
|
+
## How to add a mapping
|
|
78
|
+
|
|
79
|
+
1. Open `content/resolvers/triggers.json`.
|
|
80
|
+
2. Decide tier per the decision rule above.
|
|
81
|
+
3. Insert the entry alphabetically within the appropriate tier.
|
|
82
|
+
4. For low-confidence: write a `confirmation_prompt` that ends with `(yes / no / unsure)` and is answerable in one sentence.
|
|
83
|
+
5. Run `node scripts/validate-triggers.js` locally before submitting.
|
|
84
|
+
6. Open a PR using `.github/PULL_REQUEST_TEMPLATE/trigger_mapping.md`.
|
|
85
|
+
|
|
86
|
+
## The use-case requirement
|
|
87
|
+
|
|
88
|
+
Every trigger PR must include a one-sentence use case: *"I'm building X and I needed this trigger because Y."* This is non-negotiable. We curate based on actual demand, not theoretical taxonomy completeness. PRs without a real use case are closed.
|
|
89
|
+
|
|
90
|
+
## Curation policy
|
|
91
|
+
|
|
92
|
+
- We accept high-confidence entries only when no plausible counterexample exists.
|
|
93
|
+
- We accept low-confidence entries when the confirmation prompt is answerable yes/no in one sentence.
|
|
94
|
+
- We reject phrases that are too generic to be useful (`AI`, `data`, `users`) — they would fire on every project.
|
|
95
|
+
- We prefer English phrasings with broad reach over jargon.
|
|
96
|
+
- When the same phrase has both a strict and a loose interpretation, low-confidence wins.
|
|
97
|
+
|
|
98
|
+
## Resolver block in the IDE rules file
|
|
99
|
+
|
|
100
|
+
After `aigis init <ide>`, the rules file (`.cursorrules`, `SKILL.md`, etc.) contains a delimited block:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
# --- AIGIS RESOLVER BLOCK START (checksum: <sha256-hex>) ---
|
|
104
|
+
... rendered table ...
|
|
105
|
+
# --- AIGIS RESOLVER BLOCK END ---
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The agent reads this block alongside the user's natural-language description and applies high-confidence matches directly, asking the user for low-confidence matches. The checksum lets `aigis init` detect when the block is stale (after Aigis updates) or has been hand-edited; on mismatch, init refuses unless `--refresh` is passed.
|
|
109
|
+
|
|
110
|
+
The block is regenerated deterministically from `triggers.json`. The rendering algorithm (column widths, ordering) is in `lib/init.js`'s `renderResolverBlock()` function. Two consecutive runs with the same `triggers.json` content produce byte-identical blocks.
|
|
111
|
+
|
|
112
|
+
## The fixed checksum determinism test
|
|
113
|
+
|
|
114
|
+
`test/checksum-determinism.test.js` pins the SHA-256 of the shipped `triggers.json` as a literal. Any change to the JSON content (even a trailing space) will break the test until the new checksum is committed alongside the JSON change. This catches platform-specific serialization bugs (line endings, BOM) that would otherwise produce silent drift between local and CI builds.
|