Skip to content

Commit c2e524b

Browse files
refactor(buddy): move protocol + docs governance commands from userland into core (#2192)
The protocol-conformance and docs-freshness tooling lived under app/Commands/{protocol,docs} (userland), but these are framework-repo core commands, not app code. Move them into storage/framework/core/buddy/src/commands/ and register them through the core lazy-command loader + barrel, like every other built-in command. - git-mv the 27 tooling + test files, preserving history - Protocol.ts/Docs.ts become named-export core registrars (protocol()/docs()) - 22 protocol:* / docs:* entries added to lazy-commands.ts; commands barrel updated - fix repo-root path depth (import.meta.dir) + cross-package imports for the new location; update CI workflow + generated-doc paths - app/Commands.ts drops the protocol/docs registrations (keeps the inspire example) - fix 6 latent strict-null type errors the looser app/ tsconfig had hidden (regex-group / buffer-index access) so the tooling passes framework typecheck Verified: framework typecheck clean in the moved files, lint clean, 48/48 moved tests pass, buddy protocol:* / docs:* wire + run correctly. protocol-conformance CI stays red on the pre-existing #2179 governance-evidence drift (orphaned bf1245e pin), unrelated to this move.
1 parent 34d66f8 commit c2e524b

33 files changed

Lines changed: 121 additions & 89 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ jobs:
174174
env:
175175
PROTOCOL_REPORT_DIR: .github/protocol/reports
176176
run: |
177-
bun test ./app/Commands/protocol/run-conformance.test.ts
178-
bun test ./app/Commands/protocol/craft-evidence.test.ts ./app/Commands/protocol/desktop-lifecycle-report.test.ts
177+
bun test ./storage/framework/core/buddy/src/commands/protocol/run-conformance.test.ts
178+
bun test ./storage/framework/core/buddy/src/commands/protocol/craft-evidence.test.ts ./storage/framework/core/buddy/src/commands/protocol/desktop-lifecycle-report.test.ts
179179
bun test ./.github/scripts/deploy/resolve-target.test.ts
180180
bun run protocol:drivers:test
181181
bun run protocol:conformance

.github/workflows/desktop-lifecycle.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ on:
55
branches: [main]
66
paths:
77
- storage/framework/core/desktop/**
8-
- app/Commands/protocol/craft-evidence.ts
9-
- app/Commands/protocol/desktop-lifecycle-report.ts
8+
- storage/framework/core/buddy/src/commands/protocol/craft-evidence.ts
9+
- storage/framework/core/buddy/src/commands/protocol/desktop-lifecycle-report.ts
1010
- .github/protocol/evidence/craft.json
1111
- .github/workflows/desktop-lifecycle.yml
1212
pull_request:
1313
branches: [main]
1414
paths:
1515
- storage/framework/core/desktop/**
16-
- app/Commands/protocol/craft-evidence.ts
17-
- app/Commands/protocol/desktop-lifecycle-report.ts
16+
- storage/framework/core/buddy/src/commands/protocol/craft-evidence.ts
17+
- storage/framework/core/buddy/src/commands/protocol/desktop-lifecycle-report.ts
1818
- .github/protocol/evidence/craft.json
1919
- .github/workflows/desktop-lifecycle.yml
2020
workflow_dispatch:
@@ -123,7 +123,7 @@ jobs:
123123

124124
- name: Validate and attest lifecycle report
125125
run: >-
126-
bun app/Commands/protocol/desktop-lifecycle-report.ts
126+
bun storage/framework/core/buddy/src/commands/protocol/desktop-lifecycle-report.ts
127127
--report .craft-contract/artifacts/native-lifecycle/${{ matrix.name }}/report.json
128128
--output .github/protocol/reports/desktop/${{ matrix.name }}/attestation.json
129129
--revision "$CRAFT_SOURCE_REVISION"

app/Commands.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ export type CommandRegistry = Record<string, string | CommandConfig>
2828
*/
2929
export default {
3030
'inspire': 'Inspire',
31-
'protocol': 'Protocol',
32-
'docs': 'Docs',
3331
} satisfies CommandRegistry

docs/guide/buddy/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Buddy Command Reference
33
description: Generated reference for every Buddy command, argument, option, alias, default, and example.
44
---
5-
<!-- Generated by app/Commands/docs/buddy-commands.ts. Do not edit by hand. -->
5+
<!-- Generated by storage/framework/core/buddy/src/commands/docs/buddy-commands.ts. Do not edit by hand. -->
66

77
# Buddy Command Reference
88

app/Commands/Docs.ts renamed to storage/framework/core/buddy/src/commands/docs.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ import { run as runLinks } from './docs/links'
55
import { runTool } from './run-tool'
66

77
/**
8-
* Repo-scoped `buddy docs:*` commands wrapping the documentation-freshness
9-
* tooling under `app/Commands/docs/`: the generated buddy command reference,
8+
* Framework-repo `buddy docs:*` commands wrapping the documentation-freshness
9+
* tooling under `commands/docs/`: the generated buddy command reference,
1010
* generated API artifacts (OpenAPI + types), and internal link checking.
1111
*/
12-
export default function (cli: CLI): void {
13-
cli
12+
export function docs(buddy: CLI): void {
13+
buddy
1414
.command('docs:buddy', 'Regenerate the buddy command reference doc')
1515
.action(async () => {
1616
await runTool(runBuddyDocs, '--write')
1717
})
1818

19-
cli
19+
buddy
2020
.command('docs:buddy:check', 'Verify the buddy command reference doc is current')
2121
.action(async () => {
2222
await runTool(runBuddyDocs, '--check')
2323
})
2424

25-
cli
25+
buddy
2626
.command('docs:artifacts', 'Regenerate the generated API artifacts (OpenAPI + types)')
2727
.action(async () => {
2828
await runTool(runArtifacts, '--write')
2929
})
3030

31-
cli
31+
buddy
3232
.command('docs:artifacts:check', 'Verify the generated API artifacts are current')
3333
.action(async () => {
3434
await runTool(runArtifacts, '--check')
3535
})
3636

37-
cli
37+
buddy
3838
.command('docs:links', 'Report internal documentation links')
3939
.action(async () => {
4040
await runTool(runLinks)
4141
})
4242

43-
cli
43+
buddy
4444
.command('docs:links:check', 'Verify internal documentation links resolve')
4545
.action(async () => {
4646
await runTool(runLinks, '--check')

app/Commands/docs/buddy-commands.test.ts renamed to storage/framework/core/buddy/src/commands/docs/buddy-commands.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BuddyCommandInventoryEntry } from '../../../storage/framework/core/buddy/src/commands/list'
1+
import type { BuddyCommandInventoryEntry } from '../list'
22
import { describe, expect, it } from 'bun:test'
33
import { renderBuddyCommandReference } from './buddy-commands'
44

app/Commands/docs/buddy-commands.ts renamed to storage/framework/core/buddy/src/commands/docs/buddy-commands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BuddyCommandInventoryEntry, BuddyCommandInventoryOption } from '../../../storage/framework/core/buddy/src/commands/list'
1+
import type { BuddyCommandInventoryEntry, BuddyCommandInventoryOption } from '../list'
22
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
33
import { dirname, resolve } from 'node:path'
44

@@ -7,7 +7,7 @@ interface BuddyInventory {
77
total: number
88
}
99

10-
const root = resolve(import.meta.dir, '../../..')
10+
const root = resolve(import.meta.dir, '../../../../../../..')
1111
const outputPath = resolve(root, 'docs/guide/buddy/commands.md')
1212
const cliPath = resolve(root, 'storage/framework/core/buddy/src/cli.ts')
1313

@@ -89,7 +89,7 @@ export function renderBuddyCommandReference(inventory: BuddyInventory): string {
8989
'title: Buddy Command Reference',
9090
'description: Generated reference for every Buddy command, argument, option, alias, default, and example.',
9191
'---',
92-
'<!-- Generated by app/Commands/docs/buddy-commands.ts. Do not edit by hand. -->',
92+
'<!-- Generated by storage/framework/core/buddy/src/commands/docs/buddy-commands.ts. Do not edit by hand. -->',
9393
'',
9494
'# Buddy Command Reference',
9595
'',
@@ -128,7 +128,7 @@ export function loadBuddyInventory(): BuddyInventory {
128128
export async function run(): Promise<void> {
129129
const mode = process.argv.includes('--write') ? 'write' : process.argv.includes('--check') ? 'check' : null
130130
if (!mode) {
131-
console.error('usage: bun app/Commands/docs/buddy-commands.ts --write | --check')
131+
console.error('usage: bun storage/framework/core/buddy/src/commands/docs/buddy-commands.ts --write | --check')
132132
process.exit(2)
133133
}
134134

app/Commands/docs/generated-artifacts.test.ts renamed to storage/framework/core/buddy/src/commands/docs/generated-artifacts.test.ts

File renamed without changes.

app/Commands/docs/generated-artifacts.ts renamed to storage/framework/core/buddy/src/commands/docs/generated-artifacts.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { readFileSync, writeFileSync } from 'node:fs'
22
import { resolve } from 'node:path'
3-
import { generateOpenApi } from '../../../storage/framework/core/api/src/generate-openapi'
4-
import { type OpenApiDocument, renderOpenApiTypes } from '../../../storage/framework/core/api/src/generate-types'
3+
import { generateOpenApi } from '../../../../api/src/generate-openapi'
4+
import { type OpenApiDocument, renderOpenApiTypes } from '../../../../api/src/generate-types'
55

6-
const root = resolve(import.meta.dir, '../../..')
6+
const root = resolve(import.meta.dir, '../../../../../../..')
77
const openApiPath = resolve(root, 'storage/framework/api/openapi.json')
88
const apiTypesPath = resolve(root, 'storage/framework/api/api-types.ts')
99

@@ -56,7 +56,7 @@ export async function run(): Promise<void> {
5656
if (process.argv.includes('--write')) await write()
5757
else if (process.argv.includes('--check')) await check()
5858
else {
59-
console.error('usage: bun app/Commands/docs/generated-artifacts.ts --write | --check')
59+
console.error('usage: bun storage/framework/core/buddy/src/commands/docs/generated-artifacts.ts --write | --check')
6060
process.exit(2)
6161
}
6262
}

app/Commands/docs/links.test.ts renamed to storage/framework/core/buddy/src/commands/docs/links.test.ts

File renamed without changes.

0 commit comments

Comments
 (0)