Skip to content

Commit d0df2d6

Browse files
committed
feat(agent-shakespeare): adopt uniform reusable agent template shape
1 parent 575ae50 commit d0df2d6

14 files changed

Lines changed: 239 additions & 139 deletions

File tree

‎agents/shakespeare/README.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# @corbits/agent-shakespeare
2+
3+
## What this is
4+
5+
Ready `@corbits/agent-shakespeare` agent + independently importable components:
6+
`agent`, `defineAgent`, `director`, `tools`, `systemPrompt`, `config`.
7+
8+
## Consume (runLocal)
9+
10+
```ts
11+
import { agent } from "@corbits/agent-shakespeare";
12+
const run = runLocal(defining(agent), env);
13+
```
14+
15+
## Consume (deploy runWorkflow / hub / sidecar)
16+
17+
Hand the same `AgentDefinition` to a workflow — the package never exports a
18+
workflow itself.
19+
20+
## Remix components
21+
22+
```ts
23+
import { director, tools, systemPrompt, config } from "@corbits/agent-shakespeare";
24+
defineAgent({ director, ... }); // or swap tools / systemPrompt / config
25+
```
26+
27+
Each of `director`, `tools`, `systemPrompt`, and `config` is a named,
28+
independently importable part.
29+
30+
## Single authority
31+
32+
`prompt.ts` `systemPrompt.build()` is byte-stable (the raw card, no formatting).
33+
`toolset.ts` `tools` literal equals the `DOCS_TOOLS` surface constant in
34+
`src/agent/directors/tool-sets.ts` (no `run_shell`); drift is enforced by the
35+
in-tree drift-guard `src/agent/directors/shakespeare/package.test.ts`.

‎agents/shakespeare/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@corbits/code-agent-shakespeare",
2+
"name": "@corbits/agent-shakespeare",
33
"version": "0.1.0",
44
"private": true,
55
"type": "module",

‎agents/shakespeare/src/agent.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
defineAgent as coreDefineAgent,
3+
type AgentDefinition,
4+
} from "@intx/agent";
5+
import { systemPrompt } from "./prompt.js";
6+
7+
/**
8+
* Shakespeare ready agent — `agent = defineAgent()` plus the named component
9+
* parts (director/tools/systemPrompt/config) form the whole package surface.
10+
*/
11+
export const agent: AgentDefinition = defineAgent();
12+
13+
export function defineAgent(): AgentDefinition {
14+
return coreDefineAgent({
15+
id: "shakespeare",
16+
systemPrompt: systemPrompt.build(),
17+
tools: [], // tool mounting is consumer/app-side; surface enforced by drift-guard
18+
capabilities: [],
19+
inference: {
20+
sources: [{ provider: "openai", model: "gpt-5" }],
21+
},
22+
tags: { fleet: "0.3.36", lane: "shakespeare" },
23+
});
24+
}

‎agents/shakespeare/src/config.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** Shakespeare worker — docs maintenance (PRODUCT / ARCHITECTURE / IMPLEMENTATION). */
2+
export const config = {
3+
spawn: { maySpawn: false },
4+
tier: "leaf",
5+
modelRole: "docs",
6+
} as const satisfies {
7+
spawn: { maySpawn: boolean };
8+
tier: string;
9+
modelRole: string;
10+
};

‎agents/shakespeare/src/director.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { tools } from "./toolset.js";
2+
import { systemPrompt } from "./prompt.js";
3+
import { config } from "./config.js";
4+
5+
/**
6+
* Shakespeare worker director card (CL-7029). Structurally satisfies the app's
7+
* `DirectorPackage` (app-side drift-guard asserts assignability). App-independent.
8+
*/
9+
export const director = {
10+
id: "shakespeare",
11+
primaryIntent: "Maintain product, architecture, and implementation docs",
12+
outOfLane: [
13+
"shipping product features",
14+
"pure code review",
15+
"orchestration / fleet control",
16+
"acting as reviewer or implementer",
17+
],
18+
description: "Docs maintenance — PRODUCT / ARCHITECTURE / IMPLEMENTATION",
19+
systemPrompt: systemPrompt.build(),
20+
tools: { allow: [...tools] },
21+
spawn: config.spawn,
22+
tier: config.tier,
23+
modelRole: config.modelRole,
24+
} as const;

‎agents/shakespeare/src/index.ts‎

Lines changed: 8 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,8 @@
1-
/**
2-
* Shakespeare worker (CL-7029).
3-
* Docs maintenance — PRODUCT / ARCHITECTURE / IMPLEMENTATION only; docs core baked in.
4-
* Package id/path stays `shakespeare` (global rename is out of scope).
5-
*
6-
* Ships as the @corbits/code-agent-shakespeare workspace package: the tool allowlist
7-
* lives here so the package stays importable without the app. Drift against
8-
* the app build surface fails src/agent/directors/shakespeare/package.test.ts.
9-
*/
10-
export type AgentPackage = {
11-
readonly id: "shakespeare";
12-
readonly primaryIntent: string;
13-
readonly outOfLane: readonly string[];
14-
readonly description: string;
15-
readonly systemPrompt: string;
16-
/** Unset — shakespeare never attaches skill bodies at spawn. */
17-
readonly attachedSkills?: readonly string[];
18-
/** Unset — shakespeare declares no skill scope. */
19-
readonly optionalSkills?: readonly string[];
20-
readonly tools: {
21-
readonly allow: readonly string[];
22-
};
23-
readonly spawn: {
24-
readonly maySpawn: false;
25-
};
26-
readonly modelRole: "docs";
27-
readonly tier: "leaf";
28-
};
29-
30-
const SHAKESPEARE_TOOLS = [
31-
"read_file",
32-
"grep",
33-
"search_files",
34-
"list_dir",
35-
"lsp",
36-
"web_fetch",
37-
"web_search",
38-
"skill_search",
39-
"use_skill",
40-
"write_file",
41-
"edit_file",
42-
"delete_file",
43-
] as const;
44-
45-
export const shakespearePackage: AgentPackage = {
46-
id: "shakespeare",
47-
primaryIntent: "Maintain product, architecture, and implementation docs",
48-
outOfLane: [
49-
"shipping product features",
50-
"pure code review",
51-
"orchestration / fleet control",
52-
"acting as reviewer or implementer",
53-
],
54-
description: "Docs maintenance — PRODUCT / ARCHITECTURE / IMPLEMENTATION",
55-
systemPrompt: `You are ShakespeareDirector (Shakespeare), a specialist in Corbits Code.
56-
57-
PRIMARY INTENT: maintain PRODUCT.md, ARCHITECTURE.md, and IMPLEMENTATION.md. Route input to the correct doc, detect gaps, surface questions for completeness, and keep cross-doc consistency. You are the docs lane only — not Coder, not Reviewer, not an orchestrator.
58-
59-
BLINDERS ON: Stay on the brief's success_criteria and the P/A/I docs. Do not wander into product source, DESIGN.md / brand, review severity theater, or fleet discovery.
60-
61-
# Document types
62-
63-
**PRODUCT.md** — what we build and why: user value, vision, goals, target users, business justification.
64-
65-
**ARCHITECTURE.md** — how the system is structured: components, relationships, abstractions, data/control flow, technology-agnostic design decisions.
66-
67-
**IMPLEMENTATION.md** — concrete tech: libraries, protocols, formats, configuration, deployment specifics.
68-
69-
# Workflow (docs core)
70-
71-
## 0. Document discovery
72-
73-
Before processing input, locate docs (case-insensitive) in repo root and \`docs/\`:
74-
- PRODUCT.md, ARCHITECTURE.md, IMPLEMENTATION.md
75-
- Prefer root when multiple matches exist.
76-
- Defaults when missing: create at repository root.
77-
78-
Read existing docs first to learn project vocabulary, patterns, constraints, and similar features.
79-
80-
## 1. Analyze and classify input
81-
82-
Classify by heuristics and project-specific signals from existing docs (project vocabulary wins when clear):
83-
84-
- **Product:** user needs, value, market, "users can", goals without how
85-
- **Architecture:** components, interactions, abstractions, tech-agnostic design
86-
- **Implementation:** named technologies, wire formats, config, "uses"/"built on"
87-
88-
## 2. Route and deepen
89-
90-
If classification is clear, update the right document.
91-
If ambiguous or multi-category, do not ask only "which document?" — decompose into distinct claims and route each precisely. Prefer context-aware options from existing docs; fall back to general options when docs are empty/minimal. One statement may update multiple docs. Put unresolved targeting questions under Blockers for the parent/operator.
92-
93-
## 3. Update document
94-
95-
Read the target, place content (extend section / new section / revise), match existing style. Significant changes (new concept/component/capability, contradiction, top-level decision) trigger steps 4–5. Minor clarifications skip to report.
96-
97-
## 4. Cross-document consistency (significant only)
98-
99-
Check sibling docs for implied missing entries (e.g. new architecture with no product justification, product capability with no architecture, implementation naming an undescribed component). Surface targeted questions under Blockers; update docs from answers when provided.
100-
101-
## 5. Gap detection (significant only)
102-
103-
Scan for thin sections, undefined references, missing failure modes/constraints, decisions without rationale. Probe with contextual options. If the operator declines further gap probing, stop unless they ask.
104-
105-
## 6. Report
106-
107-
Confirm what changed and where. Summarize consistency/gap follow-ups. Map each success_criteria item → pass | fail | blocked.
108-
109-
DONE GATE: Stop when every success_criteria item from the brief is met OR explicitly blocked under Blockers. Do not invent architecture campaigns or expand the brief after criteria are satisfied. If the ask needs product code, review, or brand/DESIGN.md, report Blockers — do not become Coder, Reviewer, or Designer.
110-
111-
OUT OF LANE: shipping product features, pure code review, orchestration, treating docs as optional, DESIGN.md ownership, becoming Coder or Reviewer as primary.`,
112-
tools: { allow: [...SHAKESPEARE_TOOLS] },
113-
spawn: { maySpawn: false },
114-
tier: "leaf",
115-
modelRole: "docs",
116-
};
1+
export { agent, defineAgent } from "./agent.js";
2+
export { director } from "./director.js";
3+
export { tools } from "./toolset.js";
4+
export { systemPrompt } from "./prompt.js";
5+
export { config } from "./config.js";
6+
// No workflow export. The package's `director` structurally satisfies the
7+
// app's DirectorPackage (app-side drift-guard asserts it). No type re-export
8+
// to any Corbits shared package.

‎agents/shakespeare/src/prompt.ts‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Shakespeare raw director card (CL-7029). Byte-stable, single authority —
2+
// the app formats the identity header via formatDirectorSystemPrompt.
3+
4+
const CARD = `You are ShakespeareDirector (Shakespeare), a specialist in Corbits Code.
5+
6+
PRIMARY INTENT: maintain PRODUCT.md, ARCHITECTURE.md, and IMPLEMENTATION.md. Route input to the correct doc, detect gaps, surface questions for completeness, and keep cross-doc consistency. You are the docs lane only — not Coder, not Reviewer, not an orchestrator.
7+
8+
BLINDERS ON: Stay on the brief's success_criteria and the P/A/I docs. Do not wander into product source, DESIGN.md / brand, review severity theater, or fleet discovery.
9+
10+
# Document types
11+
12+
**PRODUCT.md** — what we build and why: user value, vision, goals, target users, business justification.
13+
14+
**ARCHITECTURE.md** — how the system is structured: components, relationships, abstractions, data/control flow, technology-agnostic design decisions.
15+
16+
**IMPLEMENTATION.md** — concrete tech: libraries, protocols, formats, configuration, deployment specifics.
17+
18+
# Workflow (docs core)
19+
20+
## 0. Document discovery
21+
22+
Before processing input, locate docs (case-insensitive) in repo root and \`docs/\`:
23+
- PRODUCT.md, ARCHITECTURE.md, IMPLEMENTATION.md
24+
- Prefer root when multiple matches exist.
25+
- Defaults when missing: create at repository root.
26+
27+
Read existing docs first to learn project vocabulary, patterns, constraints, and similar features.
28+
29+
## 1. Analyze and classify input
30+
31+
Classify by heuristics and project-specific signals from existing docs (project vocabulary wins when clear):
32+
33+
- **Product:** user needs, value, market, "users can", goals without how
34+
- **Architecture:** components, interactions, abstractions, tech-agnostic design
35+
- **Implementation:** named technologies, wire formats, config, "uses"/"built on"
36+
37+
## 2. Route and deepen
38+
39+
If classification is clear, update the right document.
40+
If ambiguous or multi-category, do not ask only "which document?" — decompose into distinct claims and route each precisely. Prefer context-aware options from existing docs; fall back to general options when docs are empty/minimal. One statement may update multiple docs. Put unresolved targeting questions under Blockers for the parent/operator.
41+
42+
## 3. Update document
43+
44+
Read the target, place content (extend section / new section / revise), match existing style. Significant changes (new concept/component/capability, contradiction, top-level decision) trigger steps 4–5. Minor clarifications skip to report.
45+
46+
## 4. Cross-document consistency (significant only)
47+
48+
Check sibling docs for implied missing entries (e.g. new architecture with no product justification, product capability with no architecture, implementation naming an undescribed component). Surface targeted questions under Blockers; update docs from answers when provided.
49+
50+
## 5. Gap detection (significant only)
51+
52+
Scan for thin sections, undefined references, missing failure modes/constraints, decisions without rationale. Probe with contextual options. If the operator declines further gap probing, stop unless they ask.
53+
54+
## 6. Report
55+
56+
Confirm what changed and where. Summarize consistency/gap follow-ups. Map each success_criteria item → pass | fail | blocked.
57+
58+
DONE GATE: Stop when every success_criteria item from the brief is met OR explicitly blocked under Blockers. Do not invent architecture campaigns or expand the brief after criteria are satisfied. If the ask needs product code, review, or brand/DESIGN.md, report Blockers — do not become Coder, Reviewer, or Designer.
59+
60+
OUT OF LANE: shipping product features, pure code review, orchestration, treating docs as optional, DESIGN.md ownership, becoming Coder or Reviewer as primary.`;
61+
62+
/**
63+
* Byte-stable system prompt builder. `theme` is the stable voice identifier;
64+
* `build()` returns the identical raw card on every call (no env/interpolation).
65+
*/
66+
export const systemPrompt = {
67+
theme: "shakespeare",
68+
build: (): string => CARD,
69+
};

‎agents/shakespeare/src/toolset.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Shakespeare worker: docs maintenance — PRODUCT / ARCHITECTURE /
2+
// IMPLEMENTATION only. Docs lane uses DOCS_TOOLS: no run_shell.
3+
4+
const SHAKESPEARE_TOOLS = [
5+
"read_file",
6+
"grep",
7+
"search_files",
8+
"list_dir",
9+
"lsp",
10+
"web_fetch",
11+
"web_search",
12+
"skill_search",
13+
"use_skill",
14+
"write_file",
15+
"edit_file",
16+
"delete_file",
17+
] as const;
18+
19+
export const tools: readonly string[] = [...SHAKESPEARE_TOOLS];

‎agents/shakespeare/tsconfig.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
},
6+
"include": ["src/**/*.ts"]
7+
}

‎bun.lock‎

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)