specdojo 0.9.0 → 0.9.1
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 +13 -0
- package/dist/commands/orchestrator.js +5 -77
- package/dist/dashboard/shared.js +2 -2
- package/dist/deliverable/trash.js +2 -1
- package/dist/exec/opencode-permissions.js +117 -0
- package/dist/exec/register-foreign-wait.js +1 -3
- package/dist/exec/repo-trace.js +2 -1
- package/dist/exec/run/agent.js +1 -1
- package/dist/exec/run/change-scope.js +2 -2
- package/dist/exec/run/in-place.js +1 -1
- package/dist/exec/shared.js +1 -1
- package/dist/exec/task-repos.js +19 -4
- package/dist/exec/worktree-command.js +3 -1
- package/dist/register/renumber.js +1 -3
- package/dist/shared/text.js +8 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +1 -1
- package/docs/ja/specdojo/references/specdojo-config-reference.md +11 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ SpecDojo の利用者に影響する変更を記録します。
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.9.1] - 2026-11-20
|
|
8
|
+
|
|
9
|
+
同梱パッケージ(`@specdojo/docs-lint` 0.5.0、`@specdojo/docs-site` 0.6.0)は変わらないため、公開しません。
|
|
10
|
+
|
|
11
|
+
### 利用者から見て動きが変わる点
|
|
12
|
+
|
|
13
|
+
- `repos` を宣言した project で opencode の agent を exec から起動するとき、`exec-defaults.yaml` の opencode の `command_template` に `--agent <name>` が必要になりました。許可を渡す agent を決めるためで、無い場合は起動の前に止まります。`specdojo init` が作る雛形には入っています(PJR-08EK)。
|
|
14
|
+
|
|
15
|
+
### 不具合修正
|
|
16
|
+
|
|
17
|
+
- `repos` を宣言した project で、exec の opencode の executor がプロダクトリポジトリの worktree を編集できなかった問題を修正しました。runner は起動時の `OPENCODE_CONFIG_CONTENT` で、その run のプロダクトの worktree だけに `external_directory` と `edit` の許可を渡します。agent の定義や `opencode.json` を書き換える必要はありません。`orchestrator launch` の `edit` の許可も、起動場所からの相対パスにそろえました(PJR-08EK)。
|
|
18
|
+
- CodeQL が指摘した 5 か所を直しました。`deliverable trash` は、記号を含む `local_id` でも別の成果物の `path:` を書き換えません。exec の変更範囲の推定は、長い個票の本文でも遅くなりません。プロダクトリポジトリの統合の記録と dashboard の表は、`\` で終わるセルでも列がずれません(PJR-A77M)。
|
|
19
|
+
|
|
7
20
|
## [0.9.0] - 2026-11-20
|
|
8
21
|
|
|
9
22
|
同梱パッケージは `@specdojo/docs-lint` 0.5.0 と `@specdojo/docs-site` 0.6.0 を同時に公開します。動作に必要な Node.js は 22.17 以上です。
|
|
@@ -3,6 +3,7 @@ import { constants as osConstants } from "node:os";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { agentExtraRootArguments, resolveProductRepos } from "../exec/task-repos.js";
|
|
5
5
|
import { antigravitySessionArguments } from "../exec/antigravity-session.js";
|
|
6
|
+
import { OPENCODE_CONFIG_CONTENT_ENV, opencodeAgentNameFromArguments, opencodeExtraRootConfig, } from "../exec/opencode-permissions.js";
|
|
6
7
|
import { loadConfig, resolveExternalProjects, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
7
8
|
import { registerNightOrchestratorCommand } from "./night-orchestrator.js";
|
|
8
9
|
const ORCHESTRATOR_EXECUTABLES = {
|
|
@@ -13,9 +14,6 @@ const ORCHESTRATOR_EXECUTABLES = {
|
|
|
13
14
|
opencode: "opencode",
|
|
14
15
|
};
|
|
15
16
|
const ORCHESTRATOR_CONFIG_ROOT_ENV = "SPECDOJO_ORCHESTRATOR_CONFIG_ROOT";
|
|
16
|
-
function isRecord(value) {
|
|
17
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
-
}
|
|
19
17
|
function resolveOrchestratorProjectId(config, projectOption, env) {
|
|
20
18
|
const projectId = projectOption?.trim() ||
|
|
21
19
|
env.SPECDOJO_PROJECT?.trim() ||
|
|
@@ -30,81 +28,11 @@ function resolveOrchestratorProjectId(config, projectOption, env) {
|
|
|
30
28
|
return projectId;
|
|
31
29
|
}
|
|
32
30
|
function opencodeAgentName(args) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const arg = args[index];
|
|
36
|
-
if (arg === "--agent") {
|
|
37
|
-
selected = args[index + 1];
|
|
38
|
-
index += 1;
|
|
39
|
-
}
|
|
40
|
-
else if (arg.startsWith("--agent=")) {
|
|
41
|
-
selected = arg.slice("--agent=".length);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!selected?.trim()) {
|
|
31
|
+
const selected = opencodeAgentNameFromArguments(args);
|
|
32
|
+
if (!selected) {
|
|
45
33
|
throw new Error("OpenCode orchestrator launch requires --agent <name> so repository permissions can be scoped to that agent.");
|
|
46
34
|
}
|
|
47
|
-
return selected
|
|
48
|
-
}
|
|
49
|
-
function inlineOpenCodeConfig(current, agentName, repoRoots) {
|
|
50
|
-
let config = {};
|
|
51
|
-
if (current?.trim()) {
|
|
52
|
-
let parsed;
|
|
53
|
-
try {
|
|
54
|
-
parsed = JSON.parse(current);
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
-
throw new Error(`Invalid OPENCODE_CONFIG_CONTENT: ${message}`);
|
|
59
|
-
}
|
|
60
|
-
if (!isRecord(parsed)) {
|
|
61
|
-
throw new Error("Invalid OPENCODE_CONFIG_CONTENT: top-level value must be an object");
|
|
62
|
-
}
|
|
63
|
-
config = parsed;
|
|
64
|
-
}
|
|
65
|
-
const agents = config.agent === undefined ? {} : config.agent;
|
|
66
|
-
if (!isRecord(agents)) {
|
|
67
|
-
throw new Error("Invalid OPENCODE_CONFIG_CONTENT: agent must be an object");
|
|
68
|
-
}
|
|
69
|
-
const selectedAgent = agents[agentName] === undefined ? {} : agents[agentName];
|
|
70
|
-
if (!isRecord(selectedAgent)) {
|
|
71
|
-
throw new Error(`Invalid OPENCODE_CONFIG_CONTENT: agent.${agentName} must be an object`);
|
|
72
|
-
}
|
|
73
|
-
const permission = selectedAgent.permission === undefined ? {} : selectedAgent.permission;
|
|
74
|
-
if (!isRecord(permission)) {
|
|
75
|
-
throw new Error(`Invalid OPENCODE_CONFIG_CONTENT: agent.${agentName}.permission must be an object`);
|
|
76
|
-
}
|
|
77
|
-
const externalDirectory = { "*": "deny" };
|
|
78
|
-
const currentEdit = permission.edit;
|
|
79
|
-
let edit = {};
|
|
80
|
-
if (isRecord(currentEdit)) {
|
|
81
|
-
edit = { ...currentEdit };
|
|
82
|
-
}
|
|
83
|
-
else if (typeof currentEdit === "string") {
|
|
84
|
-
edit = { "*": currentEdit };
|
|
85
|
-
}
|
|
86
|
-
else if (currentEdit !== undefined) {
|
|
87
|
-
throw new Error(`Invalid OPENCODE_CONFIG_CONTENT: agent.${agentName}.permission.edit must be a string or object`);
|
|
88
|
-
}
|
|
89
|
-
for (const repoRoot of repoRoots) {
|
|
90
|
-
const pattern = `${resolve(repoRoot).replaceAll("\\", "/")}/**`;
|
|
91
|
-
externalDirectory[pattern] = "allow";
|
|
92
|
-
edit[pattern] = "allow";
|
|
93
|
-
}
|
|
94
|
-
return JSON.stringify({
|
|
95
|
-
...config,
|
|
96
|
-
agent: {
|
|
97
|
-
...agents,
|
|
98
|
-
[agentName]: {
|
|
99
|
-
...selectedAgent,
|
|
100
|
-
permission: {
|
|
101
|
-
...permission,
|
|
102
|
-
external_directory: externalDirectory,
|
|
103
|
-
edit,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
});
|
|
35
|
+
return selected;
|
|
108
36
|
}
|
|
109
37
|
export function buildOrchestratorLaunch(options) {
|
|
110
38
|
const env = { ...(options.env ?? process.env) };
|
|
@@ -118,7 +46,7 @@ export function buildOrchestratorLaunch(options) {
|
|
|
118
46
|
}));
|
|
119
47
|
}
|
|
120
48
|
else if (options.provider === "opencode" && options.repoRoots.length > 0) {
|
|
121
|
-
env
|
|
49
|
+
env[OPENCODE_CONFIG_CONTENT_ENV] = opencodeExtraRootConfig(env[OPENCODE_CONFIG_CONTENT_ENV], opencodeAgentName(args), options.repoRoots, options.cwd);
|
|
122
50
|
}
|
|
123
51
|
else {
|
|
124
52
|
args.push(...agentExtraRootArguments(options.provider, options.repoRoots));
|
package/dist/dashboard/shared.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stripTerminalControlSequences } from "../shared/text.js";
|
|
1
|
+
import { escapeMarkdownTableCell, stripTerminalControlSequences } from "../shared/text.js";
|
|
2
2
|
const MAX_DASHBOARD_CELL_LENGTH = 200;
|
|
3
3
|
// dashboard の表へは event や subprocess 由来の文字列も入る。表へ埋める直前に
|
|
4
4
|
// ターミナル制御シーケンスと改行類を除き、列区切りをエスケープして長さを制限する。
|
|
@@ -10,5 +10,5 @@ export function sanitizeDashboardCell(text) {
|
|
|
10
10
|
const truncated = singleLine.length <= MAX_DASHBOARD_CELL_LENGTH
|
|
11
11
|
? singleLine
|
|
12
12
|
: `${singleLine.slice(0, MAX_DASHBOARD_CELL_LENGTH)}…`;
|
|
13
|
-
return truncated
|
|
13
|
+
return escapeMarkdownTableCell(truncated);
|
|
14
14
|
}
|
|
@@ -15,6 +15,7 @@ import { isDctCatalogFileName } from "../catalog/types.js";
|
|
|
15
15
|
import { resolveBasePath, resolveDeliverablePath } from "../catalog/paths.js";
|
|
16
16
|
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
17
17
|
import { gitOutput } from "../shared/git.js";
|
|
18
|
+
import { escapeRegExp } from "../shared/text.js";
|
|
18
19
|
function findCatalogFiles(catalogDir) {
|
|
19
20
|
return readdirSync(catalogDir).filter(isDctCatalogFileName).sort();
|
|
20
21
|
}
|
|
@@ -68,7 +69,7 @@ function resolveTrashDestination(oldDocPath, projectId) {
|
|
|
68
69
|
// re-serializing the whole document (which would drop comments/formatting).
|
|
69
70
|
function rewriteCatalogPath(rawYaml, localId, newDocPath) {
|
|
70
71
|
const lines = rawYaml.split("\n");
|
|
71
|
-
const startRe = new RegExp(`^(\\s*)- local_id:\\s*${localId}\\s*$`);
|
|
72
|
+
const startRe = new RegExp(`^(\\s*)- local_id:\\s*${escapeRegExp(localId)}\\s*$`);
|
|
72
73
|
let itemIndent = null;
|
|
73
74
|
let startIndex = -1;
|
|
74
75
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { relative, resolve } from "node:path";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime permission injection that lets an OpenCode agent edit declared extra roots (product
|
|
4
|
+
* worktrees, external projects). OpenCode merges `OPENCODE_CONFIG_CONTENT` after the
|
|
5
|
+
* `.opencode/agents/<name>.md` definitions, so the override survives the agent frontmatter, while
|
|
6
|
+
* `opencode.json` `agent.<name>.permission` would be overwritten by it.
|
|
7
|
+
*
|
|
8
|
+
* OpenCode matches the two permissions in different forms: `external_directory` by the absolute
|
|
9
|
+
* directory path and `edit` by the path relative to its working directory. The injected patterns
|
|
10
|
+
* follow those forms, and only the given roots are allowed; other external directories stay denied.
|
|
11
|
+
*/
|
|
12
|
+
export const OPENCODE_CONFIG_CONTENT_ENV = "OPENCODE_CONFIG_CONTENT";
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function toPosix(path) {
|
|
17
|
+
return path.replaceAll("\\", "/");
|
|
18
|
+
}
|
|
19
|
+
/** `external_directory` pattern: the absolute root path. */
|
|
20
|
+
export function opencodeExternalDirectoryPattern(root) {
|
|
21
|
+
return `${toPosix(resolve(root))}/**`;
|
|
22
|
+
}
|
|
23
|
+
/** `edit` pattern: the root relative to OpenCode's working directory (e.g. `../app1/**`). */
|
|
24
|
+
export function opencodeEditPattern(root, cwd) {
|
|
25
|
+
const relativePath = toPosix(relative(resolve(cwd), resolve(root)));
|
|
26
|
+
return relativePath ? `${relativePath}/**` : "**";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Merge the extra-root permissions for `agentName` into the current `OPENCODE_CONFIG_CONTENT`.
|
|
30
|
+
* Other keys and agents are preserved. Throws when the current value is not a valid config object.
|
|
31
|
+
*/
|
|
32
|
+
export function opencodeExtraRootConfig(current, agentName, roots, cwd) {
|
|
33
|
+
let config = {};
|
|
34
|
+
if (current?.trim()) {
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = JSON.parse(current);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: ${message}`, { cause: error });
|
|
42
|
+
}
|
|
43
|
+
if (!isRecord(parsed)) {
|
|
44
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: top-level value must be an object`);
|
|
45
|
+
}
|
|
46
|
+
config = parsed;
|
|
47
|
+
}
|
|
48
|
+
const agents = config.agent === undefined ? {} : config.agent;
|
|
49
|
+
if (!isRecord(agents)) {
|
|
50
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: agent must be an object`);
|
|
51
|
+
}
|
|
52
|
+
const selectedAgent = agents[agentName] === undefined ? {} : agents[agentName];
|
|
53
|
+
if (!isRecord(selectedAgent)) {
|
|
54
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: agent.${agentName} must be an object`);
|
|
55
|
+
}
|
|
56
|
+
const permission = selectedAgent.permission === undefined ? {} : selectedAgent.permission;
|
|
57
|
+
if (!isRecord(permission)) {
|
|
58
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: agent.${agentName}.permission must be an object`);
|
|
59
|
+
}
|
|
60
|
+
const externalDirectory = { "*": "deny" };
|
|
61
|
+
const currentEdit = permission.edit;
|
|
62
|
+
let edit = {};
|
|
63
|
+
if (isRecord(currentEdit)) {
|
|
64
|
+
edit = { ...currentEdit };
|
|
65
|
+
}
|
|
66
|
+
else if (typeof currentEdit === "string") {
|
|
67
|
+
edit = { "*": currentEdit };
|
|
68
|
+
}
|
|
69
|
+
else if (currentEdit !== undefined) {
|
|
70
|
+
throw new Error(`Invalid ${OPENCODE_CONFIG_CONTENT_ENV}: agent.${agentName}.permission.edit must be a string or object`);
|
|
71
|
+
}
|
|
72
|
+
for (const root of roots) {
|
|
73
|
+
externalDirectory[opencodeExternalDirectoryPattern(root)] = "allow";
|
|
74
|
+
edit[opencodeEditPattern(root, cwd)] = "allow";
|
|
75
|
+
}
|
|
76
|
+
return JSON.stringify({
|
|
77
|
+
...config,
|
|
78
|
+
agent: {
|
|
79
|
+
...agents,
|
|
80
|
+
[agentName]: {
|
|
81
|
+
...selectedAgent,
|
|
82
|
+
permission: {
|
|
83
|
+
...permission,
|
|
84
|
+
external_directory: externalDirectory,
|
|
85
|
+
edit,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Agent name from `--agent <name>` / `--agent=<name>` arguments (the last one wins). */
|
|
92
|
+
export function opencodeAgentNameFromArguments(args) {
|
|
93
|
+
let selected;
|
|
94
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
95
|
+
const arg = args[index];
|
|
96
|
+
if (arg === "--agent") {
|
|
97
|
+
selected = args[index + 1];
|
|
98
|
+
index += 1;
|
|
99
|
+
}
|
|
100
|
+
else if (arg.startsWith("--agent=")) {
|
|
101
|
+
selected = arg.slice("--agent=".length);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const trimmed = selected?.trim();
|
|
105
|
+
return trimmed ? trimmed : undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Agent name in a resolved shell command such as `opencode run --agent opencode-executor ...`.
|
|
109
|
+
* Single or double quotes around the name are accepted; anything else is split on whitespace.
|
|
110
|
+
*/
|
|
111
|
+
export function opencodeAgentNameFromCommand(command) {
|
|
112
|
+
const words = command
|
|
113
|
+
.trim()
|
|
114
|
+
.split(/\s+/)
|
|
115
|
+
.map((word) => word.replace(/^(['"])(.*)\1$/, "$2"));
|
|
116
|
+
return opencodeAgentNameFromArguments(words);
|
|
117
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { stagedMergeBlocker } from "../shared/git.js";
|
|
2
|
+
import { escapeRegExp } from "../shared/text.js";
|
|
2
3
|
import { acquireSchedulerLock, releaseSchedulerLock } from "./events.js";
|
|
3
4
|
import { currentBranch } from "./worktree-ops-commit.js";
|
|
4
5
|
import { abortMerge } from "./worktree-ops-merge.js";
|
|
@@ -12,9 +13,6 @@ import { gitOutput, gitResult, summarizeGitHookFailure } from "./worktree.js";
|
|
|
12
13
|
// 後で job の branch を本体へ統合しても、同じ commit を共有して衝突しない。
|
|
13
14
|
const LOCK_TIMEOUT_MS = 10_000;
|
|
14
15
|
const LOCK_STALE_MS = 300_000;
|
|
15
|
-
function escapeRegExp(value) {
|
|
16
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17
|
-
}
|
|
18
16
|
// exec branch の first-parent 履歴から最新の wait 後の同期 merge を探し、その統合先の commit が
|
|
19
17
|
// 本体の HEAD に含まれていなければ返す。同期 merge が無い、または含まれている場合は null。
|
|
20
18
|
export function findForeignWaitRecords(params) {
|
package/dist/exec/repo-trace.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { productMergeState } from "./repo-integration.js";
|
|
3
|
+
import { escapeMarkdownTableCell } from "../shared/text.js";
|
|
3
4
|
import { productIntegrationTarget } from "./task-repos.js";
|
|
4
5
|
import { gitOutput, gitResult } from "./worktree.js";
|
|
5
6
|
// PJR-30SW: プロダクト側の commit と merge commit へ付ける `Refs:` trailer と、統合後に result へ
|
|
@@ -96,7 +97,7 @@ function traceRows(key, traces, recordedAt) {
|
|
|
96
97
|
]);
|
|
97
98
|
}
|
|
98
99
|
function renderTable(header, rows) {
|
|
99
|
-
const escape = (cell) => cell
|
|
100
|
+
const escape = (cell) => escapeMarkdownTableCell(cell);
|
|
100
101
|
const all = [header.map(escape), ...rows.map((row) => row.map(escape))];
|
|
101
102
|
const widths = header.map((cell, column) => Math.max(3, cell.length, ...all.map((row) => (row[column] ?? "").length)));
|
|
102
103
|
const line = (cells) => `| ${cells.map((cell, column) => cell.padEnd(widths[column] ?? 0)).join(" | ")} |`;
|
package/dist/exec/run/agent.js
CHANGED
|
@@ -425,7 +425,7 @@ export async function runWithRetry(candidates, prompt, execDefaults, cwd, env, r
|
|
|
425
425
|
lastActor = candidate.actor;
|
|
426
426
|
const protectedConfigBefore = captureAgentProtectedConfigAcrossRepos(agentRepos);
|
|
427
427
|
const gitStateBefore = captureAgentGitStateAcrossRepos(agentRepos);
|
|
428
|
-
const attempt = await executeAgent(withAgentExtraRoots(candidate.command, candidate.provider, productRoots.map((root) => root.path)), prompt, detection, candidate.provider, candidatePolicy?.cooldown_seconds, cwd, env, false, stageRole);
|
|
428
|
+
const attempt = await executeAgent(withAgentExtraRoots(candidate.command, candidate.provider, productRoots.map((root) => root.path), { cwd, env }), prompt, detection, candidate.provider, candidatePolicy?.cooldown_seconds, cwd, env, false, stageRole);
|
|
429
429
|
const protectedConfigChanges = changedAgentProtectedConfigAcrossRepos(protectedConfigBefore);
|
|
430
430
|
if (protectedConfigChanges.length > 0) {
|
|
431
431
|
// 利用上限で止まった場合も保護の検査は飛ばさない。止まった理由として利用上限を先に記録する。
|
|
@@ -186,11 +186,11 @@ export function inferChangeScope(params) {
|
|
|
186
186
|
};
|
|
187
187
|
for (const match of body.matchAll(/`([^`\n]+)`/g)) {
|
|
188
188
|
const value = match[1].replace(/#.*$|:\d+(?::\d+)?$/g, "");
|
|
189
|
-
if (/^(?:[\w-]+:)
|
|
189
|
+
if (/^(?:[\w-]+:)?\.?\/?[\w@.-]+\/[\w@.*?{}[\]/-]*$/.test(value) ||
|
|
190
190
|
/^[\w.-]+\.[a-z0-9]+$/i.test(value))
|
|
191
191
|
addTextPath(value);
|
|
192
192
|
}
|
|
193
|
-
for (const match of body.matchAll(/(?:^|[\s`((・])((?:[\w-]+:)?
|
|
193
|
+
for (const match of body.matchAll(/(?:^|[\s`((・])((?:[\w-]+:)?[\w@.-]+\/[\w@.*?{}[\]/-]+)/gm)) {
|
|
194
194
|
const value = match[1];
|
|
195
195
|
// A slash in prose can also mean alternatives (executor/reporter). Accept filenames,
|
|
196
196
|
// explicit directory/glob syntax, or an existing repository path rather than every slash.
|
|
@@ -111,7 +111,7 @@ export async function spawnAgentInPlace(command, prompt, cwd, schedulePath, exec
|
|
|
111
111
|
const protectedConfigBefore = captureAgentProtectedConfigSnapshot(cwd);
|
|
112
112
|
const gitStateBefore = captureAgentGitStateSnapshot(cwd);
|
|
113
113
|
const products = configuredProductCheckouts(schedulePath);
|
|
114
|
-
const child = spawn(withAgentExtraRoots(command, provider, products.map((product) => product.path)), {
|
|
114
|
+
const child = spawn(withAgentExtraRoots(command, provider, products.map((product) => product.path), { cwd }), {
|
|
115
115
|
cwd,
|
|
116
116
|
env: {
|
|
117
117
|
...withoutInheritedRepoEnvironment(gitEnvironment()),
|
package/dist/exec/shared.js
CHANGED
|
@@ -5,7 +5,7 @@ export { formatDateOnlyUtc, isUtcIsoSeconds, normalizeDateOnly, nowUtcIsoSeconds
|
|
|
5
5
|
export { randomHex } from "../shared/random.js";
|
|
6
6
|
export { isSchYamlFilename, toScheduleFilePath } from "../shared/schedule-paths.js";
|
|
7
7
|
export function tsForFilenameUtc(ts) {
|
|
8
|
-
return ts.replace(/[-:]/g, "")
|
|
8
|
+
return ts.replace(/[-:]/g, "");
|
|
9
9
|
}
|
|
10
10
|
// worktree/branch 生成専用。project 修飾した task ID(`<projectId>:<taskId>`)を返す。
|
|
11
11
|
// projectId が未解決(env path override 等)の場合は bare のままにして後方互換を保つ。
|
package/dist/exec/task-repos.js
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync, readdirSync, rmdirSync } from "node:fs";
|
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
4
|
import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
5
5
|
import { ensureExecWorktree, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./worktree.js";
|
|
6
|
+
import { OPENCODE_CONFIG_CONTENT_ENV, opencodeAgentNameFromCommand, opencodeExtraRootConfig, } from "./opencode-permissions.js";
|
|
6
7
|
import { assertProductBranchAvailable, existingProductTaskBranch, forgetProductBranch, productBranchExists, productBranchRecords, recordedProductBranch, reserveProductBranch, } from "./product-branch-records.js";
|
|
7
8
|
// PJR-98G4: 1 つのタスクがプロジェクトリポジトリと宣言済みのプロダクトリポジトリ(`repos`)を
|
|
8
9
|
// 変更する場合の worktree を扱う。`repos` を持たない project では、ここの関数はどれも空の結果を
|
|
@@ -555,8 +556,8 @@ function shellQuote(value) {
|
|
|
555
556
|
}
|
|
556
557
|
/**
|
|
557
558
|
* Provider arguments that add the product worktrees as extra roots with write access. The agent
|
|
558
|
-
* keeps the project worktree as cwd. Returns [] for providers without a launch flag. OpenCode
|
|
559
|
-
*
|
|
559
|
+
* keeps the project worktree as cwd. Returns [] for providers without a launch flag. OpenCode has
|
|
560
|
+
* no such flag; withAgentExtraRoots injects its permissions through `OPENCODE_CONFIG_CONTENT`.
|
|
560
561
|
*/
|
|
561
562
|
export function agentExtraRootArguments(provider, dirs) {
|
|
562
563
|
if (dirs.length === 0)
|
|
@@ -580,8 +581,22 @@ export function agentExtraRootArguments(provider, dirs) {
|
|
|
580
581
|
return [];
|
|
581
582
|
}
|
|
582
583
|
}
|
|
583
|
-
/**
|
|
584
|
-
|
|
584
|
+
/**
|
|
585
|
+
* Give the agent write access to the extra roots in a resolved shell command (unchanged when there
|
|
586
|
+
* are none). Most providers get launch arguments appended. OpenCode gets an
|
|
587
|
+
* `OPENCODE_CONFIG_CONTENT` assignment prefixed to the command, scoped to the `--agent` in the
|
|
588
|
+
* command and merged with the inherited value from `options.env`; `edit` patterns are relative
|
|
589
|
+
* to `options.cwd`, the agent's working directory.
|
|
590
|
+
*/
|
|
591
|
+
export function withAgentExtraRoots(command, provider, dirs, options = {}) {
|
|
592
|
+
if (provider === "opencode" && dirs.length > 0) {
|
|
593
|
+
const agentName = opencodeAgentNameFromCommand(command);
|
|
594
|
+
if (!agentName) {
|
|
595
|
+
throw new Error(`OpenCode command needs --agent <name> to scope the product worktree permissions: ${command}`);
|
|
596
|
+
}
|
|
597
|
+
const config = opencodeExtraRootConfig((options.env ?? process.env)[OPENCODE_CONFIG_CONTENT_ENV], agentName, dirs, options.cwd ?? process.cwd());
|
|
598
|
+
return `${OPENCODE_CONFIG_CONTENT_ENV}=${shellQuote(config)} ${command}`;
|
|
599
|
+
}
|
|
585
600
|
const args = agentExtraRootArguments(provider, dirs);
|
|
586
601
|
if (args.length === 0)
|
|
587
602
|
return command;
|
|
@@ -261,7 +261,9 @@ async function agent(opts) {
|
|
|
261
261
|
requireInsideWorktree(context.repoRoot, worktree);
|
|
262
262
|
const resolved = resolveAgent(context, opts.task, opts);
|
|
263
263
|
const productDirs = (worktree.repos ?? []).map((product) => product.path);
|
|
264
|
-
const command = withAgentExtraRoots(resolved.command, resolved.provider, productDirs
|
|
264
|
+
const command = withAgentExtraRoots(resolved.command, resolved.provider, productDirs, {
|
|
265
|
+
cwd: worktree.path,
|
|
266
|
+
});
|
|
265
267
|
if (opts.dryRun) {
|
|
266
268
|
process.stdout.write(`[dry-run] actor: ${resolved.actor}\n`);
|
|
267
269
|
process.stdout.write(`[dry-run] command: ${command}\n`);
|
|
@@ -6,14 +6,12 @@ import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "
|
|
|
6
6
|
import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
|
|
7
7
|
import { applyRegisterItemFields, PJR_ID_RE, readRegisterItemContent, readSpecdojoFields, registerItemFieldsFromItem, REMOVE_REGISTER_ITEM_FIELD, setRegisterItemDescription, setRegisterItemTitle, ticketRefCell, toDisplayItem, } from "./item.js";
|
|
8
8
|
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
9
|
+
import { escapeRegExp } from "../shared/text.js";
|
|
9
10
|
import { loadItemForUpdate } from "./update.js";
|
|
10
11
|
import { findRegisterItem, loadRegisterItems, writeDerivedViews } from "./views.js";
|
|
11
12
|
// ================================
|
|
12
13
|
// Renumber (duplicate ID recovery)
|
|
13
14
|
// ================================
|
|
14
|
-
function escapeRegExp(text) {
|
|
15
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16
|
-
}
|
|
17
15
|
// 個票ファイル名 `pjr-XXXX-<topic>.md` から topic を取り出す。
|
|
18
16
|
// ID 接頭辞(`pjr-xxxx-`)と一致しない場合は undefined。
|
|
19
17
|
export function ticketTopicFromFilename(id, filename) {
|
package/dist/shared/text.js
CHANGED
|
@@ -184,3 +184,11 @@ export const SENSITIVE_TEXT_RULES = [
|
|
|
184
184
|
export function redactSensitiveText(value) {
|
|
185
185
|
return SENSITIVE_TEXT_RULES.reduce((text, { pattern, replacement }) => text.replace(pattern, replacement), value);
|
|
186
186
|
}
|
|
187
|
+
// 正規表現のメタ文字をエスケープし、外から入る値をリテラルとして埋め込めるようにする。
|
|
188
|
+
export function escapeRegExp(value) {
|
|
189
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
190
|
+
}
|
|
191
|
+
// Markdown 表のセルへ入れる文字列をエスケープする。先に `\` を `\\` にしてから `|` を `\|` にする。
|
|
192
|
+
export function escapeMarkdownTableCell(cell) {
|
|
193
|
+
return cell.replace(/\\/g, "\\\\").replace(/\|/g, "\\|");
|
|
194
|
+
}
|
|
@@ -100,7 +100,7 @@ npx specdojo config scaffold --provider <name>
|
|
|
100
100
|
|
|
101
101
|
scaffold が追加する `orch:*` は `specdojo orchestrator launch` を経由します。起動時に対象 project の `repos` を解決し、宣言済みのプロダクトリポジトリ本体だけを provider の追加ルートとして許可します。`repos` が無い場合の provider コマンドは従来どおりです。npm script に追加引数を渡す場合は `npm run orch:<name> -- <引数>` とし、その引数は provider CLI へそのまま渡されます。
|
|
102
102
|
|
|
103
|
-
OpenCode は起動引数に追加ルートの指定を持たないため、選択した orchestrator agent の `permission.external_directory` を実行時の inline config で上書きします。全外部ディレクトリを拒否してから宣言済みルートだけを許可し、同じルートの `permission.edit`
|
|
103
|
+
OpenCode は起動引数に追加ルートの指定を持たないため、選択した orchestrator agent の `permission.external_directory` を実行時の inline config で上書きします。全外部ディレクトリを拒否してから宣言済みルートだけを許可し、同じルートの `permission.edit` も許可します。`edit` は起動場所からの相対パスで照合されるため、相対パスのパターンで渡します。設定ファイル自体は変更しません。
|
|
104
104
|
|
|
105
105
|
Antigravity CLI の無人実行に必要な permission rule は、利用者のすべてのリポジトリに効くグローバル設定です。通常の scaffold では変更されないため、明示的に dry-run で追加 rule を確認してから適用します。既存設定は保持され、実適用前にバックアップされます。
|
|
106
106
|
|
|
@@ -1298,7 +1298,7 @@ specdojo orchestrator launch --provider claude --project prj-0001 -- \
|
|
|
1298
1298
|
|
|
1299
1299
|
provider CLI の実行中、起動元は `SIGINT` と `SIGQUIT` を無視して子プロセスの終了を待ちます。端末での Ctrl-C は provider CLI に直接届くため、入力の取り消しとして扱う CLI が起動元だけを終了させることはありません。`SIGTERM` と `SIGHUP` は子プロセスへ転送し、子の終了後に同じ終了コードを返します。子がシグナルで終了した場合は `128 + シグナル番号` を返します。
|
|
1300
1300
|
|
|
1301
|
-
Claude Code、Codex、Antigravity、GitHub Copilot には exec と同じ追加ルート引数を渡します。OpenCode は、起動時の `OPENCODE_CONFIG_CONTENT` に選択 agent の `permission.external_directory` を注入し、全外部ディレクトリを拒否したうえで宣言済みのリポジトリだけを許可します。外部パスへ既存の `permission.edit`
|
|
1301
|
+
Claude Code、Codex、Antigravity、GitHub Copilot には exec と同じ追加ルート引数を渡します。OpenCode は、起動時の `OPENCODE_CONFIG_CONTENT` に選択 agent の `permission.external_directory` を注入し、全外部ディレクトリを拒否したうえで宣言済みのリポジトリだけを許可します。外部パスへ既存の `permission.edit` が一致しないため、同じ宣言済みルートの編集許可を起動場所からの相対パス(例: `../<repo>/**`)で注入します。既存の inline config の他項目は保持します。未宣言のリポジトリは、どの provider でも許可対象になりません。
|
|
1302
1302
|
|
|
1303
1303
|
`orchestrator night` は `autopilot: approved` の付いた `open` todo・issue だけを夜間 queue として実行します。
|
|
1304
1304
|
|
|
@@ -305,15 +305,17 @@ agent には、各 worktree の絶対パスを次の環境変数で渡します
|
|
|
305
305
|
|
|
306
306
|
agent の起動コマンドには、provider ごとにプロダクト worktree への書き込み許可を runner が付け足します。`exec-defaults.yaml` の `command_template` を変える必要はありません。
|
|
307
307
|
|
|
308
|
-
| provider | 付け足す引数 | 制約
|
|
309
|
-
| ------------- | ---------------------------------------------------------------- |
|
|
310
|
-
| `claude` | `--add-dir <path>...` と `--allowedTools 'Edit(//<path>/**)'...` | mode 別 settings の `Edit` 許可は作業ディレクトリ相対のため、絶対パスの許可を別に渡す
|
|
311
|
-
| `codex` | `--add-dir <path>`(リポジトリの数だけ) | `--sandbox workspace-write` の書き込みルートに加わる。`.git` は codex の仕様で読み取り専用のまま
|
|
312
|
-
| `antigravity` | `--add-dir <path>`(リポジトリの数だけ) | テンプレートの `--add-dir "$(pwd)"` に追加する
|
|
313
|
-
| `copilot` | `--add-dir <path>`(リポジトリの数だけ) | 書き込みはテンプレートの `--allow-tool write` に従う
|
|
314
|
-
| `opencode` |
|
|
315
|
-
|
|
316
|
-
|
|
308
|
+
| provider | 付け足す引数 | 制約 |
|
|
309
|
+
| ------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
310
|
+
| `claude` | `--add-dir <path>...` と `--allowedTools 'Edit(//<path>/**)'...` | mode 別 settings の `Edit` 許可は作業ディレクトリ相対のため、絶対パスの許可を別に渡す |
|
|
311
|
+
| `codex` | `--add-dir <path>`(リポジトリの数だけ) | `--sandbox workspace-write` の書き込みルートに加わる。`.git` は codex の仕様で読み取り専用のまま |
|
|
312
|
+
| `antigravity` | `--add-dir <path>`(リポジトリの数だけ) | テンプレートの `--add-dir "$(pwd)"` に追加する |
|
|
313
|
+
| `copilot` | `--add-dir <path>`(リポジトリの数だけ) | 書き込みはテンプレートの `--allow-tool write` に従う |
|
|
314
|
+
| `opencode` | なし(`OPENCODE_CONFIG_CONTENT` を起動コマンドの前に付ける) | 下記の inline config で許可する。`command_template` に `--agent <name>` が無いと起動前に止まる |
|
|
315
|
+
|
|
316
|
+
OpenCode は起動引数に追加ルートの指定を持たないため、runner は `OPENCODE_CONFIG_CONTENT` で、起動コマンドの `--agent` が選ぶ agent の `permission.external_directory` を「全拒否、プロダクト worktree だけ許可」に差し替え、同じ worktree の `permission.edit` を許可に加えます。`external_directory` は絶対パス(`<path>/**`)、`edit` は作業ディレクトリ(プロジェクトの worktree)からの相対パス(`../<name>/**`)で照合されるため、それぞれの形で渡します。inline config は agent 定義の frontmatter より後に読まれるため上書きされません。継承した `OPENCODE_CONFIG_CONTENT` の他項目は保持します。
|
|
317
|
+
|
|
318
|
+
対話型オーケストレーターは `specdojo orchestrator launch` が同じ `repos` を読み、プロダクトリポジトリ本体のルートを許可します。Claude Code、Codex、Antigravity、GitHub Copilot は上表と同じ引数規則です。OpenCode は起動時の inline config で、exec と同じ形で、選択 agent の `permission.external_directory` を「全拒否、宣言済みルートだけ許可」に差し替え、宣言済みルートの `permission.edit` を起動場所からの相対パスで許可します。この設定はオーケストレーターのプロセスだけに適用され、agent 定義や利用者の設定ファイルは書き換えません。`repos` を省略した project では追加の引数・設定を渡しません。
|
|
317
319
|
|
|
318
320
|
agent 実行の前後で行う保護設定(`package.json`、CI 設定など)と Git 状態(HEAD・ローカル設定)の検査は、プロダクト worktree にも同じ一覧で行います。evidence の変更ファイルは、プロダクト側を `<name>:<path>` で記録します。
|
|
319
321
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specdojo",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A dojo for Spec-Dō, the way of specification: decide with a register, write specs and designs with kata, and keep sharpening them with AI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "naoji3x",
|