Skip to content

Commit 8e1f8a9

Browse files
authored
perf: lazy load daemon handlers and report bundle size (#608)
* perf: lazy load daemon handlers * perf: thin command metadata paths * refactor: isolate platform inventory loading * refactor: trim lazy loading cleanup * test: guard daemon routing metadata drift * ci: report startup timing with size
1 parent b7ca4fb commit 8e1f8a9

80 files changed

Lines changed: 2393 additions & 1256 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/size.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Size
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
concurrency:
11+
group: size-${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
bundle-size:
16+
name: Bundle Size
17+
if: github.event.pull_request.head.repo.full_name == github.repository
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Setup toolchain
27+
uses: ./.github/actions/setup-node-pnpm
28+
29+
- name: Preserve report script
30+
run: cp scripts/size-report.mjs /tmp/agent-device-size-report.mjs
31+
32+
- name: Measure base size
33+
run: |
34+
git checkout --detach "${{ github.event.pull_request.base.sha }}"
35+
pnpm install --frozen-lockfile
36+
pnpm build
37+
node /tmp/agent-device-size-report.mjs \
38+
--startup-runs 7 \
39+
--json /tmp/agent-device-size-base.json
40+
41+
- name: Measure PR size
42+
run: |
43+
git checkout --detach "${{ github.event.pull_request.head.sha }}"
44+
pnpm install --frozen-lockfile
45+
pnpm build
46+
node scripts/size-report.mjs \
47+
--compare /tmp/agent-device-size-base.json \
48+
--startup-runs 7 \
49+
--json .tmp/size-report.json \
50+
--markdown .tmp/size-report.md
51+
52+
- name: Add job summary
53+
run: cat .tmp/size-report.md >> "$GITHUB_STEP_SUMMARY"
54+
55+
- name: Comment on PR
56+
env:
57+
GITHUB_TOKEN: ${{ github.token }}
58+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
59+
run: node scripts/size-report.mjs --post-comment .tmp/size-report.md

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Single-context repo. Read `CONTEXT.md` for domain language and testing/architect
7676
- CLI/client/runtime output projection: `src/commands/cli-output.ts`, `src/commands/client-output.ts`, `src/commands/runtime-output.ts`
7777
- Do not reintroduce CLI-shaped command adapters or schemas as a second source of truth. CLI, Node.js, and MCP should project from command contracts.
7878
- Keep `src/daemon/request-router.ts` as request orchestration: auth, diagnostics scope, request admission, locking, handler chain, and fallback dispatch.
79+
- New daemon handler-family commands must update the relevant `DAEMON_COMMAND_GROUPS.*Handler` entry and the handler module's exported `*_COMMAND_HANDLERS` coverage table; `src/daemon/__tests__/request-handler-catalog.test.ts` guards drift and overlap.
7980
- Put request policies in focused request modules:
8081
- tenant/lease/selector/lock admission: `src/daemon/request-admission.ts`
8182
- artifact/error finalization: `src/daemon/request-finalization.ts`

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
"build:macos-helper": "swift build -c release --package-path macos-helper",
9797
"build:all": "pnpm build:node && pnpm build:xcuitest",
9898
"ad": "node bin/agent-device.mjs",
99+
"size": "node scripts/size-report.mjs",
100+
"size:markdown": "node scripts/size-report.mjs --json .tmp/size-report.json --markdown .tmp/size-report.md",
99101
"lint": "oxlint . --deny-warnings",
100102
"format": "oxfmt --write src test skills package.json tsconfig.json tsconfig.lib.json rslib.config.ts vitest.config.ts .github/actions/setup-node-pnpm/action.yml .oxlintrc.json .oxfmtrc.json '!test/skillgym/.skillgym-results/**'",
101103
"fallow": "fallow --summary",

scripts/integration-progress.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ function readClientCommandMethods() {
514514

515515
function readCommandContractBlocks(text) {
516516
const starts = [
517+
...text.matchAll(/defineExecutableCommand\(\s*metadata\(\s*['"]([^'"]+)['"]\s*\)/g),
517518
...text.matchAll(/defineFieldCommand\(\s*['"]([^'"]+)['"]/g),
518519
...text.matchAll(/defineCommand\(\s*\{[\s\S]*?\bname:\s*['"]([^'"]+)['"]/g),
519520
]

0 commit comments

Comments
 (0)