faceted-prompting 0.3.1 → 0.5.0
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/README.md +39 -12
- package/dist/cli/compose-command.d.ts +2 -2
- package/dist/cli/compose-command.d.ts.map +1 -1
- package/dist/cli/compose-command.js +16 -145
- package/dist/cli/compose-command.js.map +1 -1
- package/dist/cli/compose-definition-resolution.d.ts +12 -0
- package/dist/cli/compose-definition-resolution.d.ts.map +1 -0
- package/dist/cli/compose-definition-resolution.js +50 -0
- package/dist/cli/compose-definition-resolution.js.map +1 -0
- package/dist/cli/compose-execution.d.ts +19 -0
- package/dist/cli/compose-execution.d.ts.map +1 -0
- package/dist/cli/compose-execution.js +167 -0
- package/dist/cli/compose-execution.js.map +1 -0
- package/dist/cli/compose-options.d.ts +4 -0
- package/dist/cli/compose-options.d.ts.map +1 -0
- package/dist/cli/compose-options.js +64 -0
- package/dist/cli/compose-options.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/install-skill/facet-token-renderer.d.ts +1 -1
- package/dist/cli/install-skill/facet-token-renderer.d.ts.map +1 -1
- package/dist/cli/install-skill/facet-token-renderer.js +2 -2
- package/dist/cli/install-skill/facet-token-renderer.js.map +1 -1
- package/dist/cli/install-skill/facets.d.ts +2 -0
- package/dist/cli/install-skill/facets.d.ts.map +1 -1
- package/dist/cli/install-skill/facets.js +43 -4
- package/dist/cli/install-skill/facets.js.map +1 -1
- package/dist/cli/install-skill/flow.d.ts +2 -1
- package/dist/cli/install-skill/flow.d.ts.map +1 -1
- package/dist/cli/install-skill/flow.js +7 -2
- package/dist/cli/install-skill/flow.js.map +1 -1
- package/dist/cli/install-skill/instruction-partial-copy.d.ts +6 -0
- package/dist/cli/install-skill/instruction-partial-copy.d.ts.map +1 -0
- package/dist/cli/install-skill/instruction-partial-copy.js +32 -0
- package/dist/cli/install-skill/instruction-partial-copy.js.map +1 -0
- package/dist/cli/install-skill/modes.d.ts +3 -1
- package/dist/cli/install-skill/modes.d.ts.map +1 -1
- package/dist/cli/install-skill/modes.js +16 -14
- package/dist/cli/install-skill/modes.js.map +1 -1
- package/dist/cli/install-skill/targets.d.ts +4 -3
- package/dist/cli/install-skill/targets.d.ts.map +1 -1
- package/dist/cli/install-skill/targets.js +18 -4
- package/dist/cli/install-skill/targets.js.map +1 -1
- package/dist/cli/instruction-includes.d.ts +11 -0
- package/dist/cli/instruction-includes.d.ts.map +1 -0
- package/dist/cli/instruction-includes.js +130 -0
- package/dist/cli/instruction-includes.js.map +1 -0
- package/dist/cli/path-guard.d.ts +5 -0
- package/dist/cli/path-guard.d.ts.map +1 -1
- package/dist/cli/path-guard.js +25 -0
- package/dist/cli/path-guard.js.map +1 -1
- package/dist/cli/skill-commands.d.ts +8 -0
- package/dist/cli/skill-commands.d.ts.map +1 -1
- package/dist/cli/skill-commands.js +23 -6
- package/dist/cli/skill-commands.js.map +1 -1
- package/dist/cli/skill-document-renderer.d.ts +6 -0
- package/dist/cli/skill-document-renderer.d.ts.map +1 -0
- package/dist/cli/skill-document-renderer.js +73 -0
- package/dist/cli/skill-document-renderer.js.map +1 -0
- package/dist/cli/skill-file-ops.d.ts +1 -2
- package/dist/cli/skill-file-ops.d.ts.map +1 -1
- package/dist/cli/skill-file-ops.js +12 -38
- package/dist/cli/skill-file-ops.js.map +1 -1
- package/dist/cli/skill-renderer.d.ts +5 -3
- package/dist/cli/skill-renderer.d.ts.map +1 -1
- package/dist/cli/skill-renderer.js +98 -75
- package/dist/cli/skill-renderer.js.map +1 -1
- package/dist/cli/skill-types.d.ts +6 -2
- package/dist/cli/skill-types.d.ts.map +1 -1
- package/dist/cli/types.d.ts +6 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/compose-definition.d.ts.map +1 -1
- package/dist/compose-definition.js +4 -1
- package/dist/compose-definition.js.map +1 -1
- package/dist/compose.d.ts +3 -2
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +30 -33
- package/dist/compose.js.map +1 -1
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +44 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/install-targets.d.ts +6 -0
- package/dist/config/install-targets.d.ts.map +1 -0
- package/dist/config/install-targets.js +71 -0
- package/dist/config/install-targets.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts.map +1 -1
- package/dist/init/index.js +9 -1
- package/dist/init/index.js.map +1 -1
- package/dist/install-targets.d.ts +2 -0
- package/dist/install-targets.d.ts.map +1 -0
- package/dist/install-targets.js +2 -0
- package/dist/install-targets.js.map +1 -0
- package/dist/instruction-partial-paths.d.ts +3 -0
- package/dist/instruction-partial-paths.d.ts.map +1 -0
- package/dist/instruction-partial-paths.js +6 -0
- package/dist/instruction-partial-paths.js.map +1 -0
- package/dist/prompt-payload.d.ts +1 -0
- package/dist/prompt-payload.d.ts.map +1 -1
- package/dist/prompt-payload.js +26 -8
- package/dist/prompt-payload.js.map +1 -1
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -2
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import type { ComposeDefinition, FacetSet } from '../types.js';
|
|
2
2
|
import type { ResolvedDefinitionSections, SkillDocumentInput } from './skill-types.js';
|
|
3
|
+
export { hasYamlFrontmatter, renderSkillDocument, renderSkillFrontmatter } from './skill-document-renderer.js';
|
|
3
4
|
export declare function ensureSafeDefinitionName(name: string): string;
|
|
4
5
|
export declare function resolveDefinitionSections(params: {
|
|
5
6
|
definition: ComposeDefinition;
|
|
6
7
|
definitionDir: string;
|
|
7
8
|
facetsRoot?: string;
|
|
8
9
|
facetsRoots?: readonly string[];
|
|
10
|
+
facetedRoots?: readonly string[];
|
|
9
11
|
}): ResolvedDefinitionSections;
|
|
10
12
|
export declare function listCompositionDefinitions(compositionsDirs: string | readonly string[]): Record<string, string>;
|
|
11
13
|
export declare function buildFacetSet(params: {
|
|
12
14
|
definitionDir: string;
|
|
13
15
|
facetsRoot?: string;
|
|
14
16
|
facetsRoots?: readonly string[];
|
|
17
|
+
facetedRoots?: readonly string[];
|
|
15
18
|
definition: ComposeDefinition;
|
|
16
19
|
}): FacetSet;
|
|
20
|
+
export declare function buildFacetSetFromResolvedSections(resolved: ResolvedDefinitionSections): FacetSet;
|
|
17
21
|
export declare function buildSkillSections(params: {
|
|
18
22
|
definition: ComposeDefinition;
|
|
19
23
|
definitionDir: string;
|
|
20
24
|
facetsRoot?: string;
|
|
21
25
|
facetsRoots?: readonly string[];
|
|
26
|
+
facetedRoots?: readonly string[];
|
|
22
27
|
}): Omit<SkillDocumentInput, 'mode'>;
|
|
23
|
-
export declare function renderSkillFrontmatter(definition: ComposeDefinition): string;
|
|
24
|
-
export declare function hasYamlFrontmatter(content: string): boolean;
|
|
25
|
-
export declare function renderSkillDocument(input: SkillDocumentInput): string;
|
|
26
28
|
export declare function resolveDefinitionPathFromSource(source: string, compositionsDir: string): string;
|
|
27
29
|
//# sourceMappingURL=skill-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-renderer.d.ts","sourceRoot":"","sources":["../../src/cli/skill-renderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skill-renderer.d.ts","sourceRoot":"","sources":["../../src/cli/skill-renderer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAEV,0BAA0B,EAC1B,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAS/G,wBAAgB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2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
3
|
import { isResourcePath, resolveResourcePath } from '../resolve.js';
|
|
4
|
+
import { isScopeRef, parseScopeRef, resolveScopeRef } from '../scope.js';
|
|
4
5
|
import { ensurePathWithinRoots } from './path-guard.js';
|
|
6
|
+
import { expandInstructionIncludes } from './instruction-includes.js';
|
|
7
|
+
import { instructionPartialsDir } from '../instruction-partial-paths.js';
|
|
8
|
+
export { hasYamlFrontmatter, renderSkillDocument, renderSkillFrontmatter } from './skill-document-renderer.js';
|
|
5
9
|
function requireFile(path, label) {
|
|
6
10
|
if (!existsSync(path)) {
|
|
7
11
|
throw new Error(`Missing ${label}: ${path}`);
|
|
@@ -15,15 +19,44 @@ export function ensureSafeDefinitionName(name) {
|
|
|
15
19
|
return name;
|
|
16
20
|
}
|
|
17
21
|
function resolveFacetRefContent(options) {
|
|
18
|
-
const
|
|
22
|
+
const resolved = resolveOptionalFacetRefContent(options);
|
|
23
|
+
if (resolved) {
|
|
24
|
+
return resolved;
|
|
25
|
+
}
|
|
26
|
+
const primaryFacetDir = options.facetDirs[0];
|
|
27
|
+
if (!primaryFacetDir) {
|
|
28
|
+
throw new Error(`Missing ${options.label}: facet directory is required`);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Missing ${options.label}: ${join(primaryFacetDir, `${options.ref}.md`)}`);
|
|
31
|
+
}
|
|
32
|
+
function resolveOptionalFacetRefContent(options) {
|
|
33
|
+
const { ref, label, baseDir, facetDirs, allowedRoots, resourceAllowedRoots, repertoireRoots, scopeFacetKind } = options;
|
|
19
34
|
const primaryFacetDir = facetDirs[0];
|
|
20
35
|
if (!primaryFacetDir) {
|
|
21
36
|
throw new Error(`Missing ${label}: facet directory is required`);
|
|
22
37
|
}
|
|
38
|
+
if (isScopeRef(ref)) {
|
|
39
|
+
if (repertoireRoots.length === 0) {
|
|
40
|
+
throw new Error(`Missing ${label}: scope reference requires repertoire roots`);
|
|
41
|
+
}
|
|
42
|
+
const scopeRef = parseScopeRef(ref);
|
|
43
|
+
for (const repertoireRoot of repertoireRoots) {
|
|
44
|
+
const scopePath = resolveScopeRef(scopeRef, scopeFacetKind, repertoireRoot);
|
|
45
|
+
if (!existsSync(scopePath)) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const boundedPath = ensurePathWithinRoots(scopePath, repertoireRoots, label);
|
|
49
|
+
return { path: boundedPath, body: requireFile(boundedPath, label) };
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Missing ${label}: ${resolveScopeRef(scopeRef, scopeFacetKind, repertoireRoots[0])}`);
|
|
52
|
+
}
|
|
23
53
|
if (isResourcePath(ref)) {
|
|
24
54
|
const resourcePath = resolveResourcePath(ref, baseDir);
|
|
25
|
-
|
|
26
|
-
|
|
55
|
+
if (!existsSync(resourcePath)) {
|
|
56
|
+
throw new Error(`Missing ${label}: ${resourcePath}`);
|
|
57
|
+
}
|
|
58
|
+
const boundedPath = ensurePathWithinRoots(resourcePath, resourceAllowedRoots, label);
|
|
59
|
+
return { path: boundedPath, body: readFileSync(boundedPath, 'utf-8') };
|
|
27
60
|
}
|
|
28
61
|
for (const facetDir of facetDirs) {
|
|
29
62
|
const facetPath = join(facetDir, `${ref}.md`);
|
|
@@ -33,7 +66,7 @@ function resolveFacetRefContent(options) {
|
|
|
33
66
|
const boundedPath = ensurePathWithinRoots(facetPath, allowedRoots, label);
|
|
34
67
|
return { path: boundedPath, body: requireFile(boundedPath, label) };
|
|
35
68
|
}
|
|
36
|
-
|
|
69
|
+
return undefined;
|
|
37
70
|
}
|
|
38
71
|
function resolveFacetsRoots(params) {
|
|
39
72
|
if (params.facetsRoots && params.facetsRoots.length > 0) {
|
|
@@ -47,13 +80,22 @@ function resolveFacetsRoots(params) {
|
|
|
47
80
|
export function resolveDefinitionSections(params) {
|
|
48
81
|
const { definition, definitionDir } = params;
|
|
49
82
|
const facetsRoots = resolveFacetsRoots(params);
|
|
50
|
-
const
|
|
83
|
+
const facetAllowedRoots = facetsRoots;
|
|
84
|
+
const resourceAllowedRoots = [definitionDir, ...facetsRoots];
|
|
85
|
+
const repertoireRoots = params.facetedRoots?.map(facetedRoot => join(facetedRoot, 'repertoire')) ?? [];
|
|
86
|
+
const instructionIncludeRepertoireRoots = repertoireRoots.length > 0
|
|
87
|
+
? repertoireRoots
|
|
88
|
+
: facetsRoots.map(facetsRoot => join(dirname(facetsRoot), 'repertoire'));
|
|
89
|
+
const includeAllowedRoots = [...facetsRoots, ...instructionIncludeRepertoireRoots];
|
|
51
90
|
const personaContent = resolveFacetRefContent({
|
|
52
91
|
ref: definition.persona,
|
|
53
92
|
label: `persona facet "${definition.persona}"`,
|
|
54
93
|
baseDir: definitionDir,
|
|
55
94
|
facetDirs: facetsRoots.map(facetsRoot => join(facetsRoot, 'persona')),
|
|
56
|
-
allowedRoots,
|
|
95
|
+
allowedRoots: facetAllowedRoots,
|
|
96
|
+
resourceAllowedRoots,
|
|
97
|
+
repertoireRoots,
|
|
98
|
+
scopeFacetKind: 'personas',
|
|
57
99
|
});
|
|
58
100
|
const policies = definition.policies?.map(ref => {
|
|
59
101
|
const resolved = resolveFacetRefContent({
|
|
@@ -61,7 +103,10 @@ export function resolveDefinitionSections(params) {
|
|
|
61
103
|
label: `policy facet "${ref}"`,
|
|
62
104
|
baseDir: definitionDir,
|
|
63
105
|
facetDirs: facetsRoots.map(facetsRoot => join(facetsRoot, 'policies')),
|
|
64
|
-
allowedRoots,
|
|
106
|
+
allowedRoots: facetAllowedRoots,
|
|
107
|
+
resourceAllowedRoots,
|
|
108
|
+
repertoireRoots,
|
|
109
|
+
scopeFacetKind: 'policies',
|
|
65
110
|
});
|
|
66
111
|
return { ref, body: resolved.body, path: resolved.path };
|
|
67
112
|
}) ?? [];
|
|
@@ -71,17 +116,50 @@ export function resolveDefinitionSections(params) {
|
|
|
71
116
|
label: `knowledge facet "${ref}"`,
|
|
72
117
|
baseDir: definitionDir,
|
|
73
118
|
facetDirs: facetsRoots.map(facetsRoot => join(facetsRoot, 'knowledge')),
|
|
74
|
-
allowedRoots,
|
|
119
|
+
allowedRoots: facetAllowedRoots,
|
|
120
|
+
resourceAllowedRoots,
|
|
121
|
+
repertoireRoots,
|
|
122
|
+
scopeFacetKind: 'knowledge',
|
|
75
123
|
});
|
|
76
124
|
return { ref, body: resolved.body, path: resolved.path };
|
|
77
125
|
}) ?? [];
|
|
78
126
|
const instructions = definition.instructions?.map(ref => {
|
|
79
|
-
const resolved =
|
|
127
|
+
const resolved = resolveOptionalFacetRefContent({
|
|
80
128
|
ref,
|
|
81
129
|
label: `instruction facet "${ref}"`,
|
|
82
130
|
baseDir: definitionDir,
|
|
83
131
|
facetDirs: facetsRoots.map(facetsRoot => join(facetsRoot, 'instructions')),
|
|
84
|
-
allowedRoots,
|
|
132
|
+
allowedRoots: facetAllowedRoots,
|
|
133
|
+
resourceAllowedRoots,
|
|
134
|
+
repertoireRoots,
|
|
135
|
+
scopeFacetKind: 'instructions',
|
|
136
|
+
});
|
|
137
|
+
if (!resolved) {
|
|
138
|
+
return { ref: 'literal', body: ref };
|
|
139
|
+
}
|
|
140
|
+
const expanded = expandInstructionIncludes({
|
|
141
|
+
body: resolved.body,
|
|
142
|
+
partialDirs: facetsRoots.map(facetsRoot => instructionPartialsDir(facetsRoot)),
|
|
143
|
+
repertoireDirs: instructionIncludeRepertoireRoots,
|
|
144
|
+
allowedRoots: includeAllowedRoots,
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
ref,
|
|
148
|
+
body: expanded.body,
|
|
149
|
+
path: resolved.path,
|
|
150
|
+
sourcePaths: [resolved.path, ...expanded.sourcePaths],
|
|
151
|
+
};
|
|
152
|
+
}) ?? [];
|
|
153
|
+
const outputContracts = definition.outputContracts?.map(ref => {
|
|
154
|
+
const resolved = resolveFacetRefContent({
|
|
155
|
+
ref,
|
|
156
|
+
label: `output-contracts facet "${ref}"`,
|
|
157
|
+
baseDir: definitionDir,
|
|
158
|
+
facetDirs: facetsRoots.map(facetsRoot => join(facetsRoot, 'output-contracts')),
|
|
159
|
+
allowedRoots: facetAllowedRoots,
|
|
160
|
+
resourceAllowedRoots,
|
|
161
|
+
repertoireRoots,
|
|
162
|
+
scopeFacetKind: 'output-contracts',
|
|
85
163
|
});
|
|
86
164
|
return { ref, body: resolved.body, path: resolved.path };
|
|
87
165
|
}) ?? [];
|
|
@@ -94,6 +172,7 @@ export function resolveDefinitionSections(params) {
|
|
|
94
172
|
policies,
|
|
95
173
|
knowledge,
|
|
96
174
|
instructions,
|
|
175
|
+
outputContracts,
|
|
97
176
|
};
|
|
98
177
|
}
|
|
99
178
|
export function listCompositionDefinitions(compositionsDirs) {
|
|
@@ -120,6 +199,9 @@ export function listCompositionDefinitions(compositionsDirs) {
|
|
|
120
199
|
}
|
|
121
200
|
export function buildFacetSet(params) {
|
|
122
201
|
const resolved = resolveDefinitionSections(params);
|
|
202
|
+
return buildFacetSetFromResolvedSections(resolved);
|
|
203
|
+
}
|
|
204
|
+
export function buildFacetSetFromResolvedSections(resolved) {
|
|
123
205
|
return {
|
|
124
206
|
persona: { body: resolved.persona.body, sourcePath: resolved.persona.path },
|
|
125
207
|
policies: resolved.policies.map(policy => ({ body: policy.body, sourcePath: policy.path })),
|
|
@@ -127,6 +209,10 @@ export function buildFacetSet(params) {
|
|
|
127
209
|
instructions: resolved.instructions.map(instruction => 'path' in instruction
|
|
128
210
|
? { body: instruction.body, sourcePath: instruction.path }
|
|
129
211
|
: { body: instruction.body }),
|
|
212
|
+
outputContracts: resolved.outputContracts.map(outputContract => ({
|
|
213
|
+
body: outputContract.body,
|
|
214
|
+
sourcePath: outputContract.path,
|
|
215
|
+
})),
|
|
130
216
|
};
|
|
131
217
|
}
|
|
132
218
|
export function buildSkillSections(params) {
|
|
@@ -138,72 +224,9 @@ export function buildSkillSections(params) {
|
|
|
138
224
|
policies: resolved.policies,
|
|
139
225
|
knowledge: resolved.knowledge,
|
|
140
226
|
instructions: resolved.instructions,
|
|
227
|
+
outputContracts: resolved.outputContracts,
|
|
141
228
|
};
|
|
142
229
|
}
|
|
143
|
-
function makeSkillHeader(definition) {
|
|
144
|
-
const lines = ['---', `name: ${definition.name}`];
|
|
145
|
-
if (definition.description) {
|
|
146
|
-
lines.push(`description: ${definition.description}`);
|
|
147
|
-
}
|
|
148
|
-
lines.push('---');
|
|
149
|
-
return lines.join('\n');
|
|
150
|
-
}
|
|
151
|
-
export function renderSkillFrontmatter(definition) {
|
|
152
|
-
return `${makeSkillHeader(definition)}\n`;
|
|
153
|
-
}
|
|
154
|
-
export function hasYamlFrontmatter(content) {
|
|
155
|
-
return /^---\n[\s\S]*?\n---(?:\n|$)/u.test(content);
|
|
156
|
-
}
|
|
157
|
-
function hasInstructionPath(instruction) {
|
|
158
|
-
return instruction.ref !== 'literal';
|
|
159
|
-
}
|
|
160
|
-
export function renderSkillDocument(input) {
|
|
161
|
-
const lines = [];
|
|
162
|
-
lines.push(makeSkillHeader(input.definition));
|
|
163
|
-
lines.push('');
|
|
164
|
-
lines.push('<!-- Generated by faceted-prompting. Do not edit manually. -->');
|
|
165
|
-
lines.push('');
|
|
166
|
-
lines.push('## Persona');
|
|
167
|
-
lines.push('');
|
|
168
|
-
lines.push(input.mode === 'inline' ? input.persona.body : input.persona.path);
|
|
169
|
-
lines.push('');
|
|
170
|
-
if (input.policies.length > 0) {
|
|
171
|
-
lines.push('## Policies');
|
|
172
|
-
lines.push('');
|
|
173
|
-
for (const policy of input.policies) {
|
|
174
|
-
lines.push(`### ${policy.ref}`);
|
|
175
|
-
lines.push('');
|
|
176
|
-
lines.push(input.mode === 'inline' ? policy.body : policy.path);
|
|
177
|
-
lines.push('');
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (input.knowledge.length > 0) {
|
|
181
|
-
lines.push('## Knowledge');
|
|
182
|
-
lines.push('');
|
|
183
|
-
for (const knowledge of input.knowledge) {
|
|
184
|
-
lines.push(`### ${knowledge.ref}`);
|
|
185
|
-
lines.push('');
|
|
186
|
-
lines.push(input.mode === 'inline' ? knowledge.body : knowledge.path);
|
|
187
|
-
lines.push('');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (input.instructions.length > 0) {
|
|
191
|
-
lines.push('## Instructions');
|
|
192
|
-
lines.push('');
|
|
193
|
-
for (const instruction of input.instructions) {
|
|
194
|
-
if (input.mode === 'reference' && hasInstructionPath(instruction)) {
|
|
195
|
-
lines.push(`### ${instruction.ref}`);
|
|
196
|
-
lines.push('');
|
|
197
|
-
lines.push(instruction.path);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
lines.push(instruction.body);
|
|
201
|
-
}
|
|
202
|
-
lines.push('');
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return `${lines.join('\n').trimEnd()}\n`;
|
|
206
|
-
}
|
|
207
230
|
export function resolveDefinitionPathFromSource(source, compositionsDir) {
|
|
208
231
|
return ensurePathWithinRoots(join(compositionsDir, source), [compositionsDir], `compose definition "${source}"`);
|
|
209
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-renderer.js","sourceRoot":"","sources":["../../src/cli/skill-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"skill-renderer.js","sourceRoot":"","sources":["../../src/cli/skill-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,q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AAO;QACL,UAAU;QACV,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,eAAe,EAAE,QAAQ,CAAC,eAAe;KAC1C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,MAAc,EAAE,eAAuB;IACrF,OAAO,qBAAqB,CAC1B,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,EAC7B,CAAC,eAAe,CAAC,EACjB,uBAAuB,MAAM,GAAG,CACjC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ComposeDefinition } from '../types.js';
|
|
2
2
|
export type SkillMode = 'inline' | 'reference';
|
|
3
|
-
export type InstallTarget = 'cc' | 'codex';
|
|
4
3
|
export interface FacetRefContent {
|
|
5
4
|
readonly body: string;
|
|
6
5
|
readonly path: string;
|
|
@@ -10,7 +9,10 @@ export interface SkillSection {
|
|
|
10
9
|
readonly body: string;
|
|
11
10
|
readonly path: string;
|
|
12
11
|
}
|
|
13
|
-
export
|
|
12
|
+
export interface FileInstructionSection extends SkillSection {
|
|
13
|
+
readonly sourcePaths: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export type InstructionSection = FileInstructionSection | {
|
|
14
16
|
readonly ref: 'literal';
|
|
15
17
|
readonly body: string;
|
|
16
18
|
};
|
|
@@ -21,11 +23,13 @@ export interface SkillDocumentInput {
|
|
|
21
23
|
readonly policies: readonly SkillSection[];
|
|
22
24
|
readonly knowledge: readonly SkillSection[];
|
|
23
25
|
readonly instructions: readonly InstructionSection[];
|
|
26
|
+
readonly outputContracts: readonly SkillSection[];
|
|
24
27
|
}
|
|
25
28
|
export interface ResolvedDefinitionSections {
|
|
26
29
|
readonly persona: SkillSection;
|
|
27
30
|
readonly policies: readonly SkillSection[];
|
|
28
31
|
readonly knowledge: readonly SkillSection[];
|
|
29
32
|
readonly instructions: readonly InstructionSection[];
|
|
33
|
+
readonly outputContracts: readonly SkillSection[];
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=skill-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-types.d.ts","sourceRoot":"","sources":["../../src/cli/skill-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"skill-types.d.ts","sourceRoot":"","sources":["../../src/cli/skill-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7G,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrD,QAAQ,CAAC,eAAe,EAAE,SAAS,YAAY,EAAE,CAAC;CACnD;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrD,QAAQ,CAAC,eAAe,EAAE,SAAS,YAAY,EAAE,CAAC;CACnD"}
|
package/dist/cli/types.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export interface FacetCliOptions {
|
|
|
4
4
|
readonly select: (candidates: string[], prompt?: string) => Promise<string>;
|
|
5
5
|
readonly input: (prompt: string, defaultValue: string) => Promise<string>;
|
|
6
6
|
}
|
|
7
|
+
export interface ComposeCliOptions {
|
|
8
|
+
readonly composition?: string;
|
|
9
|
+
readonly outputMode?: 'split' | 'combined';
|
|
10
|
+
readonly output?: string;
|
|
11
|
+
readonly overwrite?: boolean;
|
|
12
|
+
}
|
|
7
13
|
export type FacetCliResult = {
|
|
8
14
|
readonly kind: 'path';
|
|
9
15
|
readonly path: string;
|
package/dist/cli/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,UAAU,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AAM,MAAM,cAAc,GACtB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-definition.d.ts","sourceRoot":"","sources":["../src/compose-definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compose-definition.d.ts","sourceRoot":"","sources":["../src/compose-definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAC;AAuFvE,wBAAsB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2B9F"}
|
|
@@ -8,9 +8,10 @@ const ALLOWED_COMPOSE_KEYS = new Set([
|
|
|
8
8
|
'knowledge',
|
|
9
9
|
'policies',
|
|
10
10
|
'instructions',
|
|
11
|
+
'output-contracts',
|
|
11
12
|
'order',
|
|
12
13
|
]);
|
|
13
|
-
const ORDER_VALUES = new Set(['persona', 'knowledge', 'policies', 'instructions']);
|
|
14
|
+
const ORDER_VALUES = new Set(['persona', 'knowledge', 'policies', 'instructions', 'output-contracts']);
|
|
14
15
|
function normalizeOrder(rawOrder) {
|
|
15
16
|
if (!rawOrder)
|
|
16
17
|
return undefined;
|
|
@@ -89,6 +90,7 @@ export async function loadComposeDefinition(definitionPath) {
|
|
|
89
90
|
const instructions = normalizeInstructions(parsed);
|
|
90
91
|
const knowledge = ensureStringList(parsed.knowledge, 'knowledge');
|
|
91
92
|
const policies = ensureStringList(parsed.policies, 'policies');
|
|
93
|
+
const outputContracts = ensureStringList(parsed['output-contracts'], 'output-contracts');
|
|
92
94
|
const rawOrder = ensureStringList(parsed.order, 'order');
|
|
93
95
|
const order = normalizeOrder(rawOrder);
|
|
94
96
|
return {
|
|
@@ -99,6 +101,7 @@ export async function loadComposeDefinition(definitionPath) {
|
|
|
99
101
|
knowledge: knowledge && knowledge.length > 0 ? knowledge : undefined,
|
|
100
102
|
policies: policies && policies.length > 0 ? policies : undefined,
|
|
101
103
|
instructions: instructions && instructions.length > 0 ? instructions : undefined,
|
|
104
|
+
outputContracts: outputContracts && outputContracts.length > 0 ? outputContracts : undefined,
|
|
102
105
|
order,
|
|
103
106
|
};
|
|
104
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-definition.js","sourceRoot":"","sources":["../src/compose-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM;IACN,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,UAAU;IACV,cAAc;IACd,OAAO;CACR,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"compose-definition.js","sourceRoot":"","sources":["../src/compose-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM;IACN,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,UAAU;IACV,cAAc;IACd,kBA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CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEvC,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC;QAC5C,OAAO;QACP,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;QACtC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACpE,QAAQ,EAAE,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QAChE,YAAY,EAAE,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QAChF,eAAe,EAAE,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;QAC5F,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/compose.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Facet composition — the core placement rule.
|
|
3
3
|
*
|
|
4
4
|
* system prompt: persona only (WHO)
|
|
5
|
-
* user message: knowledge + instructions +
|
|
5
|
+
* user message: knowledge + instructions + output-contracts + policies
|
|
6
|
+
* (WHAT TO KNOW / WHAT TO DO / HOW TO ANSWER / HOW)
|
|
6
7
|
*
|
|
7
8
|
* This module has ZERO dependencies on TAKT internals.
|
|
8
9
|
*/
|
|
@@ -12,7 +13,7 @@ import type { FacetSet, ComposedPrompt, ComposeOptions } from './types.js';
|
|
|
12
13
|
* placement rules.
|
|
13
14
|
*
|
|
14
15
|
* - persona → systemPrompt
|
|
15
|
-
* - knowledge / instructions / policies → userMessage
|
|
16
|
+
* - knowledge / instructions / output-contracts / policies → userMessage
|
|
16
17
|
*
|
|
17
18
|
* Policies are placed last so they serve as the most recent constraint
|
|
18
19
|
* the model sees before generating output.
|
package/dist/compose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAqB,MAAM,YAAY,CAAC;AAiC9F;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,GAAG,cAAc,CASjF"}
|
package/dist/compose.js
CHANGED
|
@@ -2,54 +2,51 @@
|
|
|
2
2
|
* Facet composition — the core placement rule.
|
|
3
3
|
*
|
|
4
4
|
* system prompt: persona only (WHO)
|
|
5
|
-
* user message: knowledge + instructions +
|
|
5
|
+
* user message: knowledge + instructions + output-contracts + policies
|
|
6
|
+
* (WHAT TO KNOW / WHAT TO DO / HOW TO ANSWER / HOW)
|
|
6
7
|
*
|
|
7
8
|
* This module has ZERO dependencies on TAKT internals.
|
|
8
9
|
*/
|
|
10
|
+
import { DEFAULT_USER_MESSAGE_ORDER } from './types.js';
|
|
9
11
|
import { prepareKnowledgeContent, preparePolicyContent } from './truncation.js';
|
|
12
|
+
function renderOrderedUserPart(entry, facets, contextMaxChars) {
|
|
13
|
+
if (entry === 'policies') {
|
|
14
|
+
if (!facets.policies || facets.policies.length === 0)
|
|
15
|
+
return [];
|
|
16
|
+
const joined = facets.policies.map(p => p.body).join('\n\n---\n\n');
|
|
17
|
+
const sourcePath = facets.policies.length === 1
|
|
18
|
+
? facets.policies[0].sourcePath
|
|
19
|
+
: undefined;
|
|
20
|
+
return [preparePolicyContent(joined, contextMaxChars, sourcePath)];
|
|
21
|
+
}
|
|
22
|
+
if (entry === 'knowledge') {
|
|
23
|
+
if (!facets.knowledge || facets.knowledge.length === 0)
|
|
24
|
+
return [];
|
|
25
|
+
const joined = facets.knowledge.map(k => k.body).join('\n\n---\n\n');
|
|
26
|
+
const sourcePath = facets.knowledge.length === 1
|
|
27
|
+
? facets.knowledge[0].sourcePath
|
|
28
|
+
: undefined;
|
|
29
|
+
return [prepareKnowledgeContent(joined, contextMaxChars, sourcePath)];
|
|
30
|
+
}
|
|
31
|
+
if (entry === 'instructions') {
|
|
32
|
+
return facets.instructions?.map(instruction => instruction.body) ?? [];
|
|
33
|
+
}
|
|
34
|
+
return facets.outputContracts?.map(outputContract => outputContract.body) ?? [];
|
|
35
|
+
}
|
|
10
36
|
/**
|
|
11
37
|
* Compose facets into an LLM-ready prompt according to Faceted Prompting
|
|
12
38
|
* placement rules.
|
|
13
39
|
*
|
|
14
40
|
* - persona → systemPrompt
|
|
15
|
-
* - knowledge / instructions / policies → userMessage
|
|
41
|
+
* - knowledge / instructions / output-contracts / policies → userMessage
|
|
16
42
|
*
|
|
17
43
|
* Policies are placed last so they serve as the most recent constraint
|
|
18
44
|
* the model sees before generating output.
|
|
19
45
|
*/
|
|
20
46
|
export function compose(facets, options) {
|
|
21
47
|
const systemPrompt = facets.persona?.body ?? '';
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
for (const entry of order) {
|
|
25
|
-
if (entry === 'policies') {
|
|
26
|
-
if (!facets.policies || facets.policies.length === 0)
|
|
27
|
-
continue;
|
|
28
|
-
const joined = facets.policies.map(p => p.body).join('\n\n---\n\n');
|
|
29
|
-
const sourcePath = facets.policies.length === 1
|
|
30
|
-
? facets.policies[0].sourcePath
|
|
31
|
-
: undefined;
|
|
32
|
-
userParts.push(preparePolicyContent(joined, options.contextMaxChars, sourcePath));
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (entry === 'knowledge') {
|
|
36
|
-
if (!facets.knowledge || facets.knowledge.length === 0)
|
|
37
|
-
continue;
|
|
38
|
-
const joined = facets.knowledge.map(k => k.body).join('\n\n---\n\n');
|
|
39
|
-
const sourcePath = facets.knowledge.length === 1
|
|
40
|
-
? facets.knowledge[0].sourcePath
|
|
41
|
-
: undefined;
|
|
42
|
-
userParts.push(prepareKnowledgeContent(joined, options.contextMaxChars, sourcePath));
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (entry === 'instructions') {
|
|
46
|
-
if (!facets.instructions || facets.instructions.length === 0)
|
|
47
|
-
continue;
|
|
48
|
-
for (const instruction of facets.instructions) {
|
|
49
|
-
userParts.push(instruction.body);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
48
|
+
const order = options.userMessageOrder ?? DEFAULT_USER_MESSAGE_ORDER;
|
|
49
|
+
const userParts = order.flatMap(entry => renderOrderedUserPart(entry, facets, options.contextMaxChars));
|
|
53
50
|
return {
|
|
54
51
|
systemPrompt,
|
|
55
52
|
userMessage: userParts.join('\n\n'),
|
package/dist/compose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,SAAS,qBAAqB,CAC5B,KAAwB,EACxB,MAAgB,EAChB,eAAuB;IAEvB,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAChE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,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uB;IAC/D,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IACrE,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAExG,OAAO;QACL,YAAY;QACZ,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
export interface CodexInstallTargetConfig {
|
|
2
|
+
readonly roots: readonly string[];
|
|
3
|
+
}
|
|
4
|
+
export interface InstallTargetsConfig {
|
|
5
|
+
readonly codex: CodexInstallTargetConfig;
|
|
6
|
+
}
|
|
7
|
+
export interface InstallConfig {
|
|
8
|
+
readonly targets: InstallTargetsConfig;
|
|
9
|
+
}
|
|
1
10
|
export interface FacetedConfig {
|
|
2
11
|
readonly version: number;
|
|
3
12
|
readonly skillPaths?: readonly string[];
|
|
13
|
+
readonly install: InstallConfig;
|
|
4
14
|
}
|
|
5
15
|
export declare function getFacetedRoot(homeDir: string): string;
|
|
6
16
|
export declare function getConfigPath(homeDir: string): string;
|
|
7
17
|
export declare function ensureConfigFile(homeDir: string): void;
|
|
18
|
+
export declare function createDefaultFacetedConfig(): FacetedConfig;
|
|
19
|
+
export declare function readFacetedConfigOrDefault(homeDir: string): Promise<FacetedConfig>;
|
|
8
20
|
export declare function readFacetedConfig(homeDir: string): Promise<FacetedConfig>;
|
|
9
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC;AAID,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAQtD;AAsBD,wBAAgB,0BAA0B,IAAI,aAAa,CAY1D;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAOxF;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAuE/E"}
|