-
Notifications
You must be signed in to change notification settings - Fork 51
Reject invalid skill listing prices #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,6 +78,17 @@ function slugify(s: string): string { | |||||||||||||
| } | ||||||||||||||
| function q(s: string): string { return JSON.stringify(s); } | ||||||||||||||
| async function exists(path: string): Promise<boolean> { try { await access(path); return true; } catch { return false; } } | ||||||||||||||
| function parsePriceSats(value: string): number { | ||||||||||||||
| const normalized = value.trim(); | ||||||||||||||
| if (!/^\d+$/.test(normalized)) { | ||||||||||||||
| throw new Error('--price must be a non-negative integer in sats'); | ||||||||||||||
| } | ||||||||||||||
| const price = Number(normalized); | ||||||||||||||
| if (!Number.isSafeInteger(price)) { | ||||||||||||||
| throw new Error('--price must be a safe non-negative integer in sats'); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+87
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| return price; | ||||||||||||||
| } | ||||||||||||||
| function frontmatterValue(text: string, key: string): string | undefined { | ||||||||||||||
| const m = text.match(new RegExp(`^${key}:\\s*["']?([^"'\\n]+)["']?\\s*$`, 'm')); | ||||||||||||||
| return m?.[1]?.trim(); | ||||||||||||||
|
|
@@ -349,17 +360,19 @@ skillsCmd | |||||||||||||
| const name = slugify(opts.name ?? inferred.name ?? basename(dirname(skillFile))); | ||||||||||||||
| const title = opts.title ?? inferred.title ?? name; | ||||||||||||||
| const description = opts.description ?? inferred.description ?? `Agent skill: ${title}`; | ||||||||||||||
| const tags = opts.tags.split(',').map(t => t.trim()).filter(Boolean).slice(0, 10); | ||||||||||||||
| const price = parsePriceSats(opts.price); | ||||||||||||||
| const manifest: SkillManifest = { | ||||||||||||||
| name, | ||||||||||||||
| title, | ||||||||||||||
| description, | ||||||||||||||
| tagline: opts.tagline, | ||||||||||||||
| category: opts.category, | ||||||||||||||
| tags: opts.tags.split(',').map(t => t.trim()).filter(Boolean).slice(0, 10), | ||||||||||||||
| price: Number.parseInt(opts.price, 10) || 0, | ||||||||||||||
| tags, | ||||||||||||||
| price, | ||||||||||||||
| skillFile, | ||||||||||||||
| sourceUrl: opts.sourceUrl, | ||||||||||||||
| marketplaces: Object.fromEntries(MARKETPLACES.map(mp => [mp.id, { enabled: true, status: 'pending', command: 'command' in mp && mp.command ? mp.command({ name, title, description, tagline: opts.tagline, category: opts.category, tags: opts.tags.split(',').map(t => t.trim()).filter(Boolean).slice(0, 10), price: Number.parseInt(opts.price, 10) || 0, skillFile, sourceUrl: opts.sourceUrl, marketplaces: {} }) : undefined, note: 'note' in mp ? mp.note : undefined }])) as SkillManifest['marketplaces'], | ||||||||||||||
| marketplaces: Object.fromEntries(MARKETPLACES.map(mp => [mp.id, { enabled: true, status: 'pending', command: 'command' in mp && mp.command ? mp.command({ name, title, description, tagline: opts.tagline, category: opts.category, tags, price, skillFile, sourceUrl: opts.sourceUrl, marketplaces: {} }) : undefined, note: 'note' in mp ? mp.note : undefined }])) as SkillManifest['marketplaces'], | ||||||||||||||
| }; | ||||||||||||||
| await mkdir(dirname(resolve(opts.out)), { recursive: true }); | ||||||||||||||
| await saveManifest(opts.out, manifest); | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempDiris declared asstringbut is never initialised, so its runtime value isundefineduntilskillFixture()runs. Typing it asstring | undefinedmakes the intent explicit and prevents the compiler from masking accidental reads before assignment.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!