Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/chant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
npm run --prefix lexicons/docker prepack
npm run --prefix lexicons/temporal prepack
npm run --prefix lexicons/fly prepack
npm run --prefix lexicons/fountain prepack

- name: Typecheck
run: npx tsc --noEmit -p packages/core/tsconfig.json
Expand Down Expand Up @@ -136,6 +137,7 @@ jobs:
npm run --prefix lexicons/docker prepack
npm run --prefix lexicons/temporal prepack
npm run --prefix lexicons/fly prepack
npm run --prefix lexicons/fountain prepack

# Includes examples/fold-differential.test.ts (#1025, epic #1019) — the
# fold-vs-run zero-drift gate over examples/* + every lexicon's own
Expand Down Expand Up @@ -197,6 +199,12 @@ jobs:
- name: Generate and validate Temporal lexicon
run: npm run --prefix lexicons/temporal prepack

- name: Generate and validate Fly lexicon
run: npm run --prefix lexicons/fly prepack

- name: Generate and validate Fountain lexicon
run: npm run --prefix lexicons/fountain prepack

smoke-npm:
if: false # disabled — Docker smoke tests are for local/release validation, not every push
runs-on: ubuntu-latest
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# `npm publish` re-runs the package's prepack (build + validate) anyway.
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
# 10 lexicon prepacks (build + validate) plus the full vitest suite — the
# 12 lexicon prepacks (build + validate) plus the full vitest suite — the
# suite alone runs ~5m, so a 5m cap gets killed mid-run and skips publish.
timeout-minutes: 20
steps:
Expand Down Expand Up @@ -50,6 +50,7 @@ jobs:
- run: npm run --prefix lexicons/docker prepack
- run: npm run --prefix lexicons/temporal prepack
- run: npm run --prefix lexicons/fly prepack
- run: npm run --prefix lexicons/fountain prepack
- run: npx vitest run

publish:
Expand Down Expand Up @@ -191,3 +192,11 @@ jobs:
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-fly version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-fountain
if: ${{ !cancelled() }}
working-directory: lexicons/fountain
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-fountain version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default defineConfig({
{ label: 'Azure ARM', link: '/lexicons/azure/' },
{ label: 'GCP Config Connector', link: '/lexicons/gcp/' },
{ label: 'Fly Machines', link: '/lexicons/fly/' },
{ label: 'Fountain', link: '/lexicons/fountain/' },
{
label: 'Kubernetes',
items: [
Expand Down
4 changes: 4 additions & 0 deletions docs/src/content/docs/lexicons/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ A **lexicon** is a collection of types and semantic lint rules for an operationa
| Forgejo Actions (Codeberg / Gitea) | `@intentius/chant-lexicon-forgejo` | thin github dialect (reuses github entities) | [Reference](/chant/lexicons/forgejo/) — ships GitHub Actions migration + `forgejo:compare` |
| Docker | `@intentius/chant-lexicon-docker` | 6 resources (Compose + Dockerfile) | [Reference](/chant/lexicons/docker/) |
| Temporal | `@intentius/chant-lexicon-temporal` | 4 resources + Op workflow engine | [Reference](/chant/lexicons/temporal/) |
| Fly Machines | `@intentius/chant-lexicon-fly` | 6 resources (Machines API) | [Reference](/chant/lexicons/fly/) — ships the mudflaps emulator for offline round-trips |
| Fountain | `@intentius/chant-lexicon-fountain` | 3 resources (Environment, Vault, Agent) | [Reference](/chant/lexicons/fountain/) — sandboxed agent workloads; conversations are ops, not resources |

## Runtime observation coverage

Expand All @@ -33,6 +35,8 @@ A third, optional method goes one level deeper. `observeResourcesDeep()` reads t
| GCP (Config Connector) | ✅ | | | Labels | `kubectl get <gvk>` against the GKE management cluster; cluster resolved from `k8s.profiles.<env>.context` when bound (chant #1100), else ambient — visibly |
| Kubernetes | ✅ | | | Labels | Typed API client ([`@intentius/chant-k8s-client`](/chant/lexicons/k8s/api-client/)) — concurrent reads, any kind the cluster's discovery reports including CRDs, typed errors; cluster resolved from `k8s.profiles.<env>.context` when bound (chant #1100) — a mismatched ambient context refuses loudly rather than reading the wrong cluster |
| Temporal | ✅ | | | — | Temporal client — namespaces, search attributes, schedules |
| Fly Machines | ✅ | | | Metadata | Machines API (flaps) reads, or the mudflaps emulator offline. Two-tier ownership: machines carry `managed-by: chant` in `config.metadata`; volumes, IPs and certificates have no per-resource marker, so ownership is inferred at the app boundary and says so |
| Fountain | ✅ | | | Metadata | REST reads against the fountain API, one list per declared kind; `--owned` reads the `managed-by: chant` metadata marker, which all three kinds carry |
| Helm | | | ✅ | — | `helm list -A -o json` — releases as artifacts |
| Docker | | | ✅ | — | `docker ps`, `docker image ls`, `docker network ls` (NDJSON) |
| GitHub Actions | | | | — | N/A — workflow definitions are git-tracked; drift is `git diff` ([rationale](https://github.com/INTENTIUS/chant/blob/main/lexicons/github/README.md#runtime-observation-na)) |
Expand Down
52 changes: 29 additions & 23 deletions lexicons/docker/src/lsp/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,39 @@ import { describe, test, expect } from "vitest";
import { dockerCompletions } from "./completions";
import type { CompletionContext } from "@intentius/chant/lsp/types";

// The context these tests build must match the real CompletionContext.
// They previously used an older shape (word / isConstructorContext / prefix /
// fileContent) the interface no longer has — vitest strips types without
// checking them, so every assertion passed while exercising no completion
// path at all.
function ctx(partial: Partial<CompletionContext>): CompletionContext {
return {
uri: "file:///infra.ts",
content: "",
position: { line: 0, character: 0 },
wordAtCursor: "",
linePrefix: "",
...partial,
};
}

describe("dockerCompletions", () => {
test("is a function", () => {
expect(typeof dockerCompletions).toBe("function");
test("suggests resource class names after `new `", () => {
const items = dockerCompletions(ctx({ linePrefix: "const s = new " }));

expect(items.length).toBeGreaterThan(0);
expect(items.map((i) => i.label)).toContain("Service");
expect(items.every((i) => i.kind === "resource")).toBe(true);
});

test("returns array for non-constructor context", () => {
const ctx: CompletionContext = {
word: "Ser",
isConstructorContext: false,
prefix: "",
fileContent: "",
position: { line: 0, character: 3 },
};
// May return [] if generated index not present, but should not throw
const result = dockerCompletions(ctx);
expect(Array.isArray(result)).toBe(true);
test("narrows on a typed prefix", () => {
const items = dockerCompletions(ctx({ linePrefix: "new Serv", wordAtCursor: "Serv" }));

expect(items.map((i) => i.label)).toContain("Service");
expect(items.every((i) => i.label.toLowerCase().startsWith("serv"))).toBe(true);
});

test("returns array for constructor context", () => {
const ctx: CompletionContext = {
word: "Service",
isConstructorContext: true,
prefix: "new ",
fileContent: "import { Service } from '@intentius/chant-lexicon-docker';",
position: { line: 0, character: 10 },
};
const result = dockerCompletions(ctx);
expect(Array.isArray(result)).toBe(true);
test("returns nothing in an unrelated position", () => {
expect(dockerCompletions(ctx({ linePrefix: "const x = 1" }))).toEqual([]);
});
});
47 changes: 24 additions & 23 deletions lexicons/docker/src/lsp/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@ import { describe, test, expect } from "vitest";
import { dockerHover } from "./hover";
import type { HoverContext } from "@intentius/chant/lsp/types";

// Same correction as completions.test.ts: the old shape (word / fileContent /
// position) no longer matches HoverContext, and the assertions were written to
// pass either way ("undefined or an object", "if result !== undefined"), so a
// hover that returned nothing at all still looked healthy.
function ctx(word: string): HoverContext {
return {
uri: "file:///infra.ts",
content: "",
position: { line: 0, character: 0 },
word,
lineText: "",
};
}

describe("dockerHover", () => {
test("is a function", () => {
expect(typeof dockerHover).toBe("function");
test("returns undefined for an unknown word", () => {
expect(dockerHover(ctx("NotADockerThing"))).toBeUndefined();
expect(dockerHover(ctx(""))).toBeUndefined();
});

test("returns undefined for unknown word", () => {
const ctx: HoverContext = {
word: "NotADockerThing",
fileContent: "",
position: { line: 0, character: 0 },
};
// Should not throw; returns undefined if not found
const result = dockerHover(ctx);
expect(result === undefined || typeof result === "object").toBe(true);
test("describes a known resource with its docker type", () => {
const info = dockerHover(ctx("Service"));

expect(info?.contents).toContain("**Service**");
expect(info?.contents).toContain("Docker::Compose::Service");
});

test("returns HoverInfo with content for known resource", () => {
const ctx: HoverContext = {
word: "Service",
fileContent: "import { Service } from '@intentius/chant-lexicon-docker';",
position: { line: 0, character: 10 },
};
const result = dockerHover(ctx);
// If generated index exists, will return content; otherwise undefined
if (result !== undefined) {
expect(result.contents).toBeTruthy();
expect(typeof result.contents).toBe("string");
}
test("notes which artifact a resource serializes into", () => {
expect(dockerHover(ctx("Service"))?.contents).toContain("docker-compose.yml");
});
});
4 changes: 2 additions & 2 deletions lexicons/fly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@intentius/chant": "^0.33.0",
"typescript": "^5.9.3"
},
"description": "Google Cloud lexicon for chant — declarative IaC in TypeScript",
"description": "Fly.io Machines lexicon for chant — declarative IaC in TypeScript",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand All @@ -75,7 +75,7 @@
"infrastructure-as-code",
"iac",
"typescript",
"google-cloud",
"fly-io",
"chant"
]
}
19 changes: 12 additions & 7 deletions lexicons/fly/src/codegen/package.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { packagePipeline } from "@intentius/chant/codegen/package";
import type { PackagePipelineConfig } from "@intentius/chant/codegen/package";
import { packagePipeline, collectSkills } from "@intentius/chant/codegen/package";
import { generate } from "./generate";
import { flyPlugin } from "../plugin";
import { readFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
Expand All @@ -9,25 +9,30 @@ import { fileURLToPath } from "url";
* Package the fly lexicon for distribution.
*/
export async function packageLexicon(options?: { verbose?: boolean; force?: boolean }) {
const srcDir = dirname(fileURLToPath(import.meta.url));
const pkgJson = JSON.parse(readFileSync(join(srcDir, "..", "..", "package.json"), "utf-8"));
// This file is src/codegen/package.ts — rules and skills are collected
// relative to src/, so srcDir must be the parent of this directory.
// Pointing it at src/codegen made collectRules glob a directory that does
// not exist, and the bundle shipped zero rules alongside zero skills.
const srcDir = dirname(dirname(fileURLToPath(import.meta.url)));
const pkgJson = JSON.parse(readFileSync(join(srcDir, "..", "package.json"), "utf-8"));

const { spec, stats } = await packagePipeline({
generate: (opts) => generate({ verbose: opts?.verbose, force: opts?.force }),
// chant #1067 — chantVersion/namespace/version were never populated here
// (a hardcoded "0.0.1", never the real package version), so
// `dist/manifest.json` shipped without a chantVersion at all. Matches
// the shape every other lexicon's codegen/package.ts already uses.
buildManifest: (genResult) => ({
buildManifest: (_genResult) => ({
name: "fly",
version: pkgJson.version ?? "0.0.0",
chantVersion: ">=0.1.0",
namespace: "Fly",
}),
srcDir,
collectSkills: () => new Map(),
collectSkills: () => collectSkills(flyPlugin.skills?.() ?? []),
});

console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules`);
// Both callers (the plugin's package() and package-cli) print their own
// summary — don't double-report here.
return { spec, stats };
}
4 changes: 3 additions & 1 deletion lexicons/fly/src/package-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ const force = process.argv.includes("--force");
const { spec, stats } = await packageLexicon({ verbose, force });
writeBundleSpec(spec, distDir);

console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules`);
console.error(
`Packaged ${stats.resources} resources, ${stats.ruleCount} rules, ${stats.skillCount} skills`,
);
console.error(`dist/ written to ${distDir}`);
15 changes: 13 additions & 2 deletions lexicons/fly/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ import { validateLexiconArtifacts, type ValidateResult } from "@intentius/chant/

export type { ValidateCheck, ValidateResult } from "@intentius/chant/codegen/validate";

// TODO: Add names of required entities for your lexicon
const REQUIRED_NAMES: string[] = [];
/**
* The curated top-level Machines API resources (#741). A regeneration that
* loses one — an upstream rename, a spec fetch that returned a partial
* document — must fail validation rather than ship a lexicon missing a kind.
*/
const REQUIRED_NAMES: string[] = [
"App",
"Machine",
"Volume",
"IPAddress",
"Certificate",
"Secret",
];

/**
* Validate the generated lexicon-fly artifacts.
Expand Down
3 changes: 3 additions & 0 deletions lexicons/fountain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
.cache/
63 changes: 63 additions & 0 deletions lexicons/fountain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# @intentius/chant-lexicon-fountain

fountain lexicon plugin for [chant](https://github.com/intentius/chant).

[fountain](https://github.com/BinaryBourbon/fountain) runs coding agents in
sandboxed VMs. This lexicon declares its workload layer as typed chant
resources: `Environment` (sandbox baseline), `Vault` (env-var overrides),
`Agent` (a runnable agent config). Conversations are runs, not resources —
start them with the `fountainRun` op.

`chant build` serializes to fountain's own manifest YAML (`fountain apply -f`
accepts it verbatim) plus a `fountain-plan.json` sidecar that `fountainApply`
reconciles against the API directly.

```ts
import { Environment, Agent } from "@intentius/chant-lexicon-fountain";

export const env = new Environment({
name: "team-env",
networking_type: "limited", // FTN010 requires explicit intent
networking_config: { allowed_hosts: ["github.com"] },
metadata: { "managed-by": "chant" }, // enables owned-only reconcile/prune
});

export const helper = new Agent({
name: "helper",
model: "anthropic/claude-sonnet-4-6",
runtime: "claude",
environment: env, // typed ref — dangling name = build error
});
```

For agents handling anything sensitive, `ConciergeStack` bundles the
locked-down defaults (deny-all egress, no vault overrides, ownership marker
on both resources) so loosening any of them is a visible, reviewable
parameter.

## Development

```bash
just generate # regenerate types from the upstream OpenAPI spec
just validate # check the generated artifacts
just docs # build and serve the docs site
```

The spec is a rolling endpoint with no release tag to pin, so generation
falls back to a committed snapshot (`src/spec/fountain-openapi.snapshot.json`)
when the live endpoint is unreachable. `chant dev coverage` compares the
generated surface against that spec and reports properties upstream has
added, plus the request schemas deliberately left unmodeled.

## Project structure

- `src/plugin.ts` — LexiconPlugin with all lifecycle methods
- `src/serializer.ts` — manifest YAML + `fountain-plan.json` output
- `src/codegen/`, `src/spec/` — generation pipeline and spec fetch/parse
- `src/lint/rules/`, `src/lint/post-synth/` — FTN001 (AST) and FTN010–017
- `src/op/activities/` — `fountainApply` (reconciler) and `fountainRun`
- `src/composites/` — `ConciergeStack`
- `src/skills/` — agent skills for authoring, secrets, and locked sandboxes
- `src/import/`, `src/describe-resources.ts` — adoption and live observation
- `src/lsp/` — completions and hover
- `src/generated/` — generated artifacts (do not edit)
Loading
Loading