Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/agent/prompts/skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type { FeaturesConfig } from '../../core/config.ts'
import { writeFileSync } from 'node:fs'
import { join } from 'pathe'
import { todayIsoDate } from '../../core/formatting.ts'
import { repairMarkdown, sanitizeMarkdown } from '../../core/sanitize.ts'
import { resolveSkilldCommand } from '../../core/shared.ts'
import { yamlEscape } from '../../core/yaml.ts'
Expand Down Expand Up @@ -232,7 +233,7 @@ function generateFrontmatter({ name, version, description: pkgDescription, globs
metaEntries.push(` version: ${yamlEscape(version)}`)
if (body && generatedBy)
metaEntries.push(` generated_by: ${yamlEscape(generatedBy)}`)
metaEntries.push(` generated_at: ${new Date().toISOString().split('T')[0]}`)
metaEntries.push(` generated_at: ${todayIsoDate()}`)
if (metaEntries.length) {
lines.push('metadata:')
lines.push(...metaEntries)
Expand Down
3 changes: 2 additions & 1 deletion src/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { defineCommand } from 'citty'
import { join } from 'pathe'
import { agents, linkSkillToAgents } from '../agent/index.ts'
import { resolveAgent } from '../cli-helpers.ts'
import { todayIsoDate } from '../core/formatting.ts'
import { readLock, writeLock } from '../core/lockfile.ts'
import { getShippedSkills, linkShippedSkill, restorePkgSymlink } from '../core/prepare.ts'
import { getSharedSkillsDir } from '../core/shared.ts'
Expand Down Expand Up @@ -91,7 +92,7 @@ export const prepareCommandDef = defineCommand({
packageName: entry.packageName,
version,
source: 'shipped',
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down
6 changes: 3 additions & 3 deletions src/commands/sync-git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
resolvePkgDir,
} from '../cache/index.ts'
import { defaultFeatures, readConfig, registerProject } from '../core/config.ts'
import { timedSpinner } from '../core/formatting.ts'
import { timedSpinner, todayIsoDate } from '../core/formatting.ts'
import { writeLock } from '../core/lockfile.ts'
import { sanitizeMarkdown } from '../core/sanitize.ts'
import { getSharedSkillsDir } from '../core/shared.ts'
Expand Down Expand Up @@ -154,7 +154,7 @@ export async function syncGitSkills(opts: GitSyncOptions): Promise<void> {
repo: source.type === 'local' ? source.localPath : `${source.owner}/${source.repo}`,
path: skill.path || undefined,
ref: source.ref || 'main',
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'external',
})
}
Expand Down Expand Up @@ -271,7 +271,7 @@ async function syncGitHubRepo(opts: GitSyncOptions): Promise<void> {
version,
repo: `${owner}/${repo}`,
source: resources.docSource,
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down
4 changes: 2 additions & 2 deletions src/commands/sync-parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
resolvePkgDir,
} from '../cache/index.ts'
import { defaultFeatures, readConfig, registerProject } from '../core/config.ts'
import { formatDuration } from '../core/formatting.ts'
import { formatDuration, todayIsoDate } from '../core/formatting.ts'
import { parsePackageNames, parsePackages, readLock, writeLock } from '../core/lockfile.ts'
import { parseFrontmatter } from '../core/markdown.ts'
import { getSharedSkillsDir, semverDiff, SHARED_SKILLS_DIR } from '../core/shared.ts'
Expand Down Expand Up @@ -566,7 +566,7 @@ async function syncBaseSkill(
version,
repo: repoSlug,
source: resources.docSource,
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down
3 changes: 2 additions & 1 deletion src/commands/sync-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from '../cache/index.ts'
import { isInteractive, NO_MODELS_MESSAGE, pickModel } from '../cli-helpers.ts'
import { defaultFeatures, readConfig, registerProject, updateConfig } from '../core/config.ts'
import { todayIsoDate } from '../core/formatting.ts'
import { parsePackages, readLock, writeLock } from '../core/lockfile.ts'
import { parseFrontmatter } from '../core/markdown.ts'
import { readPackageJsonSafe } from '../core/package-json.ts'
Expand Down Expand Up @@ -239,7 +240,7 @@ export function handleShippedSkills(
packageName,
version,
source: 'shipped',
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '../cache/index.ts'
import { getInstalledGenerators, introLine, isInteractive, promptForAgent, resolveAgent, sharedArgs, suggestPrepareHook } from '../cli-helpers.ts'
import { defaultFeatures, hasCompletedWizard, readConfig, registerProject } from '../core/config.ts'
import { timedSpinner } from '../core/formatting.ts'
import { timedSpinner, todayIsoDate } from '../core/formatting.ts'
import { parsePackageNames, parsePackages, readLock, removeLockEntry, writeLock } from '../core/lockfile.ts'
import { parseFrontmatter } from '../core/markdown.ts'
import { parseSkillInput, resolveSkillName, toStoragePackageName } from '../core/prefix.ts'
Expand Down Expand Up @@ -467,7 +467,7 @@ async function syncSinglePackage(packageSpec: string, config: SyncConfig): Promi
version,
repo: repoSlug,
source: existingLock.source,
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down Expand Up @@ -579,7 +579,7 @@ async function syncSinglePackage(packageSpec: string, config: SyncConfig): Promi
version,
repo: repoSlug,
source: resources.docSource,
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down Expand Up @@ -1255,7 +1255,7 @@ export async function exportPortablePrompts(packageSpec: string, opts: {
version,
repo: repoSlug,
source: resources.docSource,
syncedAt: new Date().toISOString().split('T')[0],
syncedAt: todayIsoDate(),
generator: 'skilld',
})

Expand Down
4 changes: 4 additions & 0 deletions src/core/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type { SearchSnippet } from '../retriv/index.ts'
import type { ProjectState } from './skills.ts'
import * as p from '@clack/prompts'

export function todayIsoDate(): string {
return new Date().toISOString().split('T')[0]!
}

export function timeAgo(iso?: string): string {
if (!iso)
return ''
Expand Down
13 changes: 13 additions & 0 deletions test/unit/formatting.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, it, vi } from 'vitest'
import { todayIsoDate } from '../../src/core/formatting'

describe('formatting', () => {
it('formats the current UTC day as YYYY-MM-DD', () => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-04-28T23:59:59.000Z'))

expect(todayIsoDate()).toBe('2026-04-28')

vi.useRealTimers()
})
})
Loading