Skip to content

Commit c4e1ff7

Browse files
authored
fix(schema): refresh llm-compacted context (#1894)
* fix(schema): refresh llm-compacted context * fix(deps): patch audited transitive dependencies * docs: include insights in project schema summary
1 parent 478e801 commit c4e1ff7

11 files changed

Lines changed: 494 additions & 525 deletions

File tree

src/assets/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ For Container builds, `BaseRenderer.render()` automatically copies the `containe
5757

5858
- These assets are rendered by the CLI's template renderer in `src/cli/templates/`
5959
- The `README.md` and `agents/AGENTS.md` are copied verbatim (no template rendering) during project creation
60-
- The `.llm-context/` files are sourced from `src/schema/llm-compacted/` and written during init
60+
- The `.llm-context/` files are sourced from `src/schema/llm-compacted/` and written during project creation

src/assets/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ my-project/
1313
│ ├── .env.local # Secrets — API keys (gitignored)
1414
│ ├── .llm-context/ # TypeScript type definitions for AI assistants
1515
│ │ ├── agentcore.ts # AgentCoreProjectSpec types
16-
│ │ ├── aws-targets.ts # Deployment target types
17-
│ │ └── mcp.ts # Gateway and MCP tool types
16+
│ │ └── aws-targets.ts # Deployment target types
1817
│ └── cdk/ # CDK infrastructure (@aws/agentcore-cdk)
1918
├── app/ # Agent application code
2019
└── evaluators/ # Custom evaluator code (if any)

src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7336,7 +7336,7 @@ For Container builds, \`BaseRenderer.render()\` automatically copies the \`conta
73367336
73377337
- These assets are rendered by the CLI's template renderer in \`src/cli/templates/\`
73387338
- The \`README.md\` and \`agents/AGENTS.md\` are copied verbatim (no template rendering) during project creation
7339-
- The \`.llm-context/\` files are sourced from \`src/schema/llm-compacted/\` and written during init
7339+
- The \`.llm-context/\` files are sourced from \`src/schema/llm-compacted/\` and written during project creation
73407340
"
73417341
`;
73427342
@@ -7356,8 +7356,7 @@ my-project/
73567356
│ ├── .env.local # Secrets — API keys (gitignored)
73577357
│ ├── .llm-context/ # TypeScript type definitions for AI assistants
73587358
│ │ ├── agentcore.ts # AgentCoreProjectSpec types
7359-
│ │ ├── aws-targets.ts # Deployment target types
7360-
│ │ └── mcp.ts # Gateway and MCP tool types
7359+
│ │ └── aws-targets.ts # Deployment target types
73617360
│ └── cdk/ # CDK infrastructure (@aws/agentcore-cdk)
73627361
├── app/ # Agent application code
73637362
└── evaluators/ # Custom evaluator code (if any)
@@ -7494,8 +7493,7 @@ myProject/
74947493
│ ├── .llm-context/ # TypeScript type definitions for AI assistants
74957494
│ │ ├── README.md # Guide to using schema files
74967495
│ │ ├── agentcore.ts # AgentCoreProjectSpec types
7497-
│ │ ├── aws-targets.ts # AWS deployment target types
7498-
│ │ └── mcp.ts # Gateway and MCP tool types
7496+
│ │ └── aws-targets.ts # AWS deployment target types
74997497
│ └── cdk/ # AWS CDK project (@aws/agentcore-cdk L3 constructs)
75007498
├── app/ # Agent application code
75017499
└── evaluators/ # Custom evaluator code (if any)
@@ -7509,12 +7507,11 @@ file maps to a JSON config file and includes validation constraints as comments
75097507
| JSON Config | Schema File | Root Type |
75107508
| --- | --- | --- |
75117509
| \`agentcore/agentcore.json\` | \`agentcore/.llm-context/agentcore.ts\` | \`AgentCoreProjectSpec\` |
7512-
| \`agentcore/agentcore.json\` (gateways) | \`agentcore/.llm-context/mcp.ts\` | \`AgentCoreMcpSpec\` |
75137510
| \`agentcore/aws-targets.json\` | \`agentcore/.llm-context/aws-targets.ts\` | \`AwsDeploymentTarget[]\` |
75147511
75157512
### Key Types
75167513
7517-
- **AgentCoreProjectSpec**: Root config with \`runtimes\`, \`memories\`, \`credentials\`, \`agentCoreGateways\`, \`evaluators\`, \`onlineEvalConfigs\`, \`onlineInsightsConfigs\`, \`knowledgeBases\`, \`harnesses\`, \`policyEngines\`, \`policies\`, \`payments\` (managers + connectors), \`configBundles\`, \`datasets\`, \`runtimeEndpoints\` arrays
7514+
- **AgentCoreProjectSpec**: Root config with runtimes, memories, knowledge bases, credentials, evaluators, online evals and insights, gateways, policy engines, config bundles, A/B tests, harness registrations, datasets, and payment managers
75187515
- **AgentEnvSpec**: Agent configuration (build type, entrypoint, code location, runtime version, network mode)
75197516
- **Memory**: Memory resource with strategies (SEMANTIC, SUMMARIZATION, USER_PREFERENCE, EPISODIC) and expiry
75207517
- **Credential**: API key or OAuth credential provider

src/assets/agents/AGENTS.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ myProject/
3838
│ ├── .llm-context/ # TypeScript type definitions for AI assistants
3939
│ │ ├── README.md # Guide to using schema files
4040
│ │ ├── agentcore.ts # AgentCoreProjectSpec types
41-
│ │ ├── aws-targets.ts # AWS deployment target types
42-
│ │ └── mcp.ts # Gateway and MCP tool types
41+
│ │ └── aws-targets.ts # AWS deployment target types
4342
│ └── cdk/ # AWS CDK project (@aws/agentcore-cdk L3 constructs)
4443
├── app/ # Agent application code
4544
└── evaluators/ # Custom evaluator code (if any)
@@ -53,12 +52,11 @@ file maps to a JSON config file and includes validation constraints as comments
5352
| JSON Config | Schema File | Root Type |
5453
| --- | --- | --- |
5554
| `agentcore/agentcore.json` | `agentcore/.llm-context/agentcore.ts` | `AgentCoreProjectSpec` |
56-
| `agentcore/agentcore.json` (gateways) | `agentcore/.llm-context/mcp.ts` | `AgentCoreMcpSpec` |
5755
| `agentcore/aws-targets.json` | `agentcore/.llm-context/aws-targets.ts` | `AwsDeploymentTarget[]` |
5856

5957
### Key Types
6058

61-
- **AgentCoreProjectSpec**: Root config with `runtimes`, `memories`, `credentials`, `agentCoreGateways`, `evaluators`, `onlineEvalConfigs`, `onlineInsightsConfigs`, `knowledgeBases`, `harnesses`, `policyEngines`, `policies`, `payments` (managers + connectors), `configBundles`, `datasets`, `runtimeEndpoints` arrays
59+
- **AgentCoreProjectSpec**: Root config with runtimes, memories, knowledge bases, credentials, evaluators, online evals and insights, gateways, policy engines, config bundles, A/B tests, harness registrations, datasets, and payment managers
6260
- **AgentEnvSpec**: Agent configuration (build type, entrypoint, code location, runtime version, network mode)
6361
- **Memory**: Memory resource with strategies (SEMANTIC, SUMMARIZATION, USER_PREFERENCE, EPISODIC) and expiry
6462
- **Credential**: API key or OAuth credential provider
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { AgentCoreProjectSpecSchema, AgentCoreRegionSchema } from '../../../schema';
2+
import { LLM_CONTEXT_FILES } from '../schema-assets';
3+
import { describe, expect, it } from 'vitest';
4+
import { z } from 'zod';
5+
6+
function projectSpecFields(source: string): string[] {
7+
const match = /interface AgentCoreProjectSpec \{([\s\S]*?)\n\}/.exec(source);
8+
if (!match?.[1]) {
9+
throw new Error('Missing AgentCoreProjectSpec interface');
10+
}
11+
12+
return [...match[1].matchAll(/^ {2}([$A-Za-z_][$\w]*)\??:/gm)].map(field => field[1]!);
13+
}
14+
15+
describe('LLM_CONTEXT_FILES', () => {
16+
it('vends only the current project context files', () => {
17+
expect(Object.keys(LLM_CONTEXT_FILES).sort()).toEqual(['README.md', 'agentcore.ts', 'aws-targets.ts']);
18+
expect(LLM_CONTEXT_FILES['README.md']).not.toContain('mcp.ts');
19+
});
20+
21+
it('documents every supported agentcore.json top-level field', () => {
22+
const jsonSchema = z.toJSONSchema(AgentCoreProjectSpecSchema, { target: 'draft-07' });
23+
const schemaFields = Object.keys(jsonSchema.properties ?? {}).filter(field => field !== 'httpGateways');
24+
25+
expect(projectSpecFields(LLM_CONTEXT_FILES['agentcore.ts']!)).toEqual(schemaFields);
26+
});
27+
28+
it('documents every supported AgentCore region', () => {
29+
const regionSource = LLM_CONTEXT_FILES['aws-targets.ts']!;
30+
const regionType = /type AgentCoreRegion =([\s\S]*?);/.exec(regionSource)?.[1];
31+
const documentedRegions = [...(regionType ?? '').matchAll(/'([^']+)'/g)].map(match => match[1]);
32+
33+
expect(documentedRegions).toEqual(AgentCoreRegionSchema.options);
34+
});
35+
});

src/cli/templates/schema-assets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
22
* LLM-compacted schema files embedded at build time.
3-
* Written to agentcore/.llm-context/ during init to provide
3+
* Written to agentcore/.llm-context/ during project creation to provide
44
* AI coding assistants with compact, readable type definitions.
55
*
66
* When running from built bundle: text-loader plugin embeds contents.
7-
* When running from source (bun): files are read at runtime.
7+
* When running from source without the text loader: files are read at runtime.
88
*/
99
// @ts-expect-error - text import handled by build plugin
1010
import llmContextReadmeSrc from '../../schema/llm-compacted/README.md';

src/schema/llm-compacted/AGENTS.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ This directory contains **manually maintained** TypeScript type definitions opti
44

55
## How It Works
66

7-
1. The CLI embeds these `.ts` files as text at build time (via Bun's text import)
8-
2. During `init`, they're written to the user's `agentcore/.llm-context/` directory
7+
1. The CLI embeds these `.ts` files as text through the esbuild text-loader plugin
8+
2. During `create`, they're written to the user's `agentcore/.llm-context/` directory
99
3. AI coding assistants read these files when editing AgentCore JSON configs
1010

1111
## Keeping In Sync With Zod Schemas
1212

1313
When Zod schemas in `schemas/` are updated, manually update the corresponding file here:
1414

15-
| Compacted File | Zod Source Files |
16-
| ---------------- | ---------------------------------------------- |
17-
| `agentcore.ts` | `schemas/agentcore-project.ts` |
18-
| `agent-env.ts` | `schemas/agent-env.ts`, `schemas/primitives/*` |
19-
| `mcp.ts` | `schemas/mcp.ts`, `schemas/mcp-defs.ts` |
20-
| `aws-targets.ts` | `schemas/aws-targets.ts` |
15+
| Compacted File | Zod Source Files |
16+
| ---------------- | ---------------------------------------------------------------------------------------------------- |
17+
| `agentcore.ts` | `schemas/agentcore-project.ts`, `schemas/agent-env.ts`, `schemas/mcp.ts`, and `schemas/primitives/*` |
18+
| `aws-targets.ts` | `schemas/aws-targets.ts` |
2119

2220
## Critical: Enum and Regex Accuracy
2321

src/schema/llm-compacted/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
## Files
66

7-
| File | JSON Config | Purpose |
8-
| ---------------- | ------------------ | ----------------------------------------- |
9-
| `agentcore.ts` | `agentcore.json` | Project, agent, memory, credential config |
10-
| `mcp.ts` | `agentcore.json` | Gateways, targets, MCP runtime tools |
11-
| `aws-targets.ts` | `aws-targets.json` | Deployment targets (account + region) |
7+
| File | JSON Config | Purpose |
8+
| ---------------- | ------------------ | ------------------------------------- |
9+
| `agentcore.ts` | `agentcore.json` | Project resources, including gateways |
10+
| `aws-targets.ts` | `aws-targets.json` | Deployment targets (account + region) |
1211

1312
## Usage
1413

15-
When editing schema JSON files, reference the corresponding `.ts` file here for type definitions and validation
16-
constraints (marked with `@regex`, `@min`, `@max`).
14+
When editing AgentCore JSON config files, reference the corresponding `.ts` file here for type definitions, exact enum
15+
values, defaults, and validation constraints (marked with `@regex`, `@min`, and `@max`). Run `agentcore validate` after
16+
making changes.

0 commit comments

Comments
 (0)