faceted-prompting 0.0.0 → 0.2.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/LICENSE +21 -0
- package/README.md +208 -2
- package/bin/facet +2 -0
- package/dist/cli/compose-context.d.ts +8 -0
- package/dist/cli/compose-context.d.ts.map +1 -0
- package/dist/cli/compose-context.js +194 -0
- package/dist/cli/compose-context.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +144 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install-skill/facets.d.ts +28 -0
- package/dist/cli/install-skill/facets.d.ts.map +1 -0
- package/dist/cli/install-skill/facets.js +160 -0
- package/dist/cli/install-skill/facets.js.map +1 -0
- package/dist/cli/install-skill/flow.d.ts +13 -0
- package/dist/cli/install-skill/flow.d.ts.map +1 -0
- package/dist/cli/install-skill/flow.js +63 -0
- package/dist/cli/install-skill/flow.js.map +1 -0
- package/dist/cli/install-skill/modes.d.ts +27 -0
- package/dist/cli/install-skill/modes.d.ts.map +1 -0
- package/dist/cli/install-skill/modes.js +130 -0
- package/dist/cli/install-skill/modes.js.map +1 -0
- package/dist/cli/install-skill/targets.d.ts +10 -0
- package/dist/cli/install-skill/targets.d.ts.map +1 -0
- package/dist/cli/install-skill/targets.js +27 -0
- package/dist/cli/install-skill/targets.js.map +1 -0
- package/dist/cli/path-guard.d.ts +12 -0
- package/dist/cli/path-guard.d.ts.map +1 -0
- package/dist/cli/path-guard.js +81 -0
- package/dist/cli/path-guard.js.map +1 -0
- package/dist/cli/runner.d.ts +10 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +66 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/select.d.ts +7 -0
- package/dist/cli/select.d.ts.map +1 -0
- package/dist/cli/select.js +70 -0
- package/dist/cli/select.js.map +1 -0
- package/dist/cli/skill-commands.d.ts +8 -0
- package/dist/cli/skill-commands.d.ts.map +1 -0
- package/dist/cli/skill-commands.js +44 -0
- package/dist/cli/skill-commands.js.map +1 -0
- package/dist/cli/skill-file-ops.d.ts +3 -0
- package/dist/cli/skill-file-ops.d.ts.map +1 -0
- package/dist/cli/skill-file-ops.js +89 -0
- package/dist/cli/skill-file-ops.js.map +1 -0
- package/dist/cli/skill-renderer.d.ts +24 -0
- package/dist/cli/skill-renderer.d.ts.map +1 -0
- package/dist/cli/skill-renderer.js +194 -0
- package/dist/cli/skill-renderer.js.map +1 -0
- package/dist/cli/skill-types.d.ts +31 -0
- package/dist/cli/skill-types.d.ts.map +1 -0
- package/dist/cli/skill-types.js +2 -0
- package/dist/cli/skill-types.js.map +1 -0
- package/dist/cli/types.d.ts +17 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/compose-definition.d.ts +3 -0
- package/dist/compose-definition.d.ts.map +1 -0
- package/dist/compose-definition.js +99 -0
- package/dist/compose-definition.js.map +1 -0
- package/dist/compose.d.ts +18 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +51 -0
- package/dist/compose.js.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +82 -0
- package/dist/config/index.js.map +1 -0
- package/dist/data-engine.d.ts +49 -0
- package/dist/data-engine.d.ts.map +1 -0
- package/dist/data-engine.js +85 -0
- package/dist/data-engine.js.map +1 -0
- package/dist/escape.d.ts +14 -0
- package/dist/escape.d.ts.map +1 -0
- package/dist/escape.js +16 -0
- package/dist/escape.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/init/index.d.ts +17 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +197 -0
- package/dist/init/index.js.map +1 -0
- package/dist/output/index.d.ts +10 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +67 -0
- package/dist/output/index.js.map +1 -0
- package/dist/prompt-payload.d.ts +8 -0
- package/dist/prompt-payload.d.ts.map +1 -0
- package/dist/prompt-payload.js +24 -0
- package/dist/prompt-payload.js.map +1 -0
- package/dist/resolve.d.ts +73 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +160 -0
- package/dist/resolve.js.map +1 -0
- package/dist/scope.d.ts +47 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +69 -0
- package/dist/scope.js.map +1 -0
- package/dist/template.d.ts +27 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +49 -0
- package/dist/template.js.map +1 -0
- package/dist/truncation.d.ts +36 -0
- package/dist/truncation.d.ts.map +1 -0
- package/dist/truncation.js +63 -0
- package/dist/truncation.js.map +1 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -6
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { ensureConfigFile, getFacetedRoot } from '../config/index.js';
|
|
4
|
+
const REQUIRED_FACET_DIRS = ['persona', 'knowledge', 'policies', 'output-contracts'];
|
|
5
|
+
const TAKT_BOOTSTRAP_BASE_URL = 'https://raw.githubusercontent.com/nrslib/takt/main/builtins/ja/facets';
|
|
6
|
+
function makeComposition(name, description, knowledge) {
|
|
7
|
+
const lines = [
|
|
8
|
+
`name: ${name}`,
|
|
9
|
+
`description: ${description}`,
|
|
10
|
+
'persona: coder',
|
|
11
|
+
'policies:',
|
|
12
|
+
' - coding',
|
|
13
|
+
' - ai-antipattern',
|
|
14
|
+
'knowledge:',
|
|
15
|
+
...knowledge.map(k => ` - ${k}`),
|
|
16
|
+
];
|
|
17
|
+
return lines.join('\n') + '\n';
|
|
18
|
+
}
|
|
19
|
+
const DEFAULT_COMPOSITIONS = [
|
|
20
|
+
{
|
|
21
|
+
relativePath: 'compositions/coding.yaml',
|
|
22
|
+
content: makeComposition('coding', 'General coding with architecture knowledge', ['architecture']),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
relativePath: 'compositions/frontend.yaml',
|
|
26
|
+
content: makeComposition('frontend', 'Frontend coding with architecture + frontend knowledge', ['architecture', 'frontend']),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
relativePath: 'compositions/backend.yaml',
|
|
30
|
+
content: makeComposition('backend', 'Backend coding with architecture + backend knowledge', ['architecture', 'backend']),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
relativePath: 'compositions/issue-worktree.yaml',
|
|
34
|
+
content: [
|
|
35
|
+
'name: issue-worktree',
|
|
36
|
+
'description: Issue-oriented coding skill deployed from a multi-file template',
|
|
37
|
+
'persona: coder',
|
|
38
|
+
'policies:',
|
|
39
|
+
' - coding',
|
|
40
|
+
' - ai-antipattern',
|
|
41
|
+
'knowledge:',
|
|
42
|
+
' - architecture',
|
|
43
|
+
'instruction: |',
|
|
44
|
+
' Confirm the issue scope before editing, keep the change minimal, and report build/test results.',
|
|
45
|
+
'template: issue-worktree',
|
|
46
|
+
'',
|
|
47
|
+
].join('\n'),
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const DEFAULT_TEMPLATES = [
|
|
51
|
+
{
|
|
52
|
+
relativePath: 'templates/issue-worktree/SKILL.md',
|
|
53
|
+
content: [
|
|
54
|
+
'# Issue Worker',
|
|
55
|
+
'',
|
|
56
|
+
'## Persona',
|
|
57
|
+
'{{facet:persona}}',
|
|
58
|
+
'',
|
|
59
|
+
'## Policies',
|
|
60
|
+
'{{facet:policies}}',
|
|
61
|
+
'',
|
|
62
|
+
'## Knowledge',
|
|
63
|
+
'{{facet:knowledges}}',
|
|
64
|
+
'',
|
|
65
|
+
'## Instructions',
|
|
66
|
+
'{{facet:instructions}}',
|
|
67
|
+
'',
|
|
68
|
+
'## Workflow',
|
|
69
|
+
'- Confirm the issue scope before editing.',
|
|
70
|
+
'- Keep changes minimal and explicit.',
|
|
71
|
+
'- Run build/test and report the outcome.',
|
|
72
|
+
'',
|
|
73
|
+
].join('\n'),
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
relativePath: 'templates/issue-worktree/README.md',
|
|
77
|
+
content: [
|
|
78
|
+
'# Issue Worker Template',
|
|
79
|
+
'',
|
|
80
|
+
'This sample template shows how a multi-file skill workspace can be structured for issue-oriented coding tasks.',
|
|
81
|
+
'',
|
|
82
|
+
'Included files:',
|
|
83
|
+
'- `SKILL.md`',
|
|
84
|
+
'- `templates/instructions/fix.md`',
|
|
85
|
+
'- `templates/instructions/review.md`',
|
|
86
|
+
'',
|
|
87
|
+
'Facet placeholders in `SKILL.md` are replaced during `facet install skill`.',
|
|
88
|
+
'',
|
|
89
|
+
].join('\n'),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
relativePath: 'templates/issue-worktree/templates/instructions/fix.md',
|
|
93
|
+
content: [
|
|
94
|
+
'# Fix Checklist',
|
|
95
|
+
'',
|
|
96
|
+
'- Reproduce the issue first.',
|
|
97
|
+
'- Verify the smallest safe fix.',
|
|
98
|
+
'- Record build/test evidence after the change.',
|
|
99
|
+
'',
|
|
100
|
+
].join('\n'),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
relativePath: 'templates/issue-worktree/templates/instructions/review.md',
|
|
104
|
+
content: [
|
|
105
|
+
'# Review Checklist',
|
|
106
|
+
'',
|
|
107
|
+
'- Check for scope creep.',
|
|
108
|
+
'- Check for missing tests or validation.',
|
|
109
|
+
'- Check for hidden fallback logic.',
|
|
110
|
+
'',
|
|
111
|
+
].join('\n'),
|
|
112
|
+
},
|
|
113
|
+
...DEFAULT_COMPOSITIONS,
|
|
114
|
+
];
|
|
115
|
+
const BOOTSTRAP_TARGETS = [
|
|
116
|
+
{
|
|
117
|
+
localRelativePath: 'facets/persona/coder.md',
|
|
118
|
+
remoteRelativePath: 'personas/coder.md',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
localRelativePath: 'facets/knowledge/architecture.md',
|
|
122
|
+
remoteRelativePath: 'knowledge/architecture.md',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
localRelativePath: 'facets/knowledge/frontend.md',
|
|
126
|
+
remoteRelativePath: 'knowledge/frontend.md',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
localRelativePath: 'facets/knowledge/backend.md',
|
|
130
|
+
remoteRelativePath: 'knowledge/backend.md',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
localRelativePath: 'facets/policies/coding.md',
|
|
134
|
+
remoteRelativePath: 'policies/coding.md',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
localRelativePath: 'facets/policies/ai-antipattern.md',
|
|
138
|
+
remoteRelativePath: 'policies/ai-antipattern.md',
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
function resolveFetchImpl(fetchImpl) {
|
|
142
|
+
if (fetchImpl) {
|
|
143
|
+
return fetchImpl;
|
|
144
|
+
}
|
|
145
|
+
if (typeof globalThis.fetch !== 'function') {
|
|
146
|
+
throw new Error('Global fetch is not available');
|
|
147
|
+
}
|
|
148
|
+
return globalThis.fetch.bind(globalThis);
|
|
149
|
+
}
|
|
150
|
+
async function fetchBootstrapContent(remoteRelativePath, fetchImpl) {
|
|
151
|
+
const response = await fetchImpl(`${TAKT_BOOTSTRAP_BASE_URL}/${remoteRelativePath}`);
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
throw new Error(`Failed to fetch bootstrap facet: ${remoteRelativePath} (status: ${response.status})`);
|
|
154
|
+
}
|
|
155
|
+
return response.text();
|
|
156
|
+
}
|
|
157
|
+
export function listPullSampleTargetPaths(homeDir) {
|
|
158
|
+
const facetedRoot = getFacetedRoot(homeDir);
|
|
159
|
+
return BOOTSTRAP_TARGETS.map(target => join(facetedRoot, target.localRelativePath));
|
|
160
|
+
}
|
|
161
|
+
async function bootstrapDefaultFacets(facetedRoot, fetchImpl, overwrite) {
|
|
162
|
+
for (const target of BOOTSTRAP_TARGETS) {
|
|
163
|
+
const targetPath = join(facetedRoot, target.localRelativePath);
|
|
164
|
+
if (existsSync(targetPath) && !overwrite) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const content = await fetchBootstrapContent(target.remoteRelativePath, fetchImpl);
|
|
168
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
169
|
+
writeFileSync(targetPath, content, 'utf-8');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export async function initializeFacetedHome(options) {
|
|
173
|
+
const facetedRoot = getFacetedRoot(options.homeDir);
|
|
174
|
+
ensureConfigFile(options.homeDir);
|
|
175
|
+
const facetsRoot = join(facetedRoot, 'facets');
|
|
176
|
+
const compositionsRoot = join(facetedRoot, 'compositions');
|
|
177
|
+
const templatesRoot = join(facetedRoot, 'templates');
|
|
178
|
+
mkdirSync(facetsRoot, { recursive: true });
|
|
179
|
+
mkdirSync(compositionsRoot, { recursive: true });
|
|
180
|
+
mkdirSync(templatesRoot, { recursive: true });
|
|
181
|
+
for (const dirName of REQUIRED_FACET_DIRS) {
|
|
182
|
+
mkdirSync(join(facetsRoot, dirName), { recursive: true });
|
|
183
|
+
}
|
|
184
|
+
for (const template of DEFAULT_TEMPLATES) {
|
|
185
|
+
const targetPath = join(facetedRoot, template.relativePath);
|
|
186
|
+
if (!existsSync(targetPath)) {
|
|
187
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
188
|
+
writeFileSync(targetPath, template.content, 'utf-8');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export async function pullSampleFacets(options) {
|
|
193
|
+
await initializeFacetedHome({ homeDir: options.homeDir });
|
|
194
|
+
const facetedRoot = getFacetedRoot(options.homeDir);
|
|
195
|
+
await bootstrapDefaultFacets(facetedRoot, resolveFetchImpl(options.fetchImpl), options.overwrite ?? false);
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,CAAU,CAAC;AAC9F,MAAM,uBAAuB,GAAG,uEAAuE,CAAC;AAExG,SAAS,eAAe,CAAC,IAAY,EAAE,WAAmB,EAAE,SAA4B;IACtF,MAAM,KAAK,GAAG;QACZ,SAAS,IAAI,EAAE;QACf,gBAAgB,WAAW,EAAE;QAC7B,gBAAgB;QAChB,WAAW;QACX,YAAY;QACZ,oBAAoB;QACpB,YAAY;QACZ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KAClC,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,MAAM,oBAAoB,GAA6D;IACrF;QACE,YAAY,EAAE,0BAA0B;QACxC,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,4CAA4C,EAAE,CAAC,cAAc,CAAC,CAAC;KACnG;IACD;QACE,YAAY,EAAE,4BAA4B;QAC1C,OAAO,EAAE,eAAe,CAAC,UAAU,EAAE,wDAAwD,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;KAC7H;IACD;QACE,YAAY,EAAE,2BAA2B;QACzC,OAAO,EAAE,eAAe,CAAC,SAAS,EA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a,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE9C,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;QAC1C,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAwE;IAC7G,MAAM,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;AAC7G,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComposedPrompt } from '../types.js';
|
|
2
|
+
export declare function resolveOutputDirectory(inputValue: string, defaultDirectory: string): string;
|
|
3
|
+
export declare function formatCombinedOutput(composed: ComposedPrompt): string;
|
|
4
|
+
export declare function writeComposeOutput(options: {
|
|
5
|
+
outputDir: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
content: string;
|
|
8
|
+
overwrite: boolean;
|
|
9
|
+
}): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAM3F;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CASrE;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmDlB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { closeSync, constants, mkdirSync, openSync, realpathSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, resolve, sep } from 'node:path';
|
|
3
|
+
export function resolveOutputDirectory(inputValue, defaultDirectory) {
|
|
4
|
+
const trimmed = inputValue.trim();
|
|
5
|
+
if (trimmed.length === 0) {
|
|
6
|
+
return defaultDirectory;
|
|
7
|
+
}
|
|
8
|
+
return resolve(defaultDirectory, trimmed);
|
|
9
|
+
}
|
|
10
|
+
export function formatCombinedOutput(composed) {
|
|
11
|
+
const parts = [];
|
|
12
|
+
if (composed.systemPrompt.length > 0) {
|
|
13
|
+
parts.push(composed.systemPrompt);
|
|
14
|
+
}
|
|
15
|
+
if (composed.userMessage.length > 0) {
|
|
16
|
+
parts.push(composed.userMessage);
|
|
17
|
+
}
|
|
18
|
+
return parts.join('\n\n') + '\n';
|
|
19
|
+
}
|
|
20
|
+
export async function writeComposeOutput(options) {
|
|
21
|
+
const outputDir = resolve(options.outputDir);
|
|
22
|
+
mkdirSync(outputDir, { recursive: true });
|
|
23
|
+
const outputDirRealPath = realpathSync(outputDir);
|
|
24
|
+
if (basename(options.fileName) !== options.fileName) {
|
|
25
|
+
throw new Error(`Output file name must not include path segments: ${options.fileName}`);
|
|
26
|
+
}
|
|
27
|
+
const outputPath = resolve(outputDir, options.fileName);
|
|
28
|
+
if (!(outputPath === outputDir || outputPath.startsWith(`${outputDir}${sep}`))) {
|
|
29
|
+
throw new Error(`Output path escapes target directory: ${options.fileName}`);
|
|
30
|
+
}
|
|
31
|
+
const outputParentDirectory = dirname(outputPath);
|
|
32
|
+
mkdirSync(outputParentDirectory, { recursive: true });
|
|
33
|
+
const outputParentRealPath = realpathSync(outputParentDirectory);
|
|
34
|
+
if (!(outputParentRealPath === outputDirRealPath || outputParentRealPath.startsWith(`${outputDirRealPath}${sep}`))) {
|
|
35
|
+
throw new Error(`Output path escapes target directory: ${options.fileName}`);
|
|
36
|
+
}
|
|
37
|
+
const openFlags = constants.O_WRONLY
|
|
38
|
+
| constants.O_CREAT
|
|
39
|
+
| (options.overwrite ? constants.O_TRUNC : constants.O_EXCL)
|
|
40
|
+
| constants.O_NOFOLLOW;
|
|
41
|
+
let fileDescriptor;
|
|
42
|
+
try {
|
|
43
|
+
fileDescriptor = openSync(outputPath, openFlags, 0o600);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const errorCode = error.code;
|
|
47
|
+
if (errorCode === 'ELOOP') {
|
|
48
|
+
throw new Error(`Symbolic links are not allowed for output file: ${outputPath}`);
|
|
49
|
+
}
|
|
50
|
+
if (errorCode === 'EEXIST' && !options.overwrite) {
|
|
51
|
+
throw new Error(`Output file exists and overwrite was cancelled: ${outputPath}`);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
writeFileSync(fileDescriptor, options.content, 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
closeSync(fileDescriptor);
|
|
60
|
+
}
|
|
61
|
+
const outputRealPath = realpathSync(outputPath);
|
|
62
|
+
if (!(outputRealPath === outputDirRealPath || outputRealPath.startsWith(`${outputDirRealPath}${sep}`))) {
|
|
63
|
+
throw new Error(`Output path escapes target directory: ${options.fileName}`);
|
|
64
|
+
}
|
|
65
|
+
return outputPath;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/output/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG5D,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,gBAAwB;IACjF,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,OAAO,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,QAAwB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,QAAQ,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AACnC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AS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;UAC1D,SAAS,CAAC,UAAU,CAAC;IAEzB,IAAI,cAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,cAAc,GAAG,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,SAAS,GAAI,KAA+B,CAAC,IAAI,CAAC;QACxD,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,mDAAmD,UAAU,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,SAAS,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,mDAAmD,UAAU,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,cAAc,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,CAAC,cAAc,KAAK,iBAAiB,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,iBAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QACvG,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComposeDefinition, ComposedPromptPayload, ComposeOptions } from './types.js';
|
|
2
|
+
export declare function composePromptPayload(params: {
|
|
3
|
+
definition: ComposeDefinition;
|
|
4
|
+
definitionDir: string;
|
|
5
|
+
facetsRoot: string;
|
|
6
|
+
composeOptions: ComposeOptions;
|
|
7
|
+
}): ComposedPromptPayload;
|
|
8
|
+
//# sourceMappingURL=prompt-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-payload.d.ts","sourceRoot":"","sources":["../src/prompt-payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,cAAc,EAAa,MAAM,YAAY,CAAC;AAmBtG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,qBAAqB,CAYxB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { compose } from './compose.js';
|
|
2
|
+
import { buildFacetSet, resolveDefinitionSections } from './cli/skill-renderer.js';
|
|
3
|
+
function buildCopyFiles(params) {
|
|
4
|
+
const resolved = resolveDefinitionSections(params);
|
|
5
|
+
return {
|
|
6
|
+
persona: [resolved.persona.path],
|
|
7
|
+
knowledge: resolved.knowledge.map(section => section.path),
|
|
8
|
+
policies: resolved.policies.map(section => section.path),
|
|
9
|
+
instructions: resolved.instruction && 'path' in resolved.instruction ? [resolved.instruction.path] : [],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function composePromptPayload(params) {
|
|
13
|
+
const facetSet = buildFacetSet(params);
|
|
14
|
+
const composed = compose(facetSet, {
|
|
15
|
+
...params.composeOptions,
|
|
16
|
+
userMessageOrder: params.definition.order,
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
systemPrompt: composed.systemPrompt,
|
|
20
|
+
userPrompt: composed.userMessage,
|
|
21
|
+
copyFiles: buildCopyFiles(params),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24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|
|
1
|
+
/**
|
|
2
|
+
* Facet reference resolution utilities.
|
|
3
|
+
*
|
|
4
|
+
* Resolves facet names / paths / content from section maps
|
|
5
|
+
* and candidate directories. Directory construction is delegated
|
|
6
|
+
* to the caller (TAKT provides project/global/builtin dirs).
|
|
7
|
+
*
|
|
8
|
+
* This module depends only on node:fs, node:os, node:path.
|
|
9
|
+
*/
|
|
10
|
+
/** Pre-resolved section maps passed to movement normalization. */
|
|
11
|
+
export interface PieceSections {
|
|
12
|
+
/** Persona name -> file path (raw, not content-resolved) */
|
|
13
|
+
personas?: Record<string, string>;
|
|
14
|
+
/** Policy name -> resolved content */
|
|
15
|
+
resolvedPolicies?: Record<string, string>;
|
|
16
|
+
/** Knowledge name -> resolved content */
|
|
17
|
+
resolvedKnowledge?: Record<string, string>;
|
|
18
|
+
/** Instruction name -> resolved content */
|
|
19
|
+
resolvedInstructions?: Record<string, string>;
|
|
20
|
+
/** Report format name -> resolved content */
|
|
21
|
+
resolvedReportFormats?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Check if a spec looks like a resource path (vs. a facet name).
|
|
25
|
+
* Paths start with './', '../', '/', '~' or end with '.md'.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isResourcePath(spec: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a facet name to its file path by scanning candidate directories.
|
|
30
|
+
*
|
|
31
|
+
* The caller builds the candidate list (e.g. project/.takt/{kind},
|
|
32
|
+
* ~/.takt/{kind}, builtins/{lang}/{kind}) and passes it in.
|
|
33
|
+
*
|
|
34
|
+
* @returns Absolute file path if found, undefined otherwise.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveFacetPath(name: string, candidateDirs: readonly string[]): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a facet name to its file content via candidate directories.
|
|
39
|
+
*
|
|
40
|
+
* @returns File content if found, undefined otherwise.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveFacetByName(name: string, candidateDirs: readonly string[]): string | undefined;
|
|
43
|
+
/** Resolve a resource spec to an absolute file path. */
|
|
44
|
+
export declare function resolveResourcePath(spec: string, pieceDir: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a resource spec to its file content.
|
|
47
|
+
* If the spec ends with .md and the file exists, returns file content.
|
|
48
|
+
* Otherwise returns the spec as-is (treated as inline content).
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveResourceContent(spec: string | undefined, pieceDir: string): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Resolve a section reference to content.
|
|
53
|
+
* Looks up ref in resolvedMap first, then falls back to path resolution.
|
|
54
|
+
* If candidateDirs are provided and ref is a name (not a path),
|
|
55
|
+
* falls back to facet resolution via candidate directories.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveRefToContent(ref: string, resolvedMap: Record<string, string> | undefined, pieceDir: string, candidateDirs?: readonly string[]): string | undefined;
|
|
58
|
+
/** Resolve multiple references to content strings (for fields that accept string | string[]). */
|
|
59
|
+
export declare function resolveRefList(refs: string | string[] | undefined, resolvedMap: Record<string, string> | undefined, pieceDir: string, candidateDirs?: readonly string[]): string[] | undefined;
|
|
60
|
+
/** Resolve a piece-level section map (each value resolved to file content or inline). */
|
|
61
|
+
export declare function resolveSectionMap(raw: Record<string, string> | undefined, pieceDir: string): Record<string, string> | undefined;
|
|
62
|
+
/** Extract display name from persona path (e.g., "coder.md" -> "coder"). */
|
|
63
|
+
export declare function extractPersonaDisplayName(personaPath: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve persona from YAML field to spec + absolute path.
|
|
66
|
+
*
|
|
67
|
+
* Candidate directories for name-based lookup are provided by the caller.
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolvePersona(rawPersona: string | undefined, sections: PieceSections, pieceDir: string, candidateDirs?: readonly string[]): {
|
|
70
|
+
personaSpec?: string;
|
|
71
|
+
personaPath?: string;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=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,EACX,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC/C,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,GAAG,SAAS,CAcpB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACnC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC/C,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,EAAE,GAAG,SAAS,CAStB;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACvC,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAQpC;AAED,4EAA4E;AAC5E,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CA8BhD"}
|
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facet reference resolution utilities.
|
|
3
|
+
*
|
|
4
|
+
* Resolves facet names / paths / content from section maps
|
|
5
|
+
* and candidate directories. Directory construction is delegated
|
|
6
|
+
* to the caller (TAKT provides project/global/builtin dirs).
|
|
7
|
+
*
|
|
8
|
+
* This module depends only on node:fs, node:os, node:path.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
11
|
+
import { homedir } from 'node:os';
|
|
12
|
+
import { join, basename } from 'node:path';
|
|
13
|
+
/**
|
|
14
|
+
* Check if a spec looks like a resource path (vs. a facet name).
|
|
15
|
+
* Paths start with './', '../', '/', '~' or end with '.md'.
|
|
16
|
+
*/
|
|
17
|
+
export function isResourcePath(spec) {
|
|
18
|
+
return (spec.startsWith('./') ||
|
|
19
|
+
spec.startsWith('../') ||
|
|
20
|
+
spec.startsWith('/') ||
|
|
21
|
+
spec.startsWith('~') ||
|
|
22
|
+
spec.endsWith('.md'));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a facet name to its file path by scanning candidate directories.
|
|
26
|
+
*
|
|
27
|
+
* The caller builds the candidate list (e.g. project/.takt/{kind},
|
|
28
|
+
* ~/.takt/{kind}, builtins/{lang}/{kind}) and passes it in.
|
|
29
|
+
*
|
|
30
|
+
* @returns Absolute file path if found, undefined otherwise.
|
|
31
|
+
*/
|
|
32
|
+
export function resolveFacetPath(name, candidateDirs) {
|
|
33
|
+
for (const dir of candidateDirs) {
|
|
34
|
+
const filePath = join(dir, `${name}.md`);
|
|
35
|
+
if (existsSync(filePath)) {
|
|
36
|
+
return filePath;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a facet name to its file content via candidate directories.
|
|
43
|
+
*
|
|
44
|
+
* @returns File content if found, undefined otherwise.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveFacetByName(name, candidateDirs) {
|
|
47
|
+
const filePath = resolveFacetPath(name, candidateDirs);
|
|
48
|
+
if (filePath) {
|
|
49
|
+
return readFileSync(filePath, 'utf-8');
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
/** Resolve a resource spec to an absolute file path. */
|
|
54
|
+
export function resolveResourcePath(spec, pieceDir) {
|
|
55
|
+
if (spec.startsWith('./'))
|
|
56
|
+
return join(pieceDir, spec.slice(2));
|
|
57
|
+
if (spec.startsWith('~'))
|
|
58
|
+
return join(homedir(), spec.slice(1));
|
|
59
|
+
if (spec.startsWith('/'))
|
|
60
|
+
return spec;
|
|
61
|
+
return join(pieceDir, spec);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolve a resource spec to its file content.
|
|
65
|
+
* If the spec ends with .md and the file exists, returns file content.
|
|
66
|
+
* Otherwise returns the spec as-is (treated as inline content).
|
|
67
|
+
*/
|
|
68
|
+
export function resolveResourceContent(spec, pieceDir) {
|
|
69
|
+
if (spec == null)
|
|
70
|
+
return undefined;
|
|
71
|
+
if (spec.endsWith('.md')) {
|
|
72
|
+
const resolved = resolveResourcePath(spec, pieceDir);
|
|
73
|
+
if (existsSync(resolved))
|
|
74
|
+
return readFileSync(resolved, 'utf-8');
|
|
75
|
+
}
|
|
76
|
+
return spec;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Resolve a section reference to content.
|
|
80
|
+
* Looks up ref in resolvedMap first, then falls back to path resolution.
|
|
81
|
+
* If candidateDirs are provided and ref is a name (not a path),
|
|
82
|
+
* falls back to facet resolution via candidate directories.
|
|
83
|
+
*/
|
|
84
|
+
export function resolveRefToContent(ref, resolvedMap, pieceDir, candidateDirs) {
|
|
85
|
+
const mapped = resolvedMap?.[ref];
|
|
86
|
+
if (mapped)
|
|
87
|
+
return mapped;
|
|
88
|
+
if (isResourcePath(ref)) {
|
|
89
|
+
return resolveResourceContent(ref, pieceDir);
|
|
90
|
+
}
|
|
91
|
+
if (candidateDirs) {
|
|
92
|
+
const facetContent = resolveFacetByName(ref, candidateDirs);
|
|
93
|
+
if (facetContent !== undefined)
|
|
94
|
+
return facetContent;
|
|
95
|
+
}
|
|
96
|
+
return resolveResourceContent(ref, pieceDir);
|
|
97
|
+
}
|
|
98
|
+
/** Resolve multiple references to content strings (for fields that accept string | string[]). */
|
|
99
|
+
export function resolveRefList(refs, resolvedMap, pieceDir, candidateDirs) {
|
|
100
|
+
if (refs == null)
|
|
101
|
+
return undefined;
|
|
102
|
+
const list = Array.isArray(refs) ? refs : [refs];
|
|
103
|
+
const contents = [];
|
|
104
|
+
for (const ref of list) {
|
|
105
|
+
const content = resolveRefToContent(ref, resolvedMap, pieceDir, candidateDirs);
|
|
106
|
+
if (content)
|
|
107
|
+
contents.push(content);
|
|
108
|
+
}
|
|
109
|
+
return contents.length > 0 ? contents : undefined;
|
|
110
|
+
}
|
|
111
|
+
/** Resolve a piece-level section map (each value resolved to file content or inline). */
|
|
112
|
+
export function resolveSectionMap(raw, pieceDir) {
|
|
113
|
+
if (!raw)
|
|
114
|
+
return undefined;
|
|
115
|
+
const resolved = {};
|
|
116
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
117
|
+
const content = resolveResourceContent(value, pieceDir);
|
|
118
|
+
if (content)
|
|
119
|
+
resolved[name] = content;
|
|
120
|
+
}
|
|
121
|
+
return Object.keys(resolved).length > 0 ? resolved : undefined;
|
|
122
|
+
}
|
|
123
|
+
/** Extract display name from persona path (e.g., "coder.md" -> "coder"). */
|
|
124
|
+
export function extractPersonaDisplayName(personaPath) {
|
|
125
|
+
return basename(personaPath, '.md');
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Resolve persona from YAML field to spec + absolute path.
|
|
129
|
+
*
|
|
130
|
+
* Candidate directories for name-based lookup are provided by the caller.
|
|
131
|
+
*/
|
|
132
|
+
export function resolvePersona(rawPersona, sections, pieceDir, candidateDirs) {
|
|
133
|
+
if (!rawPersona)
|
|
134
|
+
return {};
|
|
135
|
+
// If section map has explicit mapping, use it (path-based)
|
|
136
|
+
const sectionMapping = sections.personas?.[rawPersona];
|
|
137
|
+
if (sectionMapping) {
|
|
138
|
+
const resolved = resolveResourcePath(sectionMapping, pieceDir);
|
|
139
|
+
const personaPath = existsSync(resolved) ? resolved : undefined;
|
|
140
|
+
return { personaSpec: sectionMapping, personaPath };
|
|
141
|
+
}
|
|
142
|
+
// If rawPersona is a path, resolve it directly
|
|
143
|
+
if (isResourcePath(rawPersona)) {
|
|
144
|
+
const resolved = resolveResourcePath(rawPersona, pieceDir);
|
|
145
|
+
const personaPath = existsSync(resolved) ? resolved : undefined;
|
|
146
|
+
return { personaSpec: rawPersona, personaPath };
|
|
147
|
+
}
|
|
148
|
+
// Name-based: try candidate directories
|
|
149
|
+
if (candidateDirs) {
|
|
150
|
+
const filePath = resolveFacetPath(rawPersona, candidateDirs);
|
|
151
|
+
if (filePath) {
|
|
152
|
+
return { personaSpec: rawPersona, personaPath: filePath };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Fallback: try as relative path from pieceDir
|
|
156
|
+
const resolved = resolveResourcePath(rawPersona, pieceDir);
|
|
157
|
+
const personaPath = existsSync(resolved) ? resolved : undefined;
|
|
158
|
+
return { personaSpec: rawPersona, personaPath };
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAgB3C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CACrB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,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C,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;IACtD,CAAC;IAED,+CAA+C;IAC/C,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3D,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAClD,CAAC;IAED,wCAAwC;IACxC,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAC7D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAClD,CAAC"}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @scope reference resolution utilities for TAKT repertoire packages.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - isScopeRef(): detect @{owner}/{repo}/{facet-name} format
|
|
6
|
+
* - parseScopeRef(): parse and normalize components
|
|
7
|
+
* - resolveScopeRef(): build file path in repertoire directory
|
|
8
|
+
* - validateScopeOwner/Repo/FacetName(): name constraint validation
|
|
9
|
+
*/
|
|
10
|
+
/** Parsed components of an @scope reference. */
|
|
11
|
+
export interface ScopeRef {
|
|
12
|
+
/** GitHub owner (lowercase). */
|
|
13
|
+
owner: string;
|
|
14
|
+
/** Repository name (lowercase). */
|
|
15
|
+
repo: string;
|
|
16
|
+
/** Facet name. */
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Return true if the string is an @{owner}/{repo}/{facet-name} scope reference.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isScopeRef(ref: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Parse an @scope reference into its components.
|
|
25
|
+
* Normalizes owner and repo to lowercase.
|
|
26
|
+
*
|
|
27
|
+
* @param ref - e.g. "@nrslib/takt-fullstack/expert-coder"
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseScopeRef(ref: string): ScopeRef;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a scope reference to a file path in the repertoire directory.
|
|
32
|
+
*
|
|
33
|
+
* Path: {repertoireDir}/@{owner}/{repo}/facets/{facetType}/{name}.md
|
|
34
|
+
*
|
|
35
|
+
* @param scopeRef - parsed scope reference
|
|
36
|
+
* @param facetType - e.g. "personas", "policies", "knowledge"
|
|
37
|
+
* @param repertoireDir - root repertoire directory (e.g. ~/.takt/repertoire)
|
|
38
|
+
* @returns Absolute path to the facet file.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveScopeRef(scopeRef: ScopeRef, facetType: string, repertoireDir: string): string;
|
|
41
|
+
/** Validate owner name: must match /^[a-z0-9][a-z0-9-]*$/ */
|
|
42
|
+
export declare function validateScopeOwner(owner: string): void;
|
|
43
|
+
/** Validate repo name: must match /^[a-z0-9][a-z0-9._-]*$/ */
|
|
44
|
+
export declare function validateScopeRepo(repo: string): void;
|
|
45
|
+
/** Validate facet name: must match /^[a-z0-9][a-z0-9-]*$/ */
|
|
46
|
+
export declare function validateScopeFacetName(name: string): void;
|
|
47
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,gDAAgD;AAChD,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAKD;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAYnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB,MAAM,CASR;AAED,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtD;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED,6DAA6D;AAC7D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMzD"}
|