@uniqbit/mate-core 1.0.1-canary.1 → 1.0.1-canary.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/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/src/cli/commands/companion/link-refresh-report.ts +19 -0
- package/src/cli/commands/companion/sync.ts +25 -1
- package/src/cli/commands/companion/update.ts +1 -17
- package/src/cli/commands/plugin/plugin.ts +6 -1
- package/src/cli/commands/vscode/release-vsix.json +2 -2
- package/src/hooks/validate-artifact-path.ts +75 -19
- package/src/lib/delivery/staging/apply-chain.ts +1 -1
- package/src/lib/delivery/staging/project.ts +2 -1
- package/src/lib/orchestrator/projection-claude-skills.ts +13 -2
- package/src/lib/orchestrator/refresh-working-claude-links.ts +48 -30
- package/src/runtime/companion-sync.ts +3 -2
- package/src/runtime/shell-heredoc.ts +7 -6
- package/src/templates/capabilities/openspec-cap/mate-full/schema.yaml +2 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +3 -0
- package/src/tools/setup/dynamic-plugins/verify.ts +1 -2
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FRAMEWORK_NAME } from "../../../framework";
|
|
2
|
+
import type { LinkRefreshResult } from "../../../lib/orchestrator/refresh-working-claude-links";
|
|
3
|
+
|
|
4
|
+
export function reportLinkRefresh(results: LinkRefreshResult[]): void {
|
|
5
|
+
for (const result of results) {
|
|
6
|
+
const where = result.repository?.path ?? "the linked Working Repositories";
|
|
7
|
+
if (result.outcome === "written") {
|
|
8
|
+
process.stdout.write(
|
|
9
|
+
`${FRAMEWORK_NAME}: refreshed Claude skill and command links in ${where}.\n`,
|
|
10
|
+
);
|
|
11
|
+
} else if (result.outcome === "current") {
|
|
12
|
+
process.stdout.write(`${FRAMEWORK_NAME}: Claude links already current in ${where}.\n`);
|
|
13
|
+
} else {
|
|
14
|
+
process.stderr.write(
|
|
15
|
+
`${FRAMEWORK_NAME}: warning: could not refresh Claude links in ${where}: ${result.error}\n`,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -2,9 +2,13 @@ import { FRAMEWORK_NAME } from "../../../framework";
|
|
|
2
2
|
import { createStartupProgress } from "../../../lib/components/startup-progress";
|
|
3
3
|
import { settleLinkedAt } from "../../../lib/delivery/staging/settle-linked";
|
|
4
4
|
import { syncCompanionGit } from "../../../lib/orchestrator/companion-git-sync";
|
|
5
|
-
import {
|
|
5
|
+
import { readCompanionConfig } from "../../../lib/orchestrator/config-store";
|
|
6
|
+
import { refreshWorkingClaudeLinks } from "../../../lib/orchestrator/refresh-working-claude-links";
|
|
7
|
+
import { type FrameworkConfig, LaunchPreflightError } from "../../../lib/orchestrator/types";
|
|
6
8
|
import { resolveCompanionRuntime } from "../../../runtime/env";
|
|
9
|
+
import { errorMessage } from "../../../runtime/error-message";
|
|
7
10
|
import { readCompanionPolicy } from "../../../runtime/policy";
|
|
11
|
+
import { reportLinkRefresh } from "./link-refresh-report";
|
|
8
12
|
import { resolveCompanionPath, resolveRepoPath } from "./tui";
|
|
9
13
|
|
|
10
14
|
export interface CompanionSyncDeps {
|
|
@@ -15,6 +19,11 @@ export interface CompanionSyncDeps {
|
|
|
15
19
|
syncCompanionGit: typeof syncCompanionGit;
|
|
16
20
|
/** Records merges this machine's linked checkouts settle on the pending branch. */
|
|
17
21
|
settleLinked: typeof settleLinkedAt;
|
|
22
|
+
loadConfig: (companionPath: string) => Promise<FrameworkConfig>;
|
|
23
|
+
refreshWorkingClaudeLinks: (
|
|
24
|
+
companionPath: string,
|
|
25
|
+
config: FrameworkConfig,
|
|
26
|
+
) => ReturnType<typeof refreshWorkingClaudeLinks>;
|
|
18
27
|
createProgress: typeof createStartupProgress;
|
|
19
28
|
}
|
|
20
29
|
|
|
@@ -26,9 +35,23 @@ export const companionSyncDeps: CompanionSyncDeps = {
|
|
|
26
35
|
readCompanionPolicy,
|
|
27
36
|
syncCompanionGit,
|
|
28
37
|
settleLinked: settleLinkedAt,
|
|
38
|
+
loadConfig: readCompanionConfig,
|
|
39
|
+
refreshWorkingClaudeLinks,
|
|
29
40
|
createProgress: createStartupProgress,
|
|
30
41
|
};
|
|
31
42
|
|
|
43
|
+
async function refreshClaudeLinks(companionPath: string): Promise<void> {
|
|
44
|
+
try {
|
|
45
|
+
const config = await companionSyncDeps.loadConfig(companionPath);
|
|
46
|
+
const results = await companionSyncDeps.refreshWorkingClaudeLinks(companionPath, config);
|
|
47
|
+
reportLinkRefresh(results.filter((result) => result.outcome !== "current"));
|
|
48
|
+
} catch (error) {
|
|
49
|
+
process.stderr.write(
|
|
50
|
+
`${FRAMEWORK_NAME}: warning: could not refresh Claude links: ${errorMessage(error)}\n`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
/**
|
|
33
56
|
* The Projection Root answers for a Wrapped Repository, which can never take
|
|
34
57
|
* the launch path — so the command must resolve there too, not only through the
|
|
@@ -106,6 +129,7 @@ export async function runCompanionSyncCommand(): Promise<void> {
|
|
|
106
129
|
process.stdout.write(`${FRAMEWORK_NAME}: recorded the merge of ${change}.\n`);
|
|
107
130
|
}
|
|
108
131
|
if (settled.warning) process.stderr.write(`${FRAMEWORK_NAME}: ${settled.warning}\n`);
|
|
132
|
+
await refreshClaudeLinks(companionPath);
|
|
109
133
|
} catch (error) {
|
|
110
134
|
progress.fail("git");
|
|
111
135
|
if (error instanceof LaunchPreflightError) {
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
type CompanionSyncOptions,
|
|
29
29
|
} from "../../../tools/setup";
|
|
30
30
|
import type { ManagedOutputOwner, ManagedOutputReport } from "../../../tools/setup/plugin";
|
|
31
|
+
import { reportLinkRefresh } from "./link-refresh-report";
|
|
31
32
|
import { confirm } from "../../confirm";
|
|
32
33
|
import { defaultGitOps, type GitOps } from "../artifact/finish/git";
|
|
33
34
|
import { resolveCompanionPath } from "./tui";
|
|
@@ -218,23 +219,6 @@ function listPaths(paths: string[]): string {
|
|
|
218
219
|
return paths.map((changed) => ` ${changed}`).join("\n");
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
function reportLinkRefresh(results: LinkRefreshResult[]): void {
|
|
222
|
-
for (const result of results) {
|
|
223
|
-
const where = result.repository?.path ?? "the linked Working Repositories";
|
|
224
|
-
if (result.outcome === "written") {
|
|
225
|
-
process.stdout.write(
|
|
226
|
-
`${FRAMEWORK_NAME}: refreshed Claude skill and command links in ${where}.\n`,
|
|
227
|
-
);
|
|
228
|
-
} else if (result.outcome === "current") {
|
|
229
|
-
process.stdout.write(`${FRAMEWORK_NAME}: Claude links already current in ${where}.\n`);
|
|
230
|
-
} else {
|
|
231
|
-
process.stderr.write(
|
|
232
|
-
`${FRAMEWORK_NAME}: warning: could not refresh Claude links in ${where}: ${result.error}\n`,
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
222
|
/** Version precondition; returns the running version when the update may proceed. */
|
|
239
223
|
async function checkVersion(progress: StartupProgressController): Promise<string | undefined> {
|
|
240
224
|
const current = companionUpdateDeps.getCurrentVersion();
|
|
@@ -6,12 +6,17 @@ export async function runPluginCommand(
|
|
|
6
6
|
argv: string[],
|
|
7
7
|
deps: PluginInstallCommandDeps = {},
|
|
8
8
|
): Promise<void> {
|
|
9
|
+
if (!subcommand) {
|
|
10
|
+
console.error("mate: plugin command required. Use `mate plugin install <package>`.");
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
9
14
|
switch (subcommand) {
|
|
10
15
|
case "install":
|
|
11
16
|
if (!(await runPluginInstallCommand(argv, deps))) process.exitCode = 1;
|
|
12
17
|
return;
|
|
13
18
|
default:
|
|
14
|
-
console.error(`Unknown plugin command: ${subcommand
|
|
19
|
+
console.error(`Unknown plugin command: ${subcommand}`);
|
|
15
20
|
console.error(usage());
|
|
16
21
|
process.exitCode = 1;
|
|
17
22
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.1-canary.
|
|
3
|
-
"sha512": "sha512-
|
|
2
|
+
"version": "1.0.1-canary.2",
|
|
3
|
+
"sha512": "sha512-2jfqdRqW5MddrYlP+r+wCjiJI5HWCSZN8ErbgGUFcTf/VbS6mDFw7sBKqyuaemhLOX94pVebOdnnHkU3h4TBoQ=="
|
|
4
4
|
}
|
|
@@ -22,7 +22,7 @@ import type { FrictionCheck } from "../runtime/friction-fingerprint";
|
|
|
22
22
|
import { guardLaunchEnvironment } from "../runtime/launch-env-guard";
|
|
23
23
|
import { companionLinkPath } from "../runtime/repo-local";
|
|
24
24
|
import { checkSecretAccess, type SecretToolCall } from "../runtime/secret-guard";
|
|
25
|
-
import { commandTextMask, stripHeredocBodies } from "../runtime/shell-heredoc";
|
|
25
|
+
import { commandTextMask, heredocBodies, stripHeredocBodies } from "../runtime/shell-heredoc";
|
|
26
26
|
import { wordExpander } from "../runtime/shell-variables";
|
|
27
27
|
import { hookFolder, type HookEnv } from "./hook-io";
|
|
28
28
|
|
|
@@ -54,11 +54,25 @@ const ARTIFACT_PATH_MARKERS = [
|
|
|
54
54
|
];
|
|
55
55
|
|
|
56
56
|
/** `[ \t]`, not `\s`: a redirect or `tee` names its target on its own line. */
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
57
|
+
const MD_REDIRECT_PATTERN = new RegExp(
|
|
58
|
+
String.raw`>{1,2}\|?[ \t]*("[^"\n]*\.md"|'[^'\n]*\.md'|[^\s;|&<>]+\.md)(?=[\s;|&<>'"\`)\\]|$)`,
|
|
59
|
+
"g",
|
|
60
|
+
);
|
|
61
|
+
const TEE_PATTERN = /\btee[ \t]+([^|;&)\n]*)/g;
|
|
62
|
+
const TEE_WORD = String.raw`"[^"\n]*"|'[^'\n]*'|[^\s<>"']+`;
|
|
63
|
+
const TEE_INPUT_REDIRECT = String.raw`<+[ \t]*(?:${TEE_WORD})`;
|
|
64
|
+
const TEE_WORD_PATTERN = new RegExp(`${TEE_INPUT_REDIRECT}|${TEE_WORD}`, "g");
|
|
65
|
+
const SHELL_WORD = String.raw`(?:[^\s;&|()\`'"]*\/)?(?:sh|bash|dash|ksh|zsh|ash|mksh|yash|posh|csh|tcsh|fish)`;
|
|
66
|
+
const SHELL_C_OPTION = String.raw`(?:${SHELL_WORD}|su)(?:[ \t]+[^\s;&|()\`'"]+)*?[ \t]+-[A-Za-z]*c(?:[ \t]+--)?`;
|
|
67
|
+
const NESTED_SHELL_PATTERN = new RegExp(
|
|
68
|
+
String.raw`(?<![^\s;&|(\`])(?:${SHELL_C_OPTION}|eval)[ \t]+\$?(['"])`,
|
|
69
|
+
"g",
|
|
70
|
+
);
|
|
71
|
+
const COMMAND_PREFIX = String.raw`(?:[A-Za-z_]\w*=[^\s;&|]*|env|sudo|exec|command|xargs)[ \t]+`;
|
|
72
|
+
const RUNS_SHELL_PATTERN = new RegExp(
|
|
73
|
+
String.raw`(?:^|[|;&(\`\n])[ \t]*(?:${COMMAND_PREFIX})*(${SHELL_WORD}|eval)(?=[\s;&|)\`<>]|$)`,
|
|
74
|
+
"gd",
|
|
75
|
+
);
|
|
62
76
|
|
|
63
77
|
export function artifactLikePath(filePath: string): boolean {
|
|
64
78
|
if (!filePath) return false;
|
|
@@ -276,6 +290,34 @@ function nestedScript(text: string, start: number): { script: string; doubleQuot
|
|
|
276
290
|
return { script, doubleQuoted: true };
|
|
277
291
|
}
|
|
278
292
|
|
|
293
|
+
function shellWordOffsets(commandText: string, isCommand: boolean[]): number[] {
|
|
294
|
+
const offsets: number[] = [];
|
|
295
|
+
for (const match of commandText.matchAll(RUNS_SHELL_PATTERN)) {
|
|
296
|
+
const at = match.indices![1]![0];
|
|
297
|
+
if (isCommand[at]) offsets.push(at);
|
|
298
|
+
}
|
|
299
|
+
return offsets;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function scanTargets(
|
|
303
|
+
commandText: string,
|
|
304
|
+
isScanned: (offset: number) => boolean,
|
|
305
|
+
): { raw: string; at: number }[] {
|
|
306
|
+
const found: { raw: string; at: number }[] = [];
|
|
307
|
+
for (const match of commandText.matchAll(MD_REDIRECT_PATTERN)) {
|
|
308
|
+
if (isScanned(match.index)) found.push({ raw: match[1]!, at: match.index });
|
|
309
|
+
}
|
|
310
|
+
for (const match of commandText.matchAll(TEE_PATTERN)) {
|
|
311
|
+
if (!isScanned(match.index)) continue;
|
|
312
|
+
const argsAt = match.index + match[0].length - match[1]!.length;
|
|
313
|
+
for (const word of match[1]!.matchAll(TEE_WORD_PATTERN)) {
|
|
314
|
+
if (/^[-<]/.test(word[0]) || !/\.md["']?$/.test(word[0])) continue;
|
|
315
|
+
found.push({ raw: word[0], at: argsAt + word.index });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return found;
|
|
319
|
+
}
|
|
320
|
+
|
|
279
321
|
function commandTargets(
|
|
280
322
|
command: string,
|
|
281
323
|
expandInCallingShell?: (raw: string) => ReturnType<Expand>,
|
|
@@ -289,18 +331,16 @@ function commandTargets(
|
|
|
289
331
|
expandInCallingShell
|
|
290
332
|
? expandInCallingShell(raw)
|
|
291
333
|
: (own ??= wordExpander(commandText))(raw, offset);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
expanded.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (target.path) targets.push(target);
|
|
303
|
-
}
|
|
334
|
+
const shellWords = shellWordOffsets(commandText, isCommand);
|
|
335
|
+
const scanQuotedText = shellWords.length > 0;
|
|
336
|
+
const found = scanTargets(commandText, (offset) => scanQuotedText || isCommand[offset]!);
|
|
337
|
+
for (const { raw, at } of found) {
|
|
338
|
+
const expanded = expand(raw, at);
|
|
339
|
+
const target =
|
|
340
|
+
expanded.unresolved === undefined
|
|
341
|
+
? { path: expanded.text }
|
|
342
|
+
: { path: raw.replace(/^["']+|["']+$/g, ""), unresolved: expanded.unresolved };
|
|
343
|
+
if (target.path) targets.push(target);
|
|
304
344
|
}
|
|
305
345
|
for (const match of commandText.matchAll(new RegExp(NESTED_SHELL_PATTERN))) {
|
|
306
346
|
if (!isCommand[match.index]) continue;
|
|
@@ -310,7 +350,23 @@ function commandTargets(
|
|
|
310
350
|
...commandTargets(script, doubleQuoted ? (raw) => expand(raw, quoteAt) : undefined),
|
|
311
351
|
);
|
|
312
352
|
}
|
|
313
|
-
|
|
353
|
+
const shellLines = new Set(
|
|
354
|
+
shellWords.map((at) => commandText.slice(0, at).split("\n").length - 1),
|
|
355
|
+
);
|
|
356
|
+
for (const body of heredocBodies(command).filter((body) => shellLines.has(body.line))) {
|
|
357
|
+
targets.push(...commandTargets(body.text));
|
|
358
|
+
}
|
|
359
|
+
return uniqueTargets(targets);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function uniqueTargets(targets: CommandTarget[]): CommandTarget[] {
|
|
363
|
+
const seen = new Set<string>();
|
|
364
|
+
return targets.filter(({ path, unresolved }) => {
|
|
365
|
+
const key = `${path}\0${unresolved ?? ""}`;
|
|
366
|
+
if (seen.has(key)) return false;
|
|
367
|
+
seen.add(key);
|
|
368
|
+
return true;
|
|
369
|
+
});
|
|
314
370
|
}
|
|
315
371
|
|
|
316
372
|
const stringOrEmpty = (value: unknown) => (typeof value === "string" ? value : "");
|
|
@@ -139,7 +139,7 @@ export function describeFailure(failure: ChainFailure, defaultBranch: string): s
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/** `value` as one POSIX shell word: names come from teammates' specs. */
|
|
142
|
-
function shellQuote(value: string): string {
|
|
142
|
+
export function shellQuote(value: string): string {
|
|
143
143
|
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
describeFailure,
|
|
22
22
|
failureRemedy,
|
|
23
23
|
isChainFailure,
|
|
24
|
+
shellQuote,
|
|
24
25
|
type AppliedChain,
|
|
25
26
|
type ChainFailure,
|
|
26
27
|
} from "./apply-chain";
|
|
@@ -357,7 +358,7 @@ async function project(
|
|
|
357
358
|
}
|
|
358
359
|
for (const dependency of run.missing.filter((missing) => archived.has(missing))) {
|
|
359
360
|
reasons.push(
|
|
360
|
-
`${name} depends on ${inboxText(dependency)}, which is archived in this checkout but not published; run \`${FRAMEWORK_NAME} artifact publish
|
|
361
|
+
`${name} depends on ${inboxText(dependency)}, which is archived in this checkout but not published; run \`${FRAMEWORK_NAME} artifact publish ${shellQuote(inboxText(dependency))}\` to make it count.`,
|
|
361
362
|
);
|
|
362
363
|
}
|
|
363
364
|
return failed(name, "error", `mate: ${reasons.join(" ")}`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
+
import { isDirectory } from "../../runtime/git-layout";
|
|
4
5
|
import { otherServingClaudeWrapRoot } from "../../runtime/serving-claude-wrap";
|
|
5
6
|
import {
|
|
6
7
|
carriesClaudeLinks,
|
|
@@ -40,15 +41,25 @@ async function servedByMainWorktree(
|
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
export interface SkillLinkOptions {
|
|
45
|
+
keepExistingFolder?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Places none, and withdraws earlier ones, where the main worktree serves them,
|
|
50
|
+
* unless `keepExistingFolder` keeps an existing folder.
|
|
51
|
+
*/
|
|
44
52
|
export async function reconcileWorkingRepoClaudeSkillLinks(
|
|
45
53
|
repoPath: string,
|
|
46
54
|
companionPath: string | null,
|
|
47
55
|
enabled: boolean,
|
|
48
56
|
registeredCompanionPaths: string[] = [],
|
|
57
|
+
options: SkillLinkOptions = {},
|
|
49
58
|
): ReturnType<typeof reconcileClaudeLinks> {
|
|
50
59
|
const placed =
|
|
51
|
-
enabled &&
|
|
60
|
+
enabled &&
|
|
61
|
+
((options.keepExistingFolder && isDirectory(path.join(repoPath, ".claude", SKILLS.dir))) ||
|
|
62
|
+
!(await servedByMainWorktree(repoPath, companionPath, registeredCompanionPaths)));
|
|
52
63
|
return reconcileClaudeLinks(SKILLS, repoPath, companionPath, placed, registeredCompanionPaths);
|
|
53
64
|
}
|
|
54
65
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// oxlint-disable no-await-in-loop -- one
|
|
1
|
+
// oxlint-disable no-await-in-loop -- one Checkout at a time, the main worktree first
|
|
2
|
+
import { checkoutCommonDir, liveCheckouts, realPath } from "../../runtime/git-layout";
|
|
3
|
+
import { resolveProjection } from "../../runtime/projection";
|
|
2
4
|
import { readWrapState } from "../../runtime/wrap-state";
|
|
3
5
|
import { GlobalConfigStore } from "./global-config-store";
|
|
4
6
|
import { reconcileWorkingRepoClaudeCommandLinks } from "./projection-claude-commands";
|
|
@@ -38,10 +40,21 @@ const linkRefreshDeps: LinkRefreshDeps = {
|
|
|
38
40
|
reconcileCommandLinks: reconcileWorkingRepoClaudeCommandLinks,
|
|
39
41
|
};
|
|
40
42
|
|
|
43
|
+
function checkoutsOf(repository: LinkedRepository): string[] {
|
|
44
|
+
const commonDir = repository.gitCommonDir ?? checkoutCommonDir(repository.path);
|
|
45
|
+
const checkouts = commonDir ? [...liveCheckouts(commonDir)] : [];
|
|
46
|
+
return checkouts.length > 0 ? checkouts : [repository.path];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function servedByOtherCompanion(checkout: string, companionPath: string): boolean {
|
|
50
|
+
const served = resolveProjection(checkout)?.companionPath;
|
|
51
|
+
return served !== undefined && realPath(served) !== realPath(companionPath);
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
/**
|
|
42
|
-
* Re-links the companion's Claude skills and commands into every
|
|
43
|
-
* Working Repository. Links only; runtime documents
|
|
44
|
-
* are reported per
|
|
55
|
+
* Re-links the companion's Claude skills and commands into every Claude-wrapped
|
|
56
|
+
* Checkout of each linked Working Repository's clone. Links only; runtime documents
|
|
57
|
+
* wait for the wrap pass. Failures are reported per Checkout, never thrown.
|
|
45
58
|
*/
|
|
46
59
|
export async function refreshWorkingClaudeLinks(
|
|
47
60
|
companionPath: string,
|
|
@@ -50,6 +63,7 @@ export async function refreshWorkingClaudeLinks(
|
|
|
50
63
|
): Promise<LinkRefreshResult[]> {
|
|
51
64
|
const enabled = config.allowedAgents?.includes("claude") ?? false;
|
|
52
65
|
const results: LinkRefreshResult[] = [];
|
|
66
|
+
const seen = new Set<string>();
|
|
53
67
|
let registered: string[] | undefined;
|
|
54
68
|
let repositories: LinkedRepository[];
|
|
55
69
|
try {
|
|
@@ -58,32 +72,36 @@ export async function refreshWorkingClaudeLinks(
|
|
|
58
72
|
return [{ repository: null, outcome: "failed", error: errorMessage(error) }];
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
for (const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
for (const entry of repositories) {
|
|
76
|
+
for (const checkout of checkoutsOf(entry)) {
|
|
77
|
+
const key = realPath(checkout);
|
|
78
|
+
if (seen.has(key)) continue;
|
|
79
|
+
seen.add(key);
|
|
80
|
+
const repository = { ...entry, path: checkout };
|
|
81
|
+
try {
|
|
82
|
+
if (servedByOtherCompanion(checkout, companionPath)) continue;
|
|
83
|
+
if (!(await deps.isWrappedForClaude(checkout))) continue;
|
|
84
|
+
registered ??= await deps.registeredCompanionPaths();
|
|
85
|
+
const skills = await deps.reconcileSkillLinks(
|
|
86
|
+
checkout,
|
|
87
|
+
companionPath,
|
|
88
|
+
enabled,
|
|
89
|
+
registered,
|
|
90
|
+
{ keepExistingFolder: true },
|
|
91
|
+
);
|
|
92
|
+
const commands = await deps.reconcileCommandLinks(
|
|
93
|
+
checkout,
|
|
94
|
+
companionPath,
|
|
95
|
+
enabled,
|
|
96
|
+
registered,
|
|
97
|
+
);
|
|
98
|
+
const written = [skills, commands].some(
|
|
99
|
+
(result) => (typeof result === "string" ? result : result.state) === "written",
|
|
100
|
+
);
|
|
101
|
+
results.push({ repository, outcome: written ? "written" : "current" });
|
|
102
|
+
} catch (error) {
|
|
103
|
+
results.push({ repository, outcome: "failed", error: errorMessage(error) });
|
|
104
|
+
}
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
return results;
|
|
@@ -375,8 +375,9 @@ export interface ForkRefusalOptions extends ForkGuardOptions {
|
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
/**
|
|
378
|
-
* The verdict both runtimes' artifact guards share
|
|
379
|
-
*
|
|
378
|
+
* The verdict both runtimes' artifact guards share. Only the fork state is
|
|
379
|
+
* cached per interval; once the companion has forked, the ignore check runs Git
|
|
380
|
+
* per target, uncached. `null` means "no refusal" — including
|
|
380
381
|
* every case in which the check could not be completed, because the guard must
|
|
381
382
|
* never fail closed.
|
|
382
383
|
*/
|
|
@@ -3,11 +3,11 @@ export const HEREDOC_MARKER = /^<<-?\s*(['"]?)([\w.-]+)\1/;
|
|
|
3
3
|
/**
|
|
4
4
|
* Per offset, whether the shell runs it as command text: outside quotes,
|
|
5
5
|
* comments and `$((…))`, or in a `$(…)` or backtick substitution, also one
|
|
6
|
-
* inside double quotes.
|
|
6
|
+
* inside double quotes. `spans` is the quote state at the start, updated in
|
|
7
|
+
* place to the state at the end.
|
|
7
8
|
*/
|
|
8
|
-
export function commandTextMask(text: string): boolean[] {
|
|
9
|
+
export function commandTextMask(text: string, spans: string[] = []): boolean[] {
|
|
9
10
|
const mask = Array.from({ length: text.length }, () => false);
|
|
10
|
-
const spans: string[] = [];
|
|
11
11
|
for (let i = 0; i < text.length; i++) {
|
|
12
12
|
const span = spans.at(-1);
|
|
13
13
|
const char = text[i];
|
|
@@ -57,9 +57,9 @@ export function commandTextMask(text: string): boolean[] {
|
|
|
57
57
|
return mask;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function heredocTerminators(line: string): string[] {
|
|
60
|
+
function heredocTerminators(line: string, spans: string[]): string[] {
|
|
61
61
|
const terminators: string[] = [];
|
|
62
|
-
const isCommand = commandTextMask(line);
|
|
62
|
+
const isCommand = commandTextMask(line, spans);
|
|
63
63
|
for (let i = 0; i < line.length; i++) {
|
|
64
64
|
if (!isCommand[i] || line[i] !== "<" || line[i + 1] !== "<") continue;
|
|
65
65
|
if (line[i + 2] === "<") {
|
|
@@ -88,6 +88,7 @@ function splitHeredocs(command: string): { kept: string[]; bodies: HeredocBody[]
|
|
|
88
88
|
const kept: string[] = [];
|
|
89
89
|
const bodies: HeredocBody[] = [];
|
|
90
90
|
const pending: string[] = [];
|
|
91
|
+
const spans: string[] = [];
|
|
91
92
|
let body: string[] = [];
|
|
92
93
|
for (const line of command.split("\n")) {
|
|
93
94
|
if (pending.length > 0) {
|
|
@@ -101,7 +102,7 @@ function splitHeredocs(command: string): { kept: string[]; bodies: HeredocBody[]
|
|
|
101
102
|
continue;
|
|
102
103
|
}
|
|
103
104
|
kept.push(line);
|
|
104
|
-
pending.push(...heredocTerminators(line));
|
|
105
|
+
pending.push(...heredocTerminators(line, spans));
|
|
105
106
|
}
|
|
106
107
|
if (pending.length > 0) bodies.push({ line: kept.length - 1, text: body.join("\n") });
|
|
107
108
|
return { kept, bodies };
|
|
@@ -70,6 +70,8 @@ artifacts:
|
|
|
70
70
|
|
|
71
71
|
Common pitfall: Using MODIFIED with partial content loses detail at archive time. If adding new concerns without changing existing behavior, use ADDED instead.
|
|
72
72
|
|
|
73
|
+
To retire a scenario whose rule the change reverses, REMOVE the requirement (with **Reason** and **Migration**) and ADD its replacement under a new name: a MODIFIED block cannot drop a scenario.
|
|
74
|
+
|
|
73
75
|
Specs should be testable - each scenario is a potential test case.
|
|
74
76
|
|
|
75
77
|
**Obsidian**: Start each spec file with the template's `<!-- mate:delta` comment as its very first line, not YAML frontmatter, with actual values. Each `scopes` entry MUST preserve its repository/Area pairing.
|
|
@@ -31,6 +31,9 @@ artifacts:
|
|
|
31
31
|
`#### Scenario: <name>` heading over its Given/When/Then bullets, and give each new
|
|
32
32
|
criterion its own `#### Scenario:` heading. Archive refuses a story that drops a
|
|
33
33
|
scenario name, for example by folding scenarios into one Acceptance Criteria block.
|
|
34
|
+
- To retire a scenario whose rule the change reverses, REMOVE the requirement (with
|
|
35
|
+
**Reason** and **Migration**) and ADD its replacement under a new name: a MODIFIED
|
|
36
|
+
story cannot drop a scenario.
|
|
34
37
|
|
|
35
38
|
Every user story carries an **Area:** marker naming the Areas it binds, using values from
|
|
36
39
|
the `scopes` in the spec's `mate:delta` comment - always, even when there is only one Area.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
|
|
3
|
-
import { FRAMEWORK_NAME } from "../../../framework";
|
|
4
3
|
import type { PluginDeclaration } from "../../../lib/orchestrator/types";
|
|
5
4
|
import {
|
|
6
5
|
pluginInstallCommand,
|
|
@@ -75,7 +74,7 @@ export async function inspectDeclaredPlugins(
|
|
|
75
74
|
const install =
|
|
76
75
|
origin.kind === "local"
|
|
77
76
|
? pluginInstallCommand(origin)
|
|
78
|
-
: `${
|
|
77
|
+
: `${pluginInstallCommand(origin)} --yes --frozen-plugins`;
|
|
79
78
|
failures.push({
|
|
80
79
|
package: name,
|
|
81
80
|
reason: `not installed; run setup (\`${install}\`) to install it`,
|