werkmeister-core 0.94.1 → 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 +11 -0
- 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/lifecycle.js +4 -2
- package/dist/pr_lifecycle.js +27 -6
- package/dist/sandbox.js +39 -17
- 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,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.94.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
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
|
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/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).
|
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