@intentius/chant-lexicon-fountain 0.124.100 → 0.124.102

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.
@@ -9,6 +9,8 @@ export interface FountainLexiconEntry {
9
9
  resourceType: string;
10
10
  kind: "resource" | "property";
11
11
  lexicon: "fountain";
12
+ /** For a property type, the upstream schema it was generated from. */
13
+ source?: string;
12
14
  /**
13
15
  * Every authored prop name, sorted.
14
16
  *
@@ -23,6 +23,8 @@ export function generateLexiconJSON(results, naming) {
23
23
  kind: r?.isProperty ? "property" : "resource",
24
24
  lexicon: "fountain",
25
25
  };
26
+ if (r?.isProperty && r.schema)
27
+ entry.source = r.schema;
26
28
  const propNames = (r?.resource.properties ?? []).map((p) => p.name).sort();
27
29
  if (propNames.length > 0)
28
30
  entry.props = propNames;
@@ -5,7 +5,7 @@
5
5
  import { generatePipeline, writeGeneratedArtifacts, } from "@intentius/chant/codegen/generate";
6
6
  import { fetchSchemas } from "../spec/fetch.js";
7
7
  import { parseFountainOpenAPI } from "../spec/parse.js";
8
- import { NamingStrategy } from "./naming.js";
8
+ import { NamingStrategy, publishedNames, publishedSchemaNames } from "./naming.js";
9
9
  import { generateLexiconJSON } from "./generate-lexicon.js";
10
10
  import { generateTypeScriptDeclarations } from "./generate-typescript.js";
11
11
  import { generateRuntimeIndex as coreGenerateRuntimeIndex, } from "@intentius/chant/codegen/generate-runtime-index";
@@ -19,16 +19,21 @@ export async function generate(opts = {}) {
19
19
  // multiple results. The pipeline calls parseSchema once, so we return the
20
20
  // first result and inject the rest via augmentResults.
21
21
  let pendingResults = [];
22
+ // #5569: a published name stays with the type and the schema that
23
+ // published it, so a new schema sharing its name is the one qualified. A
24
+ // caller-supplied schema set names its fixtures by the rule alone.
25
+ const published = opts.schemaSource ? {} : publishedNames();
26
+ const publishedSchemas = opts.schemaSource ? {} : publishedSchemaNames();
22
27
  const config = {
23
28
  fetchSchemas: (fetchOpts) => fetchSchemas({ force: fetchOpts.force }),
24
29
  parseSchema: (_typeName, data) => {
25
- const results = parseFountainOpenAPI(data);
30
+ const results = parseFountainOpenAPI(data, publishedSchemas);
26
31
  if (results.length === 0)
27
32
  return null;
28
33
  pendingResults = results.slice(1);
29
34
  return results[0];
30
35
  },
31
- createNaming: (results) => new NamingStrategy(results),
36
+ createNaming: (results) => new NamingStrategy(results, published),
32
37
  augmentResults: (results, _opts, log) => {
33
38
  if (pendingResults.length > 0) {
34
39
  results.push(...pendingResults);
@@ -9,5 +9,26 @@ export { propertyTypeName, extractDefName } from "@intentius/chant/codegen/namin
9
9
  * Fountain-specific naming strategy. Extends the core strategy with the fountain config.
10
10
  */
11
11
  export declare class NamingStrategy extends CoreNamingStrategy {
12
- constructor(results: FountainParseResult[]);
12
+ /**
13
+ * @param published type name -> the name the lexicon already published for
14
+ * it, normally {@link publishedNames}. Each keeps its name; see core's
15
+ * `publishedNamingConfig`.
16
+ */
17
+ constructor(results: FountainParseResult[], published?: Record<string, string>);
13
18
  }
19
+ /** The committed surface snapshot beside this package's `src/`. */
20
+ export declare const SURFACE_SNAPSHOT_PATH: string;
21
+ /**
22
+ * The names the fountain lexicon has published, read from its committed surface
23
+ * snapshot: type name -> name. Property types are standalone inputs to the
24
+ * naming step here, so they are reserved alongside the resources (chant
25
+ * #5569). Empty when there is no snapshot.
26
+ */
27
+ export declare function publishedNames(snapshotPath?: string): Record<string, string>;
28
+ /**
29
+ * The property-type names the fountain lexicon has published, by the upstream
30
+ * schema each came from: schema -> the last segment of its type name. The
31
+ * parser reads it so a published name stays with its schema. Empty when there
32
+ * is no snapshot or it records no sources.
33
+ */
34
+ export declare function publishedSchemaNames(snapshotPath?: string): Record<string, string>;
@@ -2,10 +2,12 @@
2
2
  * Fountain naming strategy — maps Fountain::V1::{Kind} type names to
3
3
  * user-friendly TypeScript class names.
4
4
  */
5
- import { NamingStrategy as CoreNamingStrategy, } from "@intentius/chant/codegen/naming";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { NamingStrategy as CoreNamingStrategy, publishedNamingConfig, readPublishedNames, readPublishedSources, } from "@intentius/chant/codegen/naming";
6
8
  import { fountainShortName, fountainServiceName } from "../spec/parse.js";
7
9
  export { propertyTypeName, extractDefName } from "@intentius/chant/codegen/naming";
8
- const flyNamingConfig = {
10
+ const fountainNamingConfig = {
9
11
  priorityNames: {
10
12
  "Fountain::V1::Environment": "Environment",
11
13
  "Fountain::V1::Agent": "Agent",
@@ -23,11 +25,36 @@ const flyNamingConfig = {
23
25
  * Fountain-specific naming strategy. Extends the core strategy with the fountain config.
24
26
  */
25
27
  export class NamingStrategy extends CoreNamingStrategy {
26
- constructor(results) {
28
+ /**
29
+ * @param published type name -> the name the lexicon already published for
30
+ * it, normally {@link publishedNames}. Each keeps its name; see core's
31
+ * `publishedNamingConfig`.
32
+ */
33
+ constructor(results, published = {}) {
27
34
  const inputs = results.map((r) => ({
28
35
  typeName: r.resource.typeName,
29
36
  propertyTypes: r.propertyTypes,
30
37
  }));
31
- super(inputs, flyNamingConfig);
38
+ super(inputs, publishedNamingConfig(inputs, fountainNamingConfig, published));
32
39
  }
33
40
  }
41
+ /** The committed surface snapshot beside this package's `src/`. */
42
+ export const SURFACE_SNAPSHOT_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "surface.snapshot.json");
43
+ /**
44
+ * The names the fountain lexicon has published, read from its committed surface
45
+ * snapshot: type name -> name. Property types are standalone inputs to the
46
+ * naming step here, so they are reserved alongside the resources (chant
47
+ * #5569). Empty when there is no snapshot.
48
+ */
49
+ export function publishedNames(snapshotPath = SURFACE_SNAPSHOT_PATH) {
50
+ return { ...readPublishedNames(snapshotPath, "property"), ...readPublishedNames(snapshotPath) };
51
+ }
52
+ /**
53
+ * The property-type names the fountain lexicon has published, by the upstream
54
+ * schema each came from: schema -> the last segment of its type name. The
55
+ * parser reads it so a published name stays with its schema. Empty when there
56
+ * is no snapshot or it records no sources.
57
+ */
58
+ export function publishedSchemaNames(snapshotPath = SURFACE_SNAPSHOT_PATH) {
59
+ return readPublishedSources(snapshotPath);
60
+ }
@@ -67,6 +67,8 @@ export interface FountainCoverageReport {
67
67
  interface SurfaceSnapshot {
68
68
  entries: Record<string, {
69
69
  kind: string;
70
+ resourceType?: string;
71
+ source?: string;
70
72
  props?: string[];
71
73
  }>;
72
74
  }
package/dist/coverage.js CHANGED
@@ -92,7 +92,16 @@ function surfaceProps(entry) {
92
92
  return (entry.props ?? []).map((p) => p.split(":")[0]);
93
93
  }
94
94
  export function computeFountainCoverage(specJSON, surface) {
95
- const parsed = parseFountainOpenAPI(specJSON);
95
+ var _a;
96
+ // Parse with the published names, as generation does (#5569), so a spec
97
+ // with two schemas sharing a name parses here too.
98
+ const published = {};
99
+ for (const entry of Object.values(surface.entries)) {
100
+ if (entry.kind === "property" && entry.source && entry.resourceType) {
101
+ published[_a = entry.source] ?? (published[_a] = fountainShortName(entry.resourceType));
102
+ }
103
+ }
104
+ const parsed = parseFountainOpenAPI(specJSON, published);
96
105
  const kinds = [];
97
106
  const modeledKinds = [];
98
107
  for (const result of parsed) {
@@ -91,6 +91,7 @@
91
91
  "resourceType": "Fountain::V1::Repository",
92
92
  "kind": "property",
93
93
  "lexicon": "fountain",
94
+ "source": "Repository",
94
95
  "props": [
95
96
  "mount_path",
96
97
  "ref",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "44edfd252a571228b52c3d5ce21dc1b3b72565df9d05246f37f85f6142c82d68",
5
- "meta.json": "d7801fa823ef8598cda899fe181e20fc13ec6a5af1c0ff05399f3db031a11482",
4
+ "manifest.json": "fadcdbf09504694ce515f33f4bddf87a77b83a82525d8fccdb0904b354adc299",
5
+ "meta.json": "6792a572cdfa0b1887e3ecf182914bdabe2cb19c57a8c8a19691b847bc5b454e",
6
6
  "types/index.d.ts": "b0a929cf94d7a57769a66df8c6805e7e5303e776b39b3f39260b7081dc38701a",
7
7
  "rules/ftn001-no-secret-literals.ts": "dd1b54db3919afadcb5b8261db9a5db7c316a5f263c86f7a551fddb19f6ac532",
8
8
  "rules/ftn010-networking-explicit.ts": "29d62025b456b207758a32d463b686e1acc5f1d39e36a6e8999946df26bbe1fc",
@@ -21,5 +21,5 @@
21
21
  "skills/chant-fountain-ops.md": "3f613763a0aa9cf76e2872d6216ca4aa9a22d700f2d161e7e2865ed826591c42",
22
22
  "skills/chant-fountain-locked-sandboxes.md": "04b6cbf94cb193bb8e8fc1fde6c61e2f2a0a8f0cf3d6ef7ffbb0d7995a0d1b62"
23
23
  },
24
- "composite": "db0b516fa3a3177136ac29fcee4b93386d0fba4957b7ea74d7522ff5603a5638"
24
+ "composite": "a6d400cefad6c6eb4caf2d6c14feec24741d8486ba962b135ee184fa9640d50e"
25
25
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fountain",
3
- "version": "0.124.100",
3
+ "version": "0.124.102",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "Fountain",
6
6
  "specVersion": "v0.29.0"
package/dist/meta.json CHANGED
@@ -91,6 +91,7 @@
91
91
  "resourceType": "Fountain::V1::Repository",
92
92
  "kind": "property",
93
93
  "lexicon": "fountain",
94
+ "source": "Repository",
94
95
  "props": [
95
96
  "mount_path",
96
97
  "ref",
@@ -59,6 +59,8 @@ export interface FountainParseResult {
59
59
  }>;
60
60
  /** Whether this entity is a property type (nested config shape). */
61
61
  isProperty?: boolean;
62
+ /** For a property type, the upstream schema it was generated from (`Repository`). */
63
+ schema?: string;
62
64
  }
63
65
  /**
64
66
  * The request schemas the curated manifest models, by schema name.
@@ -70,10 +72,31 @@ export declare const MODELED_REQUEST_SCHEMAS: string[];
70
72
  /**
71
73
  * Parse the fountain OpenAPI spec into the curated resources and the
72
74
  * property types reachable from their request schemas.
75
+ *
76
+ * @param publishedSchemas upstream schema -> the name the lexicon already
77
+ * published for it, normally read from the committed surface snapshot. A
78
+ * published name stays with its schema; see {@link nameFountainSchemas}.
79
+ */
80
+ export declare function parseFountainOpenAPI(data: string | Buffer, publishedSchemas?: Record<string, string>): FountainParseResult[];
81
+ /**
82
+ * Convert a schema name into a PascalCase class-name segment.
83
+ *
84
+ * With `qualified`, the service segment leads the name: "repository" ->
85
+ * "V1Repository". Fountain's schema names have no namespace of their own, so
86
+ * that is the part a newcomer keeps when another schema holds its name.
87
+ */
88
+ export declare function schemaToClassName(schemaName: string, qualified?: boolean): string;
89
+ /**
90
+ * Give every emitted schema its class-name segment (chant #5569).
91
+ *
92
+ * A schema keeps a name it has already published. Any other schema takes its
93
+ * short name ({@link schemaToClassName}) when no other emitted schema shares
94
+ * it and no resource or published type holds it, and the qualified name
95
+ * otherwise. Upstream adding `repository` beside a published `Repository`
96
+ * therefore emits `V1Repository` for the newcomer and leaves `Repository`
97
+ * where it was.
73
98
  */
74
- export declare function parseFountainOpenAPI(data: string | Buffer): FountainParseResult[];
75
- /** Convert a schema name into a PascalCase class-name segment. */
76
- export declare function schemaToClassName(schemaName: string): string;
99
+ export declare function nameFountainSchemas(emitted: string[], published?: Record<string, string>): Map<string, string>;
77
100
  /** Extract short name: "Fountain::V1::Agent" → "Agent". */
78
101
  export declare function fountainShortName(typeName: string): string;
79
102
  /** Extract service name: "Fountain::V1::Agent" → "V1". */
@@ -28,6 +28,7 @@
28
28
  * on its manifest format rather than on either request schema.
29
29
  */
30
30
  import { extractConstraints as coreExtractConstraints, primaryType, isEnumDefinition, } from "@intentius/chant/codegen/json-schema";
31
+ import { nameSchemas } from "@intentius/chant/codegen/naming";
31
32
  // ── Curated manifest ───────────────────────────────────────────────
32
33
  /** The single service segment for all fountain type names (apiVersion fountain.dev/v1). */
33
34
  const SERVICE = "V1";
@@ -96,11 +97,15 @@ function refProperty(ref) {
96
97
  /**
97
98
  * Parse the fountain OpenAPI spec into the curated resources and the
98
99
  * property types reachable from their request schemas.
100
+ *
101
+ * @param publishedSchemas upstream schema -> the name the lexicon already
102
+ * published for it, normally read from the committed surface snapshot. A
103
+ * published name stays with its schema; see {@link nameFountainSchemas}.
99
104
  */
100
- export function parseFountainOpenAPI(data) {
105
+ export function parseFountainOpenAPI(data, publishedSchemas = {}) {
101
106
  const spec = JSON.parse(typeof data === "string" ? data : data.toString("utf-8"));
102
107
  const schemas = spec.components?.schemas ?? {};
103
- const emitted = collectPropertyTypes(schemas);
108
+ const emitted = nameFountainSchemas(collectPropertyTypes(schemas), publishedSchemas);
104
109
  const resolve = (prop) => resolveType(prop, schemas, emitted);
105
110
  const results = [];
106
111
  for (const rspec of RESOURCES) {
@@ -169,7 +174,7 @@ export function parseFountainOpenAPI(data) {
169
174
  enums: [],
170
175
  });
171
176
  }
172
- for (const schemaName of emitted) {
177
+ for (const [schemaName, className] of emitted) {
173
178
  const def = schemas[schemaName];
174
179
  const requiredSet = new Set(def.required ?? []);
175
180
  const properties = [];
@@ -184,7 +189,7 @@ export function parseFountainOpenAPI(data) {
184
189
  }
185
190
  results.push({
186
191
  resource: {
187
- typeName: `Fountain::${SERVICE}::${schemaToClassName(schemaName)}`,
192
+ typeName: `Fountain::${SERVICE}::${className}`,
188
193
  description: def.description,
189
194
  properties,
190
195
  attributes: [],
@@ -192,6 +197,7 @@ export function parseFountainOpenAPI(data) {
192
197
  propertyTypes: [],
193
198
  enums: [],
194
199
  isProperty: true,
200
+ schema: schemaName,
195
201
  });
196
202
  }
197
203
  return results;
@@ -320,8 +326,9 @@ function resolveRefType(ref, schemas, emitted) {
320
326
  const def = schemas[name];
321
327
  if (!def)
322
328
  return "any";
323
- if (emitted.includes(name))
324
- return schemaToClassName(name);
329
+ const className = emitted.get(name);
330
+ if (className !== undefined)
331
+ return className;
325
332
  if (isEnumDefinition(def)) {
326
333
  return [...(def.enum ?? [])].sort().map((v) => JSON.stringify(v)).join(" | ");
327
334
  }
@@ -347,9 +354,35 @@ function resolveRefType(ref, schemas, emitted) {
347
354
  }
348
355
  }
349
356
  // ── Naming helpers ─────────────────────────────────────────────────
350
- /** Convert a schema name into a PascalCase class-name segment. */
351
- export function schemaToClassName(schemaName) {
352
- return schemaName.charAt(0).toUpperCase() + schemaName.slice(1);
357
+ /**
358
+ * Convert a schema name into a PascalCase class-name segment.
359
+ *
360
+ * With `qualified`, the service segment leads the name: "repository" ->
361
+ * "V1Repository". Fountain's schema names have no namespace of their own, so
362
+ * that is the part a newcomer keeps when another schema holds its name.
363
+ */
364
+ export function schemaToClassName(schemaName, qualified = false) {
365
+ const name = schemaName.charAt(0).toUpperCase() + schemaName.slice(1);
366
+ return qualified ? `${SERVICE}${name}` : name;
367
+ }
368
+ const FOUNTAIN_SCHEMA_NAMING = {
369
+ lexicon: "fountain",
370
+ short: (schemaName) => schemaToClassName(schemaName),
371
+ qualified: (schemaName) => schemaToClassName(schemaName, true),
372
+ held: RESOURCES.map((r) => fountainShortName(r.typeName)),
373
+ };
374
+ /**
375
+ * Give every emitted schema its class-name segment (chant #5569).
376
+ *
377
+ * A schema keeps a name it has already published. Any other schema takes its
378
+ * short name ({@link schemaToClassName}) when no other emitted schema shares
379
+ * it and no resource or published type holds it, and the qualified name
380
+ * otherwise. Upstream adding `repository` beside a published `Repository`
381
+ * therefore emits `V1Repository` for the newcomer and leaves `Repository`
382
+ * where it was.
383
+ */
384
+ export function nameFountainSchemas(emitted, published = {}) {
385
+ return nameSchemas(emitted, FOUNTAIN_SCHEMA_NAMING, published);
353
386
  }
354
387
  /** Extract short name: "Fountain::V1::Agent" → "Agent". */
355
388
  export function fountainShortName(typeName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-fountain",
3
- "version": "0.124.100",
3
+ "version": "0.124.102",
4
4
  "type": "module",
5
5
  "description": "Fountain lexicon for chant — sandboxed agent environments, vaults, and agents as typed estate",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "bundle": "tsx src/package-cli.ts"
50
50
  },
51
51
  "peerDependencies": {
52
- "@intentius/chant": "^0.124.100",
52
+ "@intentius/chant": "^0.124.122",
53
53
  "zod": "^4.3.6"
54
54
  },
55
55
  "devDependencies": {