gentle-pi 3.6.0 → 4.0.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/README.md +37 -6
- package/assets/agents/gentle-ai-explore.md +4 -4
- package/assets/agents/gentle-ai-verify.md +6 -4
- package/assets/agents/gentle-ai-worker.md +7 -9
- package/assets/orchestrator-delegation.md +40 -41
- package/assets/orchestrator-memory.md +1 -22
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator.md +12 -24
- package/assets/support/strict-tdd-verify.md +4 -266
- package/assets/support/strict-tdd.md +8 -360
- package/bin/gentle-shell.mjs +254 -29
- package/docs/delegated-verification.md +26 -1
- package/docs/gentle-agents-activity.md +24 -0
- package/docs/gentle-shell.md +95 -30
- package/docs/native-authority-architecture.md +2 -2
- package/docs/prompt-history.md +280 -0
- package/docs/readme-reference.md +117 -235
- package/docs/telemetry.md +1 -1
- package/docs/yolo-mode.md +86 -0
- package/extensions/child-context.ts +26 -0
- package/extensions/child-safety.ts +23 -0
- package/extensions/gentle-agents.ts +509 -275
- package/extensions/gentle-ai.ts +781 -683
- package/extensions/gentle-shell.ts +1375 -88
- package/extensions/gentle-stats.ts +101 -0
- package/extensions/gentle-todo.ts +18 -7
- package/extensions/history/atomic-write.ts +38 -0
- package/extensions/history/hide-prompts.ts +183 -0
- package/extensions/history/index.ts +1419 -0
- package/extensions/history/load-shared-history.ts +39 -0
- package/extensions/history/selector-helpers.ts +538 -0
- package/extensions/history/session-scan.ts +233 -0
- package/extensions/history/store.ts +1119 -0
- package/extensions/nan-provider.ts +6 -0
- package/extensions/quiet-tools.ts +179 -87
- package/extensions/resume-hint.ts +60 -0
- package/extensions/skill-registry.ts +16 -12
- package/extensions/startup-banner.ts +60 -31
- package/lib/agent-assets.ts +604 -0
- package/lib/agent-profile-pin.ts +12 -0
- package/lib/agents-message-delivery.ts +181 -0
- package/lib/agents-protocol.ts +60 -0
- package/lib/agents-runner.ts +105 -98
- package/lib/agents-view.ts +26 -3
- package/lib/agents-widget.ts +16 -9
- package/lib/append-system-prompt.ts +21 -0
- package/lib/bounded-writer-admission.ts +147 -0
- package/lib/card-style-policy.ts +60 -0
- package/lib/child-context-files.ts +166 -0
- package/lib/codemode-renderer.ts +185 -0
- package/lib/command-palette-catalog.ts +3 -9
- package/lib/command-palette.ts +25 -14
- package/lib/destructive-command-guard.ts +144 -0
- package/lib/foreign-target-grants.ts +32 -0
- package/lib/gentle-ai-elapsed-store.ts +87 -0
- package/lib/gentle-ai-renderer.ts +196 -39
- package/lib/gentle-shell-launcher.ts +24 -13
- package/lib/gentle-shell-resume-hint.ts +176 -0
- package/lib/history-capture-policy.ts +95 -0
- package/lib/model-routing-authority.ts +5 -1
- package/lib/nan-provider.ts +227 -0
- package/lib/native-review-cli.ts +53 -108
- package/lib/odd-phase-inference.ts +231 -0
- package/lib/odd-phase.ts +141 -0
- package/lib/overlay-repaint.ts +26 -0
- package/lib/pi-tui-keys.ts +53 -0
- package/lib/review-candidate-view-owner.ts +67 -17
- package/lib/review-candidate-view.ts +112 -25
- package/lib/review-reminder-receipt.ts +48 -8
- package/lib/review-risk-assessment.ts +156 -11
- package/lib/review-sidebar-state.ts +223 -0
- package/lib/selection-engine.ts +515 -0
- package/lib/session-change-capture.ts +10 -1
- package/lib/session-messaging-grants.ts +135 -0
- package/lib/session-worktree-registry.ts +14 -2
- package/lib/shell-bar.ts +179 -24
- package/lib/shell-card.ts +287 -18
- package/lib/shell-changes-view.ts +2 -1
- package/lib/shell-prompt.ts +102 -6
- package/lib/shell-sidebar-layout.ts +78 -14
- package/lib/shell-sidebar.ts +15 -1
- package/lib/shell-todo.ts +23 -13
- package/lib/shell-usage-view.ts +9 -4
- package/lib/shell-usage.ts +66 -10
- package/lib/stats-collector.ts +381 -0
- package/lib/stats-view.ts +431 -0
- package/lib/theme-customization.ts +52 -0
- package/lib/vim-editor-adapter.ts +379 -0
- package/lib/vim-normal-engine.ts +154 -0
- package/lib/vim-operator-engine.ts +416 -0
- package/lib/vim-policy.ts +49 -0
- package/lib/vim-visual-engine.ts +107 -0
- package/lib/visual-customization-policy.ts +108 -0
- package/lib/visual-customize-view.ts +330 -0
- package/lib/visual-profiles.ts +228 -0
- package/lib/yolo-session-policy.ts +240 -0
- package/package.json +20 -8
- package/runtime/gentle-shell-launcher.mjs +23 -12
- package/runtime/gentle-shell-resume-hint.mjs +177 -0
- package/runtime/native-review-cli.mjs +53 -108
- package/runtime/review-risk-assessment.mjs +154 -9
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +14 -13
- package/scripts/mirror-odd-routing.mjs +2 -2
- package/scripts/run-test-suite.mjs +76 -0
- package/scripts/test-packed-runner.mjs +31 -14
- package/scripts/verify-package-files.mjs +11 -22
- package/skills/branch-pr/SKILL.md +24 -52
- package/skills/chained-pr/SKILL.md +31 -15
- package/skills/chained-pr/references/chaining-details.md +31 -20
- package/skills/gentle-ai/SKILL.md +9 -15
- package/skills/issue-creation/SKILL.md +8 -2
- package/skills/issue-creation/references/delegated-workflow-actions.md +19 -0
- package/skills/work-unit-commits/SKILL.md +4 -3
- package/tests/agent-profiles.test.ts +18 -0
- package/tests/agents-fake-child.ts +2 -2
- package/tests/agents-message-delivery.test.ts +106 -0
- package/tests/agents-protocol.test.ts +40 -0
- package/tests/agents-runner.test.ts +400 -89
- package/tests/agents-view-thread-identity.test.ts +169 -0
- package/tests/agents-view.test.ts +8 -2
- package/tests/agents-widget.test.ts +154 -15
- package/tests/append-system-prompt-route.test.ts +160 -0
- package/tests/append-system-prompt.test.ts +46 -0
- package/tests/artifact-language.test.ts +19 -213
- package/tests/ask-user-question.test.ts +44 -1
- package/tests/asset-installation-runtime.test.ts +5 -16
- package/tests/autonomous-guard.test.ts +69 -1
- package/tests/bounded-writer-admission.test.ts +95 -0
- package/tests/branch-pr-skill.test.ts +43 -0
- package/tests/card-style-policy.test.ts +55 -0
- package/tests/chained-pr-skill.test.ts +124 -0
- package/tests/child-context-files.test.ts +255 -0
- package/tests/child-safety.test.ts +82 -0
- package/tests/codemode-rendering.test.ts +491 -0
- package/tests/command-palette.test.ts +39 -3
- package/tests/delegated-key-learnings-contract.test.ts +0 -76
- package/tests/destructive-command-guard.test.ts +84 -0
- package/tests/devbinary/native-review-parity.devtest.ts +170 -2
- package/tests/devbinary/non-git-subagent-bootstrap.devtest.ts +193 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-28T10-00-00-000Z_aaa.jsonl +7 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-29T23-00-00-000Z_bbb.jsonl +3 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-30T08-00-00-000Z_ddd.jsonl +2 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/2026-09-30T09-00-00-000Z_eee.jsonl +3 -0
- package/tests/fixtures/stats/sessions/--work-alpha--/run-1/session.jsonl +2 -0
- package/tests/fixtures/stats/sessions/--work-beta--/2026-09-01T12-00-00-000Z_ccc.jsonl +2 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-alpha--/2026-09-28T10-00-00-000Z_aaa.jsonl +2 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-alpha--/2026-09-29T23-00-00-000Z_bbb.jsonl +4 -0
- package/tests/fixtures/stats/user-pi/sessions/--work-gamma--/2026-09-20T09-00-00-000Z_fff.jsonl +3 -0
- package/tests/foreign-target-grants.test.ts +58 -0
- package/tests/generic-agent-tools.test.ts +54 -0
- package/tests/gentle-agents.test.ts +1411 -256
- package/tests/gentle-ai-binary.test.ts +3 -3
- package/tests/gentle-ai-elapsed-store.test.ts +68 -0
- package/tests/gentle-ai-installer.test.ts +68 -54
- package/tests/gentle-ai-renderer.test.ts +487 -8
- package/tests/gentle-ai.test.ts +288 -65
- package/tests/gentle-card-text.ts +2 -1
- package/tests/gentle-shell-bin.test.ts +651 -114
- package/tests/gentle-shell-launcher.test.ts +99 -52
- package/tests/gentle-shell-resume-hint.test.ts +270 -0
- package/tests/gentle-shell.test.ts +3839 -187
- package/tests/gentle-stats.test.ts +152 -0
- package/tests/gentle-theme.test.ts +4 -1
- package/tests/gentle-todo.test.ts +80 -8
- package/tests/history-atomic-write.test.ts +57 -0
- package/tests/history-capture-policy.test.ts +102 -0
- package/tests/history-command-registration.test.ts +164 -0
- package/tests/history-dedupe-entries.test.ts +123 -0
- package/tests/history-delete-backfill.test.ts +190 -0
- package/tests/history-delete-confirm.test.ts +460 -0
- package/tests/history-dispatch.test.ts +180 -0
- package/tests/history-drain-hidden.test.ts +110 -0
- package/tests/history-drain-order.test.ts +98 -0
- package/tests/history-expanded-globals.test.ts +62 -0
- package/tests/history-gc.test.ts +832 -0
- package/tests/history-header-layout.test.ts +265 -0
- package/tests/history-hide-prompts.test.ts +275 -0
- package/tests/history-lazy-windowing.test.ts +508 -0
- package/tests/history-legacy-migrate-v2.test.ts +297 -0
- package/tests/history-load-shared-history.test.ts +53 -0
- package/tests/history-max-results-cap.test.ts +76 -0
- package/tests/history-multi-reader.test.ts +203 -0
- package/tests/history-off-path.test.ts +170 -0
- package/tests/history-openflow-integration.test.ts +173 -0
- package/tests/history-overlay-margin.test.ts +326 -0
- package/tests/history-preview-layout.test.ts +93 -0
- package/tests/history-registry.test.ts +143 -0
- package/tests/history-scope-delete.test.ts +411 -0
- package/tests/history-search-caret-keys.test.ts +142 -0
- package/tests/history-seed-bootstrap.test.ts +170 -0
- package/tests/history-seed-regen.test.ts +129 -0
- package/tests/history-selector-windowing.test.ts +94 -0
- package/tests/history-session-scan-directory.test.ts +87 -0
- package/tests/history-session-scan-extract.test.ts +583 -0
- package/tests/history-session-writer.test.ts +351 -0
- package/tests/history-store-paths.test.ts +79 -0
- package/tests/history-tombstone-exact.test.ts +139 -0
- package/tests/history-wheel-mouse.test.ts +242 -0
- package/tests/inprocess-reviewer.test.ts +29 -19
- package/tests/issue-creation-skill.test.ts +61 -0
- package/tests/model-routing-authority.test.ts +16 -0
- package/tests/nan-provider.test.ts +471 -0
- package/tests/native-review-capability-contract.test.ts +13 -1
- package/tests/native-review-cli.test.ts +6 -120
- package/tests/native-review-parity-runtime.test.ts +100 -3
- package/tests/odd-integration.test.ts +67 -0
- package/tests/odd-phase-inference.test.ts +213 -0
- package/tests/odd-phase-loader.test.ts +253 -0
- package/tests/odd-phase.test.ts +307 -0
- package/tests/odd-routing-canonical-ratchet.test.ts +11 -6
- package/tests/odd-routing-contract.test.ts +86 -35
- package/tests/orchestrator-budget.test.ts +14 -39
- package/tests/orchestrator-rdd-ownership.test.ts +3 -3
- package/tests/overlay-repaint.test.ts +74 -0
- package/tests/package-manifest.test.ts +252 -115
- package/tests/packed-runner-owned-path.test.ts +46 -0
- package/tests/persona-single-channel.test.ts +6 -6
- package/tests/provider-defect-handoff.test.ts +3 -11
- package/tests/quiet-bash-runtime.test.ts +76 -0
- package/tests/quiet-tool-rendering.test.ts +409 -184
- package/tests/rdd-aware-verification-contract.test.ts +76 -1
- package/tests/rdd-status-line.test.ts +9 -4
- package/tests/resume-hint-extension.test.ts +122 -0
- package/tests/review-agent-end-preflight.test.ts +176 -12
- package/tests/review-candidate-owner-retry.test.ts +22 -1
- package/tests/review-candidate-view.test.ts +298 -0
- package/tests/review-contract-prompt.test.ts +108 -43
- package/tests/review-controller-lock-status.test.ts +0 -1
- package/tests/review-controller-native-routing.test.ts +611 -5
- package/tests/review-controller-workspace-root.test.ts +163 -4
- package/tests/review-host-relay-routing.test.ts +338 -2
- package/tests/review-integration-v2-forward.test.ts +200 -0
- package/tests/review-ledger-contract.test.ts +10 -34
- package/tests/review-reminder-receipt.test.ts +47 -1
- package/tests/review-risk-assessment.test.ts +498 -6
- package/tests/review-sidebar-state.test.ts +402 -0
- package/tests/run-test-suite.test.ts +124 -0
- package/tests/runtime-harness.mjs +145 -786
- package/tests/runtime-metrics-children.test.ts +16 -23
- package/tests/selection-engine.test.ts +421 -0
- package/tests/session-change-capture.test.ts +12 -1
- package/tests/session-messaging-grants.test.ts +255 -0
- package/tests/session-worktree-registry.test.ts +77 -0
- package/tests/shell-bar.test.ts +382 -1
- package/tests/shell-card.test.ts +353 -1
- package/tests/shell-changes-view.test.ts +52 -0
- package/tests/shell-prompt.test.ts +94 -2
- package/tests/shell-sidebar-layout.test.ts +325 -21
- package/tests/shell-sidebar-scroll-benchmark.test.ts +255 -0
- package/tests/shell-todo.test.ts +87 -1
- package/tests/shell-usage-view.test.ts +27 -0
- package/tests/shell-usage.test.ts +73 -0
- package/tests/skill-registry.test.ts +50 -1
- package/tests/startup-banner.test.ts +130 -2
- package/tests/stats-collector.test.ts +195 -0
- package/tests/stats-view.test.ts +202 -0
- package/tests/telemetry-trigger.test.ts +81 -20
- package/tests/theme-customization.test.ts +72 -0
- package/tests/vim-editor-adapter-host-resolution.test.ts +37 -0
- package/tests/vim-editor-adapter.test.ts +804 -0
- package/tests/vim-normal-engine.test.ts +101 -0
- package/tests/vim-operator-engine.test.ts +215 -0
- package/tests/vim-policy.test.ts +19 -0
- package/tests/vim-visual-engine.test.ts +52 -0
- package/tests/visual-customization-policy.test.ts +110 -0
- package/tests/visual-customize-view.test.ts +418 -0
- package/tests/visual-profiles.test.ts +87 -0
- package/tests/yolo-customize.test.ts +256 -0
- package/tests/yolo-mode-runtime.test.ts +161 -0
- package/tests/yolo-mode.test.ts +261 -0
- package/tests/yolo-session-policy.test.ts +59 -0
- package/themes/Gentle.json +2 -1
- package/themes/Gentleman-Cute.json +2 -1
- package/themes/Gentleman-Sexy.json +2 -1
- package/assets/agents/sdd-apply.md +0 -159
- package/assets/agents/sdd-archive.md +0 -228
- package/assets/agents/sdd-design.md +0 -49
- package/assets/agents/sdd-explore.md +0 -48
- package/assets/agents/sdd-init.md +0 -56
- package/assets/agents/sdd-onboard.md +0 -52
- package/assets/agents/sdd-proposal.md +0 -64
- package/assets/agents/sdd-remediate.md +0 -37
- package/assets/agents/sdd-research.md +0 -49
- package/assets/agents/sdd-spec.md +0 -192
- package/assets/agents/sdd-status.md +0 -54
- package/assets/agents/sdd-tasks.md +0 -108
- package/assets/agents/sdd-verify.md +0 -124
- package/assets/chains/sdd-full.chain.md +0 -83
- package/assets/chains/sdd-plan.chain.md +0 -56
- package/assets/chains/sdd-verify.chain.md +0 -43
- package/assets/sdd-orchestrator-workflow.md +0 -319
- package/assets/support/sdd-status-contract.md +0 -77
- package/docs/assets/diagrams/sdd-cycle.svg +0 -14
- package/extensions/sdd-init.ts +0 -816
- package/lib/openspec-deltas.ts +0 -156
- package/lib/sdd-preflight.ts +0 -1066
- package/lib/sdd-research-capabilities.ts +0 -94
- package/lib/sdd-status.ts +0 -26
- package/tests/fixtures/legacy/sdd-research-v2.5.0.md +0 -54
- package/tests/fixtures/native-review-cli/v2.1.3/bind-sdd.json +0 -25
- package/tests/fixtures/v0.10.7/assets/agents/sdd-apply.md +0 -132
- package/tests/openspec-deltas.test.ts +0 -209
- package/tests/sdd-agent-tools.test.ts +0 -156
- package/tests/sdd-archive-replay.test.ts +0 -82
- package/tests/sdd-classical-continuation.test.ts +0 -74
- package/tests/sdd-execution-routing-contract.test.ts +0 -44
- package/tests/sdd-managed-runtime-settlement.test.ts +0 -155
- package/tests/sdd-native-managed-uptake.test.ts +0 -243
- package/tests/sdd-no-attempts-contract.test.ts +0 -15
- package/tests/sdd-odd-integration.test.ts +0 -33
- package/tests/sdd-optional-research.test.ts +0 -124
- package/tests/sdd-planning-routing-contract.test.ts +0 -45
- package/tests/sdd-preflight-rpc-input.test.ts +0 -125
- package/tests/sdd-preflight.test.ts +0 -541
- package/tests/sdd-research-capabilities.test.ts +0 -114
- package/tests/sdd-research-live.test.ts +0 -241
- package/tests/sdd-selection-transport.test.ts +0 -653
- package/tests/sdd-status.test.ts +0 -9
- package/tests/sdd-task-truth.test.ts +0 -43
|
@@ -3,10 +3,6 @@ import { readdir, readFile } from "node:fs/promises";
|
|
|
3
3
|
import { dirname, extname, join, relative } from "node:path";
|
|
4
4
|
import test from "node:test";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import {
|
|
7
|
-
renderSddPreflightPrompt,
|
|
8
|
-
type SddPreflightPreferences,
|
|
9
|
-
} from "../lib/sdd-preflight.ts";
|
|
10
6
|
|
|
11
7
|
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
12
8
|
const TEXT_EXTENSIONS = new Set([".md", ".ts", ".mjs", ".json"]);
|
|
@@ -16,96 +12,33 @@ async function collectTextFiles(dir: string): Promise<string[]> {
|
|
|
16
12
|
const files: string[] = [];
|
|
17
13
|
for (const entry of entries) {
|
|
18
14
|
const path = join(dir, entry.name);
|
|
19
|
-
if (entry.isDirectory())
|
|
20
|
-
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (entry.isFile() && TEXT_EXTENSIONS.has(extname(entry.name))) {
|
|
24
|
-
files.push(path);
|
|
25
|
-
}
|
|
15
|
+
if (entry.isDirectory()) files.push(...(await collectTextFiles(path)));
|
|
16
|
+
else if (entry.isFile() && TEXT_EXTENSIONS.has(extname(entry.name))) files.push(path);
|
|
26
17
|
}
|
|
27
18
|
return files;
|
|
28
19
|
}
|
|
29
20
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/\bArtefactos\b/i,
|
|
37
|
-
/\bPreguntarme\b/i,
|
|
38
|
-
/l[ií]neas cambiadas/i,
|
|
39
|
-
/\bhacelo\b/i,
|
|
40
|
-
/\bSoy el Gentleman\b/i,
|
|
41
|
-
];
|
|
21
|
+
const SPANISH_ARTIFACT_COPY = [/\bhacelo\b/i, /\bSoy el Gentleman\b/i];
|
|
22
|
+
|
|
23
|
+
test("ordinary startup does not load the retired SDD preflight API", async () => {
|
|
24
|
+
const extension = await readFile(join(ROOT, "extensions/gentle-ai.ts"), "utf8");
|
|
25
|
+
assert.doesNotMatch(extension, /\b(?:ensureSddPreflight|getSddPreflightPreferences|isSddPreflightTrigger|renderSddPreflightPrompt|isParentConfirmedSddPreflightContext)\b/);
|
|
26
|
+
});
|
|
42
27
|
|
|
43
28
|
test("orchestrator keeps conversation language separate from generated artifact language", async () => {
|
|
44
29
|
const orchestrator = await readFile(join(ROOT, "assets/orchestrator.md"), "utf8");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// section only carries a one-line pointer back to it.
|
|
49
|
-
assert.match(
|
|
50
|
-
orchestrator,
|
|
51
|
-
/Reply-language style and the active persona's Spanish variant are defined once in the identity\/harness section above/,
|
|
52
|
-
);
|
|
53
|
-
assert.match(
|
|
54
|
-
orchestrator,
|
|
55
|
-
/Generated technical artifacts[\s\S]*default to English, regardless of the user's conversation language or active persona/,
|
|
56
|
-
);
|
|
57
|
-
for (const artifactScope of ["code comments", "tests", "fixtures", "delegated phase outputs"]) {
|
|
30
|
+
assert.match(orchestrator, /Reply-language style and the active persona's Spanish variant are defined once in the identity\/harness section above/);
|
|
31
|
+
assert.match(orchestrator, /Generated technical artifacts[\s\S]*default to English, regardless of the user's conversation language or active persona/);
|
|
32
|
+
for (const artifactScope of ["code comments", "tests", "fixtures", "delegated outputs"]) {
|
|
58
33
|
assert.match(orchestrator, new RegExp(artifactScope));
|
|
59
34
|
}
|
|
60
|
-
assert.match(
|
|
61
|
-
orchestrator,
|
|
62
|
-
/Public\/contextual comments and replies[\s\S]*target context language by default/,
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("rendered SDD preflight prompt is English artifact copy", () => {
|
|
67
|
-
const prefs: SddPreflightPreferences = {
|
|
68
|
-
executionMode: "interactive",
|
|
69
|
-
artifactStore: "openspec",
|
|
70
|
-
chainedPrStrategy: "ask-on-risk",
|
|
71
|
-
reviewBudgetLines: 400,
|
|
72
|
-
engramAvailable: false,
|
|
73
|
-
prompted: true,
|
|
74
|
-
};
|
|
75
|
-
const prompt = renderSddPreflightPrompt(prefs);
|
|
76
|
-
|
|
77
|
-
assert.match(prompt, /These SDD preferences are explicit current-session choices/);
|
|
78
|
-
assert.match(prompt, /Delivery strategy: ask-on-risk/);
|
|
79
|
-
assert.match(prompt, /Review budget: 400 changed lines/);
|
|
80
|
-
assert.match(prompt, /complete only the current SDD phase/i);
|
|
81
|
-
assert.match(prompt, /Do not start the next SDD phase/i);
|
|
82
|
-
assert.match(prompt, /approve only the immediate next phase/i);
|
|
83
|
-
assert.match(prompt, /offer the user a proposal question round/i);
|
|
84
|
-
assert.match(prompt, /business rules, implications, impact, edge cases/i);
|
|
85
|
-
assert.match(prompt, /second question round/i);
|
|
86
|
-
assert.match(prompt, /explicit acceptance of `size:exception`/);
|
|
87
|
-
assert.match(prompt, /human-controlled consent, authorization, security, destructive\/publishing/);
|
|
88
|
-
for (const pattern of SPANISH_PREFLIGHT_COPY) {
|
|
89
|
-
assert.doesNotMatch(prompt, pattern);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const headless = renderSddPreflightPrompt({ ...prefs, executionMode: "auto", prompted: false });
|
|
93
|
-
assert.match(headless, /canonical defaults or persisted choices/);
|
|
94
|
-
assert.match(headless, /ambiguous-scope/);
|
|
35
|
+
assert.match(orchestrator, /Public\/contextual comments and replies[\s\S]*target context language by default/);
|
|
95
36
|
});
|
|
96
37
|
|
|
97
38
|
test("orchestrator Memory Contract carries the Engram memory lifecycle rule", async () => {
|
|
98
|
-
// orchestrator-lazy-diet: the lifecycle rule moved verbatim to
|
|
99
|
-
// assets/orchestrator-memory.md; core keeps only the intro + pointer.
|
|
100
|
-
// Union read so this assertion is repointed, not weakened.
|
|
101
39
|
const orchestrator =
|
|
102
40
|
(await readFile(join(ROOT, "assets/orchestrator.md"), "utf8")) +
|
|
103
41
|
(await readFile(join(ROOT, "assets/orchestrator-memory.md"), "utf8"));
|
|
104
|
-
|
|
105
|
-
// Mirrors gentle-ai's engram-protocol/engram-convention lifecycle rule (PRs #842 + #844),
|
|
106
|
-
// in its final availability-gated form: agents must treat needs_review memories as stale,
|
|
107
|
-
// use the memory-provider-injected lifecycle tool when present, fall back safely when it is not,
|
|
108
|
-
// and never auto-mark reviewed.
|
|
109
42
|
for (const required of [
|
|
110
43
|
"when Engram exposes lifecycle metadata/tooling",
|
|
111
44
|
"At session start or before architecture-sensitive work",
|
|
@@ -120,161 +53,34 @@ test("orchestrator Memory Contract carries the Engram memory lifecycle rule", as
|
|
|
120
53
|
"Do NOT call the injected Engram review tool with action `mark_reviewed` automatically",
|
|
121
54
|
"Only call `mark_reviewed` after explicit user confirmation or through a dedicated memory maintenance command",
|
|
122
55
|
]) {
|
|
123
|
-
assert.ok(
|
|
124
|
-
orchestrator.includes(required),
|
|
125
|
-
`orchestrator.md missing memory lifecycle rule: ${required}`,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test("SDD proposal questions focus on business and PRD gaps", async () => {
|
|
131
|
-
const proposalAgent = await readFile(join(ROOT, "assets/agents/sdd-proposal.md"), "utf8");
|
|
132
|
-
|
|
133
|
-
assert.match(proposalAgent, /offer the user a proposal question round/i);
|
|
134
|
-
assert.match(proposalAgent, /second question round/i);
|
|
135
|
-
assert.match(proposalAgent, /business problem/i);
|
|
136
|
-
assert.match(proposalAgent, /business rules/i);
|
|
137
|
-
assert.match(proposalAgent, /implications and impact/i);
|
|
138
|
-
assert.match(proposalAgent, /edge cases/i);
|
|
139
|
-
assert.match(proposalAgent, /target users/i);
|
|
140
|
-
assert.match(proposalAgent, /product outcome/i);
|
|
141
|
-
assert.match(proposalAgent, /decision gaps/i);
|
|
142
|
-
// Proposal-shaping questions must stay on business/product ground: the agent is
|
|
143
|
-
// explicitly told to keep harness mechanics out of the proposal question round
|
|
144
|
-
// unless the user opts into discussing delivery. Removing this guard is the most
|
|
145
|
-
// likely way harness mechanics would leak back into proposal questions.
|
|
146
|
-
assert.match(
|
|
147
|
-
proposalAgent,
|
|
148
|
-
/Do not ask about test commands, PR shape, changed-line budget, or other harness decisions unless the user explicitly asks to discuss delivery/i,
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("all shipped SDD agents and chains require parent preflight transport", async () => {
|
|
153
|
-
const agents = [
|
|
154
|
-
"sdd-init", "sdd-onboard", "sdd-explore", "sdd-research", "sdd-proposal", "sdd-spec", "sdd-design",
|
|
155
|
-
"sdd-tasks", "sdd-status", "sdd-apply", "sdd-verify", "sdd-archive", "sdd-remediate",
|
|
156
|
-
];
|
|
157
|
-
const chains = ["sdd-full", "sdd-plan", "sdd-verify"];
|
|
158
|
-
assert.equal(agents.length, 13);
|
|
159
|
-
assert.equal(chains.length, 3);
|
|
160
|
-
for (const agent of agents) {
|
|
161
|
-
const source = await readFile(join(ROOT, "assets", "agents", `${agent}.md`), "utf8");
|
|
162
|
-
assert.match(source, /## Parent Preflight Transport/);
|
|
163
|
-
assert.match(source, /never confirms or persists SDD choices/);
|
|
164
|
-
assert.doesNotMatch(source, /(?:infer|synthesize) (?:a )?(?:preflight )?(?:confirmation|defaults?) yourself/i);
|
|
165
|
-
}
|
|
166
|
-
for (const chain of chains) {
|
|
167
|
-
const source = await readFile(join(ROOT, "assets", "chains", `${chain}.chain.md`), "utf8");
|
|
168
|
-
assert.match(source, /## Parent preflight transport guard/);
|
|
169
|
-
assert.match(source, /Missing or malformed transport blocks the chain before its first phase/);
|
|
56
|
+
assert.ok(orchestrator.includes(required), `orchestrator.md missing memory lifecycle rule: ${required}`);
|
|
170
57
|
}
|
|
171
58
|
});
|
|
172
59
|
|
|
173
|
-
test("
|
|
174
|
-
const planChain = await readFile(join(ROOT, "assets/chains/sdd-plan.chain.md"), "utf8");
|
|
175
|
-
const fullChain = await readFile(join(ROOT, "assets/chains/sdd-full.chain.md"), "utf8");
|
|
176
|
-
|
|
177
|
-
assert.match(planChain, /auto mode or explicit all-planning approval/i);
|
|
178
|
-
assert.match(planChain, /interactive mode/i);
|
|
179
|
-
assert.match(planChain, /must stop after sdd-proposal/i);
|
|
180
|
-
assert.match(fullChain, /auto mode or explicit full-lifecycle approval/i);
|
|
181
|
-
assert.match(fullChain, /interactive mode/i);
|
|
182
|
-
assert.match(fullChain, /must stop at each phase boundary/i);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test("orchestrator lazy-loads detailed SDD workflow", async () => {
|
|
186
|
-
const orchestrator = await readFile(join(ROOT, "assets/orchestrator.md"), "utf8");
|
|
187
|
-
const workflow = await readFile(join(ROOT, "assets/sdd-orchestrator-workflow.md"), "utf8");
|
|
188
|
-
|
|
189
|
-
assert.match(orchestrator, /## SDD Workflow \(lazy-loaded\)/);
|
|
190
|
-
assert.match(orchestrator, /Package assets root: `\{\{GENTLE_PI_ASSETS_ROOT\}\}`\. Lazy asset paths below are relative to this root\./);
|
|
191
|
-
assert.match(orchestrator, /`sdd-orchestrator-workflow\.md`/);
|
|
192
|
-
assert.doesNotMatch(orchestrator, /\{\{GENTLE_PI_SDD_WORKFLOW_PATH\}\}/);
|
|
193
|
-
assert.match(orchestrator, /injected `## SDD Session Preflight` block or a canonical-authority resolution/);
|
|
194
|
-
assert.match(orchestrator, /Defaults and capability constraints may resolve fields without confirmation prompts/);
|
|
195
|
-
assert.doesNotMatch(orchestrator, /or an explicit user answer covering the preflight choices/);
|
|
196
|
-
assert.doesNotMatch(orchestrator, /## Native SDD Dispatcher/);
|
|
197
|
-
assert.match(workflow, /## Native SDD Dispatcher/);
|
|
198
|
-
assert.match(workflow, /## SDD Status Contract/);
|
|
199
|
-
assert.match(workflow, /## Execution Mode/);
|
|
200
|
-
assert.match(workflow, /## Strict TDD Forwarding/);
|
|
201
|
-
assert.match(workflow, /## Review Workload Guard/);
|
|
202
|
-
assert.match(workflow, /## Result Contract/);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test("persistent harness prompt assets do not hardcode Spanish SDD artifact copy", async () => {
|
|
60
|
+
test("persistent harness prompt assets use English artifact copy", async () => {
|
|
206
61
|
const files = [
|
|
207
62
|
...(await collectTextFiles(join(ROOT, "assets"))),
|
|
208
63
|
...(await collectTextFiles(join(ROOT, "prompts"))),
|
|
209
64
|
];
|
|
210
65
|
const failures: string[] = [];
|
|
211
|
-
|
|
212
66
|
for (const file of files) {
|
|
213
67
|
const text = await readFile(file, "utf8");
|
|
214
|
-
for (const pattern of
|
|
215
|
-
if (pattern.test(text)) {
|
|
216
|
-
failures.push(`${relative(ROOT, file)} matched ${pattern}`);
|
|
217
|
-
}
|
|
68
|
+
for (const pattern of SPANISH_ARTIFACT_COPY) {
|
|
69
|
+
if (pattern.test(text)) failures.push(`${relative(ROOT, file)} matched ${pattern}`);
|
|
218
70
|
}
|
|
219
71
|
}
|
|
220
|
-
|
|
221
72
|
assert.deepEqual(failures, []);
|
|
222
73
|
});
|
|
223
74
|
|
|
224
|
-
test("SDD assets route completed implementation through native archive with optional verification", async () => {
|
|
225
|
-
const [tasks, apply, status, contract, chain] = await Promise.all([
|
|
226
|
-
readFile(join(ROOT, "assets/agents/sdd-tasks.md"), "utf8"),
|
|
227
|
-
readFile(join(ROOT, "assets/agents/sdd-apply.md"), "utf8"),
|
|
228
|
-
readFile(join(ROOT, "assets/agents/sdd-status.md"), "utf8"),
|
|
229
|
-
readFile(join(ROOT, "assets/support/sdd-status-contract.md"), "utf8"),
|
|
230
|
-
readFile(join(ROOT, "assets/chains/sdd-full.chain.md"), "utf8"),
|
|
231
|
-
]);
|
|
232
|
-
const assets = [tasks, apply, status, contract, chain].join("\n");
|
|
233
|
-
|
|
234
|
-
assert.match(tasks, /- \[ \] 1\. Implement and verify the behavior\./);
|
|
235
|
-
assert.doesNotMatch(tasks, /<!-- sdd-owner:/);
|
|
236
|
-
assert.match(apply, /fresh native recommendation/);
|
|
237
|
-
assert.match(status, /gentle-ai\.sdd-status.*v2/i);
|
|
238
|
-
assert.match(status, /read-only/i);
|
|
239
|
-
assert.match(contract, /native.*(?:apply|verify).*archive/is);
|
|
240
|
-
assert.doesNotMatch(contract, /local resolver/);
|
|
241
|
-
assert.match(contract, /verification is optional/);
|
|
242
|
-
assert.match(chain, /apply -> archive/);
|
|
243
|
-
assert.doesNotMatch(chain, /^## sdd-(verify|sync)$/m);
|
|
244
|
-
assert.doesNotMatch(assets, /<!-- sdd-owner: parent -->/);
|
|
245
|
-
assert.doesNotMatch(assets, /parent-lifecycle/);
|
|
246
|
-
assert.doesNotMatch(assets, /approved receipt|bounded review/i);
|
|
247
|
-
assert.doesNotMatch(chain, /## sdd-review/);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
75
|
test("comment-writer is context-reactive and neutral by default for Spanish comments", async () => {
|
|
251
76
|
const skill = await readFile(join(ROOT, "skills/comment-writer/SKILL.md"), "utf8");
|
|
252
|
-
|
|
253
|
-
for (const required of [
|
|
254
|
-
"target context language",
|
|
255
|
-
"explicitly requests a language",
|
|
256
|
-
"neutral/professional Spanish by default",
|
|
257
|
-
]) {
|
|
77
|
+
for (const required of ["target context language", "explicitly requests a language", "neutral/professional Spanish by default"]) {
|
|
258
78
|
assert.match(skill, new RegExp(required.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
|
|
259
79
|
}
|
|
260
|
-
|
|
261
|
-
for (const regionalDefault of [
|
|
262
|
-
/\bAcá\b/,
|
|
263
|
-
/\bagregá\b/,
|
|
264
|
-
/\bpodés\b/,
|
|
265
|
-
/\btenés\b/,
|
|
266
|
-
/\bfijate\b/,
|
|
267
|
-
/\bdale\b/,
|
|
268
|
-
/\bquerés\b/i,
|
|
269
|
-
]) {
|
|
80
|
+
for (const regionalDefault of [/\bAcá\b/, /\bagregá\b/, /\bpodés\b/, /\btenés\b/, /\bfijate\b/, /\bdale\b/, /\bquerés\b/i]) {
|
|
270
81
|
assert.doesNotMatch(skill, regionalDefault);
|
|
271
82
|
}
|
|
272
|
-
|
|
273
|
-
for (const englishExample of [
|
|
274
|
-
"Good approach overall",
|
|
275
|
-
"Approved. The scope is clear",
|
|
276
|
-
"This PR exceeds the 400-line budget",
|
|
277
|
-
]) {
|
|
83
|
+
for (const englishExample of ["Good approach overall", "Approved. The scope is clear", "This PR exceeds the 400-line budget"]) {
|
|
278
84
|
assert.match(skill, new RegExp(englishExample.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
|
|
279
85
|
}
|
|
280
86
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import askUserQuestion, { askMultiSelect } from "../extensions/ask-user-question.ts";
|
|
4
|
+
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
4
5
|
|
|
5
6
|
/** Plain theme fake: identity styling keeps rendered assertions readable. */
|
|
6
7
|
interface Theme {
|
|
@@ -67,19 +68,28 @@ interface ExtensionSlot {
|
|
|
67
68
|
|
|
68
69
|
const OURS_PATH = "gentle-pi/extensions/ask-user-question.ts";
|
|
69
70
|
|
|
70
|
-
function registerQuestionTool(slot?: ExtensionSlot): { tool: RegisteredTool; slot: ExtensionSlot; emitted: LifecycleEvent[] } {
|
|
71
|
+
function registerQuestionTool(slot?: ExtensionSlot, withHerdr = false): { tool: RegisteredTool; slot: ExtensionSlot; emitted: LifecycleEvent[] } {
|
|
71
72
|
const target: ExtensionSlot = slot ?? { path: OURS_PATH, tools: new Map() };
|
|
72
73
|
const emitted: LifecycleEvent[] = [];
|
|
74
|
+
const handlers = new Map<string, (data: unknown) => void>();
|
|
73
75
|
const pi = {
|
|
76
|
+
on() {},
|
|
77
|
+
registerCommand() {},
|
|
74
78
|
registerTool(tool: RegisteredTool) {
|
|
75
79
|
target.tools.set(tool.name, tool);
|
|
76
80
|
},
|
|
77
81
|
events: {
|
|
78
82
|
emit(channel: string, data: { active: boolean }) {
|
|
79
83
|
emitted.push({ channel, data });
|
|
84
|
+
handlers.get(channel)?.(data);
|
|
85
|
+
},
|
|
86
|
+
on(channel: string, handler: (data: unknown) => void) {
|
|
87
|
+
handlers.set(channel, handler);
|
|
88
|
+
return () => handlers.delete(channel);
|
|
80
89
|
},
|
|
81
90
|
},
|
|
82
91
|
};
|
|
92
|
+
if (withHerdr) createGentleAiExtension({ nativeReviewCli: null })(pi as never);
|
|
83
93
|
askUserQuestion(pi as never);
|
|
84
94
|
const tool = target.tools.get("ask_user_question");
|
|
85
95
|
if (!tool) throw new Error("ask_user_question must register");
|
|
@@ -582,6 +592,39 @@ test("ask_user_question settles its lifecycle after a custom UI error", async ()
|
|
|
582
592
|
]);
|
|
583
593
|
});
|
|
584
594
|
|
|
595
|
+
test("native questionnaires release the Herdr projection on answer, cancellation, and UI error", async () => {
|
|
596
|
+
const failure = new Error("custom UI failed");
|
|
597
|
+
for (const outcome of ["answer", "cancel", "error"] as const) {
|
|
598
|
+
const { tool, emitted } = registerQuestionTool(undefined, true);
|
|
599
|
+
let component!: Renderable;
|
|
600
|
+
let fail!: (reason: Error) => void;
|
|
601
|
+
const request = run(tool, { questions: single() }, {
|
|
602
|
+
mode: "tui",
|
|
603
|
+
ui: { custom: async (factory: CustomFactory) => new Promise((resolve, reject) => {
|
|
604
|
+
fail = reject;
|
|
605
|
+
component = factory({ requestRender() {} }, theme, {}, resolve);
|
|
606
|
+
}) },
|
|
607
|
+
});
|
|
608
|
+
const projection = () => emitted.filter(({ channel }) => channel === "herdr:blocked");
|
|
609
|
+
assert.deepEqual(projection(), [
|
|
610
|
+
{ channel: "herdr:blocked", data: { active: true, label: "Questionnaire awaiting input" } },
|
|
611
|
+
]);
|
|
612
|
+
if (outcome === "error") {
|
|
613
|
+
fail(failure);
|
|
614
|
+
await assert.rejects(request, (error: unknown) => error === failure);
|
|
615
|
+
} else {
|
|
616
|
+
component.handleInput?.(outcome === "cancel" ? "\x1b" : "\r");
|
|
617
|
+
const result = await request;
|
|
618
|
+
if (outcome === "cancel") assert.deepEqual(result.details, { cancelled: true });
|
|
619
|
+
else assert.equal(result.content[0]!.text, "1. Proceed? — Alpha");
|
|
620
|
+
}
|
|
621
|
+
assert.deepEqual(projection(), [
|
|
622
|
+
{ channel: "herdr:blocked", data: { active: true, label: "Questionnaire awaiting input" } },
|
|
623
|
+
{ channel: "herdr:blocked", data: { active: false } },
|
|
624
|
+
]);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
|
|
585
628
|
test("ask_user_question owns an exclusive tool name across extensions", () => {
|
|
586
629
|
// Live-verified against the installed Pi runtime: tool names are exclusive
|
|
587
630
|
// across extensions. Loading two extensions that register
|
|
@@ -18,11 +18,9 @@ async function proveLazyDiscovery(): Promise<void> {
|
|
|
18
18
|
writeFileSync(shim, `
|
|
19
19
|
import { createGentleAiExtension } from ${source("gentle-ai")};
|
|
20
20
|
import gentleAgents from ${source("gentle-agents")};
|
|
21
|
-
import sddInit from ${source("sdd-init")};
|
|
22
21
|
export default function (pi) {
|
|
23
22
|
createGentleAiExtension({ nativeReviewCli: null, candidateViews: null, processEnv: {} })(pi);
|
|
24
23
|
gentleAgents(pi);
|
|
25
|
-
sddInit(pi);
|
|
26
24
|
}
|
|
27
25
|
`);
|
|
28
26
|
const modelRuntime = await ModelRuntime.create({
|
|
@@ -61,19 +59,10 @@ export default function (pi) {
|
|
|
61
59
|
assert.match(before, /- review-risk \(global\)/);
|
|
62
60
|
assert.doesNotMatch(before, /- sdd-/, "fresh startup must not install SDD definitions");
|
|
63
61
|
assert.equal(existsSync(join(agentDir, "chains", "sdd-full.chain.md")), false);
|
|
64
|
-
assert.equal(existsSync(join(agentDir, "gentle-ai", "support")),
|
|
65
|
-
|
|
66
|
-
assert.
|
|
67
|
-
|
|
68
|
-
for (const name of ["gentle-ai-explore", "review-risk", "sdd-init", "sdd-apply"]) {
|
|
69
|
-
assert.ok(after.includes(`- ${name} (global)`), `same-session discovery must include ${name}`);
|
|
70
|
-
}
|
|
71
|
-
for (const file of ["sdd-status-contract.md", "strict-tdd.md", "strict-tdd-verify.md"]) {
|
|
72
|
-
assert.ok(existsSync(join(agentDir, "gentle-ai", "support", file)), `missing support: ${file}`);
|
|
73
|
-
}
|
|
74
|
-
assert.ok(existsSync(join(agentDir, "chains", "sdd-full.chain.md")));
|
|
75
|
-
assert.equal(session.messages.length, 0, "slash activation must not start a model turn");
|
|
76
|
-
console.log("SDK discovery: delegation/review only -> /gentle:install-sdd -> same-session sdd-init/sdd-apply and support");
|
|
62
|
+
assert.equal(existsSync(join(agentDir, "gentle-ai", "support", "strict-tdd.md")), true);
|
|
63
|
+
assert.equal(existsSync(join(agentDir, "gentle-ai", "support", "strict-tdd-verify.md")), true);
|
|
64
|
+
assert.equal(session.messages.length, 0, "asset startup must not start a model turn");
|
|
65
|
+
console.log("SDK discovery: delegation/review only");
|
|
77
66
|
} finally {
|
|
78
67
|
await runtime.dispose();
|
|
79
68
|
}
|
|
@@ -82,7 +71,7 @@ export default function (pi) {
|
|
|
82
71
|
if (process.env.GENTLE_PI_ASSET_PROOF_CHILD === "1") {
|
|
83
72
|
await proveLazyDiscovery();
|
|
84
73
|
} else {
|
|
85
|
-
test("actual SDK discovers
|
|
74
|
+
test("actual SDK discovers delegation and review assets without SDD activation", () => {
|
|
86
75
|
const root = mkdtempSync(join(tmpdir(), "gentle-pi-assets-sdk-"));
|
|
87
76
|
try {
|
|
88
77
|
const home = join(root, "home");
|
|
@@ -5,7 +5,75 @@ import { dirname, join } from "node:path";
|
|
|
5
5
|
import test from "node:test";
|
|
6
6
|
import { __testing } from "../extensions/gentle-ai.ts";
|
|
7
7
|
|
|
8
|
-
const { classifyGuardedCommand, evaluateGuardedCommand, guardedCommandPreview, guardedCommandTitle } = __testing;
|
|
8
|
+
const { classifyGuardedCommand, evaluateGuardedCommand, guardedCommandPreview, guardedCommandTitle, isOrdinaryYoloPush, yoloPushConfiguredRestriction } = __testing;
|
|
9
|
+
|
|
10
|
+
test("YOLO waiver only selects a single ordinary default-confirm push after full evaluation", () => {
|
|
11
|
+
const config = { autonomousMode: false, guardedCommands: {} };
|
|
12
|
+
for (const command of ["git push", "git push -u origin feature/test", "git push --set-upstream origin main"]) {
|
|
13
|
+
assert.equal(isOrdinaryYoloPush(command, evaluateGuardedCommand(command, config)), true, command);
|
|
14
|
+
}
|
|
15
|
+
for (const command of [
|
|
16
|
+
"git push --delete origin main", "git push origin :main", "git push --mirror origin",
|
|
17
|
+
"git push --prune origin", "git push -f origin main", "git -C /other push origin main",
|
|
18
|
+
"git push origin main; git status", "env X=1 git push origin main", "sudo git push origin main",
|
|
19
|
+
"git push origin main && git rebase main", "git push origin main && npm publish",
|
|
20
|
+
`sh -c 'git push origin main'`, `git push origin main && sh -c "psql -c 'DROP TABLE users'"`,
|
|
21
|
+
"git push origin main && find data -delete", "git push origin main && rm -r data",
|
|
22
|
+
]) assert.equal(isOrdinaryYoloPush(command, evaluateGuardedCommand(command, config)), false, command);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("YOLO preserves explicit push restrictions in either config layer independently of persistent autonomy", () => {
|
|
26
|
+
const root = makeTmpDir();
|
|
27
|
+
const cwd = join(root, "repo");
|
|
28
|
+
const home = join(root, "home");
|
|
29
|
+
try {
|
|
30
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), undefined);
|
|
31
|
+
writeConfig(home, "runtime-guardrails.json", { autonomousMode: false, guardedCommands: { gitPush: "confirm" } });
|
|
32
|
+
writeConfig(cwd, ".pi/gentle-ai/runtime-guardrails.json", { autonomousMode: true, guardedCommands: { gitPush: "allow" } });
|
|
33
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), "confirm");
|
|
34
|
+
writeConfig(home, "runtime-guardrails.json", { autonomousMode: true, guardedCommands: { gitPush: "allow" } });
|
|
35
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), undefined);
|
|
36
|
+
writeConfig(cwd, ".pi/gentle-ai/runtime-guardrails.json", { guardedCommands: { gitPush: "block" } });
|
|
37
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), "block");
|
|
38
|
+
writeConfig(cwd, ".pi/gentle-ai/runtime-guardrails.json", { guardedCommands: { gitPush: "confirm" } });
|
|
39
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), "confirm");
|
|
40
|
+
writeConfig(cwd, ".pi/gentle-ai/runtime-guardrails.json", null);
|
|
41
|
+
assert.equal(yoloPushConfiguredRestriction(cwd, { gentlePiConfigHome: home }), "confirm");
|
|
42
|
+
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("recognized data loss requires fresh confirmation across autonomous and mixed commands", () => {
|
|
46
|
+
for (const command of [
|
|
47
|
+
`psql -c 'DROP TABLE users'`,
|
|
48
|
+
`mysql -e 'TRUNCATE TABLE users'`,
|
|
49
|
+
`sqlite3 app.db 'DELETE FROM users'`,
|
|
50
|
+
`git push origin main && rm -rf ./data`,
|
|
51
|
+
`sh -c "psql -c 'DROP DATABASE app'"`,
|
|
52
|
+
]) {
|
|
53
|
+
assert.equal(classifyGuardedCommand(command, { autonomousMode: true, guardedCommands: { gitPush: "allow" } }), "confirm", command);
|
|
54
|
+
}
|
|
55
|
+
assert.equal(classifyGuardedCommand(`psql -c 'DROP TABLE users' && npm publish`, {
|
|
56
|
+
autonomousMode: true, guardedCommands: { npmPublish: "block" },
|
|
57
|
+
}), "block", "configured blocks still take precedence");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("quoted separator arguments cannot waive hard denial or invent destruction", () => {
|
|
61
|
+
const config = { autonomousMode: true, guardedCommands: { gitPush: "allow" as const } };
|
|
62
|
+
for (const command of [`git push ';' -f main`, `git push '|' --force main`, `rm -r ';' /`]) {
|
|
63
|
+
assert.equal(classifyGuardedCommand(command, config), "block", command);
|
|
64
|
+
}
|
|
65
|
+
for (const command of [
|
|
66
|
+
String.raw`sh -c "psql -c \"DROP TABLE users\""`,
|
|
67
|
+
`psql -c 'DELETE FROM "where"'`,
|
|
68
|
+
String.raw`find cache -exec echo {} \; -exec rm -r {} \;`,
|
|
69
|
+
`sudo -n rm -r ./data`, `command -p psql -c 'DROP TABLE users'`,
|
|
70
|
+
]) {
|
|
71
|
+
assert.equal(classifyGuardedCommand(command, config), "confirm", command);
|
|
72
|
+
}
|
|
73
|
+
for (const command of [`echo ';' rm -r cache`, `printf '%s ' ';' rm -r ./data`]) {
|
|
74
|
+
assert.equal(classifyGuardedCommand(command, config), "not-guarded", command);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
9
77
|
|
|
10
78
|
// ---------------------------------------------------------------------------
|
|
11
79
|
// Helpers
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, realpathSync, renameSync, rmSync, symlinkSync } from "node:fs";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { __testing } from "../extensions/gentle-ai.ts";
|
|
8
|
+
import { bindSessionRepositoryPreparation, boundSessionRepositoryAuthorityCurrent, captureBoundSessionRepositoryAuthority, isDevelopmentSurface, prepareBoundSessionRepository, sessionRepositoryAuthority } from "../lib/bounded-writer-admission.ts";
|
|
9
|
+
import type { NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
10
|
+
|
|
11
|
+
test("development admission excludes sensitive, config and bookkeeping surfaces structurally", () => {
|
|
12
|
+
for (const path of ["README.md", "odd/tasks/feature.md", ".pi/settings.json", "docs/app.ts", ".ssh/app.ts", ".aws/app.ts", ".gnupg/app.ts", "credentials/app.ts", "tokens/app.ts", "secrets/app.ts", "vite.config.ts", ".env", "private.key"]) assert.equal(isDevelopmentSurface(path), false, path);
|
|
13
|
+
for (const path of ["src/app.ts", "lib/core.go", "tests/feature.test.ts", "src/**/*"]) assert.equal(isDevelopmentSurface(path), true, path);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("authority capture is synchronous and retains root/common-dir across misses", () => {
|
|
17
|
+
let identity: { root: string; commonDir: string } | undefined = { root: "/fixture", commonDir: "/fixture/git" };
|
|
18
|
+
const current = sessionRepositoryAuthority("/fixture", () => identity);
|
|
19
|
+
identity = undefined;
|
|
20
|
+
assert.equal(current(), false);
|
|
21
|
+
identity = { root: "/fixture", commonDir: "/other/git" };
|
|
22
|
+
assert.equal(current(), false);
|
|
23
|
+
identity = { root: "/other", commonDir: "/fixture/git" };
|
|
24
|
+
assert.equal(current(), false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("captured authority cannot fall back to missing or a replacement incarnation", () => {
|
|
28
|
+
const cwd = realpathSync(tmpdir());
|
|
29
|
+
const manager = { getSessionId: () => "same-id", getCwd: () => cwd };
|
|
30
|
+
const neverBound = captureBoundSessionRepositoryAuthority(manager, cwd);
|
|
31
|
+
assert.equal(neverBound(), true, "never-bound compatibility callers remain permitted");
|
|
32
|
+
const unbind = bindSessionRepositoryPreparation(manager, cwd, async () => true, () => true);
|
|
33
|
+
assert.equal(neverBound(), false, "capture cannot silently adopt a subsequently minted binding");
|
|
34
|
+
const captured = captureBoundSessionRepositoryAuthority(manager, cwd);
|
|
35
|
+
assert.equal(captured(), true);
|
|
36
|
+
unbind();
|
|
37
|
+
assert.equal(captured(), false, "revoked binding never becomes permissive absence");
|
|
38
|
+
assert.equal(boundSessionRepositoryAuthorityCurrent(manager, cwd), false, "new calls from revoked owners are also rejected");
|
|
39
|
+
const replacement = bindSessionRepositoryPreparation(manager, cwd, async () => true, () => true);
|
|
40
|
+
assert.equal(captured(), false, "same manager and ID cannot substitute another incarnation");
|
|
41
|
+
const fresh = captureBoundSessionRepositoryAuthority(manager, cwd);
|
|
42
|
+
assert.equal(fresh(), true);
|
|
43
|
+
manager.getSessionId = () => "changed-id";
|
|
44
|
+
assert.equal(fresh(), false);
|
|
45
|
+
replacement();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
for (const race of ["loss", "replacement", "cancellation"] as const) {
|
|
49
|
+
test(`pending preparation revalidates established authority and owner before STATUS: ${race}`, async t => {
|
|
50
|
+
const cwd = realpathSync(mkdtempSync(join(tmpdir(), "bootstrap-authority-race-")));
|
|
51
|
+
t.after(() => rmSync(cwd, { recursive: true, force: true }));
|
|
52
|
+
const manager = { getSessionId: () => "fixture", getCwd: () => cwd };
|
|
53
|
+
let release!: () => void;
|
|
54
|
+
const gate = new Promise<void>(resolve => { release = resolve; });
|
|
55
|
+
let calls = 0;
|
|
56
|
+
const abort = new AbortController();
|
|
57
|
+
const unbind = bindSessionRepositoryPreparation(manager, cwd, async (_root, current) => {
|
|
58
|
+
execFileSync("git", ["init", "--quiet", cwd]);
|
|
59
|
+
assert.equal(current(), true, "first authorized bootstrap establishes retained identity");
|
|
60
|
+
await gate;
|
|
61
|
+
if (!current()) return false;
|
|
62
|
+
calls++;
|
|
63
|
+
return true;
|
|
64
|
+
}, () => true);
|
|
65
|
+
const pending = prepareBoundSessionRepository(manager, cwd, abort.signal);
|
|
66
|
+
let successor: (() => void) | undefined;
|
|
67
|
+
if (race === "loss") renameSync(join(cwd, ".git"), join(cwd, "saved-git"));
|
|
68
|
+
if (race === "replacement") successor = bindSessionRepositoryPreparation(manager, cwd, async () => true, () => true);
|
|
69
|
+
if (race === "cancellation") abort.abort();
|
|
70
|
+
release();
|
|
71
|
+
assert.equal(await pending, false);
|
|
72
|
+
assert.equal(calls, 0, "no STATUS after authority/owner/cancellation drift during await");
|
|
73
|
+
unbind(); successor?.();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Never invoke native code against the real HOME or filesystem root.
|
|
78
|
+
test("explicit review protects canonical HOME aliases, filesystem root and sensitive directories", async t => {
|
|
79
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), "bootstrap-safety-")));
|
|
80
|
+
const home = join(root, "home");
|
|
81
|
+
const alias = join(root, "home-alias");
|
|
82
|
+
mkdirSync(home);
|
|
83
|
+
mkdirSync(join(home, ".ssh"));
|
|
84
|
+
symlinkSync(home, alias);
|
|
85
|
+
const previous = process.env.HOME;
|
|
86
|
+
process.env.HOME = home;
|
|
87
|
+
t.after(() => { if (previous === undefined) delete process.env.HOME; else process.env.HOME = previous; rmSync(root, { recursive: true, force: true }); });
|
|
88
|
+
let calls = 0;
|
|
89
|
+
const native = { reviewMode: async () => ({ operation: "status", status: { effective: "on", source: "global", global: "on", cloneLocal: "" } }), targetStatus: async () => { calls++; throw new Error("protected native invocation"); } } as unknown as NativeReviewCli;
|
|
90
|
+
for (const target of [home, alias, "/", join(home, ".ssh")]) {
|
|
91
|
+
try { await __testing.executeReviewControllerOperation({ operation: "inspect", workspaceRoot: target }, home, native, undefined, null); }
|
|
92
|
+
catch { /* The public boundary can reject before returning an envelope. */ }
|
|
93
|
+
}
|
|
94
|
+
assert.equal(calls, 0, "no native STATUS against protected directories");
|
|
95
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
|
|
6
|
+
const skill = readFileSync(join(import.meta.dirname, "..", "skills/branch-pr/SKILL.md"), "utf8");
|
|
7
|
+
|
|
8
|
+
test("target-host reads require explicit destination, operation and credential/session authorization", () => {
|
|
9
|
+
assert.match(skill, /explicit.*(?:destination|target).*operation.*credential\/session.*before.*target-host reads/i);
|
|
10
|
+
assert.match(skill, /reuse fresh target-bound.*issue.*default branch.*type.*labels.*checks/i);
|
|
11
|
+
assert.match(skill, /(?:do not|never).*ambient SSH/i);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("issue linkage and protected labels retain human decisions without extra proof", () => {
|
|
15
|
+
assert.match(skill, /human-selected.*closing.*nonclosing.*Refs/i);
|
|
16
|
+
assert.match(skill, /protected labels.*exact direct instruction.*MAINTAIN\/ADMIN/i);
|
|
17
|
+
assert.match(skill, /human-selected.*size:exception.*rationale.*no separate instructor proof/i);
|
|
18
|
+
assert.doesNotMatch(skill, /Every PR body MUST contain:[\s\S]*?```markdown\s*Closes #<issue-number>/i);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("oversized single PR does not impose Gentle size labels on generic users", () => {
|
|
22
|
+
assert.match(skill, /size:exception.*Gentle-owned.*not.*universal/i);
|
|
23
|
+
assert.match(skill, /destination repository's documented contribution\/size policy/i);
|
|
24
|
+
assert.match(skill, /only when.*policy.*size:exception/i);
|
|
25
|
+
assert.match(skill, /(?:never|do not).*request.*(?:create|add).*label.*generic/i);
|
|
26
|
+
assert.match(skill, /single-pr.*not.*(?:waive|bypass).*authorization/i);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("required checks are target-policy based and actions are not automatic", () => {
|
|
30
|
+
assert.match(skill, /REQUIRED CI.*target policy/i);
|
|
31
|
+
assert.match(skill, /CodeRabbit.*optional.*unless required/i);
|
|
32
|
+
assert.match(skill, /(?:do not|never).*automatically commit.*push.*open.*PR.*merge/i);
|
|
33
|
+
assert.match(skill, /applicable test-first/i);
|
|
34
|
+
assert.match(skill, /advisory 400/i);
|
|
35
|
+
assert.doesNotMatch(skill, /\bSDD\b|OpenSpec|TUI Strict TDD/i);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("template checklist reflects evidence rather than pre-checked assertions", () => {
|
|
39
|
+
assert.match(skill, /(?:do not|never).*unverified `?\[x\]`?/i);
|
|
40
|
+
assert.doesNotMatch(skill, /^- \[x\]/m);
|
|
41
|
+
assert.match(skill, /shellcheck on modified scripts/i);
|
|
42
|
+
assert.match(skill, /skills.*at least one agent/i);
|
|
43
|
+
});
|