faceted-prompting 0.3.0 → 0.4.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 +11 -6
- 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 +15 -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 +18 -0
- package/dist/cli/compose-execution.d.ts.map +1 -0
- package/dist/cli/compose-execution.js +165 -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/facets.d.ts +2 -2
- package/dist/cli/install-skill/facets.d.ts.map +1 -1
- package/dist/cli/install-skill/facets.js +30 -19
- package/dist/cli/install-skill/facets.js.map +1 -1
- package/dist/cli/install-skill/flow.d.ts +3 -2
- package/dist/cli/install-skill/flow.d.ts.map +1 -1
- package/dist/cli/install-skill/flow.js +22 -6
- package/dist/cli/install-skill/flow.js.map +1 -1
- 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 +21 -20
- 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/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 +33 -11
- package/dist/cli/skill-commands.js.map +1 -1
- 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.map +1 -1
- package/dist/cli/skill-renderer.js +27 -38
- package/dist/cli/skill-renderer.js.map +1 -1
- package/dist/cli/skill-types.d.ts +2 -3
- 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 +10 -4
- package/dist/compose-definition.js.map +1 -1
- package/dist/compose.d.ts +5 -2
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +12 -5
- 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/init/index.d.ts.map +1 -1
- package/dist/init/index.js +7 -3
- 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/prompt-payload.d.ts.map +1 -1
- package/dist/prompt-payload.js +3 -1
- package/dist/prompt-payload.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,13 +51,13 @@ const result = compose(
|
|
|
51
51
|
persona: { body: 'You are a senior TypeScript developer.' },
|
|
52
52
|
policies: [{ body: 'Follow clean code principles. No any types.' }],
|
|
53
53
|
knowledge: [{ body: 'The project uses Vitest for testing.' }],
|
|
54
|
-
|
|
54
|
+
instructions: [{ body: 'Implement a retry function with exponential backoff.' }],
|
|
55
55
|
},
|
|
56
56
|
{ contextMaxChars: 8000 },
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
// result.systemPrompt → "You are a senior TypeScript developer."
|
|
60
|
-
// result.userMessage →
|
|
60
|
+
// result.userMessage → knowledge + instructions + policies (in order)
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
### As a CLI
|
|
@@ -88,6 +88,7 @@ facet install skill
|
|
|
88
88
|
│ ├── persona/
|
|
89
89
|
│ ├── knowledge/
|
|
90
90
|
│ ├── policies/
|
|
91
|
+
│ ├── instructions/
|
|
91
92
|
│ └── compositions/
|
|
92
93
|
└── templates/
|
|
93
94
|
|
|
@@ -97,6 +98,7 @@ facet install skill
|
|
|
97
98
|
│ ├── persona/ # Persona Markdown files
|
|
98
99
|
│ ├── knowledge/ # Domain knowledge files
|
|
99
100
|
│ ├── policies/ # Policy/rules files
|
|
101
|
+
│ ├── instructions/ # Instruction files
|
|
100
102
|
│ └── compositions/ # Compose definition YAML files
|
|
101
103
|
└── templates/ # Skill templates
|
|
102
104
|
```
|
|
@@ -125,16 +127,17 @@ knowledge:
|
|
|
125
127
|
- architecture
|
|
126
128
|
policies:
|
|
127
129
|
- quality
|
|
128
|
-
|
|
130
|
+
instructions:
|
|
131
|
+
- release-summary
|
|
129
132
|
order:
|
|
130
133
|
- knowledge
|
|
134
|
+
- instructions
|
|
131
135
|
- policies
|
|
132
|
-
- instruction
|
|
133
136
|
```
|
|
134
137
|
|
|
135
138
|
- `name` and `persona` are required.
|
|
136
|
-
- `order` controls user-message section order (default: `
|
|
137
|
-
- `
|
|
139
|
+
- `order` controls user-message section order (default: `knowledge` → `instructions` → `policies`).
|
|
140
|
+
- `instructions` is a list of facet names, file paths, or inline text.
|
|
138
141
|
|
|
139
142
|
## Scope References
|
|
140
143
|
|
|
@@ -201,6 +204,7 @@ See the [API Reference](./docs/api-reference.md) for the full API surface.
|
|
|
201
204
|
│ ├── persona/
|
|
202
205
|
│ ├── knowledge/
|
|
203
206
|
│ ├── policies/
|
|
207
|
+
│ ├── instructions/
|
|
204
208
|
│ └── compositions/
|
|
205
209
|
└── templates/
|
|
206
210
|
|
|
@@ -210,6 +214,7 @@ See the [API Reference](./docs/api-reference.md) for the full API surface.
|
|
|
210
214
|
│ ├── persona/
|
|
211
215
|
│ ├── knowledge/
|
|
212
216
|
│ ├── policies/
|
|
217
|
+
│ ├── instructions/
|
|
213
218
|
│ └── compositions/
|
|
214
219
|
├── templates/ # Skill install templates
|
|
215
220
|
└── repertoire/ # Installed repertoire packages
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { FacetCliOptions, FacetCliResult } from './types.js';
|
|
2
|
-
export declare function runComposeCommand(options: FacetCliOptions): Promise<FacetCliResult>;
|
|
1
|
+
import type { ComposeCliOptions, FacetCliOptions, FacetCliResult } from './types.js';
|
|
2
|
+
export declare function runComposeCommand(options: FacetCliOptions, composeOptions: ComposeCliOptions): Promise<FacetCliResult>;
|
|
3
3
|
//# sourceMappingURL=compose-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-command.d.ts","sourceRoot":"","sources":["../../src/cli/compose-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compose-command.d.ts","sourceRoot":"","sources":["../../src/cli/compose-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErF,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,cAAc,EAAE,iBAAiB,GAChC,OAAO,CAAC,cAAc,CAAC,CAwBzB"}
|
|
@@ -1,156 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { formatCombinedOutput, resolveOutputDirectory, writeComposeOutput } from '../output/index.js';
|
|
6
|
-
import { buildFacetSet, buildSkillSections, ensureSafeDefinitionName, } from './skill-renderer.js';
|
|
7
|
-
import { getSkillPaths, selectCompositionDefinitionPath, } from './skill-commands.js';
|
|
8
|
-
import { collectDirectoryFiles, copyDirectoryTree, ensureTemplateDirectoryFromRoots, shouldOverwrite, } from './install-skill/flow.js';
|
|
9
|
-
import { applyFacetTokensToFiles, buildInlineFacetTokenValues } from './install-skill/facets.js';
|
|
10
|
-
import { ensurePathAncestorsContainNoSymbolicLinks, ensurePathIsNotSymbolicLink } from './path-guard.js';
|
|
11
|
-
function buildComposeOutputPlans(params) {
|
|
12
|
-
if (params.splitSystem) {
|
|
13
|
-
return [
|
|
14
|
-
{
|
|
15
|
-
fileName: `${params.safeName}.system.md`,
|
|
16
|
-
content: `${params.systemPrompt}\n`,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
fileName: `${params.safeName}.user.md`,
|
|
20
|
-
content: `${params.userMessage}\n`,
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
fileName: `${params.safeName}.md`,
|
|
27
|
-
content: formatCombinedOutput({
|
|
28
|
-
systemPrompt: params.systemPrompt,
|
|
29
|
-
userMessage: params.userMessage,
|
|
30
|
-
}),
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
async function confirmOverwriteForExistingPaths(params) {
|
|
35
|
-
if (params.existingPaths.length === 0) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const overwriteAnswer = await params.options.input(`${params.promptMessage} (${params.existingPaths.join(', ')}) [y/N]`, 'n');
|
|
39
|
-
if (!shouldOverwrite(overwriteAnswer)) {
|
|
40
|
-
throw new Error(`${params.cancelMessage}: ${params.existingPaths.join(', ')}`);
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
async function runTemplateBackedCompose(params) {
|
|
45
|
-
const templateName = params.definition.template;
|
|
46
|
-
if (!templateName) {
|
|
47
|
-
throw new Error(`Template-backed compose requires template: ${params.definition.name}`);
|
|
48
|
-
}
|
|
49
|
-
const templateDir = ensureTemplateDirectoryFromRoots(params.facetedRoots, templateName);
|
|
50
|
-
const outputInput = await params.options.input('Output directory', params.options.cwd);
|
|
51
|
-
const outputDir = resolveOutputDirectory(outputInput, params.options.cwd);
|
|
52
|
-
ensurePathIsNotSymbolicLink(outputDir, 'Output directory');
|
|
53
|
-
ensurePathAncestorsContainNoSymbolicLinks(outputDir, 'Output directory', params.options.cwd);
|
|
54
|
-
mkdirSync(outputDir, { recursive: true });
|
|
55
|
-
const templateRelativePaths = collectDirectoryFiles(templateDir);
|
|
56
|
-
const templateOutputPaths = templateRelativePaths.map(relativePath => resolve(outputDir, relativePath));
|
|
57
|
-
await confirmOverwriteForExistingPaths({
|
|
58
|
-
options: params.options,
|
|
59
|
-
existingPaths: templateOutputPaths.filter(path => existsSync(path)),
|
|
60
|
-
promptMessage: 'Output files exist. Overwrite?',
|
|
61
|
-
cancelMessage: 'Output files exist and overwrite was cancelled',
|
|
62
|
-
});
|
|
63
|
-
copyDirectoryTree(templateDir, outputDir);
|
|
64
|
-
const sections = buildSkillSections({
|
|
65
|
-
definition: params.definition,
|
|
66
|
-
definitionDir: dirname(params.definitionPath),
|
|
67
|
-
facetsRoots: params.facetsRoots,
|
|
68
|
-
});
|
|
69
|
-
applyFacetTokensToFiles({
|
|
70
|
-
filePaths: templateOutputPaths.filter(path => existsSync(path)),
|
|
71
|
-
tokenValues: buildInlineFacetTokenValues(sections),
|
|
72
|
-
rootDir: outputDir,
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
kind: 'path',
|
|
76
|
-
path: outputDir,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async function runStandardCompose(params) {
|
|
80
|
-
const safeName = ensureSafeDefinitionName(params.definition.name);
|
|
81
|
-
const facetSet = buildFacetSet({
|
|
82
|
-
definitionDir: dirname(params.definitionPath),
|
|
83
|
-
facetsRoots: params.facetsRoots,
|
|
84
|
-
definition: params.definition,
|
|
85
|
-
});
|
|
86
|
-
const composed = compose(facetSet, {
|
|
87
|
-
contextMaxChars: 2000,
|
|
88
|
-
userMessageOrder: params.definition.order,
|
|
89
|
-
});
|
|
90
|
-
const splitSelection = await params.options.select(['Combined (single file)', 'Split (system + user)'], 'Choose output mode with Up/Down and Enter:');
|
|
91
|
-
const outputPlans = buildComposeOutputPlans({
|
|
92
|
-
safeName,
|
|
93
|
-
systemPrompt: composed.systemPrompt,
|
|
94
|
-
userMessage: composed.userMessage,
|
|
95
|
-
splitSystem: splitSelection === 'Split (system + user)',
|
|
96
|
-
});
|
|
97
|
-
const outputInput = await params.options.input('Output directory', params.options.cwd);
|
|
98
|
-
const outputDir = resolveOutputDirectory(outputInput, params.options.cwd);
|
|
99
|
-
const existingPaths = outputPlans
|
|
100
|
-
.map(plan => resolve(outputDir, plan.fileName))
|
|
101
|
-
.filter(path => existsSync(path));
|
|
102
|
-
const overwrite = await confirmOverwriteForExistingPaths({
|
|
103
|
-
options: params.options,
|
|
104
|
-
existingPaths,
|
|
105
|
-
promptMessage: 'Output file exists. Overwrite?',
|
|
106
|
-
cancelMessage: 'Output file exists and overwrite was cancelled',
|
|
107
|
-
});
|
|
108
|
-
const outputPaths = [];
|
|
109
|
-
for (const plan of outputPlans) {
|
|
110
|
-
outputPaths.push(await writeComposeOutput({
|
|
111
|
-
outputDir,
|
|
112
|
-
fileName: plan.fileName,
|
|
113
|
-
content: plan.content,
|
|
114
|
-
overwrite,
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
if (outputPaths.length === 1) {
|
|
118
|
-
return {
|
|
119
|
-
kind: 'path',
|
|
120
|
-
path: outputPaths[0],
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
kind: 'paths',
|
|
125
|
-
paths: outputPaths,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export async function runComposeCommand(options) {
|
|
129
|
-
const { facetedRoots, facetsRoots, compositionsDirs } = getSkillPaths(options.cwd, options.homeDir);
|
|
130
|
-
const localCompositionsDir = facetedRoots.length > 1 ? resolve(facetedRoots[0], 'compositions') : undefined;
|
|
131
|
-
const globalCompositionsDir = resolve(facetedRoots[facetedRoots.length - 1], 'compositions');
|
|
132
|
-
const { definitionPath } = await selectCompositionDefinitionPath({
|
|
1
|
+
import { resolveComposeDefinition } from './compose-definition-resolution.js';
|
|
2
|
+
import { runStandardCompose, runTemplateBackedCompose } from './compose-execution.js';
|
|
3
|
+
export async function runComposeCommand(options, composeOptions) {
|
|
4
|
+
const resolved = await resolveComposeDefinition({
|
|
133
5
|
options,
|
|
134
|
-
|
|
135
|
-
localCompositionsDir,
|
|
136
|
-
globalCompositionsDir,
|
|
137
|
-
cancelAction: 'Compose',
|
|
6
|
+
composeOptions,
|
|
138
7
|
});
|
|
139
|
-
|
|
140
|
-
if (definition.template) {
|
|
8
|
+
if (resolved.definition.template) {
|
|
141
9
|
return runTemplateBackedCompose({
|
|
142
10
|
options,
|
|
143
|
-
facetedRoots,
|
|
144
|
-
facetsRoots,
|
|
145
|
-
definitionPath,
|
|
146
|
-
definition,
|
|
11
|
+
facetedRoots: resolved.facetedRoots,
|
|
12
|
+
facetsRoots: resolved.facetsRoots,
|
|
13
|
+
definitionPath: resolved.definitionPath,
|
|
14
|
+
definition: resolved.definition,
|
|
15
|
+
composeOptions,
|
|
147
16
|
});
|
|
148
17
|
}
|
|
149
18
|
return runStandardCompose({
|
|
150
19
|
options,
|
|
151
|
-
facetsRoots,
|
|
152
|
-
definitionPath,
|
|
153
|
-
definition,
|
|
20
|
+
facetsRoots: resolved.facetsRoots,
|
|
21
|
+
definitionPath: resolved.definitionPath,
|
|
22
|
+
definition: resolved.definition,
|
|
23
|
+
composeOptions,
|
|
154
24
|
});
|
|
155
25
|
}
|
|
156
26
|
//# sourceMappingURL=compose-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-command.js","sourceRoot":"","sources":["../../src/cli/compose-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"compose-command.js","sourceRoot":"","sources":["../../src/cli/compose-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGtF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAwB,EACxB,cAAiC;IAEjC,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC;QAC9C,OAAO;QACP,cAAc;KACf,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,wBAAwB,CAAC;YAC9B,OAAO;YACP,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,OAAO,kBAAkB,CAAC;QACxB,OAAO;QACP,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,cAAc;KACf,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComposeDefinition } from '../types.js';
|
|
2
|
+
import type { ComposeCliOptions, FacetCliOptions } from './types.js';
|
|
3
|
+
export declare function resolveComposeDefinition(params: {
|
|
4
|
+
options: FacetCliOptions;
|
|
5
|
+
composeOptions: ComposeCliOptions;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
facetedRoots: readonly string[];
|
|
8
|
+
facetsRoots: readonly string[];
|
|
9
|
+
definitionPath: string;
|
|
10
|
+
definition: ComposeDefinition;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=compose-definition-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-definition-resolution.d.ts","sourceRoot":"","sources":["../../src/cli/compose-definition-resolution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA0BrE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,iBAAiB,CAAC;CACnC,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC,CAqCD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { loadComposeDefinition } from '../compose-definition.js';
|
|
2
|
+
import { isNonInteractiveMode } from './compose-options.js';
|
|
3
|
+
import { getSkillPaths, resolveCompositionDefinitionPathByName, selectCompositionDefinitionPath } from './skill-commands.js';
|
|
4
|
+
function requireCompositionName(composeOptions) {
|
|
5
|
+
if (!composeOptions.composition) {
|
|
6
|
+
throw new Error('Non-interactive compose requires --composition');
|
|
7
|
+
}
|
|
8
|
+
return composeOptions.composition;
|
|
9
|
+
}
|
|
10
|
+
function validateNonInteractiveComposeOptions(params) {
|
|
11
|
+
if (params.definition.template) {
|
|
12
|
+
if (params.composeOptions.outputMode) {
|
|
13
|
+
throw new Error('Template-backed compose does not support --split or --combined');
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!params.composeOptions.outputMode) {
|
|
18
|
+
throw new Error('Non-interactive standard compose requires --split or --combined');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function resolveComposeDefinition(params) {
|
|
22
|
+
const { facetedRoots, facetsRoots, compositionsDirs, localCompositionsDir, globalCompositionsDir, } = getSkillPaths(params.options.cwd, params.options.homeDir);
|
|
23
|
+
const nonInteractive = isNonInteractiveMode(params.composeOptions);
|
|
24
|
+
const definitionPath = nonInteractive
|
|
25
|
+
? resolveCompositionDefinitionPathByName({
|
|
26
|
+
compositionName: requireCompositionName(params.composeOptions),
|
|
27
|
+
compositionDefinitionDirs: compositionsDirs,
|
|
28
|
+
}).definitionPath
|
|
29
|
+
: (await selectCompositionDefinitionPath({
|
|
30
|
+
options: params.options,
|
|
31
|
+
compositionDefinitionDirs: compositionsDirs,
|
|
32
|
+
localCompositionsDir,
|
|
33
|
+
globalCompositionsDir,
|
|
34
|
+
cancelAction: 'Compose',
|
|
35
|
+
})).definitionPath;
|
|
36
|
+
const definition = await loadComposeDefinition(definitionPath);
|
|
37
|
+
if (nonInteractive) {
|
|
38
|
+
validateNonInteractiveComposeOptions({
|
|
39
|
+
composeOptions: params.composeOptions,
|
|
40
|
+
definition,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
facetedRoots,
|
|
45
|
+
facetsRoots,
|
|
46
|
+
definitionPath,
|
|
47
|
+
definition,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=compose-definition-resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-definition-resolution.js","sourceRoot":"","sources":["../../src/cli/compose-definition-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,oBAAoB,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AAE,gBAAgB;YAC3C,oBAAoB;YACpB,qBAAqB;YACrB,YAAY,EAAE,SAAS;SACxB,CAAC,CAAC,CAAC,cAAc,CAAC;IAErB,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAC/D,IAAI,cAAc,EAAE,CAAC;QACnB,oCAAoC,CAAC;YACnC,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,YAAY;QACZ,WAAW;QACX,cAAc;QACd,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComposeDefinition } from '../types.js';
|
|
2
|
+
import type { ComposeCliOptions, FacetCliOptions, FacetCliResult } from './types.js';
|
|
3
|
+
export declare function runTemplateBackedCompose(params: {
|
|
4
|
+
options: FacetCliOptions;
|
|
5
|
+
facetedRoots: readonly string[];
|
|
6
|
+
facetsRoots: readonly string[];
|
|
7
|
+
definitionPath: string;
|
|
8
|
+
definition: ComposeDefinition;
|
|
9
|
+
composeOptions: ComposeCliOptions;
|
|
10
|
+
}): Promise<FacetCliResult>;
|
|
11
|
+
export declare function runStandardCompose(params: {
|
|
12
|
+
options: FacetCliOptions;
|
|
13
|
+
facetsRoots: readonly string[];
|
|
14
|
+
definitionPath: string;
|
|
15
|
+
definition: ComposeDefinition;
|
|
16
|
+
composeOptions: ComposeCliOptions;
|
|
17
|
+
}): Promise<FacetCliResult>;
|
|
18
|
+
//# sourceMappingURL=compose-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-execution.d.ts","sourceRoot":"","sources":["../../src/cli/compose-execution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuFrF,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,cAAc,EAAE,iBAAiB,CAAC;CACnC,GAAG,OAAO,CAAC,cAAc,CAAC,CAkD1B;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,cAAc,EAAE,iBAAiB,CAAC;CACnC,GAAG,OAAO,CAAC,cAAc,CAAC,CAsE1B"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { compose } from '../compose.js';
|
|
4
|
+
import { formatCombinedOutput, resolveOutputDirectory, writeComposeOutput } from '../output/index.js';
|
|
5
|
+
import { isNonInteractiveMode } from './compose-options.js';
|
|
6
|
+
import { buildFacetSet, buildSkillSections, ensureSafeDefinitionName, } from './skill-renderer.js';
|
|
7
|
+
import { collectDirectoryFiles, copyDirectoryTree, ensureTemplateDirectoryFromRoots, shouldOverwrite, } from './install-skill/flow.js';
|
|
8
|
+
import { applyFacetTokensToFiles, buildInlineFacetTokenValues } from './install-skill/facets.js';
|
|
9
|
+
import { ensurePathAncestorsContainNoSymbolicLinks, ensurePathIsNotSymbolicLink } from './path-guard.js';
|
|
10
|
+
function buildComposeOutputPlans(params) {
|
|
11
|
+
if (params.splitSystem) {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
fileName: `${params.safeName}.system.md`,
|
|
15
|
+
content: `${params.systemPrompt}\n`,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
fileName: `${params.safeName}.user.md`,
|
|
19
|
+
content: `${params.userMessage}\n`,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
fileName: `${params.safeName}.md`,
|
|
26
|
+
content: formatCombinedOutput({
|
|
27
|
+
systemPrompt: params.systemPrompt,
|
|
28
|
+
userMessage: params.userMessage,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
async function confirmOverwriteForExistingPaths(params) {
|
|
34
|
+
if (params.existingPaths.length === 0) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const overwriteAnswer = await params.options.input(`${params.promptMessage} (${params.existingPaths.join(', ')}) [y/N]`, 'n');
|
|
38
|
+
if (!shouldOverwrite(overwriteAnswer)) {
|
|
39
|
+
throw new Error(`${params.cancelMessage}: ${params.existingPaths.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
function resolveOutputDir(params) {
|
|
44
|
+
const outputDir = resolveOutputDirectory(params.output, params.cwd);
|
|
45
|
+
ensurePathIsNotSymbolicLink(outputDir, 'Output directory');
|
|
46
|
+
ensurePathAncestorsContainNoSymbolicLinks(outputDir, 'Output directory', params.cwd);
|
|
47
|
+
mkdirSync(outputDir, { recursive: true });
|
|
48
|
+
return outputDir;
|
|
49
|
+
}
|
|
50
|
+
async function resolveComposeOutputDir(params) {
|
|
51
|
+
const outputInput = params.composeOptions.output ?? (isNonInteractiveMode(params.composeOptions)
|
|
52
|
+
? params.options.cwd
|
|
53
|
+
: await params.options.input('Output directory', params.options.cwd));
|
|
54
|
+
return resolveOutputDir({
|
|
55
|
+
output: outputInput,
|
|
56
|
+
cwd: params.options.cwd,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export async function runTemplateBackedCompose(params) {
|
|
60
|
+
const templateName = params.definition.template;
|
|
61
|
+
if (!templateName) {
|
|
62
|
+
throw new Error(`Template-backed compose requires template: ${params.definition.name}`);
|
|
63
|
+
}
|
|
64
|
+
const templateDir = ensureTemplateDirectoryFromRoots(params.facetedRoots, templateName, dirname(params.definitionPath));
|
|
65
|
+
const nonInteractive = isNonInteractiveMode(params.composeOptions);
|
|
66
|
+
const outputDir = await resolveComposeOutputDir({
|
|
67
|
+
options: params.options,
|
|
68
|
+
composeOptions: params.composeOptions,
|
|
69
|
+
});
|
|
70
|
+
const templateRelativePaths = collectDirectoryFiles(templateDir);
|
|
71
|
+
const templateOutputPaths = templateRelativePaths.map(relativePath => resolve(outputDir, relativePath));
|
|
72
|
+
const existingPaths = templateOutputPaths.filter(path => existsSync(path));
|
|
73
|
+
if (params.composeOptions.overwrite !== true) {
|
|
74
|
+
if (nonInteractive) {
|
|
75
|
+
if (existingPaths.length > 0) {
|
|
76
|
+
throw new Error(`Output files exist and overwrite was cancelled: ${existingPaths.join(', ')}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await confirmOverwriteForExistingPaths({
|
|
81
|
+
options: params.options,
|
|
82
|
+
existingPaths,
|
|
83
|
+
promptMessage: 'Output files exist. Overwrite?',
|
|
84
|
+
cancelMessage: 'Output files exist and overwrite was cancelled',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
copyDirectoryTree(templateDir, outputDir);
|
|
89
|
+
const sections = buildSkillSections({
|
|
90
|
+
definition: params.definition,
|
|
91
|
+
definitionDir: dirname(params.definitionPath),
|
|
92
|
+
facetsRoots: params.facetsRoots,
|
|
93
|
+
});
|
|
94
|
+
applyFacetTokensToFiles({
|
|
95
|
+
filePaths: templateOutputPaths.filter(path => existsSync(path)),
|
|
96
|
+
tokenValues: buildInlineFacetTokenValues(sections),
|
|
97
|
+
rootDir: outputDir,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
kind: 'path',
|
|
101
|
+
path: outputDir,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export async function runStandardCompose(params) {
|
|
105
|
+
const safeName = ensureSafeDefinitionName(params.definition.name);
|
|
106
|
+
const facetSet = buildFacetSet({
|
|
107
|
+
definitionDir: dirname(params.definitionPath),
|
|
108
|
+
facetsRoots: params.facetsRoots,
|
|
109
|
+
definition: params.definition,
|
|
110
|
+
});
|
|
111
|
+
const composed = compose(facetSet, {
|
|
112
|
+
contextMaxChars: 2000,
|
|
113
|
+
userMessageOrder: params.definition.order,
|
|
114
|
+
});
|
|
115
|
+
const nonInteractive = isNonInteractiveMode(params.composeOptions);
|
|
116
|
+
const splitSelection = params.composeOptions.outputMode
|
|
117
|
+
? (params.composeOptions.outputMode === 'split' ? 'Split (system + user)' : 'Combined (single file)')
|
|
118
|
+
: await params.options.select(['Combined (single file)', 'Split (system + user)'], 'Choose output mode with Up/Down and Enter:');
|
|
119
|
+
const outputPlans = buildComposeOutputPlans({
|
|
120
|
+
safeName,
|
|
121
|
+
systemPrompt: composed.systemPrompt,
|
|
122
|
+
userMessage: composed.userMessage,
|
|
123
|
+
splitSystem: splitSelection === 'Split (system + user)',
|
|
124
|
+
});
|
|
125
|
+
const outputDir = await resolveComposeOutputDir({
|
|
126
|
+
options: params.options,
|
|
127
|
+
composeOptions: params.composeOptions,
|
|
128
|
+
});
|
|
129
|
+
const existingPaths = outputPlans
|
|
130
|
+
.map(plan => resolve(outputDir, plan.fileName))
|
|
131
|
+
.filter(path => existsSync(path));
|
|
132
|
+
const overwrite = params.composeOptions.overwrite === true
|
|
133
|
+
? true
|
|
134
|
+
: nonInteractive
|
|
135
|
+
? false
|
|
136
|
+
: await confirmOverwriteForExistingPaths({
|
|
137
|
+
options: params.options,
|
|
138
|
+
existingPaths,
|
|
139
|
+
promptMessage: 'Output file exists. Overwrite?',
|
|
140
|
+
cancelMessage: 'Output file exists and overwrite was cancelled',
|
|
141
|
+
});
|
|
142
|
+
if (!overwrite && existingPaths.length > 0) {
|
|
143
|
+
throw new Error(`Output file exists and overwrite was cancelled: ${existingPaths.join(', ')}`);
|
|
144
|
+
}
|
|
145
|
+
const outputPaths = [];
|
|
146
|
+
for (const plan of outputPlans) {
|
|
147
|
+
outputPaths.push(await writeComposeOutput({
|
|
148
|
+
outputDir,
|
|
149
|
+
fileName: plan.fileName,
|
|
150
|
+
content: plan.content,
|
|
151
|
+
overwrite,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
if (outputPaths.length === 1) {
|
|
155
|
+
return {
|
|
156
|
+
kind: 'path',
|
|
157
|
+
path: outputPaths[0],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
kind: 'paths',
|
|
162
|
+
paths: outputPaths,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=compose-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-execution.js","sourceRoot":"","sources":["../../src/cli/compose-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,gCAAgC,EAChC,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,yCAAyC,EAAE,2BAA2B,EAAE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
|
2
|
+
export declare function parseComposeOptions(args: readonly string[]): ComposeCliOptions;
|
|
3
|
+
export declare function isNonInteractiveMode(options: ComposeCliOptions): boolean;
|
|
4
|
+
//# sourceMappingURL=compose-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-options.d.ts","sourceRoot":"","sources":["../../src/cli/compose-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAcpD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,iBAAiB,CA0D9E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAKxE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function requireOptionValue(args, index, optionName) {
|
|
2
|
+
const value = args[index + 1];
|
|
3
|
+
if (!value || value.startsWith('--')) {
|
|
4
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
5
|
+
}
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
export function parseComposeOptions(args) {
|
|
9
|
+
let composition;
|
|
10
|
+
let outputMode;
|
|
11
|
+
let output;
|
|
12
|
+
let overwrite = false;
|
|
13
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
14
|
+
const arg = args[index];
|
|
15
|
+
if (arg === undefined) {
|
|
16
|
+
throw new Error('Unsupported compose argument: undefined');
|
|
17
|
+
}
|
|
18
|
+
if (arg === '--composition') {
|
|
19
|
+
composition = requireOptionValue(args, index, '--composition');
|
|
20
|
+
index += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (arg === '--output') {
|
|
24
|
+
output = requireOptionValue(args, index, '--output');
|
|
25
|
+
index += 1;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (arg === '--split') {
|
|
29
|
+
if (outputMode === 'combined') {
|
|
30
|
+
throw new Error('Cannot specify both --split and --combined');
|
|
31
|
+
}
|
|
32
|
+
outputMode = 'split';
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arg === '--combined') {
|
|
36
|
+
if (outputMode === 'split') {
|
|
37
|
+
throw new Error('Cannot specify both --split and --combined');
|
|
38
|
+
}
|
|
39
|
+
outputMode = 'combined';
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (arg === '--overwrite') {
|
|
43
|
+
overwrite = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg.startsWith('--')) {
|
|
47
|
+
throw new Error(`Unsupported compose option: ${arg}`);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Unsupported compose argument: ${arg}`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
composition,
|
|
53
|
+
outputMode,
|
|
54
|
+
output,
|
|
55
|
+
overwrite: overwrite || undefined,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function isNonInteractiveMode(options) {
|
|
59
|
+
return options.composition !== undefined
|
|
60
|
+
|| options.outputMode !== undefined
|
|
61
|
+
|| options.output !== undefined
|
|
62
|
+
|| options.overwrite === true;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=compose-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-options.js","sourceRoot":"","sources":["../../src/cli/compose-options.ts"],"names":[],"mappings":"AAEA,SAAS,kBAAkB,CACzB,IAAuB,EACvB,KAAa,EACb,UAAwC;IAExC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,IAAI,WAA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,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,WAAW;QACX,UAAU;QACV,MAAM;QACN,SAAS,EAAE,SAAS,IAAI,SAAS;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAA0B;IAC7D,OAAO,OAAO,CAAC,WAAW,KAAK,SAAS;WACnC,OAAO,CAAC,UAAU,KAAK,SAAS;WAChC,OAAO,CAAC,MAAM,KAAK,SAAS;WAC5B,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;AAClC,CAAC"}
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA2BlE,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CA4DzB"}
|
package/dist/cli/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { initializeGlobalFaceted, initializeLocalFaceted, listPullSampleTargetPaths, pullSampleFacets, } from '../init/index.js';
|
|
4
4
|
import { runComposeCommand, } from './compose-command.js';
|
|
5
|
+
import { parseComposeOptions } from './compose-options.js';
|
|
5
6
|
import { runInstallSkillCommand, } from './skill-commands.js';
|
|
6
7
|
import { shouldOverwrite } from './install-skill/flow.js';
|
|
7
8
|
const USAGE = [
|
|
@@ -65,7 +66,7 @@ export async function runFacetCli(args, options) {
|
|
|
65
66
|
throw new Error(`Unsupported command: ${command}`);
|
|
66
67
|
}
|
|
67
68
|
if (command === 'compose') {
|
|
68
|
-
return runComposeCommand(options);
|
|
69
|
+
return runComposeCommand(options, parseComposeOptions(args.slice(1)));
|
|
69
70
|
}
|
|
70
71
|
if (command === 'install') {
|
|
71
72
|
ensureSkillSubcommand(command, subcommand);
|