opencastle 1.4.3 → 1.5.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/dist/cli/bootstrap-on-init.test.js +5 -5
- package/dist/cli/bootstrap-on-init.test.js.map +1 -1
- package/dist/cli/bootstrap.d.ts +17 -0
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +284 -312
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/bootstrap.test.js +22 -16
- package/dist/cli/bootstrap.test.js.map +1 -1
- package/dist/cli/convoy/engine.d.ts.map +1 -1
- package/dist/cli/convoy/engine.js +8 -2
- package/dist/cli/convoy/engine.js.map +1 -1
- package/dist/cli/detect.d.ts +4 -0
- package/dist/cli/detect.d.ts.map +1 -1
- package/dist/cli/detect.js +1 -1
- package/dist/cli/detect.js.map +1 -1
- package/dist/cli/doctor.js +4 -4
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.test.js +4 -5
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/log.d.ts +2 -2
- package/dist/cli/log.d.ts.map +1 -1
- package/dist/cli/log.js +1 -1
- package/dist/cli/log.js.map +1 -1
- package/dist/cli/log.test.js +1 -1
- package/dist/cli/log.test.js.map +1 -1
- package/dist/cli/managed-paths.d.ts +1 -1
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +0 -1
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/project-facts.d.ts +103 -0
- package/dist/cli/project-facts.d.ts.map +1 -0
- package/dist/cli/project-facts.js +577 -0
- package/dist/cli/project-facts.js.map +1 -0
- package/dist/cli/project-facts.test.d.ts +2 -0
- package/dist/cli/project-facts.test.d.ts.map +1 -0
- package/dist/cli/project-facts.test.js +209 -0
- package/dist/cli/project-facts.test.js.map +1 -0
- package/dist/cli/stack-config.js +1 -1
- package/dist/cli/stack-config.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/bootstrap-on-init.test.ts +5 -5
- package/src/cli/bootstrap.test.ts +22 -16
- package/src/cli/bootstrap.ts +361 -373
- package/src/cli/convoy/engine.ts +9 -2
- package/src/cli/detect.ts +1 -1
- package/src/cli/doctor.ts +4 -4
- package/src/cli/init.test.ts +4 -5
- package/src/cli/log.test.ts +1 -1
- package/src/cli/log.ts +2 -2
- package/src/cli/managed-paths.ts +0 -1
- package/src/cli/project-facts.test.ts +228 -0
- package/src/cli/project-facts.ts +647 -0
- package/src/cli/stack-config.ts +1 -1
- package/src/orchestrator/agent-workflows/data-pipeline.md +2 -2
- package/src/orchestrator/agent-workflows/feature-implementation.md +1 -1
- package/src/orchestrator/agent-workflows/schema-changes.md +1 -1
- package/src/orchestrator/agents/team-lead.agent.md +1 -1
- package/src/orchestrator/customizations/README.md +27 -84
- package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +38 -238
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/implement-feature.prompt.md +6 -6
- package/src/orchestrator/skills/agent-memory/KNOWLEDGE-GRAPH.md +1 -1
- package/src/orchestrator/skills/agent-memory/SKILL.md +7 -16
- package/src/orchestrator/skills/documentation-standards/SKILL.md +1 -1
- package/src/orchestrator/skills/observability-logging/SKILL.md +1 -1
- package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +1 -1
- package/src/orchestrator/skills/team-lead-reference/SKILL.md +2 -2
- package/src/orchestrator/customizations/AGENT-EXPERTISE.md +0 -325
- package/src/orchestrator/customizations/AGENT-FAILURES.md +0 -69
- package/src/orchestrator/customizations/AGENT-PERFORMANCE.md +0 -55
- package/src/orchestrator/customizations/DISPUTES.md +0 -162
- package/src/orchestrator/customizations/KNOWLEDGE-GRAPH.md +0 -10
- package/src/orchestrator/customizations/agents/skill-matrix.md +0 -111
- package/src/orchestrator/customizations/logs/events.ndjson +0 -0
- package/src/orchestrator/customizations/project/decisions.md +0 -31
- package/src/orchestrator/customizations/project/docs-structure.md +0 -34
- package/src/orchestrator/customizations/project/roadmap.md +0 -24
- /package/src/orchestrator/{customizations/logs/README.md → skills/observability-logging/LOG-SCHEMA.md} +0 -0
package/src/cli/convoy/engine.ts
CHANGED
|
@@ -389,15 +389,22 @@ function buildDlqMarkdownEntry(
|
|
|
389
389
|
return { marker, entry }
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
+
/** The heading a ledger starts with: `init` no longer installs the files empty, so the first entry creates them. */
|
|
393
|
+
const LEDGER_TITLE: Record<string, string> = {
|
|
394
|
+
'AGENT-FAILURES.md': '# Agent Failures\n\nDelegations that failed for good: the dead-letter queue. Format: the **team-lead-reference** skill.\n',
|
|
395
|
+
'DISPUTES.md': '# Disputes\n\nDisagreements review could not settle, for a person to decide. Format: the **team-lead-reference** skill.\n',
|
|
396
|
+
}
|
|
397
|
+
|
|
392
398
|
function appendLedger(repoRoot: string, file: string, marker: string, entry: string): void {
|
|
393
399
|
const mdPath = join(resolve(repoRoot), '.opencastle', file)
|
|
400
|
+
let exists = true
|
|
394
401
|
try {
|
|
395
402
|
if (readFileSync(mdPath, 'utf8').includes(marker)) return
|
|
396
403
|
} catch {
|
|
397
|
-
|
|
404
|
+
exists = false
|
|
398
405
|
}
|
|
399
406
|
mkdirSync(dirname(mdPath), { recursive: true })
|
|
400
|
-
appendFileSync(mdPath, entry)
|
|
407
|
+
appendFileSync(mdPath, (exists ? '' : LEDGER_TITLE[file] ?? '') + entry)
|
|
401
408
|
}
|
|
402
409
|
|
|
403
410
|
/**
|
package/src/cli/detect.ts
CHANGED
|
@@ -196,7 +196,7 @@ const AUTH: DetectionRule[] = [
|
|
|
196
196
|
];
|
|
197
197
|
|
|
198
198
|
// Mapping of npm package names to detection labels
|
|
199
|
-
const PACKAGE_DETECTIONS: Record<string, { category: string; label: string }> = {
|
|
199
|
+
export const PACKAGE_DETECTIONS: Record<string, { category: string; label: string }> = {
|
|
200
200
|
'next': { category: 'frameworks', label: 'next' },
|
|
201
201
|
'nuxt': { category: 'frameworks', label: 'nuxt' },
|
|
202
202
|
'astro': { category: 'frameworks', label: 'astro' },
|
package/src/cli/doctor.ts
CHANGED
|
@@ -226,13 +226,13 @@ async function checkLogs(projectRoot: string): Promise<CheckResult> {
|
|
|
226
226
|
const dir = resolve(projectRoot, '.opencastle', 'logs');
|
|
227
227
|
if (!existsSync(dir)) {
|
|
228
228
|
// A local run artefact, not part of the project, so a fresh clone has none —
|
|
229
|
-
// and calling that a failure made `doctor` exit 1 on every clone.
|
|
230
|
-
// creates it; until then "
|
|
229
|
+
// and calling that a failure made `doctor` exit 1 on every clone. The first
|
|
230
|
+
// `opencastle log` creates it; until then "none yet" is the honest reading,
|
|
231
|
+
// and not something to warn about on every new install.
|
|
231
232
|
return {
|
|
232
233
|
ok: true,
|
|
233
|
-
warning: true,
|
|
234
234
|
label: 'Observability logs',
|
|
235
|
-
detail: '
|
|
235
|
+
detail: 'none yet — created when an agent first logs a session',
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
// A diagnostic does not write. This used to create five empty `.ndjson` files
|
package/src/cli/init.test.ts
CHANGED
|
@@ -396,15 +396,14 @@ describe('VS Code adapter install', () => {
|
|
|
396
396
|
expect(existsSync(join(tempDir, '.vscode', 'mcp.json'))).toBe(true)
|
|
397
397
|
})
|
|
398
398
|
|
|
399
|
-
it('
|
|
399
|
+
it('installs no empty logs or ledgers: the first record creates them', async () => {
|
|
400
400
|
const adapter = await IDE_ADAPTERS['vscode']()
|
|
401
401
|
await adapter.install(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
|
|
402
402
|
await scaffoldCustomizations(PKG_ROOT, tempDir, STACK_EMPTY)
|
|
403
403
|
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
expect(existsSync(join(logsDir, file))).toBe(true)
|
|
404
|
+
const dir = join(tempDir, '.opencastle')
|
|
405
|
+
for (const file of ['logs', 'AGENT-FAILURES.md', 'DISPUTES.md', 'AGENT-EXPERTISE.md', 'AGENT-PERFORMANCE.md', 'KNOWLEDGE-GRAPH.md']) {
|
|
406
|
+
expect(existsSync(join(dir, file)), file).toBe(false)
|
|
408
407
|
}
|
|
409
408
|
})
|
|
410
409
|
|
package/src/cli/log.test.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
5
5
|
import log, { LOG_RECORDS, parseLogArgs } from './log.js'
|
|
6
6
|
|
|
7
7
|
const repoRoot = resolve(import.meta.dirname, '..', '..')
|
|
8
|
-
const README = join(repoRoot, 'src', 'orchestrator', '
|
|
8
|
+
const README = join(repoRoot, 'src', 'orchestrator', 'skills', 'observability-logging', 'LOG-SCHEMA.md')
|
|
9
9
|
const SKILL = join(repoRoot, 'src', 'orchestrator', 'skills', 'observability-logging', 'SKILL.md')
|
|
10
10
|
|
|
11
11
|
/** The `opencastle log …` command lines in a document's sh blocks, continuation lines joined. */
|
package/src/cli/log.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { CliContext } from './types.js'
|
|
|
13
13
|
* `--type session` with no fields, `--outcome banana`, a value-less `--model`
|
|
14
14
|
* stored as `true`, `--task 007` stored as the number 7, `--agnet`, and a
|
|
15
15
|
* caller-supplied `--timestamp yesterday`. Each record type is now checked
|
|
16
|
-
* against the schema in `
|
|
16
|
+
* against the schema in `skills/observability-logging/LOG-SCHEMA.md`, field by field, and a
|
|
17
17
|
* record that does not match is refused with every reason at once.
|
|
18
18
|
*/
|
|
19
19
|
|
|
@@ -34,7 +34,7 @@ const attempt: Field = { kind: 'count', required: true, min: 1 }
|
|
|
34
34
|
|
|
35
35
|
const OUTCOMES = ['success', 'partial', 'failed'] as const
|
|
36
36
|
|
|
37
|
-
/** The record schemas, as `
|
|
37
|
+
/** The record schemas, as `skills/observability-logging/LOG-SCHEMA.md` documents them. `log.test.ts` holds the two together. */
|
|
38
38
|
export const LOG_RECORDS: Record<string, Record<string, Field>> = {
|
|
39
39
|
session: {
|
|
40
40
|
agent: req('text'),
|
package/src/cli/managed-paths.ts
CHANGED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
2
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
import { readProjectFacts } from './project-facts.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The facts `init` writes into `.opencastle/`, read from small project trees
|
|
9
|
+
* shaped like the real ones they stand for.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
let root = ''
|
|
13
|
+
|
|
14
|
+
function project(files: Record<string, string>): string {
|
|
15
|
+
root = mkdtempSync(join(tmpdir(), 'oc-facts-'))
|
|
16
|
+
for (const [path, text] of Object.entries(files)) {
|
|
17
|
+
mkdirSync(dirname(join(root, path)), { recursive: true })
|
|
18
|
+
writeFileSync(join(root, path), text)
|
|
19
|
+
}
|
|
20
|
+
return root
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
if (root) rmSync(root, { recursive: true, force: true })
|
|
25
|
+
root = ''
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const pkg = (body: object): string => JSON.stringify(body)
|
|
29
|
+
|
|
30
|
+
describe('routes', () => {
|
|
31
|
+
it('reads Next.js App Router pages and route handlers, without groups, slots or private folders', async () => {
|
|
32
|
+
const r = project({
|
|
33
|
+
'package.json': pkg({ dependencies: { next: '^15.1.0' } }),
|
|
34
|
+
'app/page.tsx': '',
|
|
35
|
+
'app/(marketing)/pricing/page.tsx': '',
|
|
36
|
+
'app/blog/[slug]/page.mdx': '',
|
|
37
|
+
'app/@modal/login/page.tsx': '',
|
|
38
|
+
'app/_components/card/page.tsx': '',
|
|
39
|
+
'app/api/posts/route.ts': 'export async function GET() {}\nexport const POST = handler',
|
|
40
|
+
'pages/api/legacy.ts': 'export default function handler() {}',
|
|
41
|
+
})
|
|
42
|
+
const facts = await readProjectFacts(r, { frameworks: ['next'] })
|
|
43
|
+
expect(facts.pages).toEqual([{ root: 'app/', routes: ['/', '/blog/[slug]', '/login', '/pricing'] }])
|
|
44
|
+
expect(facts.api).toEqual([
|
|
45
|
+
{ route: '/api/legacy', methods: [], file: 'pages/api/legacy.ts' },
|
|
46
|
+
{ route: '/api/posts', methods: ['GET', 'POST'], file: 'app/api/posts/route.ts' },
|
|
47
|
+
])
|
|
48
|
+
expect(facts.stack).toEqual([{ layer: 'Framework', name: 'Next.js', version: '15.1.0' }])
|
|
49
|
+
expect(facts.devPort).toBe(3000)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('leaves out Astro files whose path has a part starting with an underscore', async () => {
|
|
53
|
+
const r = project({
|
|
54
|
+
'package.json': pkg({ dependencies: { astro: '5.0.0' } }),
|
|
55
|
+
'src/pages/index.astro': '',
|
|
56
|
+
'src/pages/posts/[slug].astro': '',
|
|
57
|
+
'src/pages/posts/_components/Card.astro': '',
|
|
58
|
+
'src/pages/_utils/group.ts': 'export function group() {}',
|
|
59
|
+
'src/pages/rss.xml.ts': 'export const GET = () => new Response()',
|
|
60
|
+
})
|
|
61
|
+
const facts = await readProjectFacts(r, { frameworks: ['astro'] })
|
|
62
|
+
expect(facts.pages[0].routes).toEqual(['/', '/posts/[slug]'])
|
|
63
|
+
expect(facts.api.map((a) => [a.route, a.methods])).toEqual([['/rss.xml', ['GET']]])
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('reads SvelteKit pages and server routes', async () => {
|
|
67
|
+
const r = project({
|
|
68
|
+
'package.json': pkg({}),
|
|
69
|
+
'src/routes/+page.svelte': '',
|
|
70
|
+
'src/routes/about/+page.svelte': '',
|
|
71
|
+
'src/routes/api/items/+server.ts': 'export async function GET() {}\nexport async function DELETE() {}',
|
|
72
|
+
})
|
|
73
|
+
const facts = await readProjectFacts(r, { frameworks: ['sveltekit'] })
|
|
74
|
+
expect(facts.pages[0]).toEqual({ root: 'src/routes/', routes: ['/', '/about'] })
|
|
75
|
+
expect(facts.api).toEqual([{ route: '/api/items', methods: ['GET', 'DELETE'], file: 'src/routes/api/items/+server.ts' }])
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('finds routes in each app of a monorepo', async () => {
|
|
79
|
+
const r = project({
|
|
80
|
+
'package.json': pkg({ name: 'mono' }),
|
|
81
|
+
'apps/web/package.json': pkg({ name: '@x/web', dependencies: { next: '15.0.0' } }),
|
|
82
|
+
'apps/web/src/app/page.tsx': '',
|
|
83
|
+
'apps/web/src/app/settings/page.tsx': '',
|
|
84
|
+
})
|
|
85
|
+
const facts = await readProjectFacts(r, { frameworks: ['next'] })
|
|
86
|
+
expect(facts.pages).toEqual([{ root: 'apps/web/src/app/', routes: ['/', '/settings'] }])
|
|
87
|
+
expect(facts.workspaces).toEqual([{ path: 'apps/web/', name: '@x/web', purpose: 'Next.js app' }])
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('reads Express-style routes when there are no route files', async () => {
|
|
91
|
+
const r = project({
|
|
92
|
+
'package.json': pkg({ dependencies: { express: '4.19.0' } }),
|
|
93
|
+
'src/server.js': "app.get('/health', h)\napp.post('/notes', h)\nrouter.delete('/notes/:id', h)",
|
|
94
|
+
})
|
|
95
|
+
const facts = await readProjectFacts(r, { frameworks: ['express'] })
|
|
96
|
+
expect(facts.api.map((a) => `${a.methods.join(',')} ${a.route}`)).toEqual(['GET /health', 'POST /notes', 'DELETE /notes/:id'])
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('data', () => {
|
|
101
|
+
it('lists Prisma models and its migrations', async () => {
|
|
102
|
+
const r = project({
|
|
103
|
+
'package.json': pkg({ dependencies: { '@prisma/client': '^5.2.0' } }),
|
|
104
|
+
'prisma/schema.prisma': 'model User {\n id Int @id\n}\n\nmodel Post {\n id Int @id\n}\nenum Role { A }\n',
|
|
105
|
+
'prisma/migrations/20240101_init/migration.sql': '',
|
|
106
|
+
'prisma/migrations/20240202_posts/migration.sql': '',
|
|
107
|
+
'lib/db.ts': "import { PrismaClient } from '@prisma/client'",
|
|
108
|
+
'app/page.tsx': "import type { User } from '@prisma/client'",
|
|
109
|
+
})
|
|
110
|
+
const facts = await readProjectFacts(r, { databases: ['prisma'] })
|
|
111
|
+
expect(facts.models).toEqual({ source: 'prisma/schema.prisma', names: ['User', 'Post'] })
|
|
112
|
+
expect(facts.migrations).toEqual({ dir: 'prisma/migrations/', count: 2, latest: ['20240101_init', '20240202_posts'] })
|
|
113
|
+
// The file that sets the client up comes before the pages that use it.
|
|
114
|
+
expect(facts.importers.prisma[0]).toBe('lib/db.ts')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('lists Drizzle tables from every schema file', async () => {
|
|
118
|
+
const r = project({
|
|
119
|
+
'package.json': pkg({}),
|
|
120
|
+
'packages/db/src/schema.ts': 'export const Post = pgTable("post", {})',
|
|
121
|
+
'packages/db/src/auth-schema.ts': 'export const user = pgTable("user", {})\nexport const session = pgTable("session", {})',
|
|
122
|
+
})
|
|
123
|
+
const facts = await readProjectFacts(r, { databases: ['drizzle'] })
|
|
124
|
+
expect(facts.models?.names.sort()).toEqual(['post', 'session', 'user'])
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('lists Supabase tables from its migrations', async () => {
|
|
128
|
+
const r = project({
|
|
129
|
+
'package.json': pkg({}),
|
|
130
|
+
'supabase/migrations/20240101000000_init.sql': 'create table public.profiles (id uuid);\nCREATE TABLE IF NOT EXISTS "orders" ();',
|
|
131
|
+
})
|
|
132
|
+
const facts = await readProjectFacts(r, { databases: ['supabase'] })
|
|
133
|
+
expect(facts.models).toEqual({ source: 'supabase/migrations/', names: ['profiles', 'orders'] })
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
describe('everything else', () => {
|
|
138
|
+
it('takes variable names from the example file and never reads .env', async () => {
|
|
139
|
+
const r = project({
|
|
140
|
+
'package.json': pkg({}),
|
|
141
|
+
'.env': 'SECRET_ONLY_IN_ENV=hunter2\n',
|
|
142
|
+
'.env.example': 'DATABASE_URL=\nexport STRIPE_KEY=sk_test\n# COMMENTED=1\n',
|
|
143
|
+
})
|
|
144
|
+
const facts = await readProjectFacts(r, {})
|
|
145
|
+
expect(facts.envVars).toEqual({ source: '.env.example', names: ['DATABASE_URL', 'STRIPE_KEY'] })
|
|
146
|
+
expect(JSON.stringify(facts)).not.toContain('SECRET_ONLY_IN_ENV')
|
|
147
|
+
expect(JSON.stringify(facts)).not.toContain('hunter2')
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('reads Tailwind breakpoints, but not the container sizes', async () => {
|
|
151
|
+
const r = project({
|
|
152
|
+
'package.json': pkg({}),
|
|
153
|
+
'tailwind.config.js': 'module.exports = { theme: { container: { screens: { "2xl": "1400px" } }, extend: { screens: { "3xl": "1920px" } } } }',
|
|
154
|
+
})
|
|
155
|
+
const facts = await readProjectFacts(r, { styling: ['tailwind'] })
|
|
156
|
+
const values = Object.fromEntries(facts.breakpoints!.values)
|
|
157
|
+
expect(values['2xl']).toBe('1536px')
|
|
158
|
+
expect(values['3xl']).toBe('1920px')
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('resolves pnpm catalog versions from a workspace package', async () => {
|
|
162
|
+
const r = project({
|
|
163
|
+
'package.json': pkg({ name: 'mono' }),
|
|
164
|
+
'pnpm-workspace.yaml': 'packages:\n - apps/*\ncatalog:\n next: ^16.0.1\n "@prisma/client": 6.1.0\n',
|
|
165
|
+
'apps/web/package.json': pkg({ dependencies: { next: 'catalog:', '@prisma/client': 'catalog:' } }),
|
|
166
|
+
})
|
|
167
|
+
const facts = await readProjectFacts(r, { frameworks: ['next'], databases: ['prisma'] })
|
|
168
|
+
expect(facts.stack).toEqual([
|
|
169
|
+
{ layer: 'Framework', name: 'Next.js', version: '16.0.1' },
|
|
170
|
+
{ layer: 'Database', name: 'Prisma', version: '6.1.0' },
|
|
171
|
+
])
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('describes the project from the README introduction only', async () => {
|
|
175
|
+
const intro = project({
|
|
176
|
+
'package.json': pkg({ name: 'x' }),
|
|
177
|
+
'README.md': '# X\n\n[](https://x)\n\nX turns [notes](https://n) into tasks.\n\n## Install\n\nRun this:\n',
|
|
178
|
+
})
|
|
179
|
+
expect((await readProjectFacts(intro, {})).description).toBe('X turns notes into tasks.')
|
|
180
|
+
rmSync(intro, { recursive: true, force: true })
|
|
181
|
+
|
|
182
|
+
const howTo = project({
|
|
183
|
+
'package.json': pkg({ name: 'y' }),
|
|
184
|
+
'README.md': '# Y\n\nThere are two ways to start:\n\n## Setup\n\nY is great.\n',
|
|
185
|
+
})
|
|
186
|
+
expect((await readProjectFacts(howTo, {})).description).toBeUndefined()
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('takes a port from the dev script before the framework default', async () => {
|
|
190
|
+
const r = project({ 'package.json': pkg({ scripts: { dev: 'next dev -p 4000' } }) })
|
|
191
|
+
expect((await readProjectFacts(r, { frameworks: ['next'] })).devPort).toBe(4000)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
it('reads what CI runs, the Node version and the coverage the tests require', async () => {
|
|
195
|
+
const r = project({
|
|
196
|
+
'package.json': pkg({ engines: { node: '>=20' }, devDependencies: { vitest: '2.0.0' } }),
|
|
197
|
+
'.github/workflows/ci.yml': [
|
|
198
|
+
'jobs:',
|
|
199
|
+
' test:',
|
|
200
|
+
' steps:',
|
|
201
|
+
' - run: pnpm install --frozen-lockfile',
|
|
202
|
+
' - run: pnpm lint',
|
|
203
|
+
' - name: Test',
|
|
204
|
+
' run: |',
|
|
205
|
+
' pnpm test --coverage',
|
|
206
|
+
' echo done',
|
|
207
|
+
].join('\n'),
|
|
208
|
+
'vitest.config.ts': 'export default { test: { coverage: { thresholds: { lines: 80, branches: 70 } } } }',
|
|
209
|
+
})
|
|
210
|
+
const facts = await readProjectFacts(r, { packageManager: 'pnpm' })
|
|
211
|
+
expect(facts.ciCommands).toEqual(['pnpm lint', 'pnpm test --coverage'])
|
|
212
|
+
expect(facts.nodeVersion).toBe('>=20')
|
|
213
|
+
expect(facts.coverage).toEqual(['lines 80', 'branches 70'])
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('names test frameworks from package.json only, and finds the test files', async () => {
|
|
217
|
+
const r = project({
|
|
218
|
+
'package.json': pkg({ devDependencies: { vitest: '^2.0.0' } }),
|
|
219
|
+
'vitest.config.ts': '',
|
|
220
|
+
'src/a.test.ts': '',
|
|
221
|
+
'e2e/login.spec.ts': '',
|
|
222
|
+
})
|
|
223
|
+
const facts = await readProjectFacts(r, { testing: ['vitest', 'chrome-devtools'] })
|
|
224
|
+
expect(facts.testFrameworks).toEqual(['Vitest'])
|
|
225
|
+
expect(facts.testConfigs).toEqual(['vitest.config.ts'])
|
|
226
|
+
expect(facts.testFiles.sort()).toEqual(['e2e/login.spec.ts', 'src/a.test.ts'])
|
|
227
|
+
})
|
|
228
|
+
})
|