@ankhorage/templates 1.8.8 → 1.9.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +39 -0
  3. package/dist/ankh.provider.d.ts +9 -0
  4. package/dist/ankh.provider.d.ts.map +1 -0
  5. package/dist/ankh.provider.js +25 -0
  6. package/dist/ankh.provider.js.map +1 -0
  7. package/dist/catalog.d.ts +18 -0
  8. package/dist/catalog.d.ts.map +1 -0
  9. package/dist/catalog.js +84 -0
  10. package/dist/catalog.js.map +1 -0
  11. package/dist/cli.d.ts +9 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +37 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/commandContext.d.ts +12 -0
  16. package/dist/commandContext.d.ts.map +1 -0
  17. package/dist/commandContext.js +15 -0
  18. package/dist/commandContext.js.map +1 -0
  19. package/dist/commands.d.ts +64 -0
  20. package/dist/commands.d.ts.map +1 -0
  21. package/dist/commands.js +236 -0
  22. package/dist/commands.js.map +1 -0
  23. package/dist/packageMetadata.d.ts +5 -0
  24. package/dist/packageMetadata.d.ts.map +1 -0
  25. package/dist/packageMetadata.js +10 -0
  26. package/dist/packageMetadata.js.map +1 -0
  27. package/dist/projectSeed.d.ts +30 -0
  28. package/dist/projectSeed.d.ts.map +1 -0
  29. package/dist/projectSeed.js +37 -0
  30. package/dist/projectSeed.js.map +1 -0
  31. package/dist/templateSelector.d.ts +12 -0
  32. package/dist/templateSelector.d.ts.map +1 -0
  33. package/dist/templateSelector.js +60 -0
  34. package/dist/templateSelector.js.map +1 -0
  35. package/dist/templates/shared/screen.d.ts +1 -0
  36. package/dist/templates/shared/screen.d.ts.map +1 -1
  37. package/dist/templates/shared/screen.js +1 -0
  38. package/dist/templates/shared/screen.js.map +1 -1
  39. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/bindings.d.ts.map +1 -1
  40. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/bindings.js +118 -0
  41. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/bindings.js.map +1 -1
  42. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/screens.d.ts.map +1 -1
  43. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/screens.js +174 -45
  44. package/dist/templates/starter/categories/food-drink/nutrition-catalog-scan/screens.js.map +1 -1
  45. package/dist/templates/starter/index.d.ts +1 -1
  46. package/dist/templates/starter/index.d.ts.map +1 -1
  47. package/dist/templates/starter/index.js +1 -1
  48. package/dist/templates/starter/index.js.map +1 -1
  49. package/dist/templates/starter/starter.registry.d.ts.map +1 -1
  50. package/dist/templates/starter/starter.registry.js +4 -0
  51. package/dist/templates/starter/starter.registry.js.map +1 -1
  52. package/dist/templates/starter/starter.template.d.ts +3 -3
  53. package/dist/templates/starter/starter.template.d.ts.map +1 -1
  54. package/dist/templates/starter/starter.template.js +2 -2
  55. package/dist/templates/starter/starter.template.js.map +1 -1
  56. package/dist/templates/starter/starter.types.d.ts +3 -1
  57. package/dist/templates/starter/starter.types.d.ts.map +1 -1
  58. package/dist/templates/starter/starter.types.js +1 -0
  59. package/dist/templates/starter/starter.types.js.map +1 -1
  60. package/package.json +18 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ankhorage/templates
2
2
 
3
+ ## 1.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 18fd9d2: Add Ankh provider metadata, standalone CLI commands, and manifest-first template seed creation.
8
+
9
+ ## 1.8.9
10
+
11
+ ### Patch Changes
12
+
13
+ - 8114302: Update the nutrition catalog scan starter to use a generic product detail screen loader, preserve wrapped product list repeats, and render a runtime-driven empty state for successful empty product lists.
14
+
3
15
  ## 1.8.8
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  Reusable Ankhorage app templates, presets, and manifest generators.
4
4
 
5
+ ## CLI And Provider Commands
6
+
7
+ `@ankhorage/templates` is now also a package-scoped Ankh provider and standalone CLI for the
8
+ template catalog.
9
+
10
+ Shipped commands:
11
+
12
+ ```bash
13
+ ankh templates list
14
+ ankh templates list --category games
15
+
16
+ ankh templates inspect games/chess
17
+
18
+ ankh templates create my-app --template games/chess
19
+
20
+ bunx @ankhorage/templates list
21
+ bunx @ankhorage/templates inspect games/chess
22
+ bunx @ankhorage/templates create my-app --template games/chess
23
+ ```
24
+
25
+ Canonical selector syntax is strict:
26
+
27
+ - use `<category>/<templateId>`
28
+ - examples: `games/default`, `games/chess`, `social_community/creator`
29
+ - `create` and `inspect` reject bare ids like `chess`
30
+ - CLI/provider commands do not silently fall back from invalid selectors
31
+
32
+ `create` is manifest-first only in this package. It writes:
33
+
34
+ ```txt
35
+ my-app/
36
+ ankh.config.json
37
+ ankh.template.json
38
+ README.md
39
+ ```
40
+
41
+ It does not scaffold a full runnable app/workspace, install dependencies, or depend on Studio.
42
+ Root-level `ankh create ...` remains a later composition concern outside this package.
43
+
5
44
  ## Usage
6
45
 
7
46
  ```ts
@@ -0,0 +1,9 @@
1
+ import type { AnkhRuntimeCommandProvider } from '@ankhorage/ankh';
2
+ import { type RunTemplatesCommandImpl, type RunTemplatesCommandOptions } from './commands.js';
3
+ export interface CreateTemplatesRuntimeProviderOptions extends Omit<RunTemplatesCommandOptions, 'runCommandImpl'> {
4
+ readonly runCommandImpl?: RunTemplatesCommandImpl;
5
+ }
6
+ export declare function createTemplatesRuntimeProvider(options?: CreateTemplatesRuntimeProviderOptions): AnkhRuntimeCommandProvider;
7
+ declare const provider: AnkhRuntimeCommandProvider;
8
+ export default provider;
9
+ //# sourceMappingURL=ankh.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ankh.provider.d.ts","sourceRoot":"","sources":["../src/ankh.provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAEhC,MAAM,eAAe,CAAC;AAQvB,MAAM,WAAW,qCAAsC,SAAQ,IAAI,CACjE,0BAA0B,EAC1B,gBAAgB,CACjB;IACC,QAAQ,CAAC,cAAc,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,qCAA0C,GAClD,0BAA0B,CAuB5B;AAED,QAAA,MAAM,QAAQ,4BAAmC,CAAC;AAElD,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { createProviderCommandDescriptors, runTemplatesCommand, TEMPLATES_COMMANDS, } from './commands.js';
2
+ import { TEMPLATES_CAPABILITIES, TEMPLATES_COMMAND_CATEGORY, TEMPLATES_PACKAGE_NAME, TEMPLATES_PACKAGE_VERSION, } from './packageMetadata.js';
3
+ export function createTemplatesRuntimeProvider(options = {}) {
4
+ const runCommandImpl = options.runCommandImpl ?? runTemplatesCommand;
5
+ return {
6
+ id: TEMPLATES_PACKAGE_NAME,
7
+ category: TEMPLATES_COMMAND_CATEGORY,
8
+ version: TEMPLATES_PACKAGE_VERSION,
9
+ capabilities: [...TEMPLATES_CAPABILITIES],
10
+ commands: createProviderCommandDescriptors(),
11
+ handlers: TEMPLATES_COMMANDS.map((command) => ({
12
+ path: command.path,
13
+ handler(request) {
14
+ return runCommandImpl({
15
+ argv: request.argv,
16
+ command,
17
+ context: request.context,
18
+ }, options);
19
+ },
20
+ })),
21
+ };
22
+ }
23
+ const provider = createTemplatesRuntimeProvider();
24
+ export default provider;
25
+ //# sourceMappingURL=ankh.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ankh.provider.js","sourceRoot":"","sources":["../src/ankh.provider.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EAGnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAS9B,MAAM,UAAU,8BAA8B,CAC5C,UAAiD,EAAE;IAEnD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,mBAAmB,CAAC;IAErE,OAAO;QACL,EAAE,EAAE,sBAAsB;QAC1B,QAAQ,EAAE,0BAA0B;QACpC,OAAO,EAAE,yBAAyB;QAClC,YAAY,EAAE,CAAC,GAAG,sBAAsB,CAAC;QACzC,QAAQ,EAAE,gCAAgC,EAAE;QAC5C,QAAQ,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC7C,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,CAAC,OAAO;gBACb,OAAO,cAAc,CACnB;oBACE,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,OAAO;oBACP,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB,EACD,OAAO,CACR,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;KACiC,CAAC;AACzC,CAAC;AAED,MAAM,QAAQ,GAAG,8BAA8B,EAAE,CAAC;AAElD,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AppManifest } from '@ankhorage/contracts';
2
+ import { type StarterTemplateCategory } from './templates/starter/index.js';
3
+ import type { ParsedTemplateSelector } from './templateSelector.js';
4
+ export interface TemplateCatalogEntry {
5
+ readonly selector: string;
6
+ readonly category: StarterTemplateCategory;
7
+ readonly templateId: string;
8
+ readonly label: string;
9
+ readonly description: string;
10
+ }
11
+ export declare function listTemplateCatalog(category?: StarterTemplateCategory): readonly TemplateCatalogEntry[];
12
+ export declare function resolveTemplateCatalogEntry(selector: ParsedTemplateSelector): TemplateCatalogEntry;
13
+ export declare function createManifestForSelector(args: {
14
+ readonly selector: ParsedTemplateSelector;
15
+ readonly projectSlug: string;
16
+ readonly displayName: string;
17
+ }): AppManifest;
18
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,sBAAsB,CAAC;AAKrE,OAAO,EAIL,KAAK,uBAAuB,EAG7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGpE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAKD,wBAAgB,mBAAmB,CACjC,QAAQ,CAAC,EAAE,uBAAuB,GACjC,SAAS,oBAAoB,EAAE,CAQjC;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,sBAAsB,GAC/B,oBAAoB,CAoBtB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,GAAG,WAAW,CAcd"}
@@ -0,0 +1,84 @@
1
+ import { CATEGORY_PRESETS } from './presets/category-presets.js';
2
+ import { createFallbackStarterTemplate } from './templates/starter/categories/fallback/default.template.js';
3
+ import { fallbackStarterTemplates } from './templates/starter/categories/fallback/index.js';
4
+ import { createStarterTemplate, FALLBACK_TEMPLATE_CATEGORY, listStarterTemplateSummaries, } from './templates/starter/index.js';
5
+ import { createTemplateSelector } from './templateSelector.js';
6
+ const FALLBACK_THEME_HARMONY = 'analogous';
7
+ const FALLBACK_FOCUS_AREAS = ['Home', 'Details', 'Settings'];
8
+ export function listTemplateCatalog(category) {
9
+ const entries = createTemplateCatalogEntries();
10
+ if (category === undefined) {
11
+ return entries;
12
+ }
13
+ return entries.filter((entry) => entry.category === category);
14
+ }
15
+ export function resolveTemplateCatalogEntry(selector) {
16
+ const entry = listTemplateCatalog(selector.category).find((candidate) => candidate.templateId === selector.templateId);
17
+ if (entry !== undefined) {
18
+ return entry;
19
+ }
20
+ const availableSelectors = listTemplateCatalog(selector.category).map((candidate) => candidate.selector);
21
+ if (availableSelectors.length === 0) {
22
+ throw new Error(`Template category "${selector.category}" does not expose any templates.`);
23
+ }
24
+ throw new Error(`Unknown template selector "${selector.selector}". Available selectors: ${availableSelectors.join(', ')}.`);
25
+ }
26
+ export function createManifestForSelector(args) {
27
+ const seed = createTemplateSeed({
28
+ category: args.selector.category,
29
+ displayName: args.displayName,
30
+ projectSlug: args.projectSlug,
31
+ });
32
+ if (args.selector.category === FALLBACK_TEMPLATE_CATEGORY) {
33
+ return createFallbackStarterTemplate(seed);
34
+ }
35
+ return createStarterTemplate(seed, {
36
+ templateId: args.selector.templateId,
37
+ });
38
+ }
39
+ function createTemplateCatalogEntries() {
40
+ const fallbackEntries = fallbackStarterTemplates.map((template) => ({
41
+ selector: createTemplateSelector(FALLBACK_TEMPLATE_CATEGORY, template.id),
42
+ category: FALLBACK_TEMPLATE_CATEGORY,
43
+ templateId: template.id,
44
+ label: template.label,
45
+ description: template.description,
46
+ }));
47
+ const starterEntries = listStarterTemplateSummaries().map(createTemplateCatalogEntry);
48
+ return [...fallbackEntries, ...starterEntries];
49
+ }
50
+ function createTemplateCatalogEntry(summary) {
51
+ return {
52
+ selector: createTemplateSelector(summary.category, summary.id),
53
+ category: summary.category,
54
+ templateId: summary.id,
55
+ label: summary.label,
56
+ description: summary.description,
57
+ };
58
+ }
59
+ function createTemplateSeed(args) {
60
+ if (args.category === FALLBACK_TEMPLATE_CATEGORY) {
61
+ return {
62
+ category: FALLBACK_TEMPLATE_CATEGORY,
63
+ categoryLabel: 'Fallback',
64
+ appName: args.displayName,
65
+ slug: args.projectSlug,
66
+ summary: 'Generic starter seed',
67
+ focusAreas: FALLBACK_FOCUS_AREAS,
68
+ primaryColor: '#2563EB',
69
+ harmony: FALLBACK_THEME_HARMONY,
70
+ };
71
+ }
72
+ const preset = CATEGORY_PRESETS[args.category];
73
+ return {
74
+ category: args.category,
75
+ categoryLabel: preset.label,
76
+ appName: args.displayName,
77
+ slug: args.projectSlug,
78
+ summary: preset.summary,
79
+ focusAreas: preset.focusAreas,
80
+ primaryColor: preset.primaryColor,
81
+ harmony: preset.harmony,
82
+ };
83
+ }
84
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6DAA6D,CAAC;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,GAI7B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAU/D,MAAM,sBAAsB,GAAoC,WAAW,CAAC;AAC5E,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAEtE,MAAM,UAAU,mBAAmB,CACjC,QAAkC;IAElC,MAAM,OAAO,GAAG,4BAA4B,EAAE,CAAC;IAE/C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgC;IAEhC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I,CAAC,WAAW;QACzB,IAAI,EAAE,IAAI,CAAC,WAAW;QACtB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bun
2
+ import type { TemplatesCommandContext, TemplatesCommandRunResult } from './commandContext.js';
3
+ import { type RunTemplatesCommandImpl, type RunTemplatesCommandOptions } from './commands.js';
4
+ export interface TemplatesCliOptions extends Omit<RunTemplatesCommandOptions, 'runCommandImpl'> {
5
+ readonly context?: TemplatesCommandContext;
6
+ readonly runCommandImpl?: RunTemplatesCommandImpl;
7
+ }
8
+ export declare function runCli(argv: readonly string[], options?: TemplatesCliOptions): Promise<TemplatesCommandRunResult>;
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAE9F,OAAO,EAKL,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAChC,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,0BAA0B,EAAE,gBAAgB,CAAC;IAC7F,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC,CA6BpC"}
package/dist/cli.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bun
2
+ import { createDefaultCommandContext } from './commandContext.js';
3
+ import { findTemplatesCommandByStandaloneName, renderRootHelp, renderUnknownCommand, runTemplatesCommand, } from './commands.js';
4
+ export async function runCli(argv, options = {}) {
5
+ const context = options.context ?? createDefaultCommandContext();
6
+ const runCommand = options.runCommandImpl ?? runTemplatesCommand;
7
+ const [firstToken, ...restTokens] = argv;
8
+ if (firstToken === undefined || isHelpToken(firstToken)) {
9
+ context.writeStdout(renderRootHelp(context.version));
10
+ return { exitCode: 0 };
11
+ }
12
+ if (isVersionToken(firstToken)) {
13
+ context.writeStdout(`${context.version}\n`);
14
+ return { exitCode: 0 };
15
+ }
16
+ const command = findTemplatesCommandByStandaloneName(firstToken);
17
+ if (command === null) {
18
+ context.writeStderr(renderUnknownCommand(firstToken));
19
+ return { exitCode: 1 };
20
+ }
21
+ return runCommand({
22
+ argv: restTokens,
23
+ command,
24
+ context,
25
+ }, options);
26
+ }
27
+ function isHelpToken(value) {
28
+ return value === '--help' || value === '-h' || value === 'help';
29
+ }
30
+ function isVersionToken(value) {
31
+ return value === '--version' || value === '-v' || value === 'version';
32
+ }
33
+ if (import.meta.main) {
34
+ const result = await runCli(process.argv.slice(2));
35
+ process.exit(result.exitCode);
36
+ }
37
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EACL,oCAAoC,EACpC,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,eAAe,CAAC;AAOvB,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAAuB,EACvB,UAA+B,EAAE;IAEjC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,2BAA2B,EAAE,CAAC;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,IAAI,mBAAmB,CAAC;IACjE,MAAM,CAAC,UAAU,EAAE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C;AAChC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface TemplatesCommandContext {
2
+ readonly cwd: string;
3
+ readonly env: Readonly<Record<string, string | undefined>>;
4
+ readonly version: string;
5
+ writeStdout(text: string): void;
6
+ writeStderr(text: string): void;
7
+ }
8
+ export interface TemplatesCommandRunResult {
9
+ readonly exitCode: number;
10
+ }
11
+ export declare function createDefaultCommandContext(): TemplatesCommandContext;
12
+ //# sourceMappingURL=commandContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandContext.d.ts","sourceRoot":"","sources":["../src/commandContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,2BAA2B,IAAI,uBAAuB,CAYrE"}
@@ -0,0 +1,15 @@
1
+ import { TEMPLATES_PACKAGE_VERSION } from './packageMetadata.js';
2
+ export function createDefaultCommandContext() {
3
+ return {
4
+ cwd: process.cwd(),
5
+ env: process.env,
6
+ version: TEMPLATES_PACKAGE_VERSION,
7
+ writeStdout(text) {
8
+ process.stdout.write(text);
9
+ },
10
+ writeStderr(text) {
11
+ process.stderr.write(text);
12
+ },
13
+ };
14
+ }
15
+ //# sourceMappingURL=commandContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandContext.js","sourceRoot":"","sources":["../src/commandContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAcjE,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,yBAAyB;QAClC,WAAW,CAAC,IAAY;YACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,WAAW,CAAC,IAAY;YACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { AnkhCapabilityId, AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
2
+ import { createManifestForSelector, resolveTemplateCatalogEntry, type TemplateCatalogEntry } from './catalog.js';
3
+ import type { TemplatesCommandContext, TemplatesCommandRunResult } from './commandContext.js';
4
+ import { type CreateProjectSeedRequest, type ProjectSeedDependencies } from './projectSeed.js';
5
+ import type { StarterTemplateCategory } from './templates/starter/index.js';
6
+ type TemplatesCommandName = 'create' | 'inspect' | 'list';
7
+ interface TemplatesCommandRunRequest {
8
+ readonly context: TemplatesCommandContext;
9
+ }
10
+ type TemplatesCommandImplementation = (request: TemplatesCommandRunRequest, services: TemplatesCommandServices, argv: readonly string[]) => Promise<TemplatesCommandRunResult>;
11
+ export interface TemplatesCommandDefinition {
12
+ readonly capability: AnkhCapabilityId;
13
+ readonly path: readonly [TemplatesCommandName];
14
+ readonly standaloneName: TemplatesCommandName;
15
+ readonly summary: string;
16
+ readonly run: TemplatesCommandImplementation;
17
+ }
18
+ export interface TemplatesCommandInvocation {
19
+ readonly argv: readonly string[];
20
+ readonly command: TemplatesCommandDefinition;
21
+ readonly context: TemplatesCommandContext;
22
+ }
23
+ interface TemplatesCommandServices {
24
+ readonly createManifestForSelector: typeof createManifestForSelector;
25
+ readonly createProjectSeed: (request: CreateProjectSeedRequest, dependencies?: Partial<ProjectSeedDependencies>) => Promise<{
26
+ readonly projectPath: string;
27
+ }>;
28
+ readonly listTemplateCatalog: (category?: StarterTemplateCategory) => readonly TemplateCatalogEntry[];
29
+ readonly resolveTemplateCatalogEntry: typeof resolveTemplateCatalogEntry;
30
+ }
31
+ export interface RunTemplatesCommandOptions {
32
+ readonly services?: Partial<TemplatesCommandServices>;
33
+ readonly runCommandImpl?: RunTemplatesCommandImpl;
34
+ }
35
+ export type RunTemplatesCommandImpl = (request: TemplatesCommandInvocation, options?: RunTemplatesCommandOptions) => Promise<TemplatesCommandRunResult>;
36
+ export declare const TEMPLATES_COMMANDS: readonly [{
37
+ readonly standaloneName: "list";
38
+ readonly path: readonly ["list"];
39
+ readonly capability: "templates.list";
40
+ readonly summary: "List canonical template selectors from the published template catalog.";
41
+ readonly run: typeof runListCommand;
42
+ }, {
43
+ readonly standaloneName: "inspect";
44
+ readonly path: readonly ["inspect"];
45
+ readonly capability: "templates.inspect";
46
+ readonly summary: "Inspect one canonical template selector and print its manifest metadata.";
47
+ readonly run: typeof runInspectCommand;
48
+ }, {
49
+ readonly standaloneName: "create";
50
+ readonly path: readonly ["create"];
51
+ readonly capability: "templates.create";
52
+ readonly summary: "Create a manifest-first project seed from one canonical template selector.";
53
+ readonly run: typeof runCreateCommand;
54
+ }];
55
+ export declare function runTemplatesCommand(request: TemplatesCommandInvocation, options?: RunTemplatesCommandOptions): Promise<TemplatesCommandRunResult>;
56
+ export declare function createProviderCommandDescriptors(): readonly AnkhCommandDescriptor[];
57
+ export declare function findTemplatesCommandByStandaloneName(value: string): TemplatesCommandDefinition | null;
58
+ export declare function renderRootHelp(version: string): string;
59
+ export declare function renderUnknownCommand(value: string): string;
60
+ declare function runListCommand(request: TemplatesCommandRunRequest, services: TemplatesCommandServices, argv: readonly string[]): Promise<TemplatesCommandRunResult>;
61
+ declare function runInspectCommand(request: TemplatesCommandRunRequest, services: TemplatesCommandServices, argv: readonly string[]): Promise<TemplatesCommandRunResult>;
62
+ declare function runCreateCommand(request: TemplatesCommandRunRequest, services: TemplatesCommandServices, argv: readonly string[]): Promise<TemplatesCommandRunResult>;
63
+ export {};
64
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,EACL,yBAAyB,EAEzB,2BAA2B,EAC3B,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAO9F,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAQ5E,KAAK,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,UAAU,0BAA0B;IAClC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;CAC3C;AAED,KAAK,8BAA8B,GAAG,CACpC,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,SAAS,MAAM,EAAE,KACpB,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAExC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,8BAA8B,CAAC;CAC9C;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE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AAE,MAAM,GAAG,MAAM,CAI1D;AAyCD,iBAAS,cAAc,CACrB,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,CAAC,CAMpC;AAED,iBAAS,iBAAiB,CACxB,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,CAAC,CAWpC;AAED,iBAAe,gBAAgB,CAC7B,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,wBAAwB,EAClC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,yBAAyB,CAAC,CAiCpC"}
@@ -0,0 +1,236 @@
1
+ import { createManifestForSelector, listTemplateCatalog, resolveTemplateCatalogEntry, } from './catalog.js';
2
+ import { TEMPLATES_CAPABILITIES, TEMPLATES_COMMAND_CATEGORY, TEMPLATES_PACKAGE_NAME, TEMPLATES_PACKAGE_VERSION, } from './packageMetadata.js';
3
+ import { createProjectSeed, } from './projectSeed.js';
4
+ import { deriveDisplayNameFromSlug, parseProjectSlug, parseTemplateCategory, parseTemplateSelector, } from './templateSelector.js';
5
+ const COMMAND_CAPABILITIES = {
6
+ list: TEMPLATES_CAPABILITIES[0],
7
+ inspect: TEMPLATES_CAPABILITIES[1],
8
+ create: TEMPLATES_CAPABILITIES[2],
9
+ };
10
+ export const TEMPLATES_COMMANDS = [
11
+ {
12
+ standaloneName: 'list',
13
+ path: ['list'],
14
+ capability: COMMAND_CAPABILITIES.list,
15
+ summary: 'List canonical template selectors from the published template catalog.',
16
+ run: runListCommand,
17
+ },
18
+ {
19
+ standaloneName: 'inspect',
20
+ path: ['inspect'],
21
+ capability: COMMAND_CAPABILITIES.inspect,
22
+ summary: 'Inspect one canonical template selector and print its manifest metadata.',
23
+ run: runInspectCommand,
24
+ },
25
+ {
26
+ standaloneName: 'create',
27
+ path: ['create'],
28
+ capability: COMMAND_CAPABILITIES.create,
29
+ summary: 'Create a manifest-first project seed from one canonical template selector.',
30
+ run: runCreateCommand,
31
+ },
32
+ ];
33
+ export async function runTemplatesCommand(request, options = {}) {
34
+ const services = createTemplatesCommandServices(options.services);
35
+ const [firstArg] = request.argv;
36
+ try {
37
+ if (request.argv.length === 1 && firstArg !== undefined && isHelpToken(firstArg)) {
38
+ request.context.writeStdout(renderCommandHelp(request.command));
39
+ return { exitCode: 0 };
40
+ }
41
+ return await request.command.run(request, services, request.argv);
42
+ }
43
+ catch (error) {
44
+ request.context.writeStderr(renderCommandFailure(request.command.standaloneName, error));
45
+ return { exitCode: 1 };
46
+ }
47
+ }
48
+ export function createProviderCommandDescriptors() {
49
+ return TEMPLATES_COMMANDS.map((command) => ({
50
+ capability: command.capability,
51
+ path: command.path,
52
+ summary: command.summary,
53
+ }));
54
+ }
55
+ export function findTemplatesCommandByStandaloneName(value) {
56
+ return TEMPLATES_COMMANDS.find((command) => command.standaloneName === value) ?? null;
57
+ }
58
+ export function renderRootHelp(version) {
59
+ const commandLines = TEMPLATES_COMMANDS.map((command) => ` ${command.standaloneName.padEnd(8, ' ')} ${command.summary}`).join('\n');
60
+ return [
61
+ `@ankhorage/templates v${version}`,
62
+ '',
63
+ 'Usage:',
64
+ ' ankhorage-templates <command> [options]',
65
+ ` ankh ${TEMPLATES_COMMAND_CATEGORY} <command> [options]`,
66
+ '',
67
+ 'Commands:',
68
+ commandLines,
69
+ '',
70
+ 'Selector syntax:',
71
+ ' Use canonical template selectors shaped as <category>/<templateId>.',
72
+ '',
73
+ 'Project creation:',
74
+ ' Create writes manifest-first project seeds only.',
75
+ '',
76
+ ].join('\n');
77
+ }
78
+ export function renderUnknownCommand(value) {
79
+ return [`Unknown templates command: ${value}`, '', 'Run ankhorage-templates --help', ''].join('\n');
80
+ }
81
+ function renderCommandHelp(command) {
82
+ const usageLine = command.standaloneName === 'create'
83
+ ? ` ankhorage-templates create <projectSlug> --template <category>/<templateId>`
84
+ : command.standaloneName === 'inspect'
85
+ ? ` ankhorage-templates inspect <category>/<templateId>`
86
+ : ' ankhorage-templates list [--category <category>]';
87
+ const ankhUsageLine = command.standaloneName === 'create'
88
+ ? ` ankh ${TEMPLATES_COMMAND_CATEGORY} create <projectSlug> --template <category>/<templateId>`
89
+ : command.standaloneName === 'inspect'
90
+ ? ` ankh ${TEMPLATES_COMMAND_CATEGORY} inspect <category>/<templateId>`
91
+ : ` ankh ${TEMPLATES_COMMAND_CATEGORY} list [--category <category>]`;
92
+ return [
93
+ command.summary,
94
+ '',
95
+ 'Usage:',
96
+ usageLine,
97
+ ankhUsageLine,
98
+ '',
99
+ 'Selector syntax:',
100
+ ' Use canonical template selectors shaped as <category>/<templateId>.',
101
+ '',
102
+ ].join('\n');
103
+ }
104
+ function createTemplatesCommandServices(overrides = {}) {
105
+ return {
106
+ createManifestForSelector: overrides.createManifestForSelector ?? createManifestForSelector,
107
+ createProjectSeed: overrides.createProjectSeed ?? createProjectSeed,
108
+ listTemplateCatalog: overrides.listTemplateCatalog ?? listTemplateCatalog,
109
+ resolveTemplateCatalogEntry: overrides.resolveTemplateCatalogEntry ?? resolveTemplateCatalogEntry,
110
+ };
111
+ }
112
+ function runListCommand(request, services, argv) {
113
+ const category = parseListArguments(argv);
114
+ const entries = services.listTemplateCatalog(category);
115
+ request.context.writeStdout(renderTemplateList(entries));
116
+ return Promise.resolve({ exitCode: 0 });
117
+ }
118
+ function runInspectCommand(request, services, argv) {
119
+ const selector = parseInspectArguments(argv);
120
+ const entry = services.resolveTemplateCatalogEntry(selector);
121
+ const manifest = services.createManifestForSelector({
122
+ selector,
123
+ projectSlug: 'template-preview',
124
+ displayName: 'Template Preview',
125
+ });
126
+ request.context.writeStdout(renderTemplateInspection(entry, manifest));
127
+ return Promise.resolve({ exitCode: 0 });
128
+ }
129
+ async function runCreateCommand(request, services, argv) {
130
+ const { projectSlug, selector } = parseCreateArguments(argv);
131
+ const entry = services.resolveTemplateCatalogEntry(selector);
132
+ const displayName = deriveDisplayNameFromSlug(projectSlug);
133
+ const manifest = services.createManifestForSelector({
134
+ selector,
135
+ projectSlug,
136
+ displayName,
137
+ });
138
+ const readmeText = createSeedReadme({
139
+ displayName,
140
+ projectSlug,
141
+ selector: entry.selector,
142
+ });
143
+ const result = await services.createProjectSeed({
144
+ cwd: request.context.cwd,
145
+ projectSlug,
146
+ readmeText,
147
+ metadata: {
148
+ package: TEMPLATES_PACKAGE_NAME,
149
+ version: TEMPLATES_PACKAGE_VERSION,
150
+ projectSlug,
151
+ displayName,
152
+ category: entry.category,
153
+ templateId: entry.templateId,
154
+ selector: entry.selector,
155
+ },
156
+ manifest,
157
+ });
158
+ request.context.writeStdout(renderCreateSuccess(result.projectPath));
159
+ return { exitCode: 0 };
160
+ }
161
+ function parseListArguments(argv) {
162
+ if (argv.length === 0) {
163
+ return undefined;
164
+ }
165
+ if (argv.length === 2 && argv[0] === '--category') {
166
+ return parseTemplateCategory(argv[1] ?? '');
167
+ }
168
+ throw new Error('Templates list accepts only the optional --category <category> flag.');
169
+ }
170
+ function parseInspectArguments(argv) {
171
+ if (argv.length !== 1) {
172
+ throw new Error('Templates inspect requires exactly one <category>/<templateId> selector.');
173
+ }
174
+ return parseTemplateSelector(argv[0] ?? '');
175
+ }
176
+ function parseCreateArguments(argv) {
177
+ const [rawProjectSlug, firstFlag, rawSelector] = argv;
178
+ if (rawProjectSlug === undefined) {
179
+ throw new Error('Templates create requires <projectSlug> and --template <category>/<templateId>.');
180
+ }
181
+ if (argv.length !== 3 || firstFlag !== '--template' || rawSelector === undefined) {
182
+ throw new Error('Templates create requires <projectSlug> and --template <category>/<templateId>.');
183
+ }
184
+ return {
185
+ projectSlug: parseProjectSlug(rawProjectSlug),
186
+ selector: parseTemplateSelector(rawSelector),
187
+ };
188
+ }
189
+ function renderTemplateList(entries) {
190
+ const lines = entries.map((entry) => ` ${entry.selector} - ${entry.label}: ${entry.description}`);
191
+ return ['Available templates:', '', ...lines, ''].join('\n');
192
+ }
193
+ function renderTemplateInspection(entry, manifest) {
194
+ return `${JSON.stringify({
195
+ selector: entry.selector,
196
+ category: entry.category,
197
+ templateId: entry.templateId,
198
+ label: entry.label,
199
+ description: entry.description,
200
+ manifestVersion: manifest.metadata.version,
201
+ manifest,
202
+ }, null, 2)}\n`;
203
+ }
204
+ function renderCreateSuccess(projectPath) {
205
+ return [
206
+ `Created manifest-first project seed at ${projectPath}`,
207
+ '',
208
+ 'Files:',
209
+ ' ankh.config.json',
210
+ ' ankh.template.json',
211
+ ' README.md',
212
+ '',
213
+ ].join('\n');
214
+ }
215
+ function createSeedReadme(args) {
216
+ return [
217
+ `# ${args.displayName}`,
218
+ '',
219
+ `Generated from \`@ankhorage/templates\` template \`${args.selector}\`.`,
220
+ '',
221
+ 'This is a manifest-first Ankhorage project seed.',
222
+ '',
223
+ 'Next extraction step: runnable app/workspace scaffolding.',
224
+ '',
225
+ `Project slug: \`${args.projectSlug}\``,
226
+ '',
227
+ ].join('\n');
228
+ }
229
+ function renderCommandFailure(commandName, error) {
230
+ const message = error instanceof Error ? error.message : String(error);
231
+ return [`Templates ${commandName} failed: ${message}`, ''].join('\n');
232
+ }
233
+ function isHelpToken(value) {
234
+ return value === '--help' || value === '-h' || value === 'help';
235
+ }
236
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,GAE5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,GAGlB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CA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