autokap 1.9.7 → 1.9.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autokap",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "description": "AI-powered CLI tool for capturing clean screenshots of websites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,12 +0,0 @@
1
- export type SkillType = 'preset';
2
- export interface SkillPlaceholderOptions {
3
- projectUrl?: string;
4
- projectId?: string;
5
- apiBaseUrl?: string;
6
- }
7
- export declare function resolveSkillAssetDir(): Promise<string>;
8
- export declare function renderSkillSingleFile(params: {
9
- type: SkillType;
10
- agent?: string;
11
- placeholders: SkillPlaceholderOptions;
12
- }): Promise<string>;
@@ -1,110 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- function replaceSkillPlaceholders(content, opts) {
4
- let result = content;
5
- if (opts.projectUrl) {
6
- result = result.replace(/\[AUTOKAP_PROJECT_URL\]/g, opts.projectUrl);
7
- }
8
- if (opts.projectId) {
9
- result = result.replace(/\[AUTOKAP_PROJECT_ID\]/g, opts.projectId);
10
- }
11
- if (opts.apiBaseUrl) {
12
- result = result.replace(/https:\/\/autokap\.app/g, opts.apiBaseUrl);
13
- }
14
- return result;
15
- }
16
- const PRESET_SKILL_SOURCE = {
17
- coreFile: 'SKILL.md',
18
- references: [
19
- { relativePath: 'OPCODE-REFERENCE.md', title: 'Opcode Reference', anchor: 'reference-opcode-reference' },
20
- { relativePath: 'references/STANDARDS.md', title: 'Prompt Charter & Quality Standards', anchor: 'reference-prompt-standards' },
21
- { relativePath: 'references/mock-data.md', title: 'Mock Data Injection', anchor: 'reference-mock-data-injection' },
22
- { relativePath: 'references/video-workflow.md', title: 'Demo Video Workflow', anchor: 'reference-demo-video-workflow' },
23
- { relativePath: 'references/examples.md', title: 'Complete Examples', anchor: 'reference-complete-examples' },
24
- ],
25
- };
26
- function getSkillSourceSpec(type) {
27
- return PRESET_SKILL_SOURCE;
28
- }
29
- async function pathExists(candidate) {
30
- try {
31
- await fs.access(candidate);
32
- return true;
33
- }
34
- catch {
35
- return false;
36
- }
37
- }
38
- function getModuleAssetCandidates() {
39
- const url = new URL(import.meta.url);
40
- const dir = process.platform === 'win32'
41
- ? path.dirname(url.pathname.replace(/^\/([A-Za-z]:)/, '$1'))
42
- : path.dirname(url.pathname);
43
- return [
44
- path.resolve(dir, '..', 'assets', 'skill'),
45
- path.resolve(dir, '..', '..', 'assets', 'skill'),
46
- ];
47
- }
48
- export async function resolveSkillAssetDir() {
49
- const candidates = [
50
- ...getModuleAssetCandidates(),
51
- path.join(process.cwd(), 'assets', 'skill'),
52
- path.join(process.cwd(), '..', 'assets', 'skill'),
53
- path.join(process.cwd(), '..', '..', 'assets', 'skill'),
54
- ];
55
- for (const candidate of candidates) {
56
- if (await pathExists(candidate)) {
57
- return candidate;
58
- }
59
- }
60
- throw new Error('Could not find assets/skill. Make sure the autokap package is installed correctly.');
61
- }
62
- async function readSkillFile(rootDir, relativePath, placeholders) {
63
- const absolutePath = path.join(rootDir, relativePath);
64
- const raw = await fs.readFile(absolutePath, 'utf-8');
65
- return replaceSkillPlaceholders(raw, placeholders);
66
- }
67
- function insertAfterFrontmatter(content, inserted) {
68
- if (!content.startsWith('---\n')) {
69
- return `${inserted.trim()}\n\n${content}`;
70
- }
71
- const secondFence = content.indexOf('\n---\n', 4);
72
- if (secondFence === -1) {
73
- return `${inserted.trim()}\n\n${content}`;
74
- }
75
- const frontmatter = content.slice(0, secondFence + 5);
76
- const rest = content.slice(secondFence + 5).replace(/^\n+/, '');
77
- return `${frontmatter}\n${inserted.trim()}\n\n${rest}`;
78
- }
79
- function stripLeadingTitle(content) {
80
- return content.replace(/^# .*\n+/, '').trim();
81
- }
82
- function rewriteLinksForSingleFile(content, spec) {
83
- let rewritten = content.replace(/\(SKILL\.md\)/g, '(#autokap-preset-creation-skill)');
84
- for (const reference of spec.references) {
85
- const escapedPath = reference.relativePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
86
- rewritten = rewritten.replace(new RegExp(`\\(${escapedPath}\\)`, 'g'), `(#${reference.anchor})`);
87
- }
88
- return rewritten;
89
- }
90
- export async function renderSkillSingleFile(params) {
91
- const rootDir = await resolveSkillAssetDir();
92
- const spec = getSkillSourceSpec(params.type);
93
- let core = await readSkillFile(rootDir, spec.coreFile, params.placeholders);
94
- core = rewriteLinksForSingleFile(core, spec);
95
- core = insertAfterFrontmatter(core, '> Packaging note: the canonical AutoKap preset skill is a modular bundle for Codex (`SKILL.md` + companion reference files). This single-file export is generated from that same source so all agents stay in parity.');
96
- const bundledReferences = [];
97
- for (const reference of spec.references) {
98
- const content = await readSkillFile(rootDir, reference.relativePath, params.placeholders);
99
- bundledReferences.push([
100
- '---',
101
- '',
102
- `## Reference: ${reference.title}`,
103
- `Source path in the Codex bundle: \`${reference.relativePath}\``,
104
- '',
105
- rewriteLinksForSingleFile(stripLeadingTitle(content), spec),
106
- ].join('\n'));
107
- }
108
- return [core, ...bundledReferences].join('\n\n');
109
- }
110
- //# sourceMappingURL=skill-packaging.js.map