Merge remote-tracking branch 'github/master' into feat/agent-event-payload
This commit is contained in:
@@ -147,6 +147,7 @@ export function apply(ctx: Context, config: Config): void {
|
||||
content,
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
...desiredBaseline ? { baseline: true } : {},
|
||||
changes,
|
||||
},
|
||||
|
||||
@@ -36,6 +36,8 @@ export const name = 'workspace-context'
|
||||
/** Durable provenance and reconciliation facts for one workspace context. */
|
||||
export interface WorkspaceInstructionSource {
|
||||
kind: 'workspace-instructions'
|
||||
/** Every workspace context carries instructions read out of a file (the `instructions` context form). */
|
||||
form: 'instructions'
|
||||
/** Marks the complete startup/resume baseline rather than a later delta. */
|
||||
baseline?: true
|
||||
changes: WorkspaceInstructionChange[]
|
||||
@@ -77,7 +79,7 @@ export interface ReconciledInstructionContext {
|
||||
function workspaceContextHook(text: string, changes: WorkspaceInstructionChange[]): UserMessage {
|
||||
return createUserMessage({
|
||||
content: [{ type: 'text', text }],
|
||||
source: { kind: 'workspace-instructions', changes },
|
||||
source: { kind: 'workspace-instructions', form: 'instructions', changes },
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -913,6 +913,7 @@ describe('workspace context request injection', () => {
|
||||
role: 'user',
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
baseline: true,
|
||||
changes: [{ action: 'set', scope: sk('.', 'AGENTS.md'), path: 'AGENTS.md' }],
|
||||
},
|
||||
@@ -1104,6 +1105,7 @@ describe('workspace context request injection', () => {
|
||||
content: [{ type: 'text', text: 'stale nested instructions' }],
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'set', scope: sk('pkg', 'AGENTS.md'), path: join('pkg', 'AGENTS.md'), digest: 'stale' }],
|
||||
},
|
||||
}), {
|
||||
@@ -1137,6 +1139,7 @@ describe('workspace context request injection', () => {
|
||||
content: [{ type: 'text', text: 'stale nested instructions' }],
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'set', scope: sk('pkg', 'AGENTS.md'), path: join('pkg', 'AGENTS.md'), digest: 'stale' }],
|
||||
},
|
||||
}), {
|
||||
@@ -2206,7 +2209,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
expect(result.isError).toBe(false)
|
||||
expect(((await syncedWorkspaceContext(ctx, agent))).source).toMatchObject({ kind: 'workspace-instructions' })
|
||||
const queuedSource = ((await syncedWorkspaceContext(ctx, agent))).source
|
||||
expect(queuedSource).toMatchObject({ kind: 'workspace-instructions' })
|
||||
expect(queuedSource).toMatchObject({ kind: 'workspace-instructions', form: 'instructions' })
|
||||
expect(queuedSource.kind === 'workspace-instructions' && queuedSource.changes.some(change =>
|
||||
change.action === 'set'
|
||||
&& change.scope === sk('pkg', 'AGENTS.md')
|
||||
@@ -2549,6 +2552,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
|
||||
expect(((await syncedWorkspaceContext(ctx, agent))).source).toMatchObject({
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'replace', scope: sk('pkg', 'AGENTS.md'), path: join('pkg', 'AGENTS.md') }],
|
||||
})
|
||||
expect(blocksText(((await syncedWorkspaceContext(ctx, agent))).content)).toBe([
|
||||
@@ -2658,7 +2662,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
if (previous === undefined) throw new Error('missing AGENTS.md baseline state')
|
||||
const authoritative = createUserMessage({
|
||||
content: [{ type: 'text', text: 'nested rule' }],
|
||||
source: { kind: 'workspace-instructions', changes: [previous] },
|
||||
source: { kind: 'workspace-instructions', form: 'instructions', changes: [previous] },
|
||||
})
|
||||
if (authority === 'visible') {
|
||||
agent.session.append('user/message', authoritative, { surfaceOp: 'append' })
|
||||
@@ -2684,6 +2688,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
content: [{ type: 'text', text: 'pending baseline duplicate' }],
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'set', scope: sk('.', 'AGENTS.md'), path: 'AGENTS.md' }],
|
||||
},
|
||||
})],
|
||||
@@ -2727,7 +2732,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
if (previous === undefined) throw new Error('missing AGENTS.md baseline state')
|
||||
const authoritative = createUserMessage({
|
||||
content: [{ type: 'text', text: 'repo rule' }],
|
||||
source: { kind: 'workspace-instructions', changes: [previous] },
|
||||
source: { kind: 'workspace-instructions', form: 'instructions', changes: [previous] },
|
||||
})
|
||||
agent.session.append('user/message', authoritative, { surfaceOp: 'append' })
|
||||
const resolved = resolveConfig({ dshHome: home, maxBytes: 65536, localInstructionFileCandidates: [] })
|
||||
@@ -2851,6 +2856,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
|
||||
expect(((await syncedWorkspaceContext(ctx, agent))).source).toMatchObject({
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'remove', scope: sk('pkg', 'AGENTS.md'), path: join('pkg', 'AGENTS.md') }],
|
||||
})
|
||||
expect(blocksText(((await syncedWorkspaceContext(ctx, agent))).content)).toBe([
|
||||
@@ -3253,6 +3259,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
],
|
||||
source: {
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [
|
||||
null,
|
||||
{ action: 'unknown', scope: 'pkg', path: join('pkg', 'AGENTS.md') },
|
||||
@@ -3406,6 +3413,7 @@ describe('dynamic nested workspace context injection', () => {
|
||||
expect(((await syncedWorkspaceContext(ctx, agent))).source).toMatchObject({ kind: 'workspace-instructions' })
|
||||
expect(((await syncedWorkspaceContext(ctx, agent))).source).toMatchObject({
|
||||
kind: 'workspace-instructions',
|
||||
form: 'instructions',
|
||||
changes: [{ action: 'set', scope: sk('pkg', 'AGENTS.md'), path: join('pkg', 'AGENTS.md') }],
|
||||
})
|
||||
expect(blocksText(((await syncedWorkspaceContext(ctx, agent))).content)).toContain('nested package rule')
|
||||
|
||||
Reference in New Issue
Block a user