@usesketchbook/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/component-builder/SKILL.md +16 -0
- package/.agents/skills/contract-author/SKILL.md +16 -0
- package/.claude/commands/add.md +1 -5
- package/.claude/skills/component-builder/SKILL.md +15 -101
- package/.claude/skills/contract-author/SKILL.md +14 -132
- package/README.md +1 -1
- package/docs/agent-compatibility.md +42 -8
- package/harness/cli/commands/add.mjs +1 -1
- package/harness/cli/commands/api.d.mts +4 -4
- package/harness/cli/commands/check.d.mts +1 -1
- package/harness/cli/commands/init.d.mts +1 -1
- package/harness/cli.mjs +0 -0
- package/harness/commands/add.mjs +1 -1
- package/harness/commands/bootstrap.mjs +4 -3
- package/harness/lib/agent-config.d.mts +1 -0
- package/harness/lib/agent-config.mjs +7 -6
- package/harness/lib/design/sync.d.mts +1 -1
- package/harness/lib/installed.mjs +2 -0
- package/harness/manifest.json +3 -1
- package/harness/templates/CLAUDE.md +1 -1
- package/harness/templates/project/.agents/skills/sketchbook/SKILL.md +1 -1
- package/harness/templates/project/AGENT-WORKFLOWS.md +2 -2
- package/harness/templates/project/docs/getting-started.md +2 -2
- package/harness/templates/project/package-lock.json +2 -2
- package/harness/test/agent-config.test.mjs +21 -1
- package/harness/test/agent-guidance.test.mjs +16 -0
- package/harness/test/bootstrap.test.mjs +84 -15
- package/harness/test/claude-live.test.mjs +8 -3
- package/harness/test/copilot-live.test.mjs +12 -13
- package/harness/test/docs-reference.test.mjs +17 -0
- package/harness/test/opencode-live.test.mjs +25 -10
- package/harness/test/package.test.mjs +1 -0
- package/package.json +3 -1
|
@@ -2,13 +2,13 @@ import { lstatSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { readJsonSync } from './files.mjs';
|
|
4
4
|
export const STAGED = 'move-to-.claude';
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
export const WORKFLOW_SKILLS = ['.agents/skills/contract-author/SKILL.md', '.agents/skills/component-builder/SKILL.md'];
|
|
6
|
+
const SHARED = ['AGENTS.md', 'AGENT-WORKFLOWS.md', '.agents/skills/sketchbook/SKILL.md', ...WORKFLOW_SKILLS];
|
|
7
7
|
const PROFILE_FILES = {
|
|
8
|
-
claude: ['CLAUDE.md'],
|
|
9
|
-
codex: [...SHARED,
|
|
8
|
+
claude: ['CLAUDE.md', ...WORKFLOW_SKILLS],
|
|
9
|
+
codex: [...SHARED, '.codex/hooks.json', '.codex/sketchbook-guard.mjs'],
|
|
10
10
|
gemini: [...SHARED, 'GEMINI.md', '.gemini/settings.json', '.gemini/sketchbook-guard.mjs'],
|
|
11
|
-
copilot: [...SHARED,
|
|
11
|
+
copilot: [...SHARED, '.github/copilot-instructions.md', '.github/hooks/sketchbook.json', '.github/hooks/sketchbook-guard.mjs'],
|
|
12
12
|
trae: [...SHARED, '.trae/rules/sketchbook.md'],
|
|
13
13
|
jetbrains: [...SHARED, '.aiassistant/rules/sketchbook.md'],
|
|
14
14
|
generic: SHARED,
|
|
@@ -80,7 +80,8 @@ export function selectedAgentProfiles(root) {
|
|
|
80
80
|
if (found('GEMINI.md', /Sketchbook project instructions/) || found('.gemini/settings.json', /sketchbook-guard|harness\/agent\/gemini-guard/)
|
|
81
81
|
|| found('.gemini/sketchbook-guard.mjs', /gemini-guard/))
|
|
82
82
|
profiles.push('gemini');
|
|
83
|
-
|
|
83
|
+
// The source checkout links to the template, not an installed root-level workflow.
|
|
84
|
+
if (found('.github/copilot-instructions.md', /(?:^|[^/\w-])(?:\.\.?\/)?AGENT-WORKFLOWS\.md\b/) || found('.github/hooks/sketchbook.json', /sketchbook-guard/)
|
|
84
85
|
|| found('.github/hooks/sketchbook-guard.mjs', /sketchbook/i))
|
|
85
86
|
profiles.push('copilot');
|
|
86
87
|
if (found('.trae/rules/sketchbook.md', /AGENT-WORKFLOWS\.md/))
|
|
@@ -35,7 +35,7 @@ export declare function ingestVerify<R extends IngestReadback>(root: string, rea
|
|
|
35
35
|
readFile: string | null;
|
|
36
36
|
stale: unknown;
|
|
37
37
|
wrongFile: boolean;
|
|
38
|
-
tool: "
|
|
38
|
+
tool: "figma" | "none" | undefined;
|
|
39
39
|
checkedAt: string;
|
|
40
40
|
method: string;
|
|
41
41
|
specHash: string;
|
|
@@ -65,6 +65,8 @@ export function installed(root) {
|
|
|
65
65
|
const config = parseJson(read(join(root, 'harness.config.json')) ?? '{}');
|
|
66
66
|
const files = [
|
|
67
67
|
['.agents/skills/sketchbook/SKILL.md', 'Portable Agent Skill routes Sketchbook tasks to the project workflows.'],
|
|
68
|
+
['.agents/skills/contract-author/SKILL.md', 'Shared workflow for drafting and validating a component contract.'],
|
|
69
|
+
['.agents/skills/component-builder/SKILL.md', 'Shared workflow for implementing, testing and reviewing a component.'],
|
|
68
70
|
['CLAUDE.md', 'Claude Code project instructions and the design-system index.'],
|
|
69
71
|
['AGENTS.md', 'Shared project instructions for coding agents; see AGENT-WORKFLOWS.md for task guidance.'],
|
|
70
72
|
['AGENT-WORKFLOWS.md', 'Provider-neutral component, token, kit and design workflows, with references to detailed guidance.'],
|
package/harness/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$description": "Who owns which files (SB-0048, SB-0099). sketchbook upgrade replaces harness-owned files and only reports team-owned and shared ones, which it never touches. Paths match top-down: team wins over harness, except exact harness paths (docs/cli.md and the schemas in spec/schemas, which a project keeps only as editor hints of the engine's). harness/** and scripts/** are the engine: a project runs them from node_modules. move-to-.claude/** is the Claude layer before Claude installs it into .claude/.",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"harness": [
|
|
5
5
|
"harness/**",
|
|
6
6
|
".claude/skills/**",
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
".trae/rules/sketchbook.md",
|
|
46
46
|
".aiassistant/rules/sketchbook.md",
|
|
47
47
|
".agents/skills/sketchbook/SKILL.md",
|
|
48
|
+
".agents/skills/contract-author/SKILL.md",
|
|
49
|
+
".agents/skills/component-builder/SKILL.md",
|
|
48
50
|
"AGENT-WORKFLOWS.md",
|
|
49
51
|
".codex/hooks.json",
|
|
50
52
|
".codex/sketchbook-guard.mjs",
|
|
@@ -16,7 +16,7 @@ This design system started from Sketchbook: the default (UI and theme following
|
|
|
16
16
|
- `generated/**`, `src/components/*/*.styles.ts`, `src/index.ts` (`npm run generate`).
|
|
17
17
|
|
|
18
18
|
## Commands
|
|
19
|
-
- `sketchbook` is the engine's CLI, installed in `node_modules` (a devDependency): run it as `npm run sketchbook -- <command>` (or `npx sketchbook <command>`). `sketchbook help <cmd>` for options (reference `docs/cli.md`); `--json` and `--dry-run`
|
|
19
|
+
- `sketchbook` is the engine's CLI, installed in `node_modules` (a devDependency): run it as `npm run sketchbook -- <command>` (or `npx sketchbook <command>`). `sketchbook help <cmd>` for options (reference `docs/cli.md`); `--json` is available on every command, and `--dry-run` where supported.
|
|
20
20
|
- `sketchbook status`, `doctor`, `check`; `sketchbook add|remove|list`, `sketchbook kits list|add|remove`; `sketchbook tokens …`; `sketchbook explain <thing>`; `sketchbook generate` rebuilds the outputs.
|
|
21
21
|
- `sketchbook init` again puts back what is missing and never overwrites. `npm update` brings a newer engine; `sketchbook upgrade` then refreshes the harness-owned files here (the Claude layer, the commit hook, `docs/cli.md`, the schemas); yours are never touched.
|
|
22
22
|
- `npm run check`: deterministic checks (exit 0 pass, 1 fail, 2 pass with overrides); it also runs before every commit (`.githooks/pre-commit`).
|
|
@@ -7,4 +7,4 @@ description: Work on a Sketchbook design-system project using its component cont
|
|
|
7
7
|
|
|
8
8
|
Read `AGENT-WORKFLOWS.md` at the project root for the relevant task and the project's `harness.config.json` for enabled workflow gates. Use `npx sketchbook help` for the installed CLI's commands and options. Treat the spec and decisions as the source of truth and validate changes with the checks appropriate to the task.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
For component contracts or implementation, load the existing `contract-author` or `component-builder` skill. If your client cannot discover skills, read the matching `SKILL.md` under `.agents/skills/` in the project root. Client-specific integrations may add capabilities, but do not replace the shared workflow.
|
|
@@ -20,7 +20,7 @@ For a catalog component wanted as shipped, use `npx sketchbook add <name> --dry-
|
|
|
20
20
|
|
|
21
21
|
## Task routing
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
For contracts and implementation, use the shared `contract-author` and `component-builder` Agent Skills. If your client cannot load them natively, read their `SKILL.md` files under `.agents/skills/`. In the Sketchbook source checkout those same files live at the repository root. The other named skills below provide additional guidance when the project includes the Claude Code integration. Use the local agent's own capabilities and permissions to perform the steps.
|
|
24
24
|
|
|
25
25
|
| Task | Existing skill |
|
|
26
26
|
| --- | --- |
|
|
@@ -48,6 +48,6 @@ The staged or installed `commands/` directory also contains the original instruc
|
|
|
48
48
|
|
|
49
49
|
## Detailed guidance and existing workflows
|
|
50
50
|
|
|
51
|
-
When the Claude Code integration is selected, its Sketchbook material is available under `move-to-.claude/` while staged, or `.claude/` after installation. Read the relevant rule in `rules/` and skill in `skills/<name>/SKILL.md` for detailed requirements. For example: `contract-first`, `planning-gate`, `test-first`, `form-associated-controls`, `spec-is-source`, `tokens-through-the-harness`, and `figma-fidelity` are rule files; `contract-author`, `component-builder`, `playwright-worker`, `a11y-checker`, `foundations`, `kits`, `design-figma`, `review-rangers`, and `security-guardian` are skills.
|
|
51
|
+
When the Claude Code integration is selected, its Sketchbook material is available under `move-to-.claude/` while staged, or `.claude/` after installation. Read the relevant rule in `rules/` and skill in `skills/<name>/SKILL.md` for detailed requirements. For example: `contract-first`, `planning-gate`, `test-first`, `form-associated-controls`, `spec-is-source`, `tokens-through-the-harness`, and `figma-fidelity` are rule files; `contract-author`, `component-builder`, `playwright-worker`, `a11y-checker`, `foundations`, `kits`, `design-figma`, `review-rangers`, and `security-guardian` are skills. In a project created by `sketchbook init`, `docs/harness.md` lists the initial installation; later changes may not be reflected. In the Sketchbook source checkout, inspect `.claude/skills/` and `.claude/commands/` instead. Use `sketchbook doctor` for current project setup.
|
|
52
52
|
|
|
53
53
|
These files may contain Claude-specific tool names, model aliases, hooks, slash commands, and delegation instructions. Translate the underlying task into capabilities actually available in the current agent; do not claim that a hook or independent review ran when it did not. If delegation is unavailable or unauthorized, perform the applicable steps directly and report any unmet independent-review requirement. Rules and skills are guidance, while the deterministic CLI checks and configured Git hooks provide tool-independent verification.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Start in your design-system folder. Run `npx sketchbook status` to see your brand and components, then follow the steps below to make and preview your first change. To create a project, follow the [Quickstart](https://sketchbook-docs.vercel.app/start/quickstart/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
In a project created by `sketchbook init`, open `docs/harness.md` to see what init installed; this snapshot does not automatically reflect later changes. Run `npx sketchbook status` and `npx sketchbook doctor` for the current project and setup. If you selected an agent profile, confirm what your client loaded. [Agent compatibility](https://sketchbook-docs.vercel.app/concepts/agent-compatibility/)
|
|
6
6
|
|
|
7
7
|
## 1. What you are editing
|
|
8
8
|
| You edit | It controls | Sketchbook generates |
|
|
@@ -51,7 +51,7 @@ npx sketchbook explain SB-0009
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## 6. Add or change a component
|
|
54
|
-
`npx sketchbook add <name>` installs a reference component from the catalog; `npx sketchbook kits` manages page templates. To design a new
|
|
54
|
+
`npx sketchbook add <name>` installs a reference component from the catalog; `npx sketchbook kits` manages page templates. To design a new component, start with the contract and follow the project’s enabled planning and test-first gates. If you selected an agent profile, use `contract-author` and `component-builder` under `.agents/skills/`. If you selected a shared agent profile, `AGENT-WORKFLOWS.md` covers other workflows; if you selected and activated the Claude integration, you can also use `/add <Name>` in Claude Code. A core-only project includes neither integration; use `npx sketchbook init --agent <profile>` to add one, or follow the [component guide](https://sketchbook-docs.vercel.app/guides/add-component/) without an agent.
|
|
55
55
|
|
|
56
56
|
## 7. Keep the design file in step
|
|
57
57
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usesketchbook/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@usesketchbook/cli",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.4.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lucide-static": "1.76.0",
|
|
@@ -4,9 +4,29 @@ import { mkdtemp, mkdir, readFile, rm, symlink, writeFile } from 'node:fs/promis
|
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { spawnSync } from 'node:child_process';
|
|
7
|
-
import { renderAgentSetup } from '../lib/agent-config.mjs';
|
|
7
|
+
import { renderAgentSetup, selectedAgentProfiles } from '../lib/agent-config.mjs';
|
|
8
8
|
import { nativeHookStatus } from '../lib/agent-diagnostics.mjs';
|
|
9
9
|
import { packedFiles, ROOT, sourceRepoOnly } from './helpers.mjs';
|
|
10
|
+
test('a checkout Copilot entry point is not mistaken for an installed project profile', sourceRepoOnly, async () => {
|
|
11
|
+
const dir = await mkdtemp(join(tmpdir(), 'sketchbook-agent-profile-'));
|
|
12
|
+
try {
|
|
13
|
+
await mkdir(join(dir, '.github/hooks'), { recursive: true });
|
|
14
|
+
const name = '.github/copilot-instructions.md';
|
|
15
|
+
await writeFile(join(dir, name), await readFile(join(ROOT, name)));
|
|
16
|
+
assert.deepEqual(selectedAgentProfiles(dir), []);
|
|
17
|
+
const template = join(ROOT, 'harness/templates/project', name);
|
|
18
|
+
await writeFile(join(dir, name), await readFile(template));
|
|
19
|
+
assert.deepEqual(selectedAgentProfiles(dir), ['copilot']);
|
|
20
|
+
await writeFile(join(dir, name), await readFile(join(ROOT, name)));
|
|
21
|
+
await writeFile(join(dir, '.github/hooks/sketchbook.json'), await readFile(join(ROOT, 'harness/templates/project/.github/hooks/sketchbook.json')));
|
|
22
|
+
assert.deepEqual(selectedAgentProfiles(dir), ['copilot']);
|
|
23
|
+
await writeFile(join(dir, 'harness.config.json'), JSON.stringify({ agentProfiles: [] }));
|
|
24
|
+
assert.deepEqual(selectedAgentProfiles(dir), []);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
await rm(dir, { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
10
30
|
test('native agent adapters use a renamed scoped engine and retain their edit protections', sourceRepoOnly, async () => {
|
|
11
31
|
const dir = await mkdtemp(join(tmpdir(), 'sketchbook-renamed-agent-'));
|
|
12
32
|
const name = '@acme/engine';
|
|
@@ -3,6 +3,22 @@ import assert from 'node:assert/strict';
|
|
|
3
3
|
import { readFile, readdir } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { ROOT, sourceRepoOnly } from './helpers.mjs';
|
|
6
|
+
import { frontmatter } from '../lib/claude-layer.mjs';
|
|
7
|
+
test('shared component skills use standard frontmatter and Claude wrappers lead to the same source', sourceRepoOnly, async () => {
|
|
8
|
+
for (const name of ['contract-author', 'component-builder']) {
|
|
9
|
+
const path = `.agents/skills/${name}/SKILL.md`;
|
|
10
|
+
const source = await readFile(join(ROOT, path), 'utf8');
|
|
11
|
+
const data = frontmatter(source);
|
|
12
|
+
assert.deepEqual(Object.keys(data ?? {}).sort(), ['description', 'name']);
|
|
13
|
+
assert.equal(data?.name, name);
|
|
14
|
+
const description = data?.description;
|
|
15
|
+
assert.ok(typeof description === 'string' && description.length > 0 && description.length <= 400);
|
|
16
|
+
assert.match(source, /features\.planningGate/);
|
|
17
|
+
assert.doesNotMatch(source, /\.claude\/|`Agent`|haiku|sonnet|opus/);
|
|
18
|
+
const wrapper = await readFile(join(ROOT, '.claude/skills', name, 'SKILL.md'), 'utf8');
|
|
19
|
+
assert.ok(wrapper.includes(`(../../../${path})`));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
6
22
|
// Keep the portable routing map in sync with the workflows shipped in the Claude layer.
|
|
7
23
|
test('portable guidance names every shipped skill and slash workflow', sourceRepoOnly, async () => {
|
|
8
24
|
const guidance = await readFile(join(ROOT, 'harness/templates/project/AGENT-WORKFLOWS.md'), 'utf8');
|
|
@@ -175,12 +175,19 @@ pkgTest('B3 init --dir creates the project in a new folder inside an existing re
|
|
|
175
175
|
await rm(app, { recursive: true, force: true });
|
|
176
176
|
});
|
|
177
177
|
pkgTest('B4 a failing init leaves the folder exactly as it was', async () => {
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
const parent = await empty();
|
|
179
|
+
const dir = join(parent, 'project');
|
|
180
|
+
try {
|
|
181
|
+
await mkdir(dir);
|
|
182
|
+
const r = run(dir, 'init', '--start', 'pick', '--components', 'not-a-thing', '--no-install', '--json');
|
|
183
|
+
assert.equal(r.code, 1);
|
|
184
|
+
assert.deepEqual(ls(dir), []);
|
|
185
|
+
// Init stages next to its target; inspect a private parent, not the shared system temp folder.
|
|
186
|
+
assert.deepEqual(ls(parent), ['project'], 'no stage left behind');
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
await rm(parent, { recursive: true, force: true });
|
|
190
|
+
}
|
|
184
191
|
});
|
|
185
192
|
pkgTest('B5 init --dry-run in an empty folder runs the same build and checks, reports them, and writes nothing', async () => {
|
|
186
193
|
const dir = await empty();
|
|
@@ -566,8 +573,9 @@ void realTest('B16 a fresh library+kits project lints and typechecks with no err
|
|
|
566
573
|
pkgTest('portable instructions are restored only when missing and preserve team edits', async () => {
|
|
567
574
|
const { dir } = await created('blank', '--agent', ALL_PROFILES);
|
|
568
575
|
const file = join(dir, 'AGENTS.md');
|
|
576
|
+
const portable = [...new Set(Object.entries(PROFILE_PATHS).filter(([profile]) => profile !== 'claude').flatMap(([, paths]) => paths))].filter((path) => path !== 'AGENTS.md');
|
|
569
577
|
assert.match(await readFile(join(dir, '.aiassistant/rules/sketchbook.md'), 'utf8'), /^---\napply: always\n---\n/);
|
|
570
|
-
for (const path of
|
|
578
|
+
for (const path of portable) {
|
|
571
579
|
const target = join(dir, path);
|
|
572
580
|
await writeFile(target, 'Team instructions\n');
|
|
573
581
|
}
|
|
@@ -579,7 +587,7 @@ pkgTest('portable instructions are restored only when missing and preserve team
|
|
|
579
587
|
assert.equal(custom?.['AGENTS.md'], 'not-detected');
|
|
580
588
|
assert.equal(custom?.['.github/copilot-instructions.md'], 'not-detected');
|
|
581
589
|
assert.match(run(dir, 'doctor').out, /Review preserved team instructions/);
|
|
582
|
-
for (const path of
|
|
590
|
+
for (const path of portable) {
|
|
583
591
|
const target = join(dir, path);
|
|
584
592
|
assert.equal(await readFile(target, 'utf8'), 'Team instructions\n');
|
|
585
593
|
await rm(target);
|
|
@@ -594,7 +602,7 @@ pkgTest('portable instructions are restored only when missing and preserve team
|
|
|
594
602
|
assert.match(await readFile(file, 'utf8'), /contract-first/);
|
|
595
603
|
assert.equal(run(dir, 'doctor', '--json').json?.data.agentInstructionReferences['AGENTS.md'], 'referenced');
|
|
596
604
|
assert.match(await readFile(join(dir, '.aiassistant/rules/sketchbook.md'), 'utf8'), /^---\napply: always\n---\n/);
|
|
597
|
-
for (const path of
|
|
605
|
+
for (const path of portable)
|
|
598
606
|
assert.ok(existsSync(join(dir, path)), path);
|
|
599
607
|
await rm(dir, { recursive: true, force: true });
|
|
600
608
|
});
|
|
@@ -668,12 +676,13 @@ pkgTest('the staged layer can be backed up to verify the installed copy and rest
|
|
|
668
676
|
await rm(dir, { recursive: true, force: true });
|
|
669
677
|
}
|
|
670
678
|
});
|
|
671
|
-
const
|
|
679
|
+
const PORTABLE_WORKFLOWS = ['.agents/skills/contract-author/SKILL.md', '.agents/skills/component-builder/SKILL.md'];
|
|
680
|
+
const SHARED_GUIDANCE = ['AGENTS.md', 'AGENT-WORKFLOWS.md', '.agents/skills/sketchbook/SKILL.md', ...PORTABLE_WORKFLOWS];
|
|
672
681
|
const PROFILE_PATHS = {
|
|
673
|
-
claude: ['CLAUDE.md', 'move-to-.claude/INSTALL.md', 'move-to-.claude/settings.json', 'move-to-.claude/skills/contract-author/SKILL.md'],
|
|
674
|
-
codex: [...SHARED_GUIDANCE, '.
|
|
682
|
+
claude: ['CLAUDE.md', ...PORTABLE_WORKFLOWS, 'move-to-.claude/INSTALL.md', 'move-to-.claude/settings.json', 'move-to-.claude/skills/contract-author/SKILL.md'],
|
|
683
|
+
codex: [...SHARED_GUIDANCE, '.codex/hooks.json', '.codex/sketchbook-guard.mjs'],
|
|
675
684
|
gemini: [...SHARED_GUIDANCE, 'GEMINI.md', '.gemini/settings.json', '.gemini/sketchbook-guard.mjs'],
|
|
676
|
-
copilot: [...SHARED_GUIDANCE, '.
|
|
685
|
+
copilot: [...SHARED_GUIDANCE, '.github/copilot-instructions.md', '.github/hooks/sketchbook.json', '.github/hooks/sketchbook-guard.mjs'],
|
|
677
686
|
trae: [...SHARED_GUIDANCE, '.trae/rules/sketchbook.md'],
|
|
678
687
|
jetbrains: [...SHARED_GUIDANCE, '.aiassistant/rules/sketchbook.md'],
|
|
679
688
|
generic: SHARED_GUIDANCE,
|
|
@@ -701,10 +710,29 @@ void realTest('the packed CLI installs only the selected agent files', checkoutO
|
|
|
701
710
|
const expected = new Set(profiles.flatMap((profile) => PROFILE_PATHS[profile]));
|
|
702
711
|
for (const path of paths)
|
|
703
712
|
assert.equal(existsSync(join(dir, path)), expected.has(path), `${target}: ${path}`);
|
|
713
|
+
if (profiles.length) {
|
|
714
|
+
for (const path of PORTABLE_WORKFLOWS)
|
|
715
|
+
assert.deepEqual(await readFile(join(dir, path)), await readFile(join(ROOT, path)));
|
|
716
|
+
const consumer = await readJson(dir, 'package.json');
|
|
717
|
+
assert.ok(!consumer.files.some((file) => file.startsWith('.agents/')), 'the consumer library does not publish project instructions');
|
|
718
|
+
}
|
|
719
|
+
if (profiles.includes('claude')) {
|
|
720
|
+
for (const name of ['contract-author', 'component-builder']) {
|
|
721
|
+
const wrapper = join(dir, 'move-to-.claude/skills', name);
|
|
722
|
+
const source = await readFile(join(wrapper, 'SKILL.md'), 'utf8');
|
|
723
|
+
const path = must(/\]\(([^)]*\.agents\/skills\/[^)]*\/SKILL\.md)\)/.exec(source)?.[1], name);
|
|
724
|
+
assert.ok(existsSync(join(wrapper, path)), `${name} wrapper resolves in the installed project`);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
704
727
|
const expectedRoots = [...new Set([...expected].map((file) => file.split('/')[0]))].sort();
|
|
705
728
|
assert.deepEqual(ls(dir).filter((name) => rootEntries.has(name)), expectedRoots, target);
|
|
706
729
|
assert.ok(!existsSync(join(dir, '.claude')), target);
|
|
707
730
|
assert.ok(existsSync(join(dir, '.githooks/pre-commit')), target);
|
|
731
|
+
const inventory = await readFile(join(dir, 'docs/harness.md'), 'utf8');
|
|
732
|
+
assert.match(inventory, /Later changes are not reflected automatically/);
|
|
733
|
+
assert.match(inventory, /sketchbook doctor/);
|
|
734
|
+
const guide = await readFile(join(dir, 'docs/getting-started.md'), 'utf8');
|
|
735
|
+
assert.match(guide, /core-only project includes neither integration/);
|
|
708
736
|
assert.equal(parseJson(result.stdout).data.checks.exitCode, 0);
|
|
709
737
|
if (!selection || selection === 'claude')
|
|
710
738
|
assert.deepEqual(failing(await runChecks(dir)), []);
|
|
@@ -721,6 +749,40 @@ void realTest('the packed CLI installs only the selected agent files', checkoutO
|
|
|
721
749
|
await rm(temp, { recursive: true, force: true });
|
|
722
750
|
}
|
|
723
751
|
});
|
|
752
|
+
pkgTest('a core-only project can install a component, change a foundation, and reach the planning gate', async () => {
|
|
753
|
+
const { dir } = await created('blank');
|
|
754
|
+
try {
|
|
755
|
+
const cli = (...args) => {
|
|
756
|
+
const result = run(dir, ...args, '--json');
|
|
757
|
+
assert.equal(result.code, 0, result.out + result.err);
|
|
758
|
+
return must(result.json, args.join(' '));
|
|
759
|
+
};
|
|
760
|
+
const button = join(dir, 'spec/components/button/contract.json');
|
|
761
|
+
cli('add', 'button', '--dry-run');
|
|
762
|
+
assert.ok(!existsSync(button));
|
|
763
|
+
cli('add', 'button');
|
|
764
|
+
assert.ok(existsSync(button));
|
|
765
|
+
const brand = join(dir, 'brand.config.json');
|
|
766
|
+
const initial = await readFile(brand, 'utf8');
|
|
767
|
+
cli('tokens', 'set', 'color.primary', '#0F766E', '--dry-run');
|
|
768
|
+
assert.equal(await readFile(brand, 'utf8'), initial);
|
|
769
|
+
cli('tokens', 'set', 'color.primary', '#0F766E');
|
|
770
|
+
assert.match(await readFile(brand, 'utf8'), /#0F766E/i);
|
|
771
|
+
const badge = join(dir, 'spec/components/badge');
|
|
772
|
+
cli('add', 'badge', '--blank', '--dry-run');
|
|
773
|
+
assert.ok(!existsSync(badge));
|
|
774
|
+
const scaffold = cli('add', 'badge', '--blank');
|
|
775
|
+
assert.match(scaffold.next ?? '', /planning gate.*stop for approval/);
|
|
776
|
+
assert.doesNotMatch(scaffold.next ?? '', /skill|Claude/i);
|
|
777
|
+
assert.match(await readFile(join(badge, 'plan.md'), 'utf8'), /Tests and code start only after approval/);
|
|
778
|
+
assert.ok(!existsSync(join(dir, 'src/components/badge')));
|
|
779
|
+
assert.ok(!existsSync(join(dir, 'playwright/tests/badge')));
|
|
780
|
+
cli('check');
|
|
781
|
+
}
|
|
782
|
+
finally {
|
|
783
|
+
await rm(dir, { recursive: true, force: true });
|
|
784
|
+
}
|
|
785
|
+
});
|
|
724
786
|
pkgTest('adds profiles to an existing project, previews the same writes, and repairs only selected integrations', async () => {
|
|
725
787
|
const { dir } = await created('blank');
|
|
726
788
|
try {
|
|
@@ -739,7 +801,7 @@ pkgTest('adds profiles to an existing project, previews the same writes, and rep
|
|
|
739
801
|
assert.ok(!existsSync(join(dir, '.trae')));
|
|
740
802
|
const addition = must(run(dir, 'init', '--agent', 'trae,trae', '--json').json, 'profile addition');
|
|
741
803
|
assert.deepEqual(addition.changed, preview.changed);
|
|
742
|
-
assert.deepEqual(addition.changed.sort(), ['.trae/rules/sketchbook.md', 'AGENT-WORKFLOWS.md', 'harness.config.json']);
|
|
804
|
+
assert.deepEqual(addition.changed.sort(), ['.agents/skills/sketchbook/SKILL.md', ...PORTABLE_WORKFLOWS, '.trae/rules/sketchbook.md', 'AGENT-WORKFLOWS.md', 'harness.config.json'].sort());
|
|
743
805
|
assert.deepEqual(addition.data.repair.preserved, ['AGENTS.md']);
|
|
744
806
|
assert.equal(await readFile(teamGuide, 'utf8'), 'Team guide');
|
|
745
807
|
assert.deepEqual(run(dir, 'init', '--agent', 'trae', '--json').json?.changed, []);
|
|
@@ -748,8 +810,15 @@ pkgTest('adds profiles to an existing project, previews the same writes, and rep
|
|
|
748
810
|
assert.equal(run(dir, 'doctor', '--json').json?.data.agentInstructions['.trae/rules/sketchbook.md'], false);
|
|
749
811
|
assert.deepEqual(run(dir, 'init', '--json').json?.changed, ['.trae/rules/sketchbook.md']);
|
|
750
812
|
assert.equal(run(dir, 'upgrade', '--json').code, 0);
|
|
751
|
-
for (const file of ['CLAUDE.md', 'move-to-.claude', 'GEMINI.md', '.codex', '.
|
|
813
|
+
for (const file of ['CLAUDE.md', 'move-to-.claude', 'GEMINI.md', '.codex', '.github', '.aiassistant'])
|
|
752
814
|
assert.ok(!existsSync(join(dir, file)), file);
|
|
815
|
+
const [keptSkill, missingSkill] = PORTABLE_WORKFLOWS;
|
|
816
|
+
await appendFile(join(dir, keptSkill), '\nOur team note.\n');
|
|
817
|
+
await rm(join(dir, missingSkill));
|
|
818
|
+
const repaired = must(run(dir, 'init', '--json').json, 'shared skill repair');
|
|
819
|
+
assert.deepEqual(repaired.changed, [missingSkill]);
|
|
820
|
+
assert.ok(repaired.data.repair.preserved.includes(keptSkill));
|
|
821
|
+
assert.match(await readFile(join(dir, keptSkill), 'utf8'), /Our team note/);
|
|
753
822
|
assert.equal(run(dir, 'init', '--agent', 'generic', '--with', 'forge', '--json').code, 0);
|
|
754
823
|
assert.deepEqual((await readJson(dir, 'harness.config.json')).agentProfiles, ['trae', 'generic', 'claude']);
|
|
755
824
|
assert.ok(existsSync(join(dir, 'move-to-.claude/skills/forge-me-a-skill/SKILL.md')));
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { test } from 'node:test';
|
|
3
3
|
import assert from 'node:assert/strict';
|
|
4
4
|
import { execFile } from 'node:child_process';
|
|
5
|
-
import { cp, mkdir, mkdtemp, readFile, realpath, rm, symlink, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { cp, mkdir, mkdtemp, readFile, realpath, rename, rm, symlink, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { createServer } from 'node:http';
|
|
7
7
|
import { tmpdir } from 'node:os';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { promisify } from 'node:util';
|
|
10
10
|
import { ROOT } from './helpers.mjs';
|
|
11
11
|
const exec = promisify(execFile);
|
|
12
|
-
test('Claude Code
|
|
12
|
+
test('Claude Code advertises native wrappers installed by Sketchbook alongside its project instructions', { skip: process.env.SKETCHBOOK_TEST_CLAUDE_LIVE !== '1', timeout: 30000 }, async () => {
|
|
13
13
|
const dir = await mkdtemp(join(tmpdir(), 'sketchbook-claude-live-'));
|
|
14
14
|
let request = '';
|
|
15
15
|
const server = createServer((req, res) => {
|
|
@@ -37,8 +37,11 @@ test('Claude Code sends the project instructions to its model', { skip: process.
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
try {
|
|
40
|
+
await exec(process.execPath, [join(ROOT, 'harness/cli.mjs'), 'init', '--start', 'blank', '--agent', 'claude', '--no-install'], { cwd: dir });
|
|
40
41
|
await mkdir(join(dir, 'config'));
|
|
41
|
-
|
|
42
|
+
// Activate only the skill directories here. The separate hook test activates the edit hooks.
|
|
43
|
+
await mkdir(join(dir, '.claude'));
|
|
44
|
+
await rename(join(dir, 'move-to-.claude/skills'), join(dir, '.claude/skills'));
|
|
42
45
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
43
46
|
const address = server.address();
|
|
44
47
|
assert.ok(address && typeof address !== 'string');
|
|
@@ -51,6 +54,8 @@ test('Claude Code sends the project instructions to its model', { skip: process.
|
|
|
51
54
|
assert.match(result.stdout, /OK/);
|
|
52
55
|
assert.match(request, /initial installation inventory/);
|
|
53
56
|
assert.match(request, /docs\/harness\.md/);
|
|
57
|
+
assert.match(request, /Draft, resync, or validate a component contract using the shared Sketchbook/);
|
|
58
|
+
assert.match(request, /Build a component from its approved contract using the shared Sketchbook/);
|
|
54
59
|
}
|
|
55
60
|
finally {
|
|
56
61
|
if (server.listening)
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { test } from 'node:test';
|
|
3
3
|
import assert from 'node:assert/strict';
|
|
4
4
|
import { execFile, spawnSync } from 'node:child_process';
|
|
5
|
-
import {
|
|
5
|
+
import { mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { createServer } from 'node:http';
|
|
7
7
|
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join } from 'node:path';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
9
|
import { promisify } from 'node:util';
|
|
10
10
|
import { ROOT } from './helpers.mjs';
|
|
11
11
|
const exec = promisify(execFile);
|
|
@@ -43,25 +43,21 @@ test('installed Copilot CLI loads instructions and hooks from the tested workspa
|
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
assert.equal(spawnSync('git', ['init', '-q', repo]).status, 0);
|
|
47
|
+
await exec(process.execPath, [join(ROOT, 'harness/cli.mjs'), 'init', '--adopt', '--start', 'blank', '--agent', 'copilot', '--no-install'], { cwd: repo });
|
|
48
|
+
const { name } = JSON.parse(await readFile(join(ROOT, 'package.json'), 'utf8'));
|
|
49
|
+
const engine = join(project, 'node_modules', name);
|
|
50
|
+
await mkdir(dirname(engine), { recursive: true });
|
|
51
|
+
await symlink(ROOT, engine, 'dir');
|
|
50
52
|
const decisions = '# Decisions\n\n### SB-0001 · 2026-01-01 · Example\n**Status:** accepted\n**Decision:** Keep it.\n';
|
|
51
53
|
const decisionFile = join(project, 'spec/decisions/DECISIONS.md');
|
|
52
54
|
await writeFile(decisionFile, decisions);
|
|
53
55
|
await mkdir(join(repo, '.github/hooks'), { recursive: true });
|
|
54
|
-
await symlink(ROOT, join(project, 'node_modules/sketchbook'), 'dir');
|
|
55
|
-
await cp(join(ROOT, 'harness/templates/project/.github/hooks/sketchbook-guard.mjs'), join(project, '.github/hooks/sketchbook-guard.mjs'));
|
|
56
|
-
await cp(join(ROOT, 'harness/templates/project/.github/hooks/sketchbook.json'), join(project, '.github/hooks/sketchbook.json'));
|
|
57
|
-
await cp(join(ROOT, 'harness/templates/project/.github/copilot-instructions.md'), join(project, '.github/copilot-instructions.md'));
|
|
58
|
-
await cp(join(ROOT, 'harness/templates/project/AGENTS.md'), join(project, 'AGENTS.md'));
|
|
59
56
|
const docs = await readFile(join(ROOT, 'docs/agent-compatibility.md'), 'utf8');
|
|
60
57
|
const section = docs.split('## Copilot repository hooks for an adopted app')[1]?.split('## Model-family test targets')[0] ?? '';
|
|
61
58
|
const config = /```json\n([\s\S]*?)\n```/.exec(section)?.[1];
|
|
62
59
|
assert.ok(config);
|
|
63
60
|
await writeFile(join(repo, '.github/hooks/sketchbook.json'), config);
|
|
64
|
-
assert.equal(spawnSync('git', ['init', '-q', repo]).status, 0);
|
|
65
61
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
66
62
|
const address = server.address();
|
|
67
63
|
assert.ok(address && typeof address !== 'string');
|
|
@@ -70,10 +66,13 @@ test('installed Copilot CLI loads instructions and hooks from the tested workspa
|
|
|
70
66
|
if (/^(GITHUB_|GH_|COPILOT_|OPENAI_|ANTHROPIC_)|_PROXY$/i.test(key))
|
|
71
67
|
delete env[key];
|
|
72
68
|
Object.assign(env, { COPILOT_HOME: join(repo, 'copilot-home'), GH_CONFIG_DIR: join(repo, 'gh-config'), COPILOT_PROVIDER_BASE_URL: `http://127.0.0.1:${address.port}/v1`, COPILOT_MODEL: 'gpt-4.1', COPILOT_PROVIDER_TYPE: 'openai', NO_COLOR: '1' });
|
|
69
|
+
const foundSkills = await exec('copilot', ['skill', 'list', '--json'], { cwd: project, env, timeout: 10000 });
|
|
70
|
+
for (const skill of ['contract-author', 'component-builder'])
|
|
71
|
+
assert.match(foundSkills.stdout, new RegExp(`"${skill}"`));
|
|
73
72
|
const run = async (file, operation = 'create', cwd = repo) => {
|
|
74
73
|
const target = join(project, file);
|
|
75
74
|
tool = operation;
|
|
76
|
-
toolArgs = operation === 'bash' ? { command:
|
|
75
|
+
toolArgs = operation === 'bash' ? { command: `node ${JSON.stringify(join(engine, 'harness/cli.mjs'))} help --json` } : operation === 'edit' ? { path: target, old_str: 'Keep it.', new_str: 'Changed.' } : { path: target, file_text: 'test content' };
|
|
77
76
|
requests = 0;
|
|
78
77
|
firstRequest = '';
|
|
79
78
|
toolResponse = '';
|
|
@@ -80,4 +80,21 @@ test('the project getting-started guide uses the installed CLI and matches its s
|
|
|
80
80
|
assert.equal(template, source);
|
|
81
81
|
assert.doesNotMatch(template, /node harness\/cli\.mjs/);
|
|
82
82
|
assert.match(template, /npx sketchbook explain/);
|
|
83
|
+
assert.match(template, /snapshot does not automatically reflect later changes/);
|
|
84
|
+
assert.match(template, /core-only project includes neither integration/);
|
|
85
|
+
assert.match(template, /selected a shared agent profile/);
|
|
86
|
+
assert.match(template, /selected and activated the Claude integration/);
|
|
87
|
+
});
|
|
88
|
+
test('checkout and project guidance distinguish the initial inventory from current setup', sourceRepoOnly, async () => {
|
|
89
|
+
const checkout = await readFile(`${ROOT}AGENTS.md`, 'utf8');
|
|
90
|
+
const workflow = await readFile(`${ROOT}harness/templates/project/AGENT-WORKFLOWS.md`, 'utf8');
|
|
91
|
+
const quickstart = await readFile(`${ROOT}apps/docs/content/start/quickstart.md`, 'utf8');
|
|
92
|
+
assert.match(checkout, /docs\/README\.md.*checkout documentation/);
|
|
93
|
+
assert.match(checkout, /project created by `sketchbook init`[^.]*`docs\/harness\.md`/);
|
|
94
|
+
assert.match(workflow, /source checkout, inspect `\.claude\/skills\/` and `\.claude\/commands\/`/);
|
|
95
|
+
assert.match(quickstart, /initial installation inventory; it does not automatically reflect later changes/);
|
|
96
|
+
for (const file of ['CLAUDE.md', 'harness/templates/CLAUDE.md']) {
|
|
97
|
+
const text = await readFile(`${ROOT}${file}`, 'utf8');
|
|
98
|
+
assert.match(text, /`--dry-run` where supported/);
|
|
99
|
+
}
|
|
83
100
|
});
|
|
@@ -7,12 +7,13 @@ import { createServer } from 'node:http';
|
|
|
7
7
|
import { tmpdir } from 'node:os';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { ROOT } from './helpers.mjs';
|
|
10
|
-
test('OpenCode discovers
|
|
10
|
+
test('OpenCode discovers and loads portable skills in standalone and adopted projects', { skip: process.env.SKETCHBOOK_TEST_OPENCODE_LIVE !== '1', timeout: 90000 }, async () => {
|
|
11
11
|
const temp = await mkdtemp(join(tmpdir(), 'sketchbook-opencode-live-'));
|
|
12
12
|
const repo = join(temp, 'app');
|
|
13
13
|
const project = join(repo, 'design-system');
|
|
14
|
+
const standalone = join(temp, 'standalone');
|
|
14
15
|
let requests = [];
|
|
15
|
-
let
|
|
16
|
+
let action = null;
|
|
16
17
|
let clientOutput = '';
|
|
17
18
|
let sentTool = false;
|
|
18
19
|
const server = createServer((req, res) => {
|
|
@@ -23,10 +24,11 @@ test('OpenCode discovers nested guidance and invokes the CLI', { skip: process.e
|
|
|
23
24
|
requests.push(body);
|
|
24
25
|
const parsed = JSON.parse(body);
|
|
25
26
|
// OpenCode may first request a session title without any tools.
|
|
26
|
-
const tool =
|
|
27
|
+
const tool = !sentTool && parsed.tools?.length && action ? (action === 'bash' ? 'bash' : 'skill') : null;
|
|
27
28
|
if (tool)
|
|
28
29
|
sentTool = true;
|
|
29
|
-
const
|
|
30
|
+
const args = tool === 'skill' ? { id: action } : { command: 'node node_modules/sketchbook/harness/cli.mjs help --json', description: 'Inspect Sketchbook CLI help' };
|
|
31
|
+
const delta = tool ? { role: 'assistant', tool_calls: [{ index: 0, id: 'call_test', type: 'function', function: { name: tool, arguments: JSON.stringify(args) } }] } : { role: 'assistant', content: 'Test completed.' };
|
|
30
32
|
const chunks = [
|
|
31
33
|
{ id: 'chat-test', object: 'chat.completion.chunk', created: 1, model: 'local', choices: [{ index: 0, delta, finish_reason: null }] },
|
|
32
34
|
{ id: 'chat-test', object: 'chat.completion.chunk', created: 1, model: 'local', choices: [{ index: 0, delta: {}, finish_reason: tool ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 10, completion_tokens: 10, total_tokens: 20 } },
|
|
@@ -36,17 +38,20 @@ test('OpenCode discovers nested guidance and invokes the CLI', { skip: process.e
|
|
|
36
38
|
});
|
|
37
39
|
});
|
|
38
40
|
try {
|
|
39
|
-
await mkdir(
|
|
40
|
-
await mkdir(join(project, 'node_modules'));
|
|
41
|
-
await symlink(ROOT, join(project, 'node_modules/sketchbook'), 'dir');
|
|
41
|
+
await mkdir(repo);
|
|
42
42
|
assert.equal(spawnSync('git', ['init', '-q', repo]).status, 0);
|
|
43
43
|
await writeFile(join(repo, 'AGENTS.md'), 'HOST_PROJECT_GUIDANCE: preserve the app.\n');
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
for (const [cwd, mode] of [[repo, ['--adopt']], [temp, ['--dir', 'standalone']]]) {
|
|
45
|
+
const init = spawnSync(process.execPath, [join(ROOT, 'harness/cli.mjs'), 'init', ...mode, '--start', 'blank', '--agent', 'generic', '--no-install'], { cwd, encoding: 'utf8' });
|
|
46
|
+
assert.equal(init.status, 0, init.stdout + init.stderr);
|
|
47
|
+
}
|
|
48
|
+
await mkdir(join(project, 'node_modules'));
|
|
49
|
+
await symlink(ROOT, join(project, 'node_modules/sketchbook'), 'dir');
|
|
46
50
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
47
51
|
const address = server.address();
|
|
48
52
|
assert.ok(address && typeof address !== 'string');
|
|
49
53
|
await writeFile(join(repo, 'opencode.json'), JSON.stringify({ model: 'mock/local', providers: { mock: { name: 'Local mock', package: '@opencode/ai/providers/openai-compatible', settings: { baseURL: `http://127.0.0.1:${address.port}/v1`, apiKey: 'local-test' }, models: { local: { name: 'Local test', capabilities: { tools: true, input: ['text'], output: ['text'] }, limit: { context: 32768, output: 4096 } } } } } }));
|
|
54
|
+
await cp(join(repo, 'opencode.json'), join(standalone, 'opencode.json'));
|
|
50
55
|
const env = { ...process.env };
|
|
51
56
|
for (const key of Object.keys(env))
|
|
52
57
|
if (/^(OPENAI_|ANTHROPIC_|GH_|GITHUB_|OPENCODE_|GOOGLE_)|_PROXY$/i.test(key))
|
|
@@ -80,7 +85,17 @@ test('OpenCode discovers nested guidance and invokes the CLI', { skip: process.e
|
|
|
80
85
|
assert.match(nestedInput, /HOST_PROJECT_GUIDANCE/);
|
|
81
86
|
assert.match(nestedInput, /This project uses the Sketchbook CLI and a contract-first design system/);
|
|
82
87
|
assert.match(nestedInput, /Work on a Sketchbook design-system project/);
|
|
83
|
-
|
|
88
|
+
assert.match(nestedInput, /Draft, resync, or validate a Sketchbook component contract/);
|
|
89
|
+
assert.match(nestedInput, /Implement a Sketchbook Web Component/);
|
|
90
|
+
assert.doesNotMatch(rootInput, /Draft, resync, or validate a Sketchbook component contract/);
|
|
91
|
+
action = 'contract-author';
|
|
92
|
+
const standaloneInput = await run(standalone);
|
|
93
|
+
assert.ok(sentTool, 'the mock provider requested activation');
|
|
94
|
+
assert.match(standaloneInput, /Author a Sketchbook component contract/);
|
|
95
|
+
assert.match(standaloneInput, /Ask for explicit approval before any tests or implementation/);
|
|
96
|
+
action = 'component-builder';
|
|
97
|
+
assert.match(await run(project), /confirm failure for the intended behavior/);
|
|
98
|
+
action = 'bash';
|
|
84
99
|
await run(project);
|
|
85
100
|
assert.ok(sentTool, 'the mock provider requested the shell tool');
|
|
86
101
|
assert.match(clientOutput, /"command"\s*:\s*"help"/, `OpenCode output: ${clientOutput.slice(-1000)}`);
|
|
@@ -44,6 +44,7 @@ test('sideEffects covers every registration, the barrel and the token CSS', chec
|
|
|
44
44
|
const SHIPPED = [
|
|
45
45
|
'harness/cli.mjs', 'harness/cli/run.mjs', 'harness/manifest.json', 'harness/catalog/index.json', 'harness/checks/run.mjs',
|
|
46
46
|
'harness/templates/CLAUDE.md', 'harness/templates/project/harness.config.json', 'harness/templates/project/.claude/settings.json',
|
|
47
|
+
'.agents/skills/contract-author/SKILL.md', '.agents/skills/component-builder/SKILL.md',
|
|
47
48
|
'harness/templates/project/gitignore', 'harness/templates/project/AGENTS.md', 'harness/templates/project/.trae/rules/sketchbook.md', 'harness/templates/project/.aiassistant/rules/sketchbook.md', 'harness/templates/project/.agents/skills/sketchbook/SKILL.md', 'harness/templates/project/AGENT-WORKFLOWS.md', 'harness/templates/project/GEMINI.md', 'harness/templates/project/.codex/hooks.json', 'harness/templates/project/.codex/sketchbook-guard.mjs', 'harness/templates/project/.gemini/settings.json', 'harness/templates/project/.gemini/sketchbook-guard.mjs', 'harness/agent/gemini-guard.mjs', 'harness/templates/project/.github/copilot-instructions.md', 'harness/templates/project/.github/hooks/sketchbook.json', 'harness/templates/project/.github/hooks/sketchbook-guard.mjs', '.claude/skills/hammock/SKILL.md', '.claude/hooks/guard-generated.mjs', '.claude/hooks/guard-decisions.mjs',
|
|
48
49
|
'.claude/commands/add.md', '.claude/rules/contract-first.md', '.githooks/pre-commit', '.githooks/pre-push', 'scripts/build-barrel.mjs', 'docs/cli.md', 'docs/agent-compatibility.md', 'spec/schemas/contract.schema.json', 'harness/templates/move-to-claude-INSTALL.md',
|
|
49
50
|
];
|