werkmeister-core 0.94.0 → 0.94.2
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/CHANGELOG.md +20 -0
- package/dist/archetypes.d.ts +8 -1
- package/dist/archetypes.js +36 -3
- package/dist/config.d.ts +9 -0
- package/dist/config.js +44 -10
- package/dist/generate.d.ts +7 -0
- package/dist/generate.js +29 -3
- package/dist/harness/claude/claude_md.js +6 -4
- package/dist/harness/claude/hooks_gen.js +2 -26
- package/dist/lifecycle.js +4 -2
- package/dist/pr_lifecycle.js +27 -6
- package/dist/pr_rules.js +3 -3
- package/dist/sandbox.js +39 -17
- package/dist/strategies/icm_templates.js +7 -3
- package/dist/workspace_init.d.ts +2 -0
- package/dist/workspace_init.js +5 -4
- package/dist/workspace_skills.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# sandbox-core
|
|
2
2
|
|
|
3
|
+
## 0.94.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2896765: Two repos in one workspace that use the same `node_modules_volume` name now get `<repo>-<name>` volumes instead of sharing one; a workspace with one such repo keeps its volume. `clean` recognises the scoped names.
|
|
8
|
+
- 444af37: When the branch is behind `origin/<base>`, the `pr gate` base row names the files base changed that the branch also touches, with "rebase, recheck the spec and tests that name them, rerun". The row's pass or fail is unchanged.
|
|
9
|
+
- 598dbde: `workspace new` with no free slot prints the next step once: init's "container step did not run" banner is dropped when create called it; the slot warning and the "Workspace created at …" line stay.
|
|
10
|
+
- 633fcce: `workspace new` no longer takes services from a command or log quoted in the issue: it ignores code blocks, indented lines and command-shaped `{{…}}`/backtick spans, maps a named code path (`packages/werkmeister-core/src`) to its service, and reads the starting prompt only when the issue names none.
|
|
11
|
+
- 4aa1aad: `pr adopt` over an approved PR file that was never opened fills in its url, merge sha and status and keeps its body, instead of writing a follow-up file.
|
|
12
|
+
- 2bcf30b: Templates and workspace skills are read from the checkout the code runs from when `WERKMEISTER_ROOT` is only config.yaml's `paths.werkmeister_root` (the value env.sh exports into every shell), so a workspace worktree's build renders its own templates. The daemon, Caddy and shared-infra paths still follow `WERKMEISTER_ROOT`, and any other value still wins everywhere.
|
|
13
|
+
|
|
14
|
+
## 0.94.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 03c1389: Generated `.werkmeister/pr-rules.md` no longer names Changesets outside the two places that explain changesets-only behaviour: the release-bot example, the merged-PR release note and the quoted `skip_release` example now say "release entry". The repo-agnostic test now checks every markdown file `workspace init` writes (skills, `_shared/`, `CLAUDE.md`), not only the stage contracts.
|
|
19
|
+
- 448cb50: `werkmeister-context.md` § Test commands now prints the test of a container that holds the real `~/.werkmeister` or the docker socket, and mounts the workspace folder at its host path, under the temp HOME: `docker exec -w /app <container> <ws>/.werkmeister/bin/with-temp-home --no-wait sh -c '…'`, as its Validation text requires. Other containers (a docker.sock-only one cannot see `<ws>/.werkmeister/bin`) keep the bare `docker exec` line, and the allow rules are unchanged. Rerun `werkmeister workspace init` to regenerate the file.
|
|
20
|
+
- db0280e: The implement stage contracts name one way to serve a static HTML page for a browser check (the Chrome tool refuses `file://`): `python3 -I -u -m http.server 0 -b 127.0.0.1 -d <dir>` as a background job, stopped by its task ID, recorded in `exercise.md` as the method.
|
|
21
|
+
- 8223702: The implement stage contracts say the Chrome window does not size below 477 px, and check a narrower width (e.g. 375 px) in a same-origin iframe built with the JS tool: a screenshot plus `scrollWidth === clientWidth` inside the frame.
|
|
22
|
+
|
|
3
23
|
## 0.94.0
|
|
4
24
|
|
|
5
25
|
## 0.93.12
|
package/dist/archetypes.d.ts
CHANGED
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* touches the raw fields.
|
|
15
15
|
*/
|
|
16
16
|
import { type Archetype, type ArchetypeRegistry, type ReposConfig, type ServiceEntry, type ServicesConfig } from "./config.js";
|
|
17
|
+
/**
|
|
18
|
+
* True when one of *entry*'s host binds is a docker socket (any path ending `docker.sock`, e.g. OrbStack's)
|
|
19
|
+
* or the werkmeister home, or a parent of either.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hostAccess(entry: ServiceEntry | undefined): boolean;
|
|
22
|
+
/** True when *entry*'s container sees host path *p* at the same path (one of its binds covers it). */
|
|
23
|
+
export declare function seesHostPath(entry: ServiceEntry | undefined, p: string): boolean;
|
|
17
24
|
/**
|
|
18
25
|
* Return the normalized archetype dict for one service definition.
|
|
19
26
|
*
|
|
@@ -43,7 +50,7 @@ export declare function serviceNoTests(svcDef: ServiceEntry | null | undefined):
|
|
|
43
50
|
* worktree's `node_modules` live. werkmeister-context.md and the workspace's
|
|
44
51
|
* `permissions.allow` rule both use it, so the rule matches what the agent runs.
|
|
45
52
|
*/
|
|
46
|
-
export declare function containerTestCommand(feature: string, svc: string, cmd: string): string;
|
|
53
|
+
export declare function containerTestCommand(feature: string, svc: string, cmd: string, tempHome?: string): string;
|
|
47
54
|
/** True when *cmd* is simple commands joined only by `&&`: no group, pipe, `||`, `;`, `&`, newline or substitution. */
|
|
48
55
|
export declare function isPlainChain(cmd: string): boolean;
|
|
49
56
|
/**
|
package/dist/archetypes.js
CHANGED
|
@@ -13,7 +13,36 @@
|
|
|
13
13
|
* Everything downstream reads through `resolveServiceArchetype` and never
|
|
14
14
|
* touches the raw fields.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import * as path from "node:path";
|
|
18
|
+
import { expandUser, loadArchetypes, sandboxHome, } from "./config.js";
|
|
19
|
+
const realPath = (p) => {
|
|
20
|
+
try {
|
|
21
|
+
return fs.realpathSync(p);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return path.resolve(p);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/** Host sources of *entry*'s bind mounts (named volumes skipped), symlinks resolved (`/var` → `/private/var` on macOS). */
|
|
28
|
+
const hostBinds = (entry) => (entry?.extra_volumes ?? [])
|
|
29
|
+
.map((spec) => spec.split(":")[0])
|
|
30
|
+
.filter((src) => src.includes("/"))
|
|
31
|
+
.map((src) => realPath(expandUser(src)));
|
|
32
|
+
const within = (p, dir) => p === dir || p.startsWith(`${dir}${path.sep}`) || dir === "/";
|
|
33
|
+
/**
|
|
34
|
+
* True when one of *entry*'s host binds is a docker socket (any path ending `docker.sock`, e.g. OrbStack's)
|
|
35
|
+
* or the werkmeister home, or a parent of either.
|
|
36
|
+
*/
|
|
37
|
+
export function hostAccess(entry) {
|
|
38
|
+
const targets = ["/var/run/docker.sock", sandboxHome()].map(realPath);
|
|
39
|
+
return hostBinds(entry).some((host) => path.basename(host) === "docker.sock" || targets.some((t) => within(t, host)));
|
|
40
|
+
}
|
|
41
|
+
/** True when *entry*'s container sees host path *p* at the same path (one of its binds covers it). */
|
|
42
|
+
export function seesHostPath(entry, p) {
|
|
43
|
+
const target = realPath(p);
|
|
44
|
+
return hostBinds(entry).some((host) => within(target, host));
|
|
45
|
+
}
|
|
17
46
|
function isDict(value) {
|
|
18
47
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
48
|
}
|
|
@@ -80,8 +109,12 @@ export function serviceNoTests(svcDef) {
|
|
|
80
109
|
* worktree's `node_modules` live. werkmeister-context.md and the workspace's
|
|
81
110
|
* `permissions.allow` rule both use it, so the rule matches what the agent runs.
|
|
82
111
|
*/
|
|
83
|
-
export function containerTestCommand(feature, svc, cmd) {
|
|
84
|
-
|
|
112
|
+
export function containerTestCommand(feature, svc, cmd, tempHome) {
|
|
113
|
+
const quoted = `sh -c '${cmd.split("'").join(`'\\''`)}'`;
|
|
114
|
+
// SW-769: a container holding the real ~/.werkmeister runs its tests under a temp HOME, as Validation says.
|
|
115
|
+
return tempHome
|
|
116
|
+
? `docker exec -w /app ${feature}-${svc} ${tempHome} --no-wait ${quoted}`
|
|
117
|
+
: `docker exec ${feature}-${svc} ${quoted}`;
|
|
85
118
|
}
|
|
86
119
|
/** True when *cmd* is simple commands joined only by `&&`: no group, pipe, `||`, `;`, `&`, newline or substitution. */
|
|
87
120
|
export function isPlainChain(cmd) {
|
package/dist/config.d.ts
CHANGED
|
@@ -385,6 +385,8 @@ export declare function getVolumeBaseNames(): string[];
|
|
|
385
385
|
*
|
|
386
386
|
* The walk-up is what a bundled consumer cannot do — a `.vsix` has no monorepo
|
|
387
387
|
* around it — which is why `WERKMEISTER_ROOT` ranks first rather than as a fallback.
|
|
388
|
+
* Machine-wide paths (the daemon's plist entry, Caddy, shared infra) hang off this,
|
|
389
|
+
* so it stays on that order; templates and skills read {@link sourceInfraRoot}.
|
|
388
390
|
*/
|
|
389
391
|
export declare function sandboxRoot(): string;
|
|
390
392
|
/**
|
|
@@ -404,6 +406,13 @@ export declare function installedCliPackage(pathEnv?: string): string | null;
|
|
|
404
406
|
* {@link stateInfraRoot}. Nothing writes here at runtime.
|
|
405
407
|
*/
|
|
406
408
|
export declare function infraRoot(): string;
|
|
409
|
+
/**
|
|
410
|
+
* The `infra/` the templates and skills are read from: {@link infraRoot}, except that a
|
|
411
|
+
* `WERKMEISTER_ROOT` equal to config.yaml's `paths.werkmeister_root` (env.sh's export into
|
|
412
|
+
* every shell) yields to the checkout this code runs from, so a worktree's build renders its
|
|
413
|
+
* own templates. Reads only: nothing machine-wide is placed from it.
|
|
414
|
+
*/
|
|
415
|
+
export declare function sourceInfraRoot(): string;
|
|
407
416
|
/**
|
|
408
417
|
* `~/.werkmeister/infra`: the generated runtime files for the shared infra — the
|
|
409
418
|
* Caddyfile, features.json, the pinned kubeconfig, the forwards table and the
|
package/dist/config.js
CHANGED
|
@@ -559,6 +559,9 @@ function registryVolumeBases() {
|
|
|
559
559
|
const nodeModulesVol = def["node_modules_volume"];
|
|
560
560
|
if (typeof nodeModulesVol === "string" && nodeModulesVol) {
|
|
561
561
|
bases.add(nodeModulesVol);
|
|
562
|
+
// SW-110: a clash between repos names it `<repo>-<vol>` (repoScopedNodeModules).
|
|
563
|
+
if (typeof def["repo"] === "string" && def["repo"])
|
|
564
|
+
bases.add(`${def["repo"]}-${nodeModulesVol}`);
|
|
562
565
|
}
|
|
563
566
|
const extraVolumes = def["extra_volumes"];
|
|
564
567
|
if (!Array.isArray(extraVolumes)) {
|
|
@@ -593,6 +596,30 @@ export function getVolumeBaseNames() {
|
|
|
593
596
|
// ---------------------------------------------------------------------------
|
|
594
597
|
// Where the CLI checkout is
|
|
595
598
|
// ---------------------------------------------------------------------------
|
|
599
|
+
/** The `apps/cli` of the checkout this module sits in, found by walking up; null outside one. */
|
|
600
|
+
function ownCheckoutCli() {
|
|
601
|
+
let dir = import.meta.dirname;
|
|
602
|
+
for (let i = 0; i < 8; i++) {
|
|
603
|
+
const cli = path.join(dir, "apps", "cli");
|
|
604
|
+
if (fs.existsSync(cli))
|
|
605
|
+
return cli;
|
|
606
|
+
const parent = path.dirname(dir);
|
|
607
|
+
if (parent === dir)
|
|
608
|
+
break;
|
|
609
|
+
dir = parent;
|
|
610
|
+
}
|
|
611
|
+
return null;
|
|
612
|
+
}
|
|
613
|
+
/** config.yaml's `paths.werkmeister_root`, the value env.sh exports; null when unset or unreadable. */
|
|
614
|
+
function storedWerkmeisterRoot() {
|
|
615
|
+
try {
|
|
616
|
+
const stored = loadConfig().paths?.werkmeister_root;
|
|
617
|
+
return typeof stored === "string" && stored ? path.resolve(expandUser(stored)) : null;
|
|
618
|
+
}
|
|
619
|
+
catch {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
596
623
|
/**
|
|
597
624
|
* The CLI package directory (`<checkout>/apps/cli`) — the root of everything
|
|
598
625
|
* that ships as CODE: `infra/`, `dist/`, the `werkmeister` wrapper.
|
|
@@ -605,6 +632,8 @@ export function getVolumeBaseNames() {
|
|
|
605
632
|
*
|
|
606
633
|
* The walk-up is what a bundled consumer cannot do — a `.vsix` has no monorepo
|
|
607
634
|
* around it — which is why `WERKMEISTER_ROOT` ranks first rather than as a fallback.
|
|
635
|
+
* Machine-wide paths (the daemon's plist entry, Caddy, shared infra) hang off this,
|
|
636
|
+
* so it stays on that order; templates and skills read {@link sourceInfraRoot}.
|
|
608
637
|
*/
|
|
609
638
|
export function sandboxRoot() {
|
|
610
639
|
// SW-239: an unpinned test silently builds or writes in main's checkout (or turbo's walk-up).
|
|
@@ -614,16 +643,9 @@ export function sandboxRoot() {
|
|
|
614
643
|
const override = envVar("ROOT");
|
|
615
644
|
if (override)
|
|
616
645
|
return path.resolve(expandUser(override));
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (fs.existsSync(cli))
|
|
621
|
-
return cli;
|
|
622
|
-
const parent = path.dirname(dir);
|
|
623
|
-
if (parent === dir)
|
|
624
|
-
break;
|
|
625
|
-
dir = parent;
|
|
626
|
-
}
|
|
646
|
+
const own = ownCheckoutCli();
|
|
647
|
+
if (own)
|
|
648
|
+
return own;
|
|
627
649
|
const installed = installedCliPackage();
|
|
628
650
|
if (installed)
|
|
629
651
|
return installed;
|
|
@@ -675,6 +697,18 @@ export function installedCliPackage(pathEnv = process.env.PATH ?? "") {
|
|
|
675
697
|
export function infraRoot() {
|
|
676
698
|
return path.join(sandboxRoot(), "infra");
|
|
677
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* The `infra/` the templates and skills are read from: {@link infraRoot}, except that a
|
|
702
|
+
* `WERKMEISTER_ROOT` equal to config.yaml's `paths.werkmeister_root` (env.sh's export into
|
|
703
|
+
* every shell) yields to the checkout this code runs from, so a worktree's build renders its
|
|
704
|
+
* own templates. Reads only: nothing machine-wide is placed from it.
|
|
705
|
+
*/
|
|
706
|
+
export function sourceInfraRoot() {
|
|
707
|
+
const root = sandboxRoot();
|
|
708
|
+
const own = ownCheckoutCli();
|
|
709
|
+
const useOwn = own !== null && own !== root && root === storedWerkmeisterRoot();
|
|
710
|
+
return path.join(useOwn ? own : root, "infra");
|
|
711
|
+
}
|
|
678
712
|
/**
|
|
679
713
|
* `~/.werkmeister/infra`: the generated runtime files for the shared infra — the
|
|
680
714
|
* Caddyfile, features.json, the pinned kubeconfig, the forwards table and the
|
package/dist/generate.d.ts
CHANGED
|
@@ -36,6 +36,13 @@ export declare function loadWorkspaceEnvVars(workspaceRoot: string): Record<stri
|
|
|
36
36
|
* start one for a repo with no container running.
|
|
37
37
|
*/
|
|
38
38
|
export declare function onDemandServices(servicesConfig: Record<string, unknown>, localServices: string[], workspaceRoot: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* SW-110: two checked-out repos whose fragments share a `node_modules_volume`
|
|
41
|
+
* name would mount one volume, and one repo's install breaks the other's tree.
|
|
42
|
+
* On such a clash the name gets the repo (`<repo>-<vol>`); otherwise it is
|
|
43
|
+
* kept, so a workspace keeps its installed volume. Returns copies.
|
|
44
|
+
*/
|
|
45
|
+
export declare function repoScopedNodeModules([services, setups]: [ServicesConfig, ServicesConfig], workspaceRoot: string): [ServicesConfig, ServicesConfig];
|
|
39
46
|
/**
|
|
40
47
|
* Generate `<workspace>/compose.yml` for *feature*.
|
|
41
48
|
*
|
package/dist/generate.js
CHANGED
|
@@ -18,7 +18,7 @@ import { candidateServiceNames } from "./archetypes.js";
|
|
|
18
18
|
import { applyCaches } from "./build_caches.js";
|
|
19
19
|
import { projectName } from "./compose.js";
|
|
20
20
|
import { COMPOSE_FILE, migrateWorkspaceCompose } from "./compose_file.js";
|
|
21
|
-
import { baselineUpstream, containerOf, DEFAULT_CPUS, DEFAULT_SETUP_CPUS, dotDir, IDLE_SERVICE_TYPES,
|
|
21
|
+
import { baselineUpstream, containerOf, DEFAULT_CPUS, DEFAULT_SETUP_CPUS, dotDir, IDLE_SERVICE_TYPES, loadArchetypes, loadCaches, loadPorts, loadReposConfig, loadServices, loadSetupServices, resolveWorkspace, SHARED_VOLUME_MARKER, sandboxRoot, sourceInfraRoot, stateInfraRoot, } from "./config.js";
|
|
22
22
|
import { loadFeatureRouters } from "./feature_routing.js";
|
|
23
23
|
import { refuseInsideContainer } from "./global_config.js";
|
|
24
24
|
import { buildSandboxContextMd } from "./harness/claude/claude_md.js";
|
|
@@ -177,7 +177,7 @@ function installArrayAppend() {
|
|
|
177
177
|
/** Create and return a nunjucks `Environment` (jinja2-parity settings). */
|
|
178
178
|
function getNunjucksEnv() {
|
|
179
179
|
installArrayAppend();
|
|
180
|
-
const templatesDir = path.join(
|
|
180
|
+
const templatesDir = path.join(sourceInfraRoot(), "templates");
|
|
181
181
|
if (!fs.existsSync(templatesDir) || !fs.statSync(templatesDir).isDirectory()) {
|
|
182
182
|
fs.mkdirSync(templatesDir, { recursive: true });
|
|
183
183
|
}
|
|
@@ -440,6 +440,32 @@ export function onDemandServices(servicesConfig, localServices, workspaceRoot) {
|
|
|
440
440
|
.map(([name]) => name)
|
|
441
441
|
.sort();
|
|
442
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* SW-110: two checked-out repos whose fragments share a `node_modules_volume`
|
|
445
|
+
* name would mount one volume, and one repo's install breaks the other's tree.
|
|
446
|
+
* On such a clash the name gets the repo (`<repo>-<vol>`); otherwise it is
|
|
447
|
+
* kept, so a workspace keeps its installed volume. Returns copies.
|
|
448
|
+
*/
|
|
449
|
+
export function repoScopedNodeModules([services, setups], workspaceRoot) {
|
|
450
|
+
const here = (def) => isDict(def) &&
|
|
451
|
+
Boolean(def["repo"]) &&
|
|
452
|
+
Boolean(def["node_modules_volume"]) &&
|
|
453
|
+
fs.existsSync(path.join(workspaceRoot, String(def["repo"])));
|
|
454
|
+
const reposOf = new Map();
|
|
455
|
+
for (const def of [...Object.values(services), ...Object.values(setups)]) {
|
|
456
|
+
if (!here(def))
|
|
457
|
+
continue;
|
|
458
|
+
const vol = String(def["node_modules_volume"]);
|
|
459
|
+
reposOf.set(vol, (reposOf.get(vol) ?? new Set()).add(String(def["repo"])));
|
|
460
|
+
}
|
|
461
|
+
const scope = (defs) => Object.fromEntries(Object.entries(defs).map(([name, def]) => [
|
|
462
|
+
name,
|
|
463
|
+
here(def) && (reposOf.get(String(def["node_modules_volume"]))?.size ?? 0) > 1
|
|
464
|
+
? { ...def, node_modules_volume: `${def["repo"]}-${def["node_modules_volume"]}` }
|
|
465
|
+
: def,
|
|
466
|
+
]));
|
|
467
|
+
return [scope(services), scope(setups)];
|
|
468
|
+
}
|
|
443
469
|
/**
|
|
444
470
|
* Render the compose file for *feature* without writing it.
|
|
445
471
|
*
|
|
@@ -451,7 +477,7 @@ export function onDemandServices(servicesConfig, localServices, workspaceRoot) {
|
|
|
451
477
|
function renderFeatureCompose(feature, slot, localServices, config, workspaceOverride, source) {
|
|
452
478
|
const [registryServices, portsConfig] = resolveServicesAndPorts(config);
|
|
453
479
|
const [workspaceRoot, outPath] = resolveComposeOutPath(feature, workspaceOverride);
|
|
454
|
-
const [servicesConfig, cachedSetups] = applyCaches(registryServices, config && "setup_services" in config ? (config["setup_services"] ?? {}) : loadSetupServices(), config && "archetypes" in config ? (config["archetypes"] ?? {}) : loadArchetypes(), config && "caches" in config ? (config["caches"] ?? {}) : loadCaches(), workspaceRoot);
|
|
480
|
+
const [servicesConfig, cachedSetups] = repoScopedNodeModules(applyCaches(registryServices, config && "setup_services" in config ? (config["setup_services"] ?? {}) : loadSetupServices(), config && "archetypes" in config ? (config["archetypes"] ?? {}) : loadArchetypes(), config && "caches" in config ? (config["caches"] ?? {}) : loadCaches(), workspaceRoot), workspaceRoot);
|
|
455
481
|
const devLinks = loadDevLinks(workspaceRoot);
|
|
456
482
|
const header = composeHeader(feature, source);
|
|
457
483
|
// Try template first
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import * as fs from "node:fs";
|
|
13
13
|
import * as path from "node:path";
|
|
14
|
-
import { containerTestCommand, serviceNoTests, serviceTestCommand, validationRows, wrappedTestCommand, } from "../../archetypes.js";
|
|
14
|
+
import { containerTestCommand, hostAccess, seesHostPath, serviceNoTests, serviceTestCommand, validationRows, wrappedTestCommand, } from "../../archetypes.js";
|
|
15
15
|
import { cacheSource } from "../../build_caches.js";
|
|
16
16
|
import { baselineUpstream, loadArchetypes, loadCaches, } from "../../config.js";
|
|
17
17
|
import { ingressHostnames, loadFeatureRouters } from "../../feature_routing.js";
|
|
@@ -255,13 +255,15 @@ Hit a bug, or need to log a feature or task, in the \`werkmeister\` tool or a re
|
|
|
255
255
|
// ---------------------------------------------------------------------------
|
|
256
256
|
// werkmeister-context.md generation
|
|
257
257
|
// ---------------------------------------------------------------------------
|
|
258
|
-
|
|
258
|
+
// SW-769: wrap where the real ~/.werkmeister is at risk, but only if the container sees <ws> (a docker.sock-only one would exit 127).
|
|
259
|
+
const withTempHome = (entry, tempHome) => tempHome && hostAccess(entry) && seesHostPath(entry, tempHome) ? tempHome : "";
|
|
260
|
+
function testCommandLine(feature, svc, servicesConfig, archetypes, lint, tempHome = "") {
|
|
259
261
|
const cmd = serviceTestCommand(svc, servicesConfig[svc], archetypes);
|
|
260
262
|
const noTests = serviceNoTests(servicesConfig[svc]);
|
|
261
263
|
if (noTests)
|
|
262
264
|
return `- \`${svc}\`: no tests (registry: ${noTests})`;
|
|
263
265
|
return cmd
|
|
264
|
-
? `- \`${svc}\`: \`${containerTestCommand(feature, svc, lint ? `${lint} && ${cmd}` : cmd)}\``
|
|
266
|
+
? `- \`${svc}\`: \`${containerTestCommand(feature, svc, lint ? `${lint} && ${cmd}` : cmd, withTempHome(servicesConfig[svc], tempHome))}\``
|
|
265
267
|
: `- \`${svc}\`: no test command registered (add \`test:\` to its registry entry)`;
|
|
266
268
|
}
|
|
267
269
|
/** SW-720: in sw-700 host `node`, a compound line and `docker exec … node <script>` were each denied before this form ran. */
|
|
@@ -463,7 +465,7 @@ The registry's \`test:\` for each service (or its archetype's), run in its conta
|
|
|
463
465
|
? " A line starting with `<lint> &&` first runs the repo's lint, the PR gate's lint row, so a `docs:check` or format failure shows here, before the tests, and not first at the gate."
|
|
464
466
|
: ""}
|
|
465
467
|
|
|
466
|
-
${svcs.map((s, i) => testCommandLine(feature, s, servicesConfig, archetypes ?? loadArchetypes(), svcLint[i])).join("\n")}
|
|
468
|
+
${svcs.map((s, i) => testCommandLine(feature, s, servicesConfig, archetypes ?? loadArchetypes(), svcLint[i], tempHome)).join("\n")}
|
|
467
469
|
${sharedCachesLine(caches)}
|
|
468
470
|
`;
|
|
469
471
|
}
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
import * as fs from "node:fs";
|
|
45
45
|
import * as path from "node:path";
|
|
46
46
|
import { parse as parseYaml } from "yaml";
|
|
47
|
-
import { candidateServiceNames, containerTestCommand, isPlainChain, serviceTestCommand, wrappedTestCommand, } from "../../archetypes.js";
|
|
48
|
-
import { dotDir,
|
|
47
|
+
import { candidateServiceNames, containerTestCommand, hostAccess, isPlainChain, serviceTestCommand, wrappedTestCommand, } from "../../archetypes.js";
|
|
48
|
+
import { dotDir, getReposRoot, loadArchetypes, loadReposConfig, loadServices, sandboxRoot, } from "../../config.js";
|
|
49
49
|
import { frozenInstalls } from "../../fragment_detect/workspace.js";
|
|
50
50
|
import { load as loadGlobalConfig } from "../../global_config.js";
|
|
51
51
|
import { workspaceServices } from "../../registry_sync.js";
|
|
@@ -464,30 +464,6 @@ hostServices = [], reposConfig = {}) {
|
|
|
464
464
|
.map((r) => `${wrapped}--no-wait ${r.slice(wrapped.length)}`));
|
|
465
465
|
return [...new Set([...rules, ...READ_ONLY_GIT_RULES])];
|
|
466
466
|
}
|
|
467
|
-
/**
|
|
468
|
-
* True when one of *entry*'s host binds is a docker socket (any path ending `docker.sock`, e.g. OrbStack's)
|
|
469
|
-
* or the werkmeister home, or a parent of either; symlinks resolved (`/var` → `/private/var` on macOS).
|
|
470
|
-
*/
|
|
471
|
-
function hostAccess(entry) {
|
|
472
|
-
const real = (p) => {
|
|
473
|
-
try {
|
|
474
|
-
return fs.realpathSync(p);
|
|
475
|
-
}
|
|
476
|
-
catch {
|
|
477
|
-
return path.resolve(p);
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
const targets = ["/var/run/docker.sock", sandboxHome()].map(real);
|
|
481
|
-
return (entry?.extra_volumes ?? []).some((spec) => {
|
|
482
|
-
const src = spec.split(":")[0];
|
|
483
|
-
if (!src.includes("/"))
|
|
484
|
-
return false; // a named volume
|
|
485
|
-
const host = real(expandUser(src));
|
|
486
|
-
if (path.basename(host) === "docker.sock")
|
|
487
|
-
return true;
|
|
488
|
-
return targets.some((t) => t === host || t.startsWith(`${host}${path.sep}`) || host === "/");
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
467
|
/**
|
|
492
468
|
* SW-845: *registry* with each entry's `extra_volumes` widened to every bind compose mounts: the
|
|
493
469
|
* branch's own fragment and the workspace's `dev_links` too (both agent-editable), variables
|
package/dist/lifecycle.js
CHANGED
|
@@ -1391,8 +1391,10 @@ export function classifyVolumes(volumes, baseNames, live) {
|
|
|
1391
1391
|
const activeVolumes = [];
|
|
1392
1392
|
const orphanedVolumes = [];
|
|
1393
1393
|
for (const vol of volumes) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1394
|
+
// SW-110: `fix-shop-node-modules` is live feature `fix-shop` under `node-modules`, or `fix` under
|
|
1395
|
+
// `shop-node-modules`. Any reading that leaves a live feature keeps it: a wrong one deletes node_modules.
|
|
1396
|
+
const isLive = baseNames.some((b) => vol.endsWith(`-${b}`) && live.has(vol.slice(0, -b.length - 1)));
|
|
1397
|
+
(isLive ? activeVolumes : orphanedVolumes).push(vol);
|
|
1396
1398
|
}
|
|
1397
1399
|
return { activeVolumes, orphanedVolumes };
|
|
1398
1400
|
}
|
package/dist/pr_lifecycle.js
CHANGED
|
@@ -853,12 +853,24 @@ testsOnly = false) {
|
|
|
853
853
|
"-q",
|
|
854
854
|
`refs/remotes/origin/${branch}`,
|
|
855
855
|
])).code === 0;
|
|
856
|
+
// SW-191: base commits in files this branch touches made a spec or test route stale mid-run. Warns only.
|
|
857
|
+
const names = async (range) => {
|
|
858
|
+
const r = await deps.run("git", ["-C", dir, "diff", "--name-only", range]);
|
|
859
|
+
return r.code ? [] : r.stdout.split("\n").filter(Boolean);
|
|
860
|
+
};
|
|
861
|
+
const theirs = count > 0 ? new Set(await names(`HEAD...origin/${base}`)) : new Set();
|
|
862
|
+
const overlap = theirs.size
|
|
863
|
+
? (await names(`origin/${base}...HEAD`)).filter((f) => theirs.has(f))
|
|
864
|
+
: [];
|
|
865
|
+
const also = overlap.length
|
|
866
|
+
? `; origin/${base} also changed ${overlap.join(", ")} — rebase onto origin/${base}, recheck the spec and tests that name them, rerun`
|
|
867
|
+
: "";
|
|
856
868
|
add("base", behind.code === 0 && (count === 0 || pushed), behind.code
|
|
857
869
|
? `cannot check against origin/${base}: ${(behind.stderr || behind.stdout).trim()}`
|
|
858
870
|
: pushed
|
|
859
|
-
? `${commits}; ${branch} is already pushed, so \`pr watch\` flags a conflict and rule 5's \`--force-with-lease\` hand-off applies`
|
|
871
|
+
? `${commits}; ${branch} is already pushed, so \`pr watch\` flags a conflict and rule 5's \`--force-with-lease\` hand-off applies${also}`
|
|
860
872
|
: count
|
|
861
|
-
? `${commits} — \`git -C ${file.dir} rebase origin/${base}\` (keeps one commit per ticket), rerun the tests, then rerun`
|
|
873
|
+
? `${commits} — \`git -C ${file.dir} rebase origin/${base}\` (keeps one commit per ticket), rerun the tests, then rerun${also}`
|
|
862
874
|
: `up to date with origin/${base}`);
|
|
863
875
|
const status = await deps.run("git", ["-C", dir, "status", "--porcelain"]);
|
|
864
876
|
add("clean", status.code === 0 && status.stdout.trim() === "", status.code
|
|
@@ -2448,6 +2460,7 @@ export async function adoptPr(ws, opts, deps = defaultDeps()) {
|
|
|
2448
2460
|
};
|
|
2449
2461
|
let fm;
|
|
2450
2462
|
let title;
|
|
2463
|
+
let unopened = null;
|
|
2451
2464
|
if (opts.noPr !== undefined) {
|
|
2452
2465
|
if (!opts.noPr.trim())
|
|
2453
2466
|
throw new WorkspaceError("--no-pr needs a reason.");
|
|
@@ -2473,12 +2486,17 @@ export async function adoptPr(ws, opts, deps = defaultDeps()) {
|
|
|
2473
2486
|
const tracked = readPrFiles(ws).find((f) => f.fm["url"] === pr.url);
|
|
2474
2487
|
if (tracked)
|
|
2475
2488
|
throw new WorkspaceError(`${pr.url} is already tracked in ${path.basename(tracked.path)}.`);
|
|
2489
|
+
const merged = pr.state === "MERGED";
|
|
2490
|
+
const existing = fs.existsSync(file) ? parsePrFile(file) : null;
|
|
2491
|
+
// SW-735: a PR file never opened (no url) is this PR's record: fill in its fields, keep its body.
|
|
2492
|
+
if (existing && !existing.fm["url"])
|
|
2493
|
+
unopened = existing;
|
|
2476
2494
|
// The worktree's first PR file is taken: adopt as a follow-up named by PR number (SW-103).
|
|
2477
|
-
const followUp =
|
|
2495
|
+
const followUp = Boolean(existing) && !unopened;
|
|
2478
2496
|
if (followUp)
|
|
2479
2497
|
file = path.join(dir, `pr-${repo}-${/\/pull\/(\d+)/.exec(pr.url)?.[1]}.md`);
|
|
2480
|
-
|
|
2481
|
-
|
|
2498
|
+
if (!unopened)
|
|
2499
|
+
taken();
|
|
2482
2500
|
fm = {
|
|
2483
2501
|
...(followUp ? { worktree: repo } : {}),
|
|
2484
2502
|
repo: /github\.com\/([^/]+\/[^/]+)\/pull\//.exec(pr.url)?.[1] ?? "",
|
|
@@ -2493,7 +2511,10 @@ export async function adoptPr(ws, opts, deps = defaultDeps()) {
|
|
|
2493
2511
|
title = pr.title;
|
|
2494
2512
|
}
|
|
2495
2513
|
// Through the YAML library: a hand-written `release: @scope/pkg@1.0` is invalid YAML.
|
|
2496
|
-
|
|
2514
|
+
if (unopened)
|
|
2515
|
+
writePrFields(unopened, fm);
|
|
2516
|
+
else
|
|
2517
|
+
fs.writeFileSync(file, `---\n${YAML.stringify(fm)}---\n# ${title}\n\nAdopted with \`werkmeister pr adopt\`: the work landed outside this workspace.\n`);
|
|
2497
2518
|
const lines = [`${path.basename(file, ".md").replace(/^pr-/, "")}: adopted as ${fm["status"]}`];
|
|
2498
2519
|
if (fm["status"] !== "closed")
|
|
2499
2520
|
lines.push(...(await refreshPrStatus(ws, deps)).lines);
|
package/dist/pr_rules.js
CHANGED
|
@@ -31,7 +31,7 @@ These hold for every PR this workspace produces, whatever skill or command was a
|
|
|
31
31
|
3. **Gate.** Before a PR opens, all of these hold: every earlier stage/phase is done; every follow-up a decided question in \`decisions.md\` promises names its issue key; the PR file's acceptance table is all PASS (MANUAL rows pass and the gate lists them); the code worktree is clean; a branch not yet pushed is not behind \`origin/<base>\` (the gate fetches it first; a pushed one passes with a note, rule 5; when behind, rebase with \`git -C <repo> rebase origin/<base>\` and rerun the tests, before the first push so no force-push is needed); each touched service's registry test command passes (\`.werkmeister/werkmeister-context.md\`); the exercise evidence is all PASS (or \`skip_exercise\` gives the reason); the code review in \`review.md\` is all PASS (or \`skip_review\` gives the reason; only in a workspace whose build stage has the review step); the repo's release check passes; the PR file reads \`status: approved\`. The PR-file checks (stages, acceptance table, approved, exercise evidence, review) and the base check run first; if one fails, the gate stops before any test command. With the tests the gate can run past a 10-minute tool call. Run \`pr open\`, and \`pr gate\` or \`pr gate --tests\` too, alone as a background job your harness tracks (Claude Code: \`run_in_background\`), with only its log redirect and no \`cd\`, pipe or other command around it, so an allow rule for it matches (an autonomous run has one; an interactive one asks): \`werkmeister pr open > <absolute workspace path>/.werkmeister/pr-open.log 2>&1\`, or \`werkmeister pr gate --tests > <absolute workspace path>/.werkmeister/gate-run.log 2>&1\`. The log path is absolute because the shell's cwd can drift into a code worktree, which would write the log there as an untracked file. Wait for its completion notice, which carries the exit code, then read the log's end. A bare \`&\` dies when the tool call returns, and \`nohup … &\` sends no notice when it ends.
|
|
32
32
|
4. **Only \`werkmeister pr open\` opens PRs.** \`gh pr create\`, \`/create-pr\` and \`finishing-a-development-branch\` are blocked inside a workspace.
|
|
33
33
|
5. **Auto-fix is always on.** \`werkmeister pr watch\` wakes the session that opened the PR when a check fails, a review comes in or the PR conflicts with its base, with the cause in the message. On a conflict, rebase onto \`origin/<base>\`; never merge the base into the branch, or GitHub can't rebase-merge it. A conflict in a generated file (a snapshot, a lockfile): take the base's copy and regenerate it with the repo's generator (\`.werkmeister/werkmeister-context.md\` names it); never hand-merge it. The agent can't force-push, so give the person \`git -C <absolute worktree path> push --force-with-lease=<branch>:<old sha>\`, where \`<old sha>\` is the PR head before the rebase; the wake message prints it filled in. With no wake message (a manual second rebase), run \`git fetch\` and take \`<old sha>\` from the output of \`git rev-parse origin/<branch>\`, pasted verbatim: never shortened or retyped, or the push fails \`stale info\`. ${DESKTOP_AUTOFIX_RULE} Never turn on auto-merge.
|
|
34
|
-
6. **Merge is the person's act.** Tooling never merges. On a repo with a merge queue, the queue's method decides how every PR merges (\`gh api repos/<repo>/rules/branches/<base>\`, the \`merge_queue\` rule's \`merge_method\`); without one, squash is the default. A PR that needs another method says so at the top of its body, and the person merges it that way, bypassing the queue: a grouped PR (\`group\` in \`workspace.yml\`) says "Rebase and merge, not squash" and keeps its per-ticket commits (\`werkmeister pr gate\` warns when the base won't allow it); a PR whose commit SHAs must survive (e.g. a commit listed in \`.git-blame-ignore-revs\`) says "Merge with a merge commit", since squash and rebase both rewrite SHAs. A PR that must wait for a step outside the code (e.g. a ruleset applied after its CI goes green) sets \`hold: <reason>\` in its PR file: \`werkmeister pr open\` then opens it as a draft, which GitHub won't merge, with \`Don't merge until: <reason>\` at the top of the body. The session that does the step runs \`gh pr ready <url>\` and empties \`hold:\`. A PR the repo's own automation queues (a release bot's version PR
|
|
34
|
+
6. **Merge is the person's act.** Tooling never merges. On a repo with a merge queue, the queue's method decides how every PR merges (\`gh api repos/<repo>/rules/branches/<base>\`, the \`merge_queue\` rule's \`merge_method\`); without one, squash is the default. A PR that needs another method says so at the top of its body, and the person merges it that way, bypassing the queue: a grouped PR (\`group\` in \`workspace.yml\`) says "Rebase and merge, not squash" and keeps its per-ticket commits (\`werkmeister pr gate\` warns when the base won't allow it); a PR whose commit SHAs must survive (e.g. a commit listed in \`.git-blame-ignore-revs\`) says "Merge with a merge commit", since squash and rebase both rewrite SHAs. A PR that must wait for a step outside the code (e.g. a ruleset applied after its CI goes green) sets \`hold: <reason>\` in its PR file: \`werkmeister pr open\` then opens it as a draft, which GitHub won't merge, with \`Don't merge until: <reason>\` at the top of the body. The session that does the step runs \`gh pr ready <url>\` and empties \`hold:\`. A PR the repo's own automation queues (a release bot's version PR) is the exception: leave it to that automation, and don't tell the person it's theirs to merge.
|
|
35
35
|
7. **Close out only when every PR file is \`shipped\`, \`closed\` or \`abandoned\`, and after the post-mortem:** the werkmeister \`postmortem\` skill writes \`postmortem.md\` at the workspace root. \`werkmeister workspace close\` refuses without it unless \`--skip-postmortem "<reason>"\`.
|
|
36
36
|
|
|
37
37
|
## PR file — \`${prFileDir}pr-<worktree>[-<slug>].md\`
|
|
@@ -50,7 +50,7 @@ merge_sha: # written by werkmeister pr status
|
|
|
50
50
|
release: # release tag that shipped it, written by werkmeister pr status; \`none\` for a merged skip_release PR with no changeset (changesets repos), else set it yourself for a change that ships nothing
|
|
51
51
|
reason: "" # required for closed / abandoned
|
|
52
52
|
skip_tests: {} # <service>: <reason> — for a service with no test command or no running container (a service that has no tests says \`test: none: <reason>\` in its registry entry instead); tests: <reason> when no service maps to the changed files
|
|
53
|
-
skip_release: "" # <reason> — skips the gate's release check; a ship: tag repo still waits for its release tag unless release: none, or the merged PR has no
|
|
53
|
+
skip_release: "" # <reason> — skips the gate's release check; a ship: tag repo still waits for its release tag unless release: none, or the merged PR has no release entry
|
|
54
54
|
skip_exercise: "" # <reason> — skips the gate's exercise check, e.g. a doc deliverable with nothing to run
|
|
55
55
|
skip_review: "" # <reason> — skips the gate's review check, e.g. a doc deliverable with no code to review
|
|
56
56
|
hold: "" # <reason> — pr open opens the PR as a draft, body starting "Don't merge until: <reason>"; when the step is done, gh pr ready <url> and empty this (rule 6)
|
|
@@ -59,7 +59,7 @@ hold: "" # <reason> — pr open opens the PR as a draft, body sta
|
|
|
59
59
|
<PR body: summary, test and exercise results, acceptance table, Fixes <issue>>
|
|
60
60
|
\`\`\`
|
|
61
61
|
|
|
62
|
-
**Quote free-text values.** \`reason\`, \`skip_*\` (each \`skip_tests\` entry too) and \`hold\` take a double-quoted string, e.g. \`skip_release: "no
|
|
62
|
+
**Quote free-text values.** \`reason\`, \`skip_*\` (each \`skip_tests\` entry too) and \`hold\` take a double-quoted string, e.g. \`skip_release: "no release entry: docs only"\`. An unquoted value that contains \`: \` is invalid YAML and \`werkmeister pr open\` fails on it.
|
|
63
63
|
|
|
64
64
|
**Acceptance table.** One row per criterion. The result cell holds exactly \`PASS\` or \`FAIL\` and nothing else; evidence goes in its own column. A criterion only the reviewer can check (it needs a real PR, the desktop app or the real machine) reads \`MANUAL\`, with why in the evidence: the gate passes it and lists it, and never \`PASS\` for a check nobody ran. Only this table takes \`MANUAL\`; exercise and review rows are PASS or FAIL. \`| criterion | PASS: repro.md §1 |\` fails the gate.
|
|
65
65
|
|
package/dist/sandbox.js
CHANGED
|
@@ -960,19 +960,32 @@ export async function distillIssue(issue, distill = (p) => harness().ask(p)) {
|
|
|
960
960
|
: { fields, warning: "the answer held no usable fields" };
|
|
961
961
|
}
|
|
962
962
|
/**
|
|
963
|
-
* The registered services in *repos*
|
|
964
|
-
*
|
|
965
|
-
|
|
966
|
-
|
|
963
|
+
* The registered services in *repos* that *text* names: by id as a whole word,
|
|
964
|
+
* or by the service's `path` (`packages/x`, `packages/x/src/y.ts`). Matched, not
|
|
965
|
+
* model-picked: on the issue text an unattended create is deterministic; the
|
|
966
|
+
* starting-prompt fallback is only as stable as the brief it reads. Quoted commands and
|
|
967
|
+
* logs are evidence, not a choice (SW-707): code blocks, indented lines and code
|
|
968
|
+
* spans holding whitespace are dropped first; a one-word span like `{{api}}` stays.
|
|
969
|
+
*/
|
|
970
|
+
function servicesNamedIn(text, repos) {
|
|
967
971
|
const wanted = new Set(repos.map((r) => r.trim()).filter(Boolean));
|
|
968
|
-
|
|
969
|
-
const
|
|
970
|
-
.
|
|
971
|
-
.replace(
|
|
972
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
973
|
+
const prose = text
|
|
974
|
+
.replace(/\\/g, "") // Jira wiki markup escapes hyphens (`smart\-app`).
|
|
975
|
+
.replace(/\{(code|noformat)[^}]*\}[\s\S]*?\{\1\}/g, "")
|
|
976
|
+
.replace(/```[\s\S]*?```/g, "")
|
|
977
|
+
.replace(/^(?: {4}|\t).*$/gm, "")
|
|
978
|
+
// One span at a time: a pattern spanning two spans would eat the prose between them.
|
|
979
|
+
.replace(/\{\{[^}]*\}\}|`[^`\n]*`/g, (m) => (/\s/.test(m) ? "" : m));
|
|
972
980
|
return Object.entries(loadServices())
|
|
973
981
|
.filter(([, def]) => wanted.has(String(def?.repo ?? "")))
|
|
982
|
+
.filter(([id, def]) => {
|
|
983
|
+
const p = String(def?.path ?? "").replace(/^\.?\/+|\/+$/g, "");
|
|
984
|
+
return (new RegExp(`(?<![\\w./-])${esc(id)}(?![\\w/-])`).test(prose) ||
|
|
985
|
+
// A one-segment path (`docs`) is too often a plain word.
|
|
986
|
+
(p.includes("/") && new RegExp(`(?<![\\w.-])${esc(p)}(?![\\w.-])`).test(prose)));
|
|
987
|
+
})
|
|
974
988
|
.map(([id]) => id)
|
|
975
|
-
.filter((id) => new RegExp(`(?<![\\w./-])${id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w/-])`).test(text))
|
|
976
989
|
.sort();
|
|
977
990
|
}
|
|
978
991
|
/** Resolve inputs, fetch the issue (failing the create), then fill an empty task, services, description and starting_prompt from it. */
|
|
@@ -1017,22 +1030,31 @@ export async function prepareCreate(formData, opts = {}) {
|
|
|
1017
1030
|
const blankOnPurpose = rawServices !== null &&
|
|
1018
1031
|
rawServices !== undefined &&
|
|
1019
1032
|
(Array.isArray(rawServices) ? rawServices : [rawServices]).every((v) => !String(v).trim());
|
|
1020
|
-
if (!resolved.services && resolved.repos && !blankOnPurpose) {
|
|
1021
|
-
const named = servicesNamedIn(issue, resolved.repos.split(","));
|
|
1022
|
-
if (named.length) {
|
|
1023
|
-
resolved.services = named.join(",");
|
|
1024
|
-
info(`Services taken from the issue text: ${resolved.services} (pass --services "" for none)`);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
1033
|
if (opts.distill !== false && (!resolved.description || !resolved.starting_prompt)) {
|
|
1028
1034
|
const { fields, warning } = await distillIssue(issue, opts.distill ?? ((p) => harness().ask(p)));
|
|
1029
|
-
// Only the prose
|
|
1035
|
+
// Only the prose, never a model-picked feature or services list; the services step below may
|
|
1036
|
+
// still match names in this starting prompt when the issue text names none (SW-707).
|
|
1030
1037
|
for (const k of ["description", "starting_prompt"])
|
|
1031
1038
|
if (!resolved[k] && fields[k])
|
|
1032
1039
|
resolved[k] = fields[k];
|
|
1033
1040
|
if (warning)
|
|
1034
1041
|
warn(`description/starting_prompt not filled from the issue: ${warning}`);
|
|
1035
1042
|
}
|
|
1043
|
+
if (!resolved.services && resolved.repos && !blankOnPurpose) {
|
|
1044
|
+
const repos = resolved.repos.split(",");
|
|
1045
|
+
const issueText = [issue.title, issue.body, ...issue.comments.map((c) => c.body)].join("\n");
|
|
1046
|
+
let named = servicesNamedIn(issueText, repos);
|
|
1047
|
+
let from = "the issue text";
|
|
1048
|
+
// SW-707: the issue may name a service only as evidence; the brief's "service X" is the next signal.
|
|
1049
|
+
if (!named.length && resolved.starting_prompt) {
|
|
1050
|
+
named = servicesNamedIn(resolved.starting_prompt, repos);
|
|
1051
|
+
from = "the starting prompt";
|
|
1052
|
+
}
|
|
1053
|
+
if (named.length) {
|
|
1054
|
+
resolved.services = named.join(",");
|
|
1055
|
+
info(`Services taken from ${from}: ${resolved.services} (pass --services "" for none)`);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1036
1058
|
return { resolved, issue };
|
|
1037
1059
|
}
|
|
1038
1060
|
// Creation is workspace_init's, called in-process (it used to be a `workspace new` child; note 087).
|
|
@@ -16,6 +16,10 @@ const RELOAD_RULE = "If the container is not running, run `werkmeister feature u
|
|
|
16
16
|
"they are slower, and init rewrites the stage contracts.";
|
|
17
17
|
// SW-612: sw-588 fell back to a published port after `feature up` warned a routed hostname did not resolve.
|
|
18
18
|
const HOSTNAME_RULE = "If `werkmeister feature up` warns that a routed hostname does not resolve to 127.0.0.1 (its last warning line points to `werkmeister machine setup`), stop before any browser check and ask the person to run `werkmeister machine setup` (it needs sudo for the hosts entries and certificate trust). Never click through or bypass a certificate warning. Use the container's published port instead only when the person says to skip setup, and record it in `exercise.md` as a deviation.";
|
|
19
|
+
// SW-791: sw-772 hand-ran http.server to check a docs page; the Chrome tool refuses file://.
|
|
20
|
+
const STATIC_PAGE_RULE = "A static HTML page with no service to load it from is served for the browser check, since the Chrome tool refuses `file://`: run `python3 -I -u -m http.server 0 -b 127.0.0.1 -d <dir>` as a background Bash job (never without `-b 127.0.0.1`: it binds every interface by default), open the port its first line prints, and stop the job by its task ID when the check ends. Record it in `exercise.md` as the method.";
|
|
21
|
+
// SW-792: Chrome won't size its window below 477 px, so sw-772's 375 px check ran at 477.
|
|
22
|
+
const NARROW_VIEWPORT_RULE = 'The Chrome window does not size below 477 px, so check a narrower width in an iframe on the same origin: open the server\'s root, then with the JS tool replace the body with `<iframe src="<page>" width="375" height="812">`, screenshot it, and check `frame.contentDocument.documentElement.scrollWidth === frame.contentDocument.documentElement.clientWidth`. A page on another origin can\'t be read in the frame: ask the person for that row.';
|
|
19
23
|
// SW-143: a library or CLI has nothing to restart. How to exercise one is the service's (or its archetype's)
|
|
20
24
|
// `validate:` text, so app-specific steps stay out of the generic templates.
|
|
21
25
|
const NO_SERVICE_RULE = "A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` § How to validate says.";
|
|
@@ -297,7 +301,7 @@ const feature = [
|
|
|
297
301
|
implementReview(v),
|
|
298
302
|
GATE_STEP,
|
|
299
303
|
REVIEW_DELTA,
|
|
300
|
-
`Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${NO_SERVICE_RULE} ${PROBE_RULE} ${EXERCISE_WORKAROUND} ${TIMING_CLAIM}`,
|
|
304
|
+
`Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${STATIC_PAGE_RULE} ${NARROW_VIEWPORT_RULE} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${NO_SERVICE_RULE} ${PROBE_RULE} ${EXERCISE_WORKAROUND} ${TIMING_CLAIM}`,
|
|
301
305
|
`Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${PER_SERVICE}, ${SKIPPED}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${exerciseFormat("evidence")}.`,
|
|
302
306
|
MANUAL_STEP,
|
|
303
307
|
],
|
|
@@ -401,7 +405,7 @@ const bugfix = [
|
|
|
401
405
|
],
|
|
402
406
|
doNotLoad: "`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`.",
|
|
403
407
|
process: [
|
|
404
|
-
`Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${NO_SERVICE_RULE} ${PROBE_RULE}`,
|
|
408
|
+
`Reload the running code: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${STATIC_PAGE_RULE} ${NARROW_VIEWPORT_RULE} ${NO_SERVICE_RULE} ${PROBE_RULE}`,
|
|
405
409
|
"Rerun the reproduction steps from `repro.md` exactly. Capture the output.",
|
|
406
410
|
`Exercise one neighbouring path through each caller \`repro.md\` listed. Capture the output. ${EXERCISE_WORKAROUND} ${TIMING_CLAIM}`,
|
|
407
411
|
`Write \`output/exercise.md\`: steps 2–3 as ${exerciseFormat("detail")}.`,
|
|
@@ -474,7 +478,7 @@ const refactor = [
|
|
|
474
478
|
implementReview(v),
|
|
475
479
|
GATE_STEP,
|
|
476
480
|
REVIEW_DELTA,
|
|
477
|
-
`After the last step, reload and exercise the service: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${NO_SERVICE_RULE} ${PROBE_RULE} ${EXERCISE_WORKAROUND} ${TIMING_CLAIM}`,
|
|
481
|
+
`After the last step, reload and exercise the service: ${v.restart}. ${RELOAD_RULE} ${HOSTNAME_RULE} ${STATIC_PAGE_RULE} ${NARROW_VIEWPORT_RULE} ${NO_SERVICE_RULE} ${PROBE_RULE} ${EXERCISE_WORKAROUND} ${TIMING_CLAIM}`,
|
|
478
482
|
`Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${PER_SERVICE}, ${SKIPPED}, and the final exercise checks as ${exerciseFormat("evidence")}.`,
|
|
479
483
|
MANUAL_STEP,
|
|
480
484
|
],
|
package/dist/workspace_init.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ export interface InitWorkspaceOptions {
|
|
|
76
76
|
* outlive it on the real docker daemon, holding a slot.
|
|
77
77
|
*/
|
|
78
78
|
build?: boolean;
|
|
79
|
+
/** Skip the no-slot banner: `workspace new` prints its own next step after it. */
|
|
80
|
+
quietNoSlot?: boolean;
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
81
83
|
* Write the issue copy when one is handed over or a refresh is asked for, then
|
package/dist/workspace_init.js
CHANGED
|
@@ -756,9 +756,10 @@ export async function initWorkspace(args, workspaceRootOverride, opts = {}) {
|
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
if (!containers) {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
759
|
+
if (!opts.quietNoSlot)
|
|
760
|
+
warn(`Workspace initialised, but the container step did not run: no slot, so ${COMPOSE_FILE} was not (re)generated ` +
|
|
761
|
+
"(see the slot warning above). `werkmeister feature up` fails until you free a slot " +
|
|
762
|
+
"and rerun `werkmeister workspace init`.");
|
|
762
763
|
return { containers };
|
|
763
764
|
}
|
|
764
765
|
raw(`\n${Colors.BOLD}Workspace initialised.${Colors.RESET} ` +
|
|
@@ -778,7 +779,7 @@ export async function initWorkspace(args, workspaceRootOverride, opts = {}) {
|
|
|
778
779
|
async function runInitWorkspace(workspaceDir, featureSlug, resolved, opts) {
|
|
779
780
|
info(`Running: werkmeister workspace init (feature: ${featureSlug})`);
|
|
780
781
|
try {
|
|
781
|
-
return await initWorkspace({ ...resolved, feature: featureSlug, force: opts.force }, workspaceDir, opts);
|
|
782
|
+
return await initWorkspace({ ...resolved, feature: featureSlug, force: opts.force }, workspaceDir, { ...opts, quietNoSlot: true });
|
|
782
783
|
}
|
|
783
784
|
catch (exc) {
|
|
784
785
|
// A WorkspaceInitError has already emitted its own `[err]` line — the
|
package/dist/workspace_skills.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import * as fs from "node:fs";
|
|
26
26
|
import * as path from "node:path";
|
|
27
|
-
import {
|
|
27
|
+
import { sourceInfraRoot } from "./config.js";
|
|
28
28
|
import { loadManifest } from "./gate.js";
|
|
29
29
|
import { harnessLayoutFor } from "./harness/layout.js";
|
|
30
30
|
import { info, success } from "./reporter.js";
|
|
@@ -37,7 +37,7 @@ import { loadConfigFile, loadSandboxServiceConfigs, planFor } from "./workspace_
|
|
|
37
37
|
const _MANAGED_PREFIXES = ["w9r-", "sb-"];
|
|
38
38
|
/** The hand-authored entry-skill sources: infra/skills/<name>/SKILL.md. */
|
|
39
39
|
export function skillsSourceDir() {
|
|
40
|
-
return path.join(
|
|
40
|
+
return path.join(sourceInfraRoot(), "skills");
|
|
41
41
|
}
|
|
42
42
|
function isDir(p) {
|
|
43
43
|
return fs.existsSync(p) && fs.statSync(p).isDirectory();
|
package/package.json
CHANGED