Skip to content

Fix first-publish auth for new repo-backed skills - #200

Merged
kentcdodds merged 5 commits into
mainfrom
cursor/new-repo-backed-skill-creation-7b8f
Apr 18, 2026
Merged

kentcdodds merged 5 commits into
mainfrom
cursor/new-repo-backed-skill-creation-7b8f

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • preserve the initial Artifacts repo create credentials as bootstrap access when provisioning a new repo-backed source
  • thread that bootstrap access through the unpublished-source sync path so the very first publish reuses the create response instead of minting a fresh token immediately
  • add focused regression tests for source provisioning, unpublished-source sync, meta_save_skill, and immediate repo-backed runSavedSkill execution

Testing

  • npm run test -- --run packages/worker/src/repo/source-service.node.test.ts packages/worker/src/repo/source-sync.node.test.ts packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
  • npx vitest run --project node-unit --typecheck packages/worker/src/repo/source-service.node.test.ts packages/worker/src/repo/source-sync.node.test.ts packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
  • npx oxlint packages/worker/src/jobs/service.ts packages/worker/src/mcp/capabilities/apps/ui-save-app.ts packages/worker/src/mcp/capabilities/meta/meta-save-skill.ts packages/worker/src/repo/artifacts.ts packages/worker/src/repo/repo-session-do.ts packages/worker/src/repo/repo-session-rpc.ts packages/worker/src/repo/source-backfill.ts packages/worker/src/repo/source-service.ts packages/worker/src/repo/source-sync.ts packages/worker/src/repo/source-service.node.test.ts packages/worker/src/repo/source-sync.node.test.ts packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
  • npm run typecheck
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Introduced credential management for artifact repository bootstrap operations, enabling streamlined initialization and improved synchronization during project setup.
    • Enhanced repository session handling to support pre-configured access credentials in bootstrap flows for faster repository configuration.
  • Tests

    • Added comprehensive test coverage for skill publishing, execution workflows, and save operations.
    • Added validation tests for entity source creation and bootstrap access credential handling across various scenarios.

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@cursor[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 10 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 10 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7d97331-982e-42a5-8426-90bdc409a954

📥 Commits

Reviewing files that changed from the base of the PR and between e71b38d and 76be690.

📒 Files selected for processing (3)
  • packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts
  • packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
  • packages/worker/src/repo/source-sync.node.test.ts
📝 Walkthrough

Walkthrough

The PR introduces and threads a bootstrapAccess field (containing artifact repository credentials: remote URL, auth token, default branch, token expiration) through the artifact source initialization flow. Changes include: adding the ArtifactBootstrapAccess type definition, extending method signatures and RPC payloads in source-service, repo-session, and source-sync layers, propagating this value through job/skill/app save handlers, and adding comprehensive tests validating the bootstrap flow for new repo-backed sources.

Changes

Cohort / File(s) Summary
Type Definitions & Exports
packages/worker/src/repo/artifacts.ts, packages/worker/src/repo/source-service.ts
Introduce ArtifactBootstrapAccess type with defaultBranch, remote, token, expiresAt fields. Add EnsuredEntitySource type extending entity source rows with optional bootstrapAccess field.
Source Service Implementation
packages/worker/src/repo/source-service.ts
Update ensureEntitySource to return typed result with bootstrapAccess. Refactor createArtifactsRepoIfMissing to return ArtifactBootstrapAccess | null instead of repo object, capturing bootstrap credentials on first-time repo creation.
Repo Session Layers
packages/worker/src/repo/repo-session-do.ts, packages/worker/src/repo/repo-session-rpc.ts
Add bootstrapAccess parameter to bootstrapSource method signature and RPC payload. Bypass remote resolution and token generation when bootstrapAccess is provided; use provided credentials instead.
Source Sync Flow
packages/worker/src/repo/source-sync.ts
Extend SyncArtifactSourceInput with optional bootstrapAccess field. Pass bootstrapAccess into session.bootstrapSource() when initializing unpublished sources.
Handler Integration
packages/worker/src/jobs/service.ts, packages/worker/src/mcp/capabilities/apps/ui-save-app.ts, packages/worker/src/mcp/capabilities/meta/meta-save-skill.ts, packages/worker/src/repo/source-backfill.ts
Propagate bootstrapAccess (derived from ensuredSource) through syncArtifactSourceSnapshot calls in job, app, skill save, and backfill handlers.
Test Coverage
packages/worker/src/repo/source-service.node.test.ts, packages/worker/src/repo/source-sync.node.test.ts, packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts, packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
Add comprehensive test cases: source-service tests verify ensureEntitySource captures bootstrap tokens; source-sync tests validate bootstrap path vs. open-session path; meta-save-skill tests assert full skill-publish bootstrap flow; run-saved-skill tests cover skill execution with mocked session.

Sequence Diagram(s)

sequenceDiagram
    participant Handler as Job/Skill/App Handler
    participant Service as ensureEntitySource
    participant Artifacts as createArtifactsRepoIfMissing
    participant Sync as syncArtifactSourceSnapshot
    participant Session as RepoSession.bootstrapSource

    Handler->>Service: ensureEntitySource(...)
    Service->>Artifacts: createArtifactsRepoIfMissing()
    alt Repo exists (ready)
        Artifacts-->>Service: null
    else Repo created (new)
        Artifacts-->>Service: ArtifactBootstrapAccess{remote, token, defaultBranch, expiresAt}
    end
    Service-->>Handler: EnsuredEntitySource{...source, bootstrapAccess}
    
    Handler->>Sync: syncArtifactSourceSnapshot({..., bootstrapAccess})
    alt First-time publish (no published_commit)
        Sync->>Session: bootstrapSource({..., bootstrapAccess})
        Session-->>Sync: publishedCommit
    else Already published
        Sync->>Session: openSession(...) + applyEdits(...) + publishSession(...)
        Session-->>Sync: publishedCommit
    end
    Sync-->>Handler: success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A token hops through the garden of repos,
From service to sync, where bootstrap flow goes,
New sources awaken with credentials in paw,
First-time creation needs no failing call,
The rabbit approves this bootstrap ballet! 🌿✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing first-publish authentication for newly created repo-backed skills by preserving initial credentials.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/new-repo-backed-skill-creation-7b8f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kentcdodds
kentcdodds marked this pull request as ready for review April 18, 2026 05:14
@github-actions

github-actions Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-200.kentcdodds.workers.dev

Worker: kody-pr-200
D1: kody-pr-200-db
KV: kody-pr-200-oauth-kv

Mocks:

Comment thread packages/worker/src/repo/repo-session-do.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test fixtures have wrong year for epoch timestamp
    • Updated the mismatched test fixture expiry timestamps to align with the epoch in the token.

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 03fabc3. Configure here.

Comment thread packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts Outdated
cursoragent and others added 4 commits April 18, 2026 13:16
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@cursor
cursor Bot force-pushed the cursor/new-repo-backed-skill-creation-7b8f branch from d1e8da6 to e71b38d Compare April 18, 2026 13:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/worker/src/mcp/skills/run-saved-skill.node.test.ts (1)

74-86: Make the readFile mock fail on unexpected repo paths.

Line 77 returns the skill module for every path other than kody.json, so this regression test would still pass if runSavedSkill read the wrong entrypoint. Gate the mock on skill.ts and validate the read payload so the test proves the manifest-derived wiring.

🧪 Proposed test tightening
-		readFile: vi.fn(async ({ path }: { path: string }) => ({
-			path,
-			content:
-				path === 'kody.json'
-					? JSON.stringify({
-							version: 1,
-							kind: 'skill',
-							title: 'Fresh skill',
-							description: 'Runs from repo',
-							entrypoint: 'skill.ts',
-						})
-					: 'async () => ({ ok: true, repoBacked: true })',
-		})),
+		readFile: vi.fn(
+			async ({
+				path,
+				sessionId,
+				userId,
+			}: {
+				path: string
+				sessionId: string
+				userId: string
+			}) => {
+				expect(sessionId).toBe('skill-runtime-skill-1-session')
+				expect(userId).toBe('user-1')
+
+				if (path === 'kody.json') {
+					return {
+						path,
+						content: JSON.stringify({
+							version: 1,
+							kind: 'skill',
+							title: 'Fresh skill',
+							description: 'Runs from repo',
+							entrypoint: 'skill.ts',
+						}),
+					}
+				}
+
+				if (path === 'skill.ts') {
+					return {
+						path,
+						content: 'async () => ({ ok: true, repoBacked: true })',
+					}
+				}
+
+				throw new Error(`Unexpected readFile path: ${path}`)
+			},
+		),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/worker/src/mcp/skills/run-saved-skill.node.test.ts` around lines 74
- 86, The readFile mock in the test is too permissive and returns the skill
module for any path other than 'kody.json', so change the mock in
run-saved-skill.node.test.ts to only return the module string when the path
equals 'skill.ts' (and continue returning the manifest JSON for 'kody.json');
for any other path have the mock throw or reject with a clear error to fail the
test if runSavedSkill reads the wrong entrypoint, and validate the mock's input
shape (i.e., ensure the call provides a { path: string } payload) so the test
enforces manifest-derived wiring.
packages/worker/src/repo/source-sync.node.test.ts (1)

204-273: Consider also asserting the returned publishedCommit.

The new test verifies wiring of bootstrapAccess and that openSession is skipped, but discards the return value of syncArtifactSourceSnapshot. Asserting the returned commit ('commit-bootstrap-2') would protect against a regression where the function forwards the input but forgets to return bootstrapResult.publishedCommit.

Suggested addition
-	await syncArtifactSourceSnapshot({
+	const publishedCommit = await syncArtifactSourceSnapshot({
@@
-	expect(sessionClient.bootstrapSource).toHaveBeenCalledWith({
+	expect(publishedCommit).toBe('commit-bootstrap-2')
+	expect(sessionClient.bootstrapSource).toHaveBeenCalledWith({
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/worker/src/repo/source-sync.node.test.ts` around lines 204 - 273,
The test for syncArtifactSourceSnapshot should also assert that the function
returns the published commit from the bootstrap result; capture the result of
calling syncArtifactSourceSnapshot and add an expectation that the returned
publishedCommit equals 'commit-bootstrap-2' (since sessionClient.bootstrapSource
returns publishedCommit: 'commit-bootstrap-2'), referencing the test's use of
syncArtifactSourceSnapshot and sessionClient.bootstrapSource to locate where to
add the assertion.
packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts (1)

146-153: Use expect.objectContaining for ensureEntitySource assertion to avoid brittleness.

The current strict toHaveBeenCalledWith at lines 146-153 will fail if the handler passes any optional fields (e.g., requirePersistence, id, manifestPath, repoId) that are defined in the ensureEntitySource function signature, even though the bootstrap-access propagation behavior under test remains unaffected. This inconsistency with the syncArtifactSourceSnapshot assertion below (which already uses expect.objectContaining) makes the test unnecessarily fragile.

Suggested change
-	expect(mockModule.ensureEntitySource).toHaveBeenCalledWith({
-		db: {},
-		env: { APP_DB: {} },
-		userId: 'user-1',
-		entityKind: 'skill',
-		entityId: expect.any(String),
-		sourceRoot: '/',
-	})
+	expect(mockModule.ensureEntitySource).toHaveBeenCalledWith(
+		expect.objectContaining({
+			db: {},
+			env: { APP_DB: {} },
+			userId: 'user-1',
+			entityKind: 'skill',
+			entityId: expect.any(String),
+			sourceRoot: '/',
+		}),
+	)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts`
around lines 146 - 153, The test assertion for mockModule.ensureEntitySource is
too strict; replace the exact toHaveBeenCalledWith check with a
toHaveBeenCalledWith(expect.objectContaining(...)) so only the required props
(db, env, userId, entityKind, entityId, sourceRoot) are asserted and optional
fields (e.g., requirePersistence, id, manifestPath, repoId) can be present
without breaking the test; update the assertion in meta-save-skill.node.test.ts
referencing mockModule.ensureEntitySource and keep entityId as
expect.any(String) inside the objectContaining.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/worker/src/repo/repo-session-do.ts`:
- Around line 545-563: The code assumes any input.bootstrapAccess is usable;
change the logic in the section handling input.bootstrapAccess so it verifies
bootstrapAccess.expiresAt against the current time and only reuses the provided
token if not expired. If expiresAt is missing or in the past, call
resolveArtifactSourceRepo(this.env, source.repo_id) and
ensureArtifactRepoRemote({ repo: sourceRepo, scope: 'write' }) to obtain a fresh
sourceAccess and populate sourceInfo via sourceRepo.info(); otherwise reuse
input.bootstrapAccess for sourceAccess but still set sourceInfo (fetch via
resolveArtifactSourceRepo(...).info() if needed) so targetBranch selection
(input.bootstrapAccess?.defaultBranch ?? sourceInfo?.defaultBranch ??
defaultSessionBranch) works correctly. Ensure references to sourceAccess,
sourceInfo, input.bootstrapAccess, resolveArtifactSourceRepo, and
ensureArtifactRepoRemote are updated accordingly.

---

Nitpick comments:
In `@packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts`:
- Around line 146-153: The test assertion for mockModule.ensureEntitySource is
too strict; replace the exact toHaveBeenCalledWith check with a
toHaveBeenCalledWith(expect.objectContaining(...)) so only the required props
(db, env, userId, entityKind, entityId, sourceRoot) are asserted and optional
fields (e.g., requirePersistence, id, manifestPath, repoId) can be present
without breaking the test; update the assertion in meta-save-skill.node.test.ts
referencing mockModule.ensureEntitySource and keep entityId as
expect.any(String) inside the objectContaining.

In `@packages/worker/src/mcp/skills/run-saved-skill.node.test.ts`:
- Around line 74-86: The readFile mock in the test is too permissive and returns
the skill module for any path other than 'kody.json', so change the mock in
run-saved-skill.node.test.ts to only return the module string when the path
equals 'skill.ts' (and continue returning the manifest JSON for 'kody.json');
for any other path have the mock throw or reject with a clear error to fail the
test if runSavedSkill reads the wrong entrypoint, and validate the mock's input
shape (i.e., ensure the call provides a { path: string } payload) so the test
enforces manifest-derived wiring.

In `@packages/worker/src/repo/source-sync.node.test.ts`:
- Around line 204-273: The test for syncArtifactSourceSnapshot should also
assert that the function returns the published commit from the bootstrap result;
capture the result of calling syncArtifactSourceSnapshot and add an expectation
that the returned publishedCommit equals 'commit-bootstrap-2' (since
sessionClient.bootstrapSource returns publishedCommit: 'commit-bootstrap-2'),
referencing the test's use of syncArtifactSourceSnapshot and
sessionClient.bootstrapSource to locate where to add the assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51e697d7-cfaa-4bfd-871b-f1cd668ab4ad

📥 Commits

Reviewing files that changed from the base of the PR and between 413721c and e71b38d.

📒 Files selected for processing (13)
  • packages/worker/src/jobs/service.ts
  • packages/worker/src/mcp/capabilities/apps/ui-save-app.ts
  • packages/worker/src/mcp/capabilities/meta/meta-save-skill.node.test.ts
  • packages/worker/src/mcp/capabilities/meta/meta-save-skill.ts
  • packages/worker/src/mcp/skills/run-saved-skill.node.test.ts
  • packages/worker/src/repo/artifacts.ts
  • packages/worker/src/repo/repo-session-do.ts
  • packages/worker/src/repo/repo-session-rpc.ts
  • packages/worker/src/repo/source-backfill.ts
  • packages/worker/src/repo/source-service.node.test.ts
  • packages/worker/src/repo/source-service.ts
  • packages/worker/src/repo/source-sync.node.test.ts
  • packages/worker/src/repo/source-sync.ts

Comment on lines +545 to +563
let sourceInfo: ArtifactRepoInfo | null = null
let sourceAccess: { remote: string; token: string }
if (input.bootstrapAccess) {
sourceAccess = {
remote: input.bootstrapAccess.remote,
token: input.bootstrapAccess.token,
}
} else {
const sourceRepo = await resolveArtifactSourceRepo(this.env, source.repo_id)
sourceInfo = await sourceRepo.info()
sourceAccess = await ensureArtifactRepoRemote({
repo: sourceRepo,
scope: 'write',
})
}
const targetBranch =
input.bootstrapAccess?.defaultBranch ??
sourceInfo?.defaultBranch ??
defaultSessionBranch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Respect bootstrapAccess.expiresAt before skipping fresh token minting.

Line 547 treats any provided bootstrap access as usable, but the new type carries expiresAt. If a first publish is retried or delayed past expiry, this bypasses ensureArtifactRepoRemote and fails the push with a stale token instead of falling back to a fresh write token.

🛡️ Proposed freshness guard
 		let sourceInfo: ArtifactRepoInfo | null = null
 		let sourceAccess: { remote: string; token: string }
-		if (input.bootstrapAccess) {
+		const bootstrapAccessExpiresAt = input.bootstrapAccess
+			? Date.parse(input.bootstrapAccess.expiresAt)
+			: Number.NaN
+		const activeBootstrapAccess =
+			input.bootstrapAccess &&
+			Number.isFinite(bootstrapAccessExpiresAt) &&
+			bootstrapAccessExpiresAt > Date.now() + 30_000
+				? input.bootstrapAccess
+				: null
+		if (activeBootstrapAccess) {
 			sourceAccess = {
-				remote: input.bootstrapAccess.remote,
-				token: input.bootstrapAccess.token,
+				remote: activeBootstrapAccess.remote,
+				token: activeBootstrapAccess.token,
 			}
 		} else {
 			const sourceRepo = await resolveArtifactSourceRepo(this.env, source.repo_id)
 			sourceInfo = await sourceRepo.info()
 			sourceAccess = await ensureArtifactRepoRemote({
@@
 		}
 		const targetBranch =
-			input.bootstrapAccess?.defaultBranch ??
+			activeBootstrapAccess?.defaultBranch ??
 			sourceInfo?.defaultBranch ??
 			defaultSessionBranch
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let sourceInfo: ArtifactRepoInfo | null = null
let sourceAccess: { remote: string; token: string }
if (input.bootstrapAccess) {
sourceAccess = {
remote: input.bootstrapAccess.remote,
token: input.bootstrapAccess.token,
}
} else {
const sourceRepo = await resolveArtifactSourceRepo(this.env, source.repo_id)
sourceInfo = await sourceRepo.info()
sourceAccess = await ensureArtifactRepoRemote({
repo: sourceRepo,
scope: 'write',
})
}
const targetBranch =
input.bootstrapAccess?.defaultBranch ??
sourceInfo?.defaultBranch ??
defaultSessionBranch
let sourceInfo: ArtifactRepoInfo | null = null
let sourceAccess: { remote: string; token: string }
const bootstrapAccessExpiresAt = input.bootstrapAccess
? Date.parse(input.bootstrapAccess.expiresAt)
: Number.NaN
const activeBootstrapAccess =
input.bootstrapAccess &&
Number.isFinite(bootstrapAccessExpiresAt) &&
bootstrapAccessExpiresAt > Date.now() + 30_000
? input.bootstrapAccess
: null
if (activeBootstrapAccess) {
sourceAccess = {
remote: activeBootstrapAccess.remote,
token: activeBootstrapAccess.token,
}
} else {
const sourceRepo = await resolveArtifactSourceRepo(this.env, source.repo_id)
sourceInfo = await sourceRepo.info()
sourceAccess = await ensureArtifactRepoRemote({
repo: sourceRepo,
scope: 'write',
})
}
const targetBranch =
activeBootstrapAccess?.defaultBranch ??
sourceInfo?.defaultBranch ??
defaultSessionBranch
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/worker/src/repo/repo-session-do.ts` around lines 545 - 563, The code
assumes any input.bootstrapAccess is usable; change the logic in the section
handling input.bootstrapAccess so it verifies bootstrapAccess.expiresAt against
the current time and only reuses the provided token if not expired. If expiresAt
is missing or in the past, call resolveArtifactSourceRepo(this.env,
source.repo_id) and ensureArtifactRepoRemote({ repo: sourceRepo, scope: 'write'
}) to obtain a fresh sourceAccess and populate sourceInfo via sourceRepo.info();
otherwise reuse input.bootstrapAccess for sourceAccess but still set sourceInfo
(fetch via resolveArtifactSourceRepo(...).info() if needed) so targetBranch
selection (input.bootstrapAccess?.defaultBranch ?? sourceInfo?.defaultBranch ??
defaultSessionBranch) works correctly. Ensure references to sourceAccess,
sourceInfo, input.bootstrapAccess, resolveArtifactSourceRepo, and
ensureArtifactRepoRemote are updated accordingly.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds merged commit dd92c73 into main Apr 18, 2026
9 checks passed
@kentcdodds
kentcdodds deleted the cursor/new-repo-backed-skill-creation-7b8f branch April 18, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants