yadflow 4.10.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +97 -0
- package/README.md +12 -3
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +109 -15
- package/cli/agent-guard-worker.mjs +13 -0
- package/cli/agent-guard.mjs +1053 -57
- package/cli/agent-rules.mjs +34 -3
- package/cli/argv-flags.mjs +2 -2
- package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
- package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
- package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
- package/cli/brain/vendor/graphology-library.min.js +2 -0
- package/cli/brain/vendor/graphology.umd.min.js +2 -0
- package/cli/brain/vendor/sigma.min.js +1369 -0
- package/cli/brain/view/app.js +382 -0
- package/cli/brain/view/index.html +63 -0
- package/cli/brain/view/live.css +228 -0
- package/cli/brain/view/live.html +110 -0
- package/cli/brain/view/live.js +884 -0
- package/cli/brain/view/style.css +141 -0
- package/cli/brain-about.mjs +206 -0
- package/cli/brain-activity.mjs +285 -0
- package/cli/brain-skills.mjs +118 -0
- package/cli/brain-vendor.mjs +71 -0
- package/cli/brain-view.mjs +344 -0
- package/cli/brain.mjs +810 -0
- package/cli/ci-check.mjs +3 -3
- package/cli/doctor.mjs +80 -13
- package/cli/epic-state.mjs +93 -1
- package/cli/epic.mjs +15 -3
- package/cli/errors.mjs +2 -1
- package/cli/find-product.mjs +69 -15
- package/cli/foundation-publish.mjs +256 -0
- package/cli/gate.mjs +29 -3
- package/cli/git-read.mjs +38 -0
- package/cli/guard-stream.mjs +409 -0
- package/cli/hook.mjs +59 -9
- package/cli/issues-act.mjs +57 -13
- package/cli/issues-write.mjs +19 -6
- package/cli/issues.mjs +62 -23
- package/cli/lib.mjs +37 -2
- package/cli/local-page.mjs +138 -0
- package/cli/machine.mjs +1 -1
- package/cli/manifest.mjs +50 -0
- package/cli/map/view/app.js +712 -0
- package/cli/map/view/index.html +50 -0
- package/cli/map/view/style.css +142 -0
- package/cli/map-view.mjs +186 -0
- package/cli/map.mjs +637 -0
- package/cli/members.mjs +9 -15
- package/cli/next.mjs +1 -1
- package/cli/openpr.mjs +2 -2
- package/cli/plan.mjs +125 -0
- package/cli/platform.mjs +5 -5
- package/cli/product-index.mjs +1 -1
- package/cli/protection.mjs +32 -0
- package/cli/reconcile.mjs +8 -2
- package/cli/report.mjs +9 -3
- package/cli/reports-dir.mjs +391 -0
- package/cli/reports.mjs +65 -0
- package/cli/run-checks.mjs +5 -2
- package/cli/scan.mjs +1 -1
- package/cli/setup.mjs +30 -5
- package/cli/standup.mjs +87 -71
- package/cli/status.mjs +6 -5
- package/cli/test-agents-file.mjs +614 -8
- package/cli/test-brain-activity.mjs +753 -0
- package/cli/test-brain-view.mjs +381 -0
- package/cli/test-brain.mjs +795 -0
- package/cli/test-guide.mjs +211 -0
- package/cli/test-machine.mjs +59 -0
- package/cli/test-map.mjs +615 -0
- package/cli/test-reports.mjs +382 -0
- package/cli/test-run-checks.mjs +4 -0
- package/cli/test-worktree.mjs +24 -3
- package/cli/toolbox-connect.mjs +21 -6
- package/cli/toolbox.mjs +59 -4
- package/cli/update-commit.mjs +101 -9
- package/cli/usage.mjs +8 -4
- package/package.json +8 -4
- package/skills/yad-architecture/SKILL.md +22 -4
- package/skills/yad-change/SKILL.md +3 -1
- package/skills/yad-change/references/triage.md +2 -0
- package/skills/yad-checks/SKILL.md +2 -0
- package/skills/yad-checks/references/check-gates.md +8 -5
- package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
- package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
- package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
- package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
- package/skills/yad-connect-repos/SKILL.md +14 -0
- package/skills/yad-discovery/SKILL.md +11 -0
- package/skills/yad-discovery/references/foundation-schema.md +11 -0
- package/skills/yad-docs/templates/app/package-lock.json +18 -10
- package/skills/yad-docs/templates/app/package.json +6 -1
- package/skills/yad-epic/SKILL.md +3 -0
- package/skills/yad-epic/references/state-schema.md +35 -1
- package/skills/yad-guide/SKILL.md +4 -4
- package/skills/yad-implement/SKILL.md +76 -15
- package/skills/yad-issues/SKILL.md +2 -1
- package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
- package/skills/yad-spec/SKILL.md +19 -0
- package/skills/yad-stories/SKILL.md +22 -4
- package/skills/yad-stories/references/story-schema.md +1 -1
package/cli/members.mjs
CHANGED
|
@@ -42,11 +42,12 @@ import os from 'node:os';
|
|
|
42
42
|
import path from 'node:path';
|
|
43
43
|
import { createHash } from 'node:crypto';
|
|
44
44
|
import { spawnSync } from 'node:child_process';
|
|
45
|
+
import { readBlobsAt } from './git-read.mjs';
|
|
45
46
|
|
|
46
47
|
import { c, log, ok, info, warn, fail, hand, run, readJSON, forTerminal, isPlainObject, asset, inJSON, refuse as refuseJSON } from './lib.mjs';
|
|
47
48
|
import { productConfigPath, isVerifiedLedger, SCHEMA_VERSION } from './manifest.mjs';
|
|
48
49
|
import { LOGIN_RE, hostFromGitUrl, plainHost } from './platform.mjs';
|
|
49
|
-
import { repoPathFromGitUrl, httpStatus } from './protection.mjs';
|
|
50
|
+
import { repoPathFromGitUrl, configuredGitUrl, httpStatus } from './protection.mjs';
|
|
50
51
|
import { readRegistry, judgeRepo, runnable } from './workspace.mjs';
|
|
51
52
|
import { resolveDefaultBranch } from './productcommit.mjs';
|
|
52
53
|
|
|
@@ -83,8 +84,10 @@ export const accountLabel = (a) => `${a.platform === 'github' ? 'GitHub' : 'GitL
|
|
|
83
84
|
// clone's `origin`. `platform` is null on a Product with no platform: then nothing can be proven.
|
|
84
85
|
export function productIdentity(root, { runner = run, productConfig = readJSON(productConfigPath(root), null) } = {}) {
|
|
85
86
|
const platform = PLATFORMS.includes(productConfig?.platform) ? productConfig.platform : null;
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
// A git_url that names only a host is no repo: its repo path comes from origin then, and the host stays
|
|
88
|
+
// the settings' — the order the CI member check reads it in (#513, review 1).
|
|
89
|
+
const set = typeof productConfig?.git_url === 'string' ? productConfig.git_url : '';
|
|
90
|
+
const url = configuredGitUrl(set, () => runner('git', ['remote', 'get-url', 'origin'], { cwd: root }).stdout) || set;
|
|
88
91
|
const host = plainHost(hostFromGitUrl(url)) || (platform ? DEFAULT_HOST[platform] : null);
|
|
89
92
|
return { platform, host, repo: repoPathFromGitUrl(url), defaultBranch: typeof productConfig?.default_branch === 'string' ? productConfig.default_branch : null, verified: isVerifiedLedger(productConfig) };
|
|
90
93
|
}
|
|
@@ -265,20 +268,11 @@ export function judgedMemberFiles(root, identity) {
|
|
|
265
268
|
// Each candidate must be on disk byte for byte as origin holds it (review 5): an untracked copy, or an edit
|
|
266
269
|
// git was told to ignore (`--assume-unchanged`), is not what the gate judged. One git run for them all.
|
|
267
270
|
const cands = [...new Set(changed.out.split('\n').filter(Boolean))];
|
|
268
|
-
const
|
|
269
|
-
const out = batch.status === 0 ? batch.stdout : Buffer.alloc(0);
|
|
271
|
+
const blobs = readBlobsAt(root, cands.map((f) => `${base}:./${f}`));
|
|
270
272
|
const files = new Set();
|
|
271
|
-
let at = 0;
|
|
272
273
|
for (const f of cands) {
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
const header = out.subarray(at, nl).toString();
|
|
276
|
-
at = nl + 1;
|
|
277
|
-
const m = header.match(/^[0-9a-f]+ (\w+) (\d+)$/);
|
|
278
|
-
if (!m) continue; // `<name> missing`: deleted at origin, and no body follows
|
|
279
|
-
const blob = out.subarray(at, at + Number(m[2]));
|
|
280
|
-
at += Number(m[2]) + 1; // every body is skipped, whatever its type (review 6)
|
|
281
|
-
if (m[1] !== 'blob') continue;
|
|
274
|
+
const blob = blobs.get(`${base}:./${f}`);
|
|
275
|
+
if (!blob) continue; // deleted at origin, or not a file there
|
|
282
276
|
let disk;
|
|
283
277
|
try { if (fs.lstatSync(path.join(root, f)).isSymbolicLink()) continue; disk = fs.readFileSync(path.join(root, f)); } catch { continue; }
|
|
284
278
|
if (sameText(disk.toString('utf8'), blob.toString('utf8'))) files.add(f);
|
package/cli/next.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// `yad next` — the unified next-step driver. Read-only: it never writes state or acts. It reads the
|
|
2
2
|
// file ledger and prints the ONE concrete, copy-pasteable next action (and a one-line why), so a user
|
|
3
|
-
// never has to remember which of the
|
|
3
|
+
// never has to remember which of the 41 skills / gate commands comes next. "Guide, don't act" — the
|
|
4
4
|
// Shape still never auto-advances. Once an epic is `ready-for-build`, it reads each story's
|
|
5
5
|
// build-state and prints the next BUILD sub-step per repo (spec → tasks → implement → checks → engineer-review)
|
|
6
6
|
// plus the remaining chain — so Build is guided too, not just hinted at.
|
package/cli/openpr.mjs
CHANGED
|
@@ -35,8 +35,8 @@ function resolveRepo(root, { repo, dir, product }) {
|
|
|
35
35
|
if (found) return { repoRoot: path.resolve(productRoot, found.path), meta: found };
|
|
36
36
|
}
|
|
37
37
|
const here = path.resolve(root, dir || '.');
|
|
38
|
-
// The checkout it runs in, when that checkout is a registered repo
|
|
39
|
-
// folder inside it.
|
|
38
|
+
// The checkout it runs in, when that checkout is a registered repo or a git worktree of one (#515): worked
|
|
39
|
+
// at its own top, from any folder inside it. A nested repo stays exactly where it is, with no entry.
|
|
40
40
|
const hit = registryEntryFor(product, here);
|
|
41
41
|
return { repoRoot: hit ? hit.top : here, meta: hit ? hit.meta : null };
|
|
42
42
|
}
|
package/cli/plan.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
VERSION, SKILLS, IDE_TARGETS, IDE_OPENCODE_DIR, IDE_OPENCODE_TARGET, IDE_RECOVERY_TARGET, MODULE_CONFIG, wiringFor, PRODUCT_WIRING, PROJECT_FILES, isVerifiedLedger,
|
|
12
12
|
HOOK_WIRING, HOOK_ADAPTERS, CLAUDE_HOOK_ADAPTER, CAPTURE_WIRING, CAPTURE_ADAPTERS, AGENT_GUARD_WIRING, AGENT_GUARD_ADAPTERS, REPO_AGENT_GUARD_DEST, agentGuardAdapters,
|
|
13
|
+
ACTIVITY_WIRING, ACTIVITY_ADAPTERS, REPO_ACTIVITY_DEST, activityAdapters,
|
|
13
14
|
legacySkillPairs, REMOVED_SKILLS, LEGACY_REPO_FILES, LEGACY_PRODUCT_FILES, LEGACY_HOOK_SCRIPTS, MANAGED_LEDGER, BACKUP_SUFFIX,
|
|
14
15
|
productConfigPath, PRODUCT_LINK, PRODUCT_LINK_DEFAULT_PATH,
|
|
15
16
|
} from './manifest.mjs';
|
|
@@ -918,6 +919,8 @@ export function repoActions(root, repo) {
|
|
|
918
919
|
actions.push(...agentFileActions(repoRoot, ideTargetsFor(root), { scope: repo.name, lines: pointerBlock(), relabel: false }));
|
|
919
920
|
// E158b: the agent guard and the read-only allow list, so a session opened in the code repo has them too.
|
|
920
921
|
actions.push(...repoAgentGuardActions(repoRoot, ideTargetsFor(root), { scope: repo.name, ledger }));
|
|
922
|
+
// E178: the live activity record, while the Product says `"activity": true`.
|
|
923
|
+
actions.push(...repoActivityActions(root, repoRoot, ideTargetsFor(root), { scope: repo.name, ledger }));
|
|
921
924
|
}
|
|
922
925
|
if (!wired) return actions;
|
|
923
926
|
// The record is not a template: an absent one on a wired repo is always `new` (nothing to respect).
|
|
@@ -1664,6 +1667,128 @@ export function orphanCaptureHookActions(root, ideTargets = ideTargetsFor(root))
|
|
|
1664
1667
|
return actions;
|
|
1665
1668
|
}
|
|
1666
1669
|
|
|
1670
|
+
// ---- the live activity record (E178) -------------------------------------------------------------
|
|
1671
|
+
//
|
|
1672
|
+
// OFF by default: wired only while the Product config says `"activity": true` (`yad brain view --live` draws
|
|
1673
|
+
// it). The opposite polarity of capture's switch, read the same way: only the committed CONFIG decides, so two
|
|
1674
|
+
// people's `yad check` never disagree.
|
|
1675
|
+
export function activityWanted(root) {
|
|
1676
|
+
const cfgPath = productConfigPath(root);
|
|
1677
|
+
if (!exists(cfgPath)) return false;
|
|
1678
|
+
const cfg = readJSON(cfgPath, null);
|
|
1679
|
+
return !!(cfg && cfg.activity === true);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
// Is any folder on the way to `rel` under `root` a link (or not a folder)? Then nothing is written or removed
|
|
1683
|
+
// there: it would land wherever the link points (E178 review 1).
|
|
1684
|
+
function linkOnTheWay(root, rel) {
|
|
1685
|
+
let cur = root;
|
|
1686
|
+
const parts = rel.split('/');
|
|
1687
|
+
for (const part of parts.slice(0, -1)) {
|
|
1688
|
+
cur = path.join(cur, part);
|
|
1689
|
+
const st = lstatIfPresent(cur);
|
|
1690
|
+
if (st && (st.isSymbolicLink() || !st.isDirectory())) return true;
|
|
1691
|
+
}
|
|
1692
|
+
const last = lstatIfPresent(path.join(root, rel));
|
|
1693
|
+
return !!last && last.isSymbolicLink();
|
|
1694
|
+
}
|
|
1695
|
+
const keptSaid = new Set();
|
|
1696
|
+
function sayKept(where, rel) {
|
|
1697
|
+
if (keptSaid.has(`${where}\0${rel}`)) return;
|
|
1698
|
+
keptSaid.add(`${where}\0${rel}`);
|
|
1699
|
+
info(`${where}: ${rel} is not yad's copy (edited, or from before yad recorded it), so it is left in place; nothing runs it now — delete it if it is not yours`);
|
|
1700
|
+
}
|
|
1701
|
+
const linkSaid = new Set();
|
|
1702
|
+
function sayLinked(where, rel) {
|
|
1703
|
+
if (linkSaid.has(`${where}\0${rel}`)) return;
|
|
1704
|
+
linkSaid.add(`${where}\0${rel}`);
|
|
1705
|
+
warn(`${where}: a folder on the way to ${rel} is a link (or not a folder) — the live activity record is not wired there; make it a plain folder, then re-run \`yad check --fix\``);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// The script and one entry per adapter whose target this Product uses. Landed together, as capture's are.
|
|
1709
|
+
export function activityHookActions(root, ideTargets = ideTargetsFor(root)) {
|
|
1710
|
+
if (!activityWanted(root)) return [];
|
|
1711
|
+
if (linkOnTheWay(root, ACTIVITY_WIRING[0].dest)) { sayLinked('the Product', ACTIVITY_WIRING[0].dest); return []; }
|
|
1712
|
+
const ledger = readManagedLedger(root);
|
|
1713
|
+
const actions = ACTIVITY_WIRING.map((w) =>
|
|
1714
|
+
wiredFileAction('product', w.dest, asset(w.src), path.join(root, w.dest), { root, exec: !!w.exec, ledger }),
|
|
1715
|
+
);
|
|
1716
|
+
const targets = new Set(safeIdeTargetsFor(root, ideTargets));
|
|
1717
|
+
for (const adapter of ACTIVITY_ADAPTERS) if (targets.has(adapter.target)) actions.push({ ...hookSettingsAction(root, adapter), item: `${path.basename(adapter.settings)} (activity: ${adapter.event})` });
|
|
1718
|
+
return actions.map(asNew);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
// Our entries for a target that left, or every entry and the script once `activity` is off.
|
|
1722
|
+
export function orphanActivityHookActions(root, ideTargets = ideTargetsFor(root)) {
|
|
1723
|
+
if (!exists(productConfigPath(root))) return [];
|
|
1724
|
+
const on = activityWanted(root);
|
|
1725
|
+
const kept = on ? new Set(safeIdeTargetsFor(root, ideTargets)) : new Set();
|
|
1726
|
+
return activityOrphans(root, kept, ACTIVITY_ADAPTERS, ACTIVITY_WIRING[0].dest, { removeScript: !on, scope: null });
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
// The entries to unmerge (every adapter whose target is not kept), and the script when asked.
|
|
1730
|
+
function activityOrphans(root, kept, adapters, dest, { removeScript, scope }) {
|
|
1731
|
+
const actions = [];
|
|
1732
|
+
for (const adapter of adapters) {
|
|
1733
|
+
if (kept.has(adapter.target)) continue;
|
|
1734
|
+
const settingsPath = path.join(root, adapter.settings);
|
|
1735
|
+
if (!exists(settingsPath)) continue;
|
|
1736
|
+
let parsed;
|
|
1737
|
+
try { parsed = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch { continue; }
|
|
1738
|
+
if (!isPlainObject(parsed) || !unmergeHookSettings(parsed, adapter).changed) continue;
|
|
1739
|
+
actions.push({
|
|
1740
|
+
scope: scope || adapter.target,
|
|
1741
|
+
item: `${path.basename(adapter.settings)} (activity entry removed: ${adapter.event})`,
|
|
1742
|
+
status: 'removed',
|
|
1743
|
+
root,
|
|
1744
|
+
paths: [],
|
|
1745
|
+
apply: () => {
|
|
1746
|
+
let current;
|
|
1747
|
+
try { current = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch { return; }
|
|
1748
|
+
if (!isPlainObject(current)) return;
|
|
1749
|
+
const { settings, changed } = unmergeHookSettings(current, adapter);
|
|
1750
|
+
if (changed) writeJSON(settingsPath, settings);
|
|
1751
|
+
},
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
// ONLY A COPY YAD PROVABLY WROTE, reached with no link on the way (E178 review 1, the E113 rule): its sha is
|
|
1755
|
+
// the one `.sdlc/managed.json` recorded, or it is byte for byte the script this release ships. A team's own
|
|
1756
|
+
// edited copy is theirs — their hook may run it — and a `checks/` or `hooks/` that is a link would take the
|
|
1757
|
+
// removal to wherever it points.
|
|
1758
|
+
if (removeScript && !linkOnTheWay(root, dest)) {
|
|
1759
|
+
const file = path.join(root, dest);
|
|
1760
|
+
const st = lstatIfPresent(file);
|
|
1761
|
+
const sha = st && st.isFile() ? contentSha(file) : null;
|
|
1762
|
+
const ours = sha && (readManagedLedger(root)[dest] === sha || sha === contentSha(asset(ACTIVITY_WIRING[0].src)));
|
|
1763
|
+
if (ours) actions.push({ scope: scope || 'product', item: `${dest} (removed)`, status: 'removed', root, paths: scope ? [] : [dest], apply: () => fs.rmSync(file, { force: true }) });
|
|
1764
|
+
else if (sha) sayKept(scope || 'the Product', dest);
|
|
1765
|
+
}
|
|
1766
|
+
return actions;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// In a connected code repo cloned here: the script in `checks/` and the entries in the repo's own settings
|
|
1770
|
+
// files, for the Product's targets, as the agent guard's are (`repoAgentGuardActions`).
|
|
1771
|
+
export function repoActivityActions(productRoot, repoRoot, ideTargets, { scope, ledger = readManagedLedger(repoRoot) }) {
|
|
1772
|
+
if (!activityWanted(productRoot)) return [];
|
|
1773
|
+
if (linkOnTheWay(repoRoot, REPO_ACTIVITY_DEST)) { sayLinked(scope, REPO_ACTIVITY_DEST); return []; }
|
|
1774
|
+
const targets = new Set(repoTargets(repoRoot, ideTargets, scope));
|
|
1775
|
+
const settings = activityAdapters(REPO_ACTIVITY_DEST).filter((a) => targets.has(a.target))
|
|
1776
|
+
.map((a) => ({ ...hookSettingsAction(repoRoot, a, undefined, scope), scope, item: `${a.settings} (activity: ${a.event})` }));
|
|
1777
|
+
if (!settings.length) return [];
|
|
1778
|
+
return [wiredFileAction(scope, REPO_ACTIVITY_DEST, asset(ACTIVITY_WIRING[0].src), path.join(repoRoot, REPO_ACTIVITY_DEST), { root: repoRoot, ledger }), ...settings];
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
// The same, taken out of a code repo: a target that left, or everything once `activity` is off. A tool folder
|
|
1782
|
+
// that is a link or not a folder is never written through.
|
|
1783
|
+
export function repoOrphanActivityActions(productRoot, repoRoot, ideTargets, { scope }) {
|
|
1784
|
+
if (!isDirectory(repoRoot)) return [];
|
|
1785
|
+
const on = activityWanted(productRoot);
|
|
1786
|
+
const kept = on ? new Set(repoTargets(repoRoot, ideTargets, null)) : new Set();
|
|
1787
|
+
const linked = (ide) => { const st = lstatIfPresent(path.join(repoRoot, ide)); return !!st && (st.isSymbolicLink() || !st.isDirectory()); };
|
|
1788
|
+
const adapters = activityAdapters(REPO_ACTIVITY_DEST).filter((a) => !linked(a.target));
|
|
1789
|
+
return activityOrphans(repoRoot, kept, adapters, REPO_ACTIVITY_DEST, { removeScript: !on, scope });
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1667
1792
|
// The read-only yad commands, pre-approved for Claude Code (E158, issue #353): `readAllowList` added to
|
|
1668
1793
|
// `permissions.allow` in `.claude/settings.json`. Additive: the team's own entries are kept, and an entry of
|
|
1669
1794
|
// ours already there is not added twice. A shape it cannot read is refused, as the hook merge refuses one.
|
package/cli/platform.mjs
CHANGED
|
@@ -639,7 +639,7 @@ export function createPr(platform, opts = {}) {
|
|
|
639
639
|
if (platform === 'github') {
|
|
640
640
|
const r = run('gh', buildPrArgs('github', { ...opts, reviewers: [] }), { cwd: opts.cwd });
|
|
641
641
|
if (!r.ok) return { ok: false, reason: r.stderr };
|
|
642
|
-
const url = r.stdout
|
|
642
|
+
const url = urlFromStdout(r.stdout);
|
|
643
643
|
const number = prNumberFromUrl(url);
|
|
644
644
|
const added = []; const dropped = [];
|
|
645
645
|
if (number) {
|
|
@@ -652,7 +652,7 @@ export function createPr(platform, opts = {}) {
|
|
|
652
652
|
// gitlab
|
|
653
653
|
const r = run('glab', buildPrArgs('gitlab', opts), { cwd: opts.cwd });
|
|
654
654
|
if (!r.ok) return { ok: false, reason: r.stderr };
|
|
655
|
-
const url = r.stdout
|
|
655
|
+
const url = urlFromStdout(r.stdout);
|
|
656
656
|
const iid = prNumberFromUrl(url);
|
|
657
657
|
const rest = reviewers.slice(1);
|
|
658
658
|
// Only report a reviewer as `mentioned` if the @-mention note actually posted; otherwise they were
|
|
@@ -790,12 +790,12 @@ export function createDraftAdvisory(t, { summary, description, severity, cwe },
|
|
|
790
790
|
// ---- acting on an item when a person asks (E173) -------------------------------------------------------
|
|
791
791
|
// Each returns the runner's result. A GitLab list field cannot be sent through `glab api` (it refuses a
|
|
792
792
|
// bracketed field name), so GitLab takes one assignee by id.
|
|
793
|
-
export function newItem(t, { title, body, labels, assignee = null, confidential = false }, { runner = run } = {}) {
|
|
793
|
+
export function newItem(t, { title, body, labels, assignee = null, confidential = false, milestone = null }, { runner = run } = {}) {
|
|
794
794
|
if (t.platform === 'github') {
|
|
795
|
-
const fields = ['-f', `title=${title}`, '-f', `body=${body}`, ...labels.flatMap((l) => ['-f', `labels[]=${l}`]), ...(assignee ? ['-f', `assignees[]=${assignee}`] : [])];
|
|
795
|
+
const fields = ['-f', `title=${title}`, '-f', `body=${body}`, ...labels.flatMap((l) => ['-f', `labels[]=${l}`]), ...(assignee ? ['-f', `assignees[]=${assignee}`] : []), ...(milestone !== null ? ['-F', `milestone=${milestone}`] : [])];
|
|
796
796
|
return runner('gh', ['api', '--hostname', t.host, '-X', 'POST', `repos/${t.repo}/issues`, ...fields], { timeout: 30000 });
|
|
797
797
|
}
|
|
798
|
-
const fields = ['-f', `title=${title}`, '-f', `description=${body}`, '-f', `labels=${labels.join(',')}`, ...(assignee ? ['-F', `assignee_id=${assignee}`] : []), ...(confidential ? ['-F', 'confidential=true'] : [])];
|
|
798
|
+
const fields = ['-f', `title=${title}`, '-f', `description=${body}`, '-f', `labels=${labels.join(',')}`, ...(assignee ? ['-F', `assignee_id=${assignee}`] : []), ...(confidential ? ['-F', 'confidential=true'] : []), ...(milestone !== null ? ['-F', `milestone_id=${milestone}`] : [])];
|
|
799
799
|
return runner('glab', ['api', '--hostname', t.host, '-X', 'POST', `projects/${encodeURIComponent(t.repo)}/issues`, ...fields], { timeout: 30000 });
|
|
800
800
|
}
|
|
801
801
|
|
package/cli/product-index.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export const INDEX_FORMAT = 'e111-1';
|
|
|
43
43
|
// Line endings are made `\n` before anything else: a checkout with `core.autocrlf` (the Windows default)
|
|
44
44
|
// holds CRLF where git stores LF, and the same Product must hash the same on every machine — and parse
|
|
45
45
|
// the same, since the frontmatter reader expects `\n`. Nothing else in the bytes is touched.
|
|
46
|
-
function readInput(file) {
|
|
46
|
+
export function readInput(file) {
|
|
47
47
|
try {
|
|
48
48
|
const raw = fs.readFileSync(file);
|
|
49
49
|
return { bytes: raw.includes(13) ? Buffer.from(raw.toString('latin1').replace(/\r\n/g, '\n'), 'latin1') : raw };
|
package/cli/protection.mjs
CHANGED
|
@@ -54,6 +54,38 @@ export function repoPathFromGitUrl(url = '') {
|
|
|
54
54
|
return parts.length >= 2 ? parts.join('/') : null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// A git_url that names a repo, as written (trimmed), else ''. A url that names only a host
|
|
58
|
+
// (`https://gitlab.example.com`, `git@host:`) says where the platform is but not which repo, so a reader
|
|
59
|
+
// that falls back to the clone's origin remote must fall back for it too (#513) — through `configuredGitUrl`.
|
|
60
|
+
export const repoGitUrl = (u) => (typeof u === 'string' && repoPathFromGitUrl(u) ? u.trim() : '');
|
|
61
|
+
|
|
62
|
+
// The address to ask the platform about, from a settings `git_url` and the clone's origin remote (#513):
|
|
63
|
+
// - the settings' url when it names a repo;
|
|
64
|
+
// - else origin — but the HOST stays the settings' when they name one: origin can be a person's own SSH
|
|
65
|
+
// alias (`git@gitlab-work:acme/product.git`), and the CI member check reads the host from the settings
|
|
66
|
+
// first. So a host-only url and origin on another host give the settings' host with origin's repo path.
|
|
67
|
+
// - else '' when neither names anything.
|
|
68
|
+
// `origin` is the url, or a function that reads it — asked only when the settings name no repo. A rebuilt url
|
|
69
|
+
// is for asking the platform (host + repo path) only, never for git to clone: the login name is dropped, and
|
|
70
|
+
// a GitLab installed under a sub-path (`https://example.com/gitlab`) is not kept. An origin with no plain host
|
|
71
|
+
// (`file://`, a local path) is never rebuilt onto the platform's host: it names no repo there.
|
|
72
|
+
export function configuredGitUrl(set, origin) {
|
|
73
|
+
const own = repoGitUrl(set);
|
|
74
|
+
if (own) return own;
|
|
75
|
+
const read = typeof origin === 'function' ? origin() : origin;
|
|
76
|
+
const o = typeof read === 'string' ? read.trim() : '';
|
|
77
|
+
const repo = repoPathFromGitUrl(o);
|
|
78
|
+
const host = plainHost(hostFromGitUrl(typeof set === 'string' ? set : ''));
|
|
79
|
+
const originHost = plainHost(hostFromGitUrl(o));
|
|
80
|
+
if (!repo || !host || !originHost || originHost === host) return o;
|
|
81
|
+
const s = set.trim();
|
|
82
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) {
|
|
83
|
+
try { const u = new URL(s); u.username = ''; u.password = ''; u.search = ''; u.hash = ''; u.pathname = `/${repo}.git`; return u.toString(); } catch { /* below */ }
|
|
84
|
+
}
|
|
85
|
+
const scp = s.match(/^((?:[^@/]+@)?[^/:]+):/);
|
|
86
|
+
return scp ? `${scp[1]}:${repo}.git` : `https://${host}/${repo}.git`;
|
|
87
|
+
}
|
|
88
|
+
|
|
57
89
|
// The HTTP status of a failed `gh api` / `glab api` call, or null when there was none (offline, a timeout,
|
|
58
90
|
// the host is down). gh ends with `gh: Not Found (HTTP 404)`; glab with `glab: 404 Not Found (HTTP 404)`
|
|
59
91
|
// and prints the body `{"message":"401 Unauthorized"}` on stdout.
|
package/cli/reconcile.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { preflightGuardReadiness } from './productcommit.mjs';
|
|
|
14
14
|
import { VERSION, PROJECT_FILES, MANAGED_LEDGER, BACKUP_SUFFIX , productConfigPath, PRODUCT_LINK } from './manifest.mjs';
|
|
15
15
|
import {
|
|
16
16
|
moduleActions, repoActions, productActions, hookActions, agentFileActions, agentGuardActions, orphanAgentGuardActions, allowListActions, orphanAllowListActions, repoOrphanAgentGuardActions,
|
|
17
|
-
legacyModuleActions, removedModuleActions, orphanHookActions, captureHookActions, orphanCaptureHookActions, legacyHookScriptActions, legacyRepoActions, legacyProductActions,
|
|
17
|
+
legacyModuleActions, removedModuleActions, orphanHookActions, captureHookActions, orphanCaptureHookActions, activityHookActions, orphanActivityHookActions, repoOrphanActivityActions, legacyHookScriptActions, legacyRepoActions, legacyProductActions,
|
|
18
18
|
ideTargetStateFor, recordManagedWrites, gitHookActions, orphanGitHookActions, gitHookState, gitHookAdvice, renamedNameHits, withoutKeptRenames, PRODUCT_PROFILE_GATES, productProfileGap, productProfileEffect, PRODUCT_PROFILE_FIX, workflowsPassingProduct, productGateBlockers, oldProfileAdvice,
|
|
19
19
|
} from './plan.mjs';
|
|
20
20
|
import { gitHead, packRepo } from './setup.mjs';
|
|
@@ -73,6 +73,8 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
73
73
|
...gitHookActions(root), ...orphanGitHookActions(root),
|
|
74
74
|
// E43: the post-edit capture hook, in both ledger modes.
|
|
75
75
|
...captureHookActions(root, ideTargets), ...orphanCaptureHookActions(root, ideTargets),
|
|
76
|
+
// E178: the live activity record, only while the config says `"activity": true`.
|
|
77
|
+
...activityHookActions(root, ideTargets), ...orphanActivityHookActions(root, ideTargets),
|
|
76
78
|
// E113: the old shell-script hooks. LAST, so the entries above that named them are rewritten first.
|
|
77
79
|
...legacyHookScriptActions(root, ideTargets),
|
|
78
80
|
];
|
|
@@ -90,7 +92,11 @@ export async function reconcile(root, { fix = false, scope = 'all', force = fals
|
|
|
90
92
|
for (const repo of registry.repos) {
|
|
91
93
|
const repoRoot = path.resolve(root, repo.path);
|
|
92
94
|
// E158b: a target that left takes yad's guard and allow-list entries out of the repo's own settings too.
|
|
93
|
-
|
|
95
|
+
// E178: and the activity record's, when the Product turned `activity` off.
|
|
96
|
+
const orphans = samePath(repoRoot, path.resolve(root)) ? [] : [
|
|
97
|
+
...repoOrphanAgentGuardActions(repoRoot, ideTargets, { scope: repo.name }),
|
|
98
|
+
...repoOrphanActivityActions(root, repoRoot, ideTargets, { scope: repo.name }),
|
|
99
|
+
];
|
|
94
100
|
const own = withoutKeptRenames([...repoActions(root, repo), ...legacyRepoActions(root, repo)]).concat(orphans);
|
|
95
101
|
// Set on the action itself: later steps compare actions by identity. `true`, not the name, which may be empty.
|
|
96
102
|
for (const a of own) { a.fromRepo = true; if (repo.name === 'product') a.shownScope = repoShown(repo); }
|
package/cli/report.mjs
CHANGED
|
@@ -159,9 +159,15 @@ const OWN_FLAGS = new Set(['--json', '--post', '--confirm', '--kind']);
|
|
|
159
159
|
const withoutOwnFlags = (argv) => argv.filter((a) => !OWN_FLAGS.has(String(a).split('=')[0]));
|
|
160
160
|
|
|
161
161
|
// ---- open a URL (best-effort) -------------------------------------------------------------------
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
// Returns whether an opener was found, so a caller can say "open it yourself" when none was. On Windows
|
|
163
|
+
// `start` is a built-in of cmd.exe, not a program, so it is never on PATH and cannot be spawned without a
|
|
164
|
+
// shell: `explorer.exe` opens a URL or a file in its default app, and takes the argument with no shell to
|
|
165
|
+
// parse it (E177 review 1).
|
|
166
|
+
export function openUrl(url, { runner = run, platform = process.platform, exists = has } = {}) {
|
|
167
|
+
const cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'explorer' : 'xdg-open';
|
|
168
|
+
if (!exists(cmd)) return false;
|
|
169
|
+
runner(cmd, [url]);
|
|
170
|
+
return true;
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
// ---- the flow -----------------------------------------------------------------------------------
|