@metaobjectsdev/sdk 0.23.2 → 0.24.1
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/agent-context/skills/metaobjects-audit/SKILL.md +20 -7
- package/agent-context/skills/metaobjects-audit/references/capability-checklist.md +65 -19
- package/agent-context/skills/metaobjects-audit/references/csharp.md +2 -1
- package/agent-context/skills/metaobjects-audit/references/java.md +3 -2
- package/agent-context/skills/metaobjects-audit/references/kotlin.md +2 -1
- package/agent-context/skills/metaobjects-audit/references/requirements.md +3 -4
- package/agent-context/skills/metaobjects-audit/references/typescript.md +1 -1
- package/agent-context/skills/metaobjects-authoring/SKILL.md +53 -10
- package/agent-context/skills/metaobjects-authoring/references/requirements.md +49 -23
- package/agent-context/skills/metaobjects-codegen/SKILL.md +4 -3
- package/agent-context/skills/metaobjects-codegen/references/csharp.md +12 -2
- package/agent-context/skills/metaobjects-codegen/references/java.md +3 -3
- package/agent-context/skills/metaobjects-codegen/references/kotlin.md +4 -4
- package/agent-context/skills/metaobjects-codegen/references/python.md +12 -2
- package/agent-context/skills/metaobjects-codegen/references/typescript.md +14 -3
- package/agent-context/skills/metaobjects-fit-assessment/SKILL.md +4 -4
- package/agent-context/skills/metaobjects-prompts/SKILL.md +53 -32
- package/agent-context/skills/metaobjects-prompts/references/csharp.md +26 -21
- package/agent-context/skills/metaobjects-prompts/references/java.md +24 -18
- package/agent-context/skills/metaobjects-prompts/references/kotlin.md +25 -20
- package/agent-context/skills/metaobjects-prompts/references/python.md +68 -26
- package/agent-context/skills/metaobjects-prompts/references/typescript.md +29 -23
- package/agent-context/skills/metaobjects-verify/references/migration.md +1 -1
- package/agent-context/skills/metaobjects-verify/references/requirements.md +36 -22
- package/agent-context/templates/always-on.md.mustache +3 -1
- package/dist/agent-docs/body.d.ts +1 -1
- package/dist/agent-docs/body.d.ts.map +1 -1
- package/dist/agent-docs/body.js +24 -2
- package/dist/agent-docs/body.js.map +1 -1
- package/dist/collection.d.ts +71 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +203 -0
- package/dist/collection.js.map +1 -0
- package/dist/config.d.ts +51 -21
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +76 -10
- package/dist/config.js.map +1 -1
- package/dist/discovery.d.ts +43 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +100 -0
- package/dist/discovery.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +42 -19
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -95
- package/dist/memory.js.map +1 -1
- package/dist/metadata-files.d.ts +67 -0
- package/dist/metadata-files.d.ts.map +1 -0
- package/dist/metadata-files.js +155 -0
- package/dist/metadata-files.js.map +1 -0
- package/dist/records/any.d.ts +8 -8
- package/dist/records/decision.d.ts +2 -2
- package/dist/records/glossary.d.ts +4 -4
- package/dist/records/principle.d.ts +2 -2
- package/dist/scope.d.ts +16 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +75 -0
- package/dist/scope.js.map +1 -0
- package/dist/sources.d.ts +86 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +130 -0
- package/dist/sources.js.map +1 -0
- package/package.json +2 -2
- package/src/agent-docs/body.ts +24 -2
- package/src/collection.ts +268 -0
- package/src/config.ts +80 -12
- package/src/discovery.ts +110 -0
- package/src/index.ts +26 -9
- package/src/memory.ts +65 -99
- package/src/metadata-files.ts +158 -0
- package/src/scope.ts +95 -0
- package/src/sources.ts +160 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Exported for reuse — `collection.ts` had its own byte-identical copy
|
|
2
|
+
* (`fileExists`); one definition, imported. */
|
|
3
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
4
|
+
/** `exists`, narrowed to directories — `collection.ts`'s default-source probe
|
|
5
|
+
* needs that distinction to raise its friendlier `ERR_COLLECTION_NOT_FOUND`
|
|
6
|
+
* (a plain FILE where the default source directory should be is not a
|
|
7
|
+
* metadata home). Lives here beside `exists` so there is one filesystem
|
|
8
|
+
* predicate pair in the package rather than a copy per caller. */
|
|
9
|
+
export declare function isDir(path: string): Promise<boolean>;
|
|
10
|
+
/** Where the discovery walk stopped, and what it found there. */
|
|
11
|
+
export interface DiscoveredRoot {
|
|
12
|
+
/** The project root the walk settled on. Always absolute; falls back to the
|
|
13
|
+
* resolved start directory when the walk found no marker at all. */
|
|
14
|
+
readonly dir: string;
|
|
15
|
+
/** Whether `dir` carries `.metaobjects/config.json`. False only on the
|
|
16
|
+
* no-marker fallback, where the DEFAULT sources apply. */
|
|
17
|
+
readonly hasConfig: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Walk up from `startDir` for the nearest project root — a directory holding
|
|
21
|
+
* `.metaobjects/config.json`, and nothing else (see the file header). The walk
|
|
22
|
+
* stops after examining a directory that contains `.git`, so a monorepo can
|
|
23
|
+
* never silently adopt a parent checkout's configuration.
|
|
24
|
+
*
|
|
25
|
+
* Never fails: with no config anywhere below the boundary it reports the
|
|
26
|
+
* resolved `startDir` with `hasConfig: false`, which is what
|
|
27
|
+
* `resolveCollection` turns into either the default source or
|
|
28
|
+
* `ERR_COLLECTION_NOT_FOUND`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function discoverCollectionRoot(startDir: string): Promise<DiscoveredRoot>;
|
|
31
|
+
/**
|
|
32
|
+
* The directory whose configuration governs a run started in `startDir` — the
|
|
33
|
+
* `dir` half of {@link discoverCollectionRoot}.
|
|
34
|
+
*
|
|
35
|
+
* Exists as its own export for the callers that must NOT require metadata to
|
|
36
|
+
* exist: `meta migrate apply-pending` and `--rollback` replay committed SQL and
|
|
37
|
+
* load no model at all, so they resolve their `.metaobjects/` directory through
|
|
38
|
+
* this rather than through `resolveCollection`. Sharing the walk is the point —
|
|
39
|
+
* a second "find the project root" implementation is how the migrations
|
|
40
|
+
* directory and the metadata directory come to disagree.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveConfigDir(startDir: string): Promise<string>;
|
|
43
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAkCA;gDACgD;AAChD,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO3D;AAED;;;;mEAImE;AACnE,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM1D;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B;yEACqE;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;+DAC2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAetF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// server/typescript/packages/sdk/src/discovery.ts
|
|
2
|
+
//
|
|
3
|
+
// Phase-1 metadata-source-resolution — nearest-ancestor collection discovery.
|
|
4
|
+
//
|
|
5
|
+
// Walks up from a starting directory to find the nearest directory that IS a
|
|
6
|
+
// project root. This is what makes a CLI *contextual*: run it inside an app in
|
|
7
|
+
// a monorepo and it finds that app's configuration rather than the repo root's.
|
|
8
|
+
//
|
|
9
|
+
// Three properties are load-bearing.
|
|
10
|
+
//
|
|
11
|
+
// 1. **One marker.** A directory is a project root when it carries
|
|
12
|
+
// `.metaobjects/config.json`, and on no other evidence. A directory that
|
|
13
|
+
// merely *holds* metadata is not a project boundary: where metadata lives is
|
|
14
|
+
// the `sources` key's answer, and `metaobjects/` is only that key's default
|
|
15
|
+
// value. Stopping on a bare `metaobjects/` directory would put a second
|
|
16
|
+
// definition of "where metadata lives" back into the walk — the exact
|
|
17
|
+
// duplication `resolveCollection` exists to be the only instance of — and it
|
|
18
|
+
// would ignore a project whose config points its `sources` somewhere else
|
|
19
|
+
// entirely. See design §4.6.1.
|
|
20
|
+
// 2. **Nearest wins** — the walk returns on the FIRST directory carrying the
|
|
21
|
+
// marker, so a config in a subdirectory beats one in an ancestor.
|
|
22
|
+
// 3. **The walk stops at a repository boundary** (`.git`), so a monorepo
|
|
23
|
+
// checkout can never silently adopt a *parent checkout's* configuration. The
|
|
24
|
+
// marker check runs BEFORE the `.git` check within each directory —
|
|
25
|
+
// reversed, a root-level project (where `.git` also lives) would be
|
|
26
|
+
// unreachable from any subdirectory, since the boundary would stop the walk
|
|
27
|
+
// one directory too early.
|
|
28
|
+
import { stat } from "node:fs/promises";
|
|
29
|
+
import { dirname, join, resolve } from "node:path";
|
|
30
|
+
import { CONFIG_FILE } from "./config.js";
|
|
31
|
+
import { DEFAULT_METAOBJECTS_DIR } from "./metadata-files.js";
|
|
32
|
+
const GIT_DIR = ".git";
|
|
33
|
+
/** Exported for reuse — `collection.ts` had its own byte-identical copy
|
|
34
|
+
* (`fileExists`); one definition, imported. */
|
|
35
|
+
export async function exists(path) {
|
|
36
|
+
try {
|
|
37
|
+
await stat(path);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** `exists`, narrowed to directories — `collection.ts`'s default-source probe
|
|
45
|
+
* needs that distinction to raise its friendlier `ERR_COLLECTION_NOT_FOUND`
|
|
46
|
+
* (a plain FILE where the default source directory should be is not a
|
|
47
|
+
* metadata home). Lives here beside `exists` so there is one filesystem
|
|
48
|
+
* predicate pair in the package rather than a copy per caller. */
|
|
49
|
+
export async function isDir(path) {
|
|
50
|
+
try {
|
|
51
|
+
return (await stat(path)).isDirectory();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Walk up from `startDir` for the nearest project root — a directory holding
|
|
59
|
+
* `.metaobjects/config.json`, and nothing else (see the file header). The walk
|
|
60
|
+
* stops after examining a directory that contains `.git`, so a monorepo can
|
|
61
|
+
* never silently adopt a parent checkout's configuration.
|
|
62
|
+
*
|
|
63
|
+
* Never fails: with no config anywhere below the boundary it reports the
|
|
64
|
+
* resolved `startDir` with `hasConfig: false`, which is what
|
|
65
|
+
* `resolveCollection` turns into either the default source or
|
|
66
|
+
* `ERR_COLLECTION_NOT_FOUND`.
|
|
67
|
+
*/
|
|
68
|
+
export async function discoverCollectionRoot(startDir) {
|
|
69
|
+
const start = resolve(startDir);
|
|
70
|
+
let dir = start;
|
|
71
|
+
for (;;) {
|
|
72
|
+
if (await exists(join(dir, DEFAULT_METAOBJECTS_DIR, CONFIG_FILE))) {
|
|
73
|
+
return { dir, hasConfig: true };
|
|
74
|
+
}
|
|
75
|
+
// Boundary check AFTER the marker check: a repo-root project (sharing its
|
|
76
|
+
// directory with `.git`) is still findable from any subdirectory.
|
|
77
|
+
if (await exists(join(dir, GIT_DIR)))
|
|
78
|
+
break;
|
|
79
|
+
const parent = dirname(dir);
|
|
80
|
+
if (parent === dir)
|
|
81
|
+
break;
|
|
82
|
+
dir = parent;
|
|
83
|
+
}
|
|
84
|
+
return { dir: start, hasConfig: false };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The directory whose configuration governs a run started in `startDir` — the
|
|
88
|
+
* `dir` half of {@link discoverCollectionRoot}.
|
|
89
|
+
*
|
|
90
|
+
* Exists as its own export for the callers that must NOT require metadata to
|
|
91
|
+
* exist: `meta migrate apply-pending` and `--rollback` replay committed SQL and
|
|
92
|
+
* load no model at all, so they resolve their `.metaobjects/` directory through
|
|
93
|
+
* this rather than through `resolveCollection`. Sharing the walk is the point —
|
|
94
|
+
* a second "find the project root" implementation is how the migrations
|
|
95
|
+
* directory and the metadata directory come to disagree.
|
|
96
|
+
*/
|
|
97
|
+
export async function resolveConfigDir(startDir) {
|
|
98
|
+
return (await discoverCollectionRoot(startDir)).dir;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,8EAA8E;AAC9E,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,EAAE;AACF,qCAAqC;AACrC,EAAE;AACF,mEAAmE;AACnE,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,yEAAyE;AACzE,gFAAgF;AAChF,6EAA6E;AAC7E,kCAAkC;AAClC,6EAA6E;AAC7E,qEAAqE;AACrE,yEAAyE;AACzE,gFAAgF;AAChF,uEAAuE;AACvE,uEAAuE;AACvE,+EAA+E;AAC/E,8BAA8B;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB;gDACgD;AAChD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;mEAImE;AACnE,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAYD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,QAAgB;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,GAAG,GAAG,KAAK,CAAC;IAChB,SAAS,CAAC;QACR,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAClC,CAAC;QACD,0EAA0E;QAC1E,kEAAkE;QAClE,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAAE,MAAM;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IACrD,OAAO,CAAC,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;AACtD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,17 @@ export { ConfigSchema, DEFAULT_CONFIG, loadConfig, saveConfig, AllowTokenEnum }
|
|
|
12
12
|
export type { Config } from "./config.js";
|
|
13
13
|
export { FORGE_TYPE_DECISION, FORGE_TYPE_PRINCIPLE, FORGE_TYPE_CONVENTION, FORGE_TYPE_GLOSSARY, FORGE_TYPE_FAILURE, FORGE_TYPES, FORGE_DECISION_SUBTYPES, FORGE_PRINCIPLE_SUBTYPES, FORGE_CONVENTION_SUBTYPES, FORGE_GLOSSARY_SUBTYPES, FORGE_FAILURE_SUBTYPES, FORGE_ATTR_CONFIDENCE, FORGE_ATTR_SOURCE, FORGE_ATTR_CAPTURED_AT, FORGE_ATTR_LAST_VALIDATED_COMMIT, FORGE_ATTR_PRIMARY_LOCATION, FORGE_ATTR_OCCURRENCES, FORGE_ATTR_RATIONALE, FORGE_ATTR_ALTERNATIVES, FORGE_ATTR_SCOPE, FORGE_ATTR_STATEMENT, FORGE_ATTR_ENFORCEMENT, FORGE_ATTR_PATTERN_DESCRIPTION, FORGE_ATTR_EXAMPLES, FORGE_ATTR_COUNTER_EXAMPLES, FORGE_ATTR_APPLIES_TO, FORGE_ATTR_TERM, FORGE_ATTR_SYNONYMS, FORGE_ATTR_DEFINITION, FORGE_ATTR_CODE_ANCHORS, FORGE_ATTR_SEE_ALSO, FORGE_ATTR_WHAT_WAS_TRIED, FORGE_ATTR_WHY_IT_FAILED, FORGE_ATTRS, registerForgeTypes, forgeTypesProvider, } from "./forge-types.js";
|
|
14
14
|
export type { ForgeType, ForgeAttr } from "./forge-types.js";
|
|
15
|
-
export { loadMemory, defaultLoadMemoryProviders
|
|
15
|
+
export { loadMemory, defaultLoadMemoryProviders } from "./memory.js";
|
|
16
16
|
export type { LoadMemoryOptions } from "./memory.js";
|
|
17
|
+
export { DEFAULT_METADATA_DIR, DEFAULT_METAOBJECTS_DIR } from "./metadata-files.js";
|
|
18
|
+
export { compileScope, matchesScope } from "./scope.js";
|
|
19
|
+
export type { Scope, CompiledScope } from "./scope.js";
|
|
20
|
+
export { resolveSources, resolveSpecPath, orderedPathSpecs, DEFAULT_SOURCES } from "./sources.js";
|
|
21
|
+
export type { SourceSpec, ResolvedSource } from "./sources.js";
|
|
22
|
+
export { discoverCollectionRoot, resolveConfigDir } from "./discovery.js";
|
|
23
|
+
export type { DiscoveredRoot } from "./discovery.js";
|
|
24
|
+
export { resolveCollection } from "./collection.js";
|
|
25
|
+
export type { Collection } from "./collection.js";
|
|
17
26
|
export { discoverWorkspace, resolveExtendsOrder, packageLabel } from "./workspace.js";
|
|
18
27
|
export type { Workspace, WorkspacePackage } from "./workspace.js";
|
|
19
28
|
export { PackageManifestSchema, readPackageManifest, resolveMetaobjectsPackage, PACKAGE_MANIFEST_FILE, } from "./package.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,SAAS,EACT,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACnG,YAAY,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;AAGvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClG,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI/D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,10 +24,23 @@ FORGE_DECISION_SUBTYPES, FORGE_PRINCIPLE_SUBTYPES, FORGE_CONVENTION_SUBTYPES, FO
|
|
|
24
24
|
FORGE_ATTR_CONFIDENCE, FORGE_ATTR_SOURCE, FORGE_ATTR_CAPTURED_AT, FORGE_ATTR_LAST_VALIDATED_COMMIT, FORGE_ATTR_PRIMARY_LOCATION, FORGE_ATTR_OCCURRENCES, FORGE_ATTR_RATIONALE, FORGE_ATTR_ALTERNATIVES, FORGE_ATTR_SCOPE, FORGE_ATTR_STATEMENT, FORGE_ATTR_ENFORCEMENT, FORGE_ATTR_PATTERN_DESCRIPTION, FORGE_ATTR_EXAMPLES, FORGE_ATTR_COUNTER_EXAMPLES, FORGE_ATTR_APPLIES_TO, FORGE_ATTR_TERM, FORGE_ATTR_SYNONYMS, FORGE_ATTR_DEFINITION, FORGE_ATTR_CODE_ANCHORS, FORGE_ATTR_SEE_ALSO, FORGE_ATTR_WHAT_WAS_TRIED, FORGE_ATTR_WHY_IT_FAILED, FORGE_ATTRS,
|
|
25
25
|
// Registration helper + provider
|
|
26
26
|
registerForgeTypes, forgeTypesProvider, } from "./forge-types.js";
|
|
27
|
-
// Memory loader — read
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
export { loadMemory, defaultLoadMemoryProviders
|
|
27
|
+
// Memory loader — read a project's resolved metadata into a MetaData tree.
|
|
28
|
+
// Where those files come from is `resolveCollection`'s decision (below), which
|
|
29
|
+
// `loadMemory` calls when the caller supplies no explicit file set.
|
|
30
|
+
export { loadMemory, defaultLoadMemoryProviders } from "./memory.js";
|
|
31
|
+
// Default project layout — the DEFAULT value of `sources` (applied by
|
|
32
|
+
// `resolveCollection` alone) and the fixed directory holding the config that
|
|
33
|
+
// declares them. Exported for `meta init`, which SCAFFOLDS that layout.
|
|
34
|
+
export { DEFAULT_METADATA_DIR, DEFAULT_METAOBJECTS_DIR } from "./metadata-files.js";
|
|
35
|
+
// Scope — output filter over fully-qualified node names
|
|
36
|
+
export { compileScope, matchesScope } from "./scope.js";
|
|
37
|
+
// Source resolution — a declared source SET to a canonically-sorted file list
|
|
38
|
+
export { resolveSources, resolveSpecPath, orderedPathSpecs, DEFAULT_SOURCES } from "./sources.js";
|
|
39
|
+
// Discovery — nearest-ancestor project root (a `.metaobjects/config.json`,
|
|
40
|
+
// the only marker), bounded by the repo root
|
|
41
|
+
export { discoverCollectionRoot, resolveConfigDir } from "./discovery.js";
|
|
42
|
+
// Collection — the single authority on where a project's metadata lives
|
|
43
|
+
export { resolveCollection } from "./collection.js";
|
|
31
44
|
// Workspace discovery — finds peer metadata packages in a monorepo
|
|
32
45
|
export { discoverWorkspace, resolveExtendsOrder, packageLabel } from "./workspace.js";
|
|
33
46
|
// Package manifest — the v0.3 package.meta.json model. Three-field manifest
|
package/dist/index.js.map
CHANGED
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OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,cAAc,0BAA0B,CAAC"}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { type MetaDataTypeProvider, type MetaRoot } from "@metaobjectsdev/metadata";
|
|
2
|
-
/**
|
|
3
|
-
* Default directory name (relative to project root) where metadata JSON files
|
|
4
|
-
* are scanned. Scaffold via `meta init`; the directory is committed to git.
|
|
5
|
-
*/
|
|
6
|
-
export declare const DEFAULT_METADATA_DIR = "metaobjects";
|
|
7
|
-
/**
|
|
8
|
-
* Default directory name (relative to project root) for MetaObjects' own
|
|
9
|
-
* runtime state: config.json, .gen-state/, package.meta.json, agent docs.
|
|
10
|
-
* Scaffold via `meta init`; most contents are committed to git.
|
|
11
|
-
*/
|
|
12
|
-
export declare const DEFAULT_METAOBJECTS_DIR = ".metaobjects";
|
|
13
2
|
/**
|
|
14
3
|
* Options for {@link loadMemory}. Consumers can supply additional
|
|
15
4
|
* {@link MetaDataTypeProvider}s to extend the metamodel with their own
|
|
@@ -36,6 +25,31 @@ export interface LoadMemoryOptions {
|
|
|
36
25
|
* the `meta verify` command opts in to `true` (strict-by-default, #96).
|
|
37
26
|
*/
|
|
38
27
|
strict?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* An already-resolved, absolute metadata file list — normally
|
|
30
|
+
* `resolveCollection(...).files`. When supplied, `loadMemory` loads exactly
|
|
31
|
+
* these files and resolves nothing itself.
|
|
32
|
+
*
|
|
33
|
+
* Omitting it is not a different WAY of finding metadata, only a different
|
|
34
|
+
* place the same resolution happens: `loadMemory` then calls
|
|
35
|
+
* `resolveCollection(repoRoot)` itself. Passing it saves the second
|
|
36
|
+
* resolution when the caller already holds a collection (every routed CLI
|
|
37
|
+
* command does) and lets a caller load a file set it computed some other
|
|
38
|
+
* way; it can no longer diverge from what the config declares.
|
|
39
|
+
*/
|
|
40
|
+
files?: readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* MetaObjects-shipped library packages to load ALONGSIDE the project's own files
|
|
43
|
+
* (e.g. `["ai"]` for `metaobjects::ai::LlmCallBase`). Prepended, so an
|
|
44
|
+
* `extends: "metaobjects::ai::LlmCallBase"` in project metadata resolves.
|
|
45
|
+
*
|
|
46
|
+
* Opt-in rather than always-on: a library package registers real top-level nodes, and
|
|
47
|
+
* a project that never references one should not have them appear in its model, its
|
|
48
|
+
* generated output or its docs. Without this the CLI could not load the metadata that
|
|
49
|
+
* shipped generators like `trace-helper` exist to consume, so the generator was
|
|
50
|
+
* reachable from the command line while its input was not (#333).
|
|
51
|
+
*/
|
|
52
|
+
libraries?: readonly string[];
|
|
39
53
|
}
|
|
40
54
|
/** Default provider bundle threaded by {@link loadMemory} when no options
|
|
41
55
|
* override is supplied. Exposed for tests/inspection; callers shouldn't need
|
|
@@ -43,10 +57,15 @@ export interface LoadMemoryOptions {
|
|
|
43
57
|
* composes `[...defaultLoadMemoryProviders, mine]` automatically. */
|
|
44
58
|
export declare const defaultLoadMemoryProviders: readonly MetaDataTypeProvider[];
|
|
45
59
|
/**
|
|
46
|
-
* Load
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
60
|
+
* Load a project's metadata into a single MetaData tree.
|
|
61
|
+
*
|
|
62
|
+
* Which files those are is `resolveCollection`'s decision, never this
|
|
63
|
+
* function's: with no {@link LoadMemoryOptions.files} it calls
|
|
64
|
+
* `resolveCollection(repoRoot)` — nearest-ancestor `.metaobjects/config.json`,
|
|
65
|
+
* then that config's declared `sources`, falling back to the default source
|
|
66
|
+
* directory only when a project declares none. `loadMemory` names no directory
|
|
67
|
+
* of its own, so a caller cannot end up loading from somewhere the rest of the
|
|
68
|
+
* toolchain does not.
|
|
50
69
|
*
|
|
51
70
|
* Excludes `_pending/`. Registers metaobjects core types plus Meta Forge's
|
|
52
71
|
* descriptive top-level types (decision, principle, etc.) so mixed content
|
|
@@ -54,11 +73,15 @@ export declare const defaultLoadMemoryProviders: readonly MetaDataTypeProvider[]
|
|
|
54
73
|
* {@link LoadMemoryOptions.providers}) are composed AFTER the defaults so
|
|
55
74
|
* they may depend on core/forge ids.
|
|
56
75
|
*
|
|
57
|
-
* Throws
|
|
76
|
+
* Throws `ERR_COLLECTION_NOT_FOUND` when nothing resolves (callers should run
|
|
77
|
+
* `meta init`), unless `options.files` is supplied.
|
|
58
78
|
*
|
|
59
|
-
* @param repoRoot
|
|
60
|
-
* `
|
|
61
|
-
*
|
|
79
|
+
* @param repoRoot Where resolution STARTS — the working directory, typically
|
|
80
|
+
* `process.cwd()`. The walk goes up from here for the governing config, so
|
|
81
|
+
* this need not be the project root itself.
|
|
82
|
+
* **Ignored entirely when `options.files` is supplied**: that list is already
|
|
83
|
+
* resolved, so nothing reads this path. Every routed CLI command passes both,
|
|
84
|
+
* and the argument is inert at all of them.
|
|
62
85
|
* @param options Optional {@link LoadMemoryOptions} — supply additional
|
|
63
86
|
* providers or replace the default bundle entirely.
|
|
64
87
|
*/
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAKlC;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC5C;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED;;;sEAGsE;AACtE,eAAO,MAAM,0BAA0B,EAAE,SAAS,oBAAoB,EAGrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAiDnB"}
|
package/dist/memory.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { readdir, stat } from "node:fs/promises";
|
|
3
1
|
import { composeRegistry, coreProviders, MetaDataLoader, } from "@metaobjectsdev/metadata";
|
|
4
2
|
import { FileSource } from "@metaobjectsdev/metadata/core";
|
|
3
|
+
import { resolveCollection } from "./collection.js";
|
|
5
4
|
import { forgeTypesProvider } from "./forge-types.js";
|
|
6
|
-
import { discoverWorkspace, resolveExtendsOrder } from "./workspace.js";
|
|
7
|
-
/**
|
|
8
|
-
* Default directory name (relative to project root) where metadata JSON files
|
|
9
|
-
* are scanned. Scaffold via `meta init`; the directory is committed to git.
|
|
10
|
-
*/
|
|
11
|
-
export const DEFAULT_METADATA_DIR = "metaobjects";
|
|
12
|
-
/**
|
|
13
|
-
* Default directory name (relative to project root) for MetaObjects' own
|
|
14
|
-
* runtime state: config.json, .gen-state/, package.meta.json, agent docs.
|
|
15
|
-
* Scaffold via `meta init`; most contents are committed to git.
|
|
16
|
-
*/
|
|
17
|
-
export const DEFAULT_METAOBJECTS_DIR = ".metaobjects";
|
|
18
5
|
/** Default provider bundle threaded by {@link loadMemory} when no options
|
|
19
6
|
* override is supplied. Exposed for tests/inspection; callers shouldn't need
|
|
20
7
|
* to spread this manually — `loadMemory(root, { providers: [mine] })`
|
|
@@ -24,10 +11,15 @@ export const defaultLoadMemoryProviders = [
|
|
|
24
11
|
forgeTypesProvider,
|
|
25
12
|
];
|
|
26
13
|
/**
|
|
27
|
-
* Load
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
14
|
+
* Load a project's metadata into a single MetaData tree.
|
|
15
|
+
*
|
|
16
|
+
* Which files those are is `resolveCollection`'s decision, never this
|
|
17
|
+
* function's: with no {@link LoadMemoryOptions.files} it calls
|
|
18
|
+
* `resolveCollection(repoRoot)` — nearest-ancestor `.metaobjects/config.json`,
|
|
19
|
+
* then that config's declared `sources`, falling back to the default source
|
|
20
|
+
* directory only when a project declares none. `loadMemory` names no directory
|
|
21
|
+
* of its own, so a caller cannot end up loading from somewhere the rest of the
|
|
22
|
+
* toolchain does not.
|
|
31
23
|
*
|
|
32
24
|
* Excludes `_pending/`. Registers metaobjects core types plus Meta Forge's
|
|
33
25
|
* descriptive top-level types (decision, principle, etc.) so mixed content
|
|
@@ -35,11 +27,15 @@ export const defaultLoadMemoryProviders = [
|
|
|
35
27
|
* {@link LoadMemoryOptions.providers}) are composed AFTER the defaults so
|
|
36
28
|
* they may depend on core/forge ids.
|
|
37
29
|
*
|
|
38
|
-
* Throws
|
|
30
|
+
* Throws `ERR_COLLECTION_NOT_FOUND` when nothing resolves (callers should run
|
|
31
|
+
* `meta init`), unless `options.files` is supplied.
|
|
39
32
|
*
|
|
40
|
-
* @param repoRoot
|
|
41
|
-
* `
|
|
42
|
-
*
|
|
33
|
+
* @param repoRoot Where resolution STARTS — the working directory, typically
|
|
34
|
+
* `process.cwd()`. The walk goes up from here for the governing config, so
|
|
35
|
+
* this need not be the project root itself.
|
|
36
|
+
* **Ignored entirely when `options.files` is supplied**: that list is already
|
|
37
|
+
* resolved, so nothing reads this path. Every routed CLI command passes both,
|
|
38
|
+
* and the argument is inert at all of them.
|
|
43
39
|
* @param options Optional {@link LoadMemoryOptions} — supply additional
|
|
44
40
|
* providers or replace the default bundle entirely.
|
|
45
41
|
*/
|
|
@@ -56,87 +52,34 @@ export async function loadMemory(repoRoot, options) {
|
|
|
56
52
|
providers = [...defaultLoadMemoryProviders, ...extra];
|
|
57
53
|
}
|
|
58
54
|
const registry = composeRegistry(providers);
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
55
|
+
// Both arms are `resolveCollection`'s answer — one already computed by the
|
|
56
|
+
// caller, one computed here. There is no third way to find metadata, and
|
|
57
|
+
// that is the whole of this line's design: the previous no-`files` arm
|
|
58
|
+
// scanned `<repoRoot>/<default dir>` directly, so a caller that copied the
|
|
59
|
+
// routed shape but forgot `files` silently loaded from a directory the
|
|
60
|
+
// project's config may never have mentioned.
|
|
61
|
+
const paths = options?.files !== undefined
|
|
62
|
+
? [...options.files]
|
|
63
|
+
: [...(await resolveCollection(repoRoot)).files];
|
|
63
64
|
const loader = new MetaDataLoader({
|
|
64
65
|
registry,
|
|
65
66
|
...(options?.strict === true ? { strict: true } : {}),
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
+
// Library sources are imported lazily and only when asked for — the same reason
|
|
69
|
+
// `MetaDataLoader.fromDirectory` does it. `library-sources.ts` reads `node:fs`, so a
|
|
70
|
+
// static import from a root-reachable module drags Node built-ins into every consumer's
|
|
71
|
+
// graph; that is the #287 bundle defect, and the `./library` subpath exists for exactly
|
|
72
|
+
// the reason `./constants` does. Prepended, so a project's `extends` onto a
|
|
73
|
+
// library-shipped abstract base resolves — super resolution is order-independent, but
|
|
74
|
+
// prepending is the deterministic choice and matches `fromDirectory`.
|
|
75
|
+
const libSources = options?.libraries !== undefined && options.libraries.length > 0
|
|
76
|
+
? (await import("@metaobjectsdev/metadata/library")).librarySources([...options.libraries])
|
|
77
|
+
: [];
|
|
78
|
+
const result = await loader.load([...libSources, ...paths.map((p) => new FileSource(p))]);
|
|
68
79
|
if (result.errors.length > 0) {
|
|
69
80
|
const first = result.errors[0];
|
|
70
81
|
throw first;
|
|
71
82
|
}
|
|
72
83
|
return result.root;
|
|
73
84
|
}
|
|
74
|
-
// Dep packages' metaobjects/ files first (topological order), then current.
|
|
75
|
-
async function collectMetadataPaths(repoRoot) {
|
|
76
|
-
const currentMetaDir = join(repoRoot, ".meta");
|
|
77
|
-
const ws = await discoverWorkspace(repoRoot);
|
|
78
|
-
// Workspace path: walk extends, load dep metaobjects/ dirs first
|
|
79
|
-
if (ws !== undefined) {
|
|
80
|
-
const currentPkg = ws.packages.find((p) => p.metaDir === currentMetaDir);
|
|
81
|
-
if (currentPkg !== undefined && currentPkg.manifest.extends.length > 0) {
|
|
82
|
-
const ordered = resolveExtendsOrder(ws, currentMetaDir);
|
|
83
|
-
const paths = [];
|
|
84
|
-
for (const pkg of ordered) {
|
|
85
|
-
// Each workspace package's metadata lives alongside its .meta/ dir
|
|
86
|
-
const pkgRoot = join(pkg.metaDir, "..");
|
|
87
|
-
paths.push(...(await listMetadataFiles(join(pkgRoot, DEFAULT_METADATA_DIR))));
|
|
88
|
-
}
|
|
89
|
-
return paths;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// Single-package path: scan metaobjects/ at the project root
|
|
93
|
-
return listMetadataFiles(join(repoRoot, DEFAULT_METADATA_DIR));
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Recursively list metadata files (*.json, *.yaml, *.yml) under a directory,
|
|
97
|
-
* excluding _pending/ at any level. Subdirectories (e.g. projections/) are
|
|
98
|
-
* walked depth-first. Files within a directory are sorted alphabetically for
|
|
99
|
-
* deterministic load order; subdirectories are visited after files at the
|
|
100
|
-
* same level.
|
|
101
|
-
*
|
|
102
|
-
* Format selection (parsing) happens downstream in `FileSource` from
|
|
103
|
-
* `@metaobjectsdev/metadata`, which infers the parser from file extension.
|
|
104
|
-
*/
|
|
105
|
-
async function listMetadataFiles(dir) {
|
|
106
|
-
let entries;
|
|
107
|
-
try {
|
|
108
|
-
entries = await readdir(dir);
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
throw new Error(`loadMemory: cannot read ${dir}: ${err.message}`);
|
|
112
|
-
}
|
|
113
|
-
const paths = [];
|
|
114
|
-
const subdirs = [];
|
|
115
|
-
// #188: sort the raw `readdir` entries so file order is deterministic across
|
|
116
|
-
// runtimes/filesystems (Node vs Bun return different `readdir` orders), matching
|
|
117
|
-
// this function's docstring and the metadata package's own `DirectorySource`.
|
|
118
|
-
// (Resolution is now order-INDEPENDENT — super-resolve.ts #188 — so this is the
|
|
119
|
-
// deterministic-enumeration FLOOR, not the fix; it keeps every derived artifact
|
|
120
|
-
// that preserves declaration order, e.g. serialization, stable across runtimes.)
|
|
121
|
-
for (const entry of [...entries].sort()) {
|
|
122
|
-
if (entry === "_pending")
|
|
123
|
-
continue;
|
|
124
|
-
const full = join(dir, entry);
|
|
125
|
-
const s = await stat(full);
|
|
126
|
-
if (s.isDirectory()) {
|
|
127
|
-
subdirs.push(full);
|
|
128
|
-
}
|
|
129
|
-
else if (s.isFile() && isMetadataFile(entry)) {
|
|
130
|
-
paths.push(full);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Recurse into subdirectories after collecting files at this level
|
|
134
|
-
for (const sub of subdirs.sort()) {
|
|
135
|
-
paths.push(...(await listMetadataFiles(sub)));
|
|
136
|
-
}
|
|
137
|
-
return paths;
|
|
138
|
-
}
|
|
139
|
-
function isMetadataFile(name) {
|
|
140
|
-
return name.endsWith(".json") || name.endsWith(".yaml") || name.endsWith(".yml");
|
|
141
|
-
}
|
|
142
85
|
//# sourceMappingURL=memory.js.map
|
package/dist/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,GAGf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EA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IAEH,gFAAgF;IAChF,qFAAqF;IACrF,wFAAwF;IACxF,wFAAwF;IACxF,4EAA4E;IAC5E,sFAAsF;IACtF,sEAAsE;IACtE,MAAM,UAAU,GACd,OAAO,EAAE,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QAC9D,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3F,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1F,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC;QAChC,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DEFAULT value of `sources` — the directory scanned when
|
|
3
|
+
* `.metaobjects/config.json` declares no sources. Scaffold via `meta init`;
|
|
4
|
+
* the directory is committed to git.
|
|
5
|
+
*
|
|
6
|
+
* **A default, and nothing else.** No read path may assume a directory of this
|
|
7
|
+
* name exists or is where metadata lives: that question is answered by
|
|
8
|
+
* `resolveCollection`, which applies this constant exactly once (via
|
|
9
|
+
* `DEFAULT_SOURCES` in `sources.ts`) when a project declares nothing. A
|
|
10
|
+
* project that declares `sources` may put its metadata anywhere, and every
|
|
11
|
+
* command follows the config. `test/no-hardcoded-metadata-dir.test.ts` is the
|
|
12
|
+
* enforcer.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_METADATA_DIR = "metaobjects";
|
|
15
|
+
/**
|
|
16
|
+
* Default directory name (relative to project root) for MetaObjects' own
|
|
17
|
+
* runtime state: config.json, .gen-state/, package.meta.json, agent docs.
|
|
18
|
+
* Scaffold via `meta init`; most contents are committed to git.
|
|
19
|
+
*
|
|
20
|
+
* Unlike {@link DEFAULT_METADATA_DIR} this one IS a fixed convention — it is
|
|
21
|
+
* where the config that answers "where is the metadata?" lives, so it cannot
|
|
22
|
+
* itself be configured.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_METAOBJECTS_DIR = ".metaobjects";
|
|
25
|
+
/** Recognized metadata file extensions, matched case-insensitively — mirrors
|
|
26
|
+
* `DirectorySource` in `@metaobjectsdev/metadata`, which checks
|
|
27
|
+
* `extname().toLowerCase()`. The single definition every metadata-file
|
|
28
|
+
* walker in this package uses — and since `resolveSources` (`sources.ts`)
|
|
29
|
+
* calls {@link listMetadataFiles} outright rather than keeping a second
|
|
30
|
+
* recursive walk of its own, there is exactly one walker to keep honest. */
|
|
31
|
+
export declare const METADATA_EXTENSIONS: Set<string>;
|
|
32
|
+
export declare function isMetadataFile(name: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Recursively list metadata files (*.json, *.yaml, *.yml, matched
|
|
35
|
+
* case-insensitively — see `isMetadataFile` above) under a directory,
|
|
36
|
+
* excluding _pending/ at any level. Subdirectories (e.g. projections/) are
|
|
37
|
+
* walked depth-first. Files within a directory are sorted alphabetically for
|
|
38
|
+
* deterministic load order; subdirectories are visited AFTER the files at the
|
|
39
|
+
* same level.
|
|
40
|
+
*
|
|
41
|
+
* That per-level rule is a contract, not an implementation detail. This is the
|
|
42
|
+
* order production has always handed the loader, and declaration order survives
|
|
43
|
+
* into generated output: `codegen-ts`'s barrel emits from `root.objects()`
|
|
44
|
+
* order, and so do the shared `enums.ts`, `meta docs` page ordering and `meta
|
|
45
|
+
* export`'s `canonicalSerialize` sibling order. A flat lexicographic sort of
|
|
46
|
+
* absolute paths is NOT the same list — it disagrees whenever a subdirectory
|
|
47
|
+
* name sorts before a sibling file (`common/` before `meta.users.json`) — so
|
|
48
|
+
* `resolveSources` calls this function rather than re-walking and re-sorting.
|
|
49
|
+
* Pinned by `test/source-order.test.ts`.
|
|
50
|
+
*
|
|
51
|
+
* Exported for that gate and for `sources.ts`; not re-exported from the package
|
|
52
|
+
* index — `resolveCollection` is the public door.
|
|
53
|
+
*
|
|
54
|
+
* An entry whose `stat` fails (a dangling symlink, a TOCTOU removal between
|
|
55
|
+
* `readdir` and `stat`, an EACCES entry) is SKIPPED, matching `DirectorySource`
|
|
56
|
+
* in `@metaobjectsdev/metadata`, which this walk otherwise mirrors. A failure to
|
|
57
|
+
* read the directory itself still throws — that is the "you have no metadata
|
|
58
|
+
* here" case callers report.
|
|
59
|
+
*
|
|
60
|
+
* A symlink CYCLE (e.g. `metaobjects/link -> ..`) is a loud error rather than
|
|
61
|
+
* unbounded recursion — see {@link listMetadataFilesGuarded}.
|
|
62
|
+
*
|
|
63
|
+
* Format selection (parsing) happens downstream in `FileSource` from
|
|
64
|
+
* `@metaobjectsdev/metadata`, which infers the parser from file extension.
|
|
65
|
+
*/
|
|
66
|
+
export declare function listMetadataFiles(dir: string): Promise<string[]>;
|
|
67
|
+
//# sourceMappingURL=metadata-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-files.d.ts","sourceRoot":"","sources":["../src/metadata-files.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD;;;;;6EAK6E;AAC7E,eAAO,MAAM,mBAAmB,aAAsC,CAAC;AAEvE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAEtE"}
|