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
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import test from "node:test";
|
|
5
|
-
|
|
6
|
-
const repoRoot = process.cwd();
|
|
7
|
-
const assetsAgentsDir = join(repoRoot, "assets", "agents");
|
|
8
|
-
const GENERIC_ROLE_TOOLS: Record<string, string[]> = {
|
|
9
|
-
"gentle-ai-explore.md": ["read", "grep", "find", "codegraph"],
|
|
10
|
-
"gentle-ai-worker.md": ["read", "grep", "find", "edit", "write", "bash", "mem_save"],
|
|
11
|
-
"gentle-ai-verify.md": ["read", "grep", "find", "bash"],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function readFrontmatter(path: string): string {
|
|
15
|
-
const text = readFileSync(path, "utf8");
|
|
16
|
-
const match = text.match(/^---\n([\s\S]*?)\n---/);
|
|
17
|
-
assert.ok(match, `${path} must have YAML frontmatter`);
|
|
18
|
-
return match[1];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function readTools(path: string): string[] {
|
|
22
|
-
const frontmatter = readFrontmatter(path);
|
|
23
|
-
const lines = frontmatter.split("\n");
|
|
24
|
-
const toolsIndex = lines.findIndex((line) => line === "tools:");
|
|
25
|
-
assert.notEqual(toolsIndex, -1, `${path} must declare tools as a YAML array`);
|
|
26
|
-
|
|
27
|
-
const scalarTools = lines.find((line) => /^tools:\s+/.test(line));
|
|
28
|
-
assert.equal(scalarTools, undefined, `${path} must not declare scalar comma-separated tools`);
|
|
29
|
-
|
|
30
|
-
const tools: string[] = [];
|
|
31
|
-
for (const line of lines.slice(toolsIndex + 1)) {
|
|
32
|
-
if (!line.startsWith(" - ")) break;
|
|
33
|
-
tools.push(line.slice(4).trim());
|
|
34
|
-
}
|
|
35
|
-
assert.ok(tools.length > 0, `${path} must declare at least one tool`);
|
|
36
|
-
return tools;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function assertGenericRoleBody(fileName: string, source: string): void {
|
|
40
|
-
assert.match(source, /generic non-SDD work/);
|
|
41
|
-
assert.match(source, /Do not (?:fix findings, delegate to child agents|delegate to child agents, commit)/);
|
|
42
|
-
assert.match(source, /Do not (?:edit, write|edit, write, or fix findings)/);
|
|
43
|
-
assert.match(source, /compressed (?:handoff|evidence handoff)/);
|
|
44
|
-
assert.match(source, /supporting (?:paths|evidence)/);
|
|
45
|
-
assert.match(source, /Do not use SDD phase protocols or review lenses\./);
|
|
46
|
-
|
|
47
|
-
if (fileName === "gentle-ai-explore.md") {
|
|
48
|
-
assert.match(source, /sole permitted mutation/);
|
|
49
|
-
assert.match(source, /all tracked files, source files, and other project content remain read-only/);
|
|
50
|
-
assert.match(source, /CodeGraph reports that it is unavailable or fails/);
|
|
51
|
-
assert.match(source, /Do not use that fallback before CodeGraph is unavailable or fails/);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (fileName === "gentle-ai-verify.md") {
|
|
55
|
-
assert.match(source, /execute only exact test, build, or lint commands explicitly authorized by the parent/);
|
|
56
|
-
assert.match(source, /only outputs the parent explicitly identified as expected/);
|
|
57
|
-
assert.match(source, /unexpected mutation as a blocker/);
|
|
58
|
-
assert.match(source, /report it, but do not clean it up or fix it/);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const requiredToolsByAgent: Record<string, string[]> = {
|
|
63
|
-
"sdd-apply.md": ["read", "grep", "find", "edit", "write", "bash", "mem_search", "mem_get_observation", "mem_save", "mem_update"],
|
|
64
|
-
"sdd-archive.md": ["read", "grep", "find", "edit", "write", "bash", "mem_search", "mem_get_observation", "mem_save"],
|
|
65
|
-
"sdd-design.md": ["read", "grep", "find", "edit", "write", "mem_search", "mem_get_observation", "mem_save"],
|
|
66
|
-
"sdd-explore.md": ["read", "grep", "find", "edit", "write", "mem_save"],
|
|
67
|
-
"sdd-init.md": ["read", "grep", "find", "edit", "write", "bash", "mem_search", "mem_get_observation", "mem_save", "mem_update"],
|
|
68
|
-
"sdd-onboard.md": ["read", "grep", "find", "edit", "write", "bash", "mem_search", "mem_get_observation", "mem_save", "mem_update"],
|
|
69
|
-
"sdd-proposal.md": ["read", "grep", "find", "edit", "write", "mem_search", "mem_get_observation", "mem_save"],
|
|
70
|
-
"sdd-research.md": [ "fetch_content", "web_search", "source_check", "get_search_content"],
|
|
71
|
-
"sdd-spec.md": ["read", "grep", "find", "edit", "write", "mem_search", "mem_get_observation", "mem_save"],
|
|
72
|
-
"sdd-status.md": ["read", "grep", "find", "bash", "mem_search", "mem_get_observation"],
|
|
73
|
-
"sdd-tasks.md": ["read", "grep", "find", "edit", "write", "mem_search", "mem_get_observation", "mem_save"],
|
|
74
|
-
"sdd-verify.md": ["read", "grep", "find", "edit", "write", "bash", "mem_search", "mem_get_observation", "mem_save"],
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
test("SDD package agents declare role-appropriate tools as YAML arrays", () => {
|
|
78
|
-
for (const [fileName, requiredTools] of Object.entries(requiredToolsByAgent)) {
|
|
79
|
-
const path = join(assetsAgentsDir, fileName);
|
|
80
|
-
assert.ok(existsSync(path), `${fileName} must exist`);
|
|
81
|
-
const tools = readTools(path);
|
|
82
|
-
for (const tool of requiredTools) {
|
|
83
|
-
assert.ok(tools.includes(tool), `${fileName} must include ${tool}`);
|
|
84
|
-
}
|
|
85
|
-
for (const tool of tools) {
|
|
86
|
-
assert.ok(!tool.startsWith("subagent_"), `${fileName} must not allow child subagent tool ${tool}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("artifact-producing SDD agents can persist OpenSpec files while status remains read-only", () => {
|
|
92
|
-
for (const fileName of Object.keys(requiredToolsByAgent).filter(
|
|
93
|
-
(fileName) => !["sdd-status.md", "sdd-research.md"].includes(fileName),
|
|
94
|
-
)) {
|
|
95
|
-
const tools = readTools(join(assetsAgentsDir, fileName));
|
|
96
|
-
assert.ok(tools.includes("edit"), `${fileName} must include edit`);
|
|
97
|
-
assert.ok(tools.includes("write"), `${fileName} must include write`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
assert.deepEqual(readTools(join(assetsAgentsDir, "sdd-research.md")), requiredToolsByAgent["sdd-research.md"]);
|
|
101
|
-
const statusTools = readTools(join(assetsAgentsDir, "sdd-status.md"));
|
|
102
|
-
assert.ok(!statusTools.includes("edit"), "sdd-status.md must remain read-only");
|
|
103
|
-
assert.ok(!statusTools.includes("write"), "sdd-status.md must remain read-only");
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test("research instructions require executed evidence rather than blanket denial", () => {
|
|
107
|
-
const source = readFileSync(join(assetsAgentsDir, "sdd-research.md"), "utf8");
|
|
108
|
-
assert.doesNotMatch(source, /documentation=\[\]; open-web=\[\]/);
|
|
109
|
-
assert.match(source, /Actually call approved tools/);
|
|
110
|
-
assert.match(source, /claim maps to source IDs/);
|
|
111
|
-
assert.match(source, /partial or unavailable research is not a failed proposal gate/);
|
|
112
|
-
assert.ok(!readTools(join(assetsAgentsDir, "sdd-research.md")).includes("bash"));
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("project does not ship local SDD agent overrides", () => {
|
|
116
|
-
for (const relativeDir of [join(".pi", "agents"), join(".pi", "subagents")]) {
|
|
117
|
-
const dir = join(repoRoot, relativeDir);
|
|
118
|
-
if (!existsSync(dir)) continue;
|
|
119
|
-
const overrides = readdirSync(dir).filter((entry) => /^sdd-.*\.md$/i.test(entry));
|
|
120
|
-
assert.deepEqual(overrides, [], `${relativeDir} must not shadow package SDD agents`);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test("generic non-SDD agents declare exact role tool allowlists", () => {
|
|
125
|
-
for (const [fileName, expectedTools] of Object.entries(GENERIC_ROLE_TOOLS)) {
|
|
126
|
-
const path = join(assetsAgentsDir, fileName);
|
|
127
|
-
assert.ok(existsSync(path), `${fileName} must exist`);
|
|
128
|
-
assert.deepEqual(readTools(path), expectedTools);
|
|
129
|
-
if (fileName !== "gentle-ai-worker.md") {
|
|
130
|
-
assertGenericRoleBody(fileName, readFileSync(path, "utf8"));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("optional verification retains practical evidence without retired attestation admission", () => {
|
|
136
|
-
const agent = readFileSync(join(assetsAgentsDir, "sdd-verify.md"), "utf8");
|
|
137
|
-
const chain = readFileSync(join(repoRoot, "assets/chains/sdd-verify.chain.md"), "utf8");
|
|
138
|
-
for (const source of [agent, chain]) {
|
|
139
|
-
assert.doesNotMatch(source, /sdd-verify-validate|gentle-ai\.verify-result\/v1/);
|
|
140
|
-
assert.match(source, /commands/);
|
|
141
|
-
assert.match(source, /blockers/);
|
|
142
|
-
}
|
|
143
|
-
assert.match(agent, /strict TDD compliance/);
|
|
144
|
-
assert.match(agent, /exit codes/);
|
|
145
|
-
assert.match(agent, /never fabricate PASS/);
|
|
146
|
-
assert.match(chain, /does not make verification mandatory/);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test("the retired Pi adversarial role agents are not packaged", () => {
|
|
150
|
-
// gentle-pi#311 P5: the refuter and targeted validator verdicts execute
|
|
151
|
-
// through Go-owned pi processes via provider-rendered self-contained
|
|
152
|
-
// vectors; no Pi agent definition may reintroduce a Pi-authored verdict.
|
|
153
|
-
for (const retired of ["review-refuter.md", "review-validator.md"]) {
|
|
154
|
-
assert.ok(!existsSync(join(assetsAgentsDir, retired)), `${retired} must stay deleted`);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import { applyDeltaSpec, parseRequirementBlocks } from "../lib/openspec-deltas.ts";
|
|
5
|
-
|
|
6
|
-
const archive = readFileSync(new URL("../assets/agents/sdd-archive.md", import.meta.url), "utf8");
|
|
7
|
-
|
|
8
|
-
// These checks exercise the shipped instruction contract, not an autonomous executor.
|
|
9
|
-
test("archive reconciles prior composition per operation before applying remaining deltas", () => {
|
|
10
|
-
assert.match(archive, /### Resume prior composition/);
|
|
11
|
-
assert.match(archive, /Classify each operation as already applied, pending, or unresolved/);
|
|
12
|
-
assert.match(archive, /existing change-specific artifacts.*history/);
|
|
13
|
-
assert.match(archive, /PASS.*absence alone.*not proof/);
|
|
14
|
-
assert.match(archive, /REMOVED.*absent.*same requirement.*removed by this change/);
|
|
15
|
-
assert.match(archive, /ADDED.*MODIFIED.*full current requirement block.*intended delta result/);
|
|
16
|
-
assert.match(archive, /Apply only pending operations/);
|
|
17
|
-
assert.match(archive, /unresolved.*before any canonical write or archive move/);
|
|
18
|
-
assert.match(archive, /Do not create a new report schema.*hash inventory/);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("archive reconciliation preserves safety and backend closure boundaries", () => {
|
|
22
|
-
assert.match(archive, /collision.*order.*still apply/);
|
|
23
|
-
assert.match(archive, /Fail or block.*REMOVED target is missing without corroborating history/);
|
|
24
|
-
assert.match(archive, /differing current content.*unresolved/);
|
|
25
|
-
assert.match(archive, /re-read the persisted tasks artifact/i);
|
|
26
|
-
assert.match(archive, /resolved symlink targets/);
|
|
27
|
-
assert.match(archive, /Block rather than overwrite an existing archive destination/);
|
|
28
|
-
assert.match(archive, /Engram.*do not create or require.*canonical/);
|
|
29
|
-
assert.match(archive, /already-applied.*pending.*unresolved.*supporting artifact/);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const original = `# Domain
|
|
33
|
-
|
|
34
|
-
## Requirements
|
|
35
|
-
|
|
36
|
-
### Requirement: Retained
|
|
37
|
-
|
|
38
|
-
Keep the original behavior.
|
|
39
|
-
|
|
40
|
-
### Requirement: Removed
|
|
41
|
-
|
|
42
|
-
Retire this behavior.
|
|
43
|
-
`;
|
|
44
|
-
const removal = "## REMOVED Requirements\n\n### Requirement: Removed\n\nRetired by this change.\n";
|
|
45
|
-
const modification = "## MODIFIED Requirements\n\n### Requirement: Retained\n\nKeep the revised behavior.\n";
|
|
46
|
-
const addition = "## ADDED Requirements\n\n### Requirement: Added\n\nAdd this behavior.\n";
|
|
47
|
-
|
|
48
|
-
// Existing helpers deliberately reject replay; they do not infer historical ownership.
|
|
49
|
-
// Explicit pending inputs below demonstrate composition after instruction-level reconciliation.
|
|
50
|
-
test("an already-applied removal is preserved without reapplying it", () => {
|
|
51
|
-
const synced = applyDeltaSpec(original, removal);
|
|
52
|
-
assert.throws(() => applyDeltaSpec(synced, removal), /Missing canonical requirement.*REMOVED/);
|
|
53
|
-
const unchanged = applyDeltaSpec(synced, "");
|
|
54
|
-
assert.equal(unchanged, synced);
|
|
55
|
-
assert.deepEqual(parseRequirementBlocks(unchanged).map((block) => block.name), ["Retained"]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("unapplied missing removal cannot become a successful helper operation", () => {
|
|
59
|
-
const neverExisted = removal.replaceAll("Removed", "Never existed");
|
|
60
|
-
assert.throws(() => applyDeltaSpec(original, neverExisted), /Missing canonical requirement.*Never existed/);
|
|
61
|
-
assert.match(original, /### Requirement: Removed/);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("mixed prior removal and pending modification/addition compose without duplicating prior effects", () => {
|
|
65
|
-
const partiallySynced = applyDeltaSpec(original, removal);
|
|
66
|
-
const resumed = applyDeltaSpec(partiallySynced, `${modification}\n${addition}`);
|
|
67
|
-
const uninterrupted = applyDeltaSpec(original, `${removal}\n${modification}\n${addition}`);
|
|
68
|
-
assert.equal(resumed, uninterrupted);
|
|
69
|
-
assert.deepEqual(parseRequirementBlocks(resumed).map((block) => block.name), ["Retained", "Added"]);
|
|
70
|
-
assert.throws(() => applyDeltaSpec(resumed, addition), /Cannot add existing canonical requirement/);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("canonical content comparison distinguishes matching effects from later drift", () => {
|
|
74
|
-
const synced = applyDeltaSpec(original, modification);
|
|
75
|
-
const intended = parseRequirementBlocks(modification)[0].content;
|
|
76
|
-
assert.equal(parseRequirementBlocks(synced)[0].content, intended);
|
|
77
|
-
const drifted = synced.replace("Keep the revised behavior.", "A later change owns this behavior.");
|
|
78
|
-
assert.notEqual(parseRequirementBlocks(drifted)[0].content, intended);
|
|
79
|
-
// The helper is not a drift/consent authority: the executor must stop before calling it.
|
|
80
|
-
assert.match(drifted, /A later change owns this behavior/);
|
|
81
|
-
assert.match(applyDeltaSpec(drifted, modification), /Keep the revised behavior/);
|
|
82
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import test from "node:test";
|
|
6
|
-
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
|
|
8
|
-
import type { NativeReviewCli } from "../lib/native-review-cli.ts";
|
|
9
|
-
import { ensureSddPreflight } from "../lib/sdd-preflight.ts";
|
|
10
|
-
|
|
11
|
-
type Hook = (event: unknown, ctx: ExtensionContext) => Promise<{ systemPrompt: string }>;
|
|
12
|
-
|
|
13
|
-
for (const store of ["openspec", "engram", "hybrid"] as const) {
|
|
14
|
-
for (const selected of [true, false]) {
|
|
15
|
-
test(`classical startup preserves native archive and admits optional verify (store=${store}, selected=${selected})`, async (t) => {
|
|
16
|
-
const root = realpathSync(mkdtempSync(join(tmpdir(), "pi-classical-")));
|
|
17
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
18
|
-
const status = {
|
|
19
|
-
schemaName: "gentle-ai.sdd-status", schemaVersion: 2, changeName: "alpha", artifactStore: store,
|
|
20
|
-
planningHome: { mode: "repo-local", path: store === "openspec" ? join(root, "openspec") : "engram:sdd" }, changeRoot: store === "openspec" ? join(root, "openspec/changes/alpha") : null,
|
|
21
|
-
actionContext: { mode: "repo-local", workspaceRoot: root, allowedEditRoots: [root] },
|
|
22
|
-
dependencies: { proposal: "all_done", specs: "all_done", design: "all_done", tasks: "all_done", apply: "all_done", verify: "ready", archive: "ready" },
|
|
23
|
-
phaseInstructions: { apply: [], verify: ["Optional functional verification."], archive: ["Compose applicable specs and archive." ] },
|
|
24
|
-
blockedReasons: [] as string[], nextRecommended: "archive",
|
|
25
|
-
};
|
|
26
|
-
let phase = "verify";
|
|
27
|
-
let reply: unknown = status;
|
|
28
|
-
const hooks = new Map<string, Hook>();
|
|
29
|
-
const pi = {
|
|
30
|
-
on(name: string, hook: Hook) { hooks.set(name, hook); }, events: { emit() {} }, registerCommand() {}, registerTool() {},
|
|
31
|
-
getFlag: () => selected ? JSON.stringify({ changeName: "alpha", workspaceRoot: root, phase }) : undefined,
|
|
32
|
-
getActiveTools: () => [],
|
|
33
|
-
} as unknown as ExtensionAPI;
|
|
34
|
-
const ctx = { cwd: root, hasUI: false, sessionManager: { getSessionId: () => root } } as unknown as ExtensionContext;
|
|
35
|
-
await ensureSddPreflight(ctx, { pi, installAssets: () => ({ agents: 0, chains: 0, support: 0, skipped: 0 }) });
|
|
36
|
-
createGentleAiExtension({ nativeReviewCli: { sddStatus: async () => reply } as unknown as NativeReviewCli, processEnv: {} })(pi);
|
|
37
|
-
const start = () => hooks.get("before_agent_start")!({ agentName: `sdd-${phase}`, systemPrompt: `SDD ${phase} executor` }, ctx);
|
|
38
|
-
for (const next of ["verify", "archive"]) {
|
|
39
|
-
phase = next;
|
|
40
|
-
await t.test(`explicit ${next}`, async () => {
|
|
41
|
-
const result = await start();
|
|
42
|
-
assert.doesNotMatch(result.systemPrompt, /SDD selection blocked:/);
|
|
43
|
-
assert.ok(result.systemPrompt.includes(JSON.stringify(status, null, 2)), "never rewrite the native recommended action");
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
phase = "verify";
|
|
47
|
-
reply = { ...status, nextRecommended: "apply", dependencies: { ...status.dependencies, apply: "ready" } };
|
|
48
|
-
await t.test("partial verification", async () => {
|
|
49
|
-
assert.doesNotMatch((await start()).systemPrompt, /SDD selection blocked:/, "explicit partial verification preserves native apply selection");
|
|
50
|
-
});
|
|
51
|
-
reply = { ...status, dependencies: { ...status.dependencies, verify: "blocked" } };
|
|
52
|
-
assert.match((await start()).systemPrompt, /SDD selection blocked:/);
|
|
53
|
-
phase = "archive";
|
|
54
|
-
for (const blocked of [
|
|
55
|
-
{ ...status, nextRecommended: "apply", dependencies: { ...status.dependencies, apply: "ready", archive: "blocked" } },
|
|
56
|
-
{ ...status, blockedReasons: ["edit authority missing"] },
|
|
57
|
-
{ ...status, dependencies: { ...status.dependencies, archive: "blocked" } },
|
|
58
|
-
{ ...status, nextRecommended: "verify" },
|
|
59
|
-
]) {
|
|
60
|
-
reply = blocked;
|
|
61
|
-
assert.match((await start()).systemPrompt, /SDD selection blocked:/);
|
|
62
|
-
}
|
|
63
|
-
phase = "sync";
|
|
64
|
-
reply = status;
|
|
65
|
-
await t.test("stale sync is mechanically blocked", async () => {
|
|
66
|
-
assert.match((await start()).systemPrompt, /SDD selection blocked:/, "stale sync executors must not bypass native authority");
|
|
67
|
-
const callTool = hooks.get("tool_call")! as unknown as (event: unknown, ctx: ExtensionContext) => Promise<{ block?: boolean }>;
|
|
68
|
-
for (const toolName of ["write", "edit", "bash"]) {
|
|
69
|
-
assert.equal((await callTool({ toolName, input: { path: "unsafe.ts", command: "echo unsafe" } }, ctx))?.block, true);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
|
|
5
|
-
const guidancePaths = [
|
|
6
|
-
"assets/support/sdd-status-contract.md",
|
|
7
|
-
"assets/sdd-orchestrator-workflow.md",
|
|
8
|
-
"assets/agents/sdd-status.md",
|
|
9
|
-
"assets/agents/sdd-verify.md",
|
|
10
|
-
"assets/agents/sdd-archive.md",
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
for (const path of guidancePaths) {
|
|
14
|
-
test(`${path}: native v2 status remains read-only and authoritative`, () => {
|
|
15
|
-
const guidance = readFileSync(new URL(`../${path}`, import.meta.url), "utf8");
|
|
16
|
-
assert.match(guidance, /native.*(?:status|v2)|gentle-ai\.sdd-status/i);
|
|
17
|
-
assert.match(guidance, /read-only/i);
|
|
18
|
-
assert.doesNotMatch(guidance, /resolve-via-engram/i);
|
|
19
|
-
assert.doesNotMatch(guidance, /local SDD status engine|manual (?:fallback )?status|reconstruct(?:ing)? (?:native )?status/i);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
test("workflow preserves explicit continuation and native-only classical completion", () => {
|
|
24
|
-
const workflow = readFileSync(new URL("../assets/sdd-orchestrator-workflow.md", import.meta.url), "utf8");
|
|
25
|
-
assert.match(workflow, /only.*sdd-continue|sdd-continue.*only/i);
|
|
26
|
-
assert.doesNotMatch(workflow, /manual sdd-sync|local resolver/i);
|
|
27
|
-
assert.match(workflow, /verification is optional/);
|
|
28
|
-
assert.doesNotMatch(workflow, /sdd-(?:apply|verify|archive).*local|local.*sdd-(?:apply|verify|archive)/i);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("archive owns composition without mandatory verification or a standalone sync receipt", () => {
|
|
32
|
-
const archive = readFileSync(new URL("../assets/agents/sdd-archive.md", import.meta.url), "utf8");
|
|
33
|
-
const full = readFileSync(new URL("../assets/chains/sdd-full.chain.md", import.meta.url), "utf8");
|
|
34
|
-
assert.doesNotMatch(full, /^## sdd-(verify|sync)$/m);
|
|
35
|
-
assert.match(full, /apply -> archive/);
|
|
36
|
-
assert.match(archive, /missing optional report is not a blocker/);
|
|
37
|
-
assert.match(archive, /no separate sync phase or successful sync-report artifact is required/);
|
|
38
|
-
for (const guard of ["Final Task Completion Gate", "allowed edit roots", "resolved symlink targets", "existing archive destination",
|
|
39
|
-
"ADDED Requirements", "MODIFIED Requirements", "REMOVED Requirements", "RENAMED Requirements",
|
|
40
|
-
"explicit composition/archive order", "explicit approval for the destructive sync", "dependsOn", "rules.sync",
|
|
41
|
-
"archive-report", "observation-ID traceability", "Preserve every canonical requirement not mentioned by the delta"]) {
|
|
42
|
-
assert.ok(archive.includes(guard), `archive retains ${guard}`);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { parseRemediationPlan, type RemediationPlan, type RemediationScope } from "../lib/agents-runner.ts";
|
|
5
|
-
|
|
6
|
-
const testCwd = process.cwd();
|
|
7
|
-
const shellScope = (cwd: string, commands: string[]): RemediationScope => ({ cwd, commands, editPaths: [], allowedEditRoots: [cwd] });
|
|
8
|
-
const plan: RemediationPlan = { cwd: testCwd, commands: ["pnpm test"], runtimeHarness: { naReason: "Not applicable because this correction changes only static assets." }, rollback: { boundary: "Revert the changed asset and paired test", command: "git diff --check" } };
|
|
9
|
-
|
|
10
|
-
test("remediation plan is bounded and cannot select another working directory", () => {
|
|
11
|
-
assert.throws(() => parseRemediationPlan({ ...plan, cwd: "/other" }, testCwd), /plan/);
|
|
12
|
-
assert.throws(() => parseRemediationPlan({ ...plan, commands: [] }, testCwd), /plan/);
|
|
13
|
-
assert.throws(() => parseRemediationPlan({ ...plan, runtimeHarness: { naReason: "N/A" } }, testCwd), /plan/);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
test("remediation shell captures numeric exit, preserves stock errors and executes once", async () => {
|
|
18
|
-
const { remediationBash } = await import("../extensions/gentle-agents.ts");
|
|
19
|
-
for (const exitCode of [0, 7, null]) {
|
|
20
|
-
let calls = 0;
|
|
21
|
-
const shell = remediationBash(testCwd, { exec: async (command, cwd, options) => {
|
|
22
|
-
calls++; assert.equal(command, "pnpm test"); assert.equal(cwd, testCwd);
|
|
23
|
-
options.onData(Buffer.from("real output")); return { exitCode };
|
|
24
|
-
} }, shellScope(testCwd, ["pnpm test"]));
|
|
25
|
-
const run = shell.definition.execute("call", { command: "pnpm test" }, undefined, undefined, undefined);
|
|
26
|
-
if (exitCode === 7) await assert.rejects(run, /code 7/); else await run;
|
|
27
|
-
const patch = shell.result({ toolCallId: "call", details: { fullOutputPath: "/retained", remediationCommand: { exitCode: 99 } } } as unknown as Parameters<typeof shell.result>[0]);
|
|
28
|
-
const details = patch.details as typeof patch.details & { fullOutputPath?: string };
|
|
29
|
-
assert.equal(details.remediationCommand.exitCode, exitCode);
|
|
30
|
-
assert.equal(details.remediationCommand.command, "pnpm test");
|
|
31
|
-
assert.equal(details.remediationCommand.cwd, testCwd);
|
|
32
|
-
assert.equal(details.fullOutputPath, "/retained");
|
|
33
|
-
assert.equal(shell.result({ toolCallId: "call" }), undefined);
|
|
34
|
-
assert.equal(calls, 1);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
test("remediation owner and packaged actor are installed through existing ownership", async () => {
|
|
40
|
-
const { getPackageAssetOwner } = await import("../lib/sdd-preflight.ts");
|
|
41
|
-
const { readFileSync } = await import("node:fs");
|
|
42
|
-
assert.equal(getPackageAssetOwner("agents/sdd-remediate.md"), "sdd");
|
|
43
|
-
assert.match(readFileSync("assets/agents/sdd-remediate.md", "utf8"), /SDD remediate executor/);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
test("stock local shell wrapper observes real exit zero and preserves cancellation", async () => {
|
|
48
|
-
const { remediationBash } = await import("../extensions/gentle-agents.ts");
|
|
49
|
-
const { createBashToolDefinition } = await import("@earendil-works/pi-coding-agent");
|
|
50
|
-
const shell = remediationBash(process.cwd(), undefined, shellScope(process.cwd(), ["printf wrapper-proof", "sleep 30"]));
|
|
51
|
-
assert.deepEqual(shell.definition.parameters, createBashToolDefinition(process.cwd()).parameters);
|
|
52
|
-
const result = await shell.definition.execute("real", { command: "printf wrapper-proof" }, undefined, undefined, undefined);
|
|
53
|
-
const [content] = result.content;
|
|
54
|
-
assert.ok(content?.type === "text");
|
|
55
|
-
assert.equal(content.text, "wrapper-proof");
|
|
56
|
-
assert.equal(shell.result({ toolCallId: "real", details: result.details }).details.remediationCommand.exitCode, 0);
|
|
57
|
-
const controller = new AbortController();
|
|
58
|
-
const timeout = setTimeout(() => controller.abort(), 30);
|
|
59
|
-
try { await assert.rejects(shell.definition.execute("cancel", { command: "sleep 30" }, controller.signal, undefined, undefined), /aborted/); }
|
|
60
|
-
finally { clearTimeout(timeout); controller.abort(); }
|
|
61
|
-
assert.equal(shell.result({ toolCallId: "cancel" }), undefined);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
test("remediation actor preserves separately authorized memory artifact tools", async () => {
|
|
67
|
-
const { parseAgentDefinition } = await import("../lib/agents-config.ts");
|
|
68
|
-
const { readFileSync } = await import("node:fs");
|
|
69
|
-
const agent = parseAgentDefinition(readFileSync("assets/agents/sdd-remediate.md", "utf8"), "/agents/sdd-remediate.md", "global");
|
|
70
|
-
assert.ok("instructions" in agent);
|
|
71
|
-
for (const tool of ["mem_search", "mem_get_observation", "mem_save", "mem_update"]) assert.ok(agent.tools.includes(tool), tool);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
test("R1 confirms exact canonical paths and commands; data, denial and symlinks grant nothing", async t => {
|
|
77
|
-
const { confirmRemediationScope, remediationToolAllowed } = await import("../extensions/gentle-agents.ts");
|
|
78
|
-
const { mkdtempSync, realpathSync, writeFileSync, symlinkSync, rmSync } = await import("node:fs");
|
|
79
|
-
const { tmpdir } = await import("node:os"); const { join } = await import("node:path");
|
|
80
|
-
const cwd = realpathSync(mkdtempSync(join(tmpdir(), "remediation-scope-"))); t.after(() => rmSync(cwd, { recursive: true, force: true }));
|
|
81
|
-
const target = join(cwd, "allowed.ts"); writeFileSync(target, "original"); symlinkSync(target, join(cwd, "alias.ts"));
|
|
82
|
-
const candidate = { ...plan, cwd, editPaths: [target] }, native = { mode: "repo-local", workspaceRoot: cwd, allowedEditRoots: [cwd] };
|
|
83
|
-
let shown = "", confirmations = 0;
|
|
84
|
-
const ui = { hasUI: true, ui: { confirm: async (_title: string, text: string) => { shown = text; confirmations++; return true; } } } as unknown as Pick<ExtensionContext, "hasUI" | "ui">;
|
|
85
|
-
const scope = await confirmRemediationScope(candidate, native, ui);
|
|
86
|
-
assert.match(shown, /pnpm test/); assert.ok(shown.includes(target)); assert.ok(shown.includes(cwd));
|
|
87
|
-
assert.equal(remediationToolAllowed(scope, cwd, "write", { path: target }), true);
|
|
88
|
-
for (const tool of ["mem_search", "mem_get_observation", "mem_save", "mem_update"]) assert.equal(remediationToolAllowed(scope, cwd, tool, { id: 7, project: "other", content: "outside" }), false);
|
|
89
|
-
assert.equal(remediationToolAllowed(scope, cwd, "write", { path: join(cwd, "other.ts") }), false);
|
|
90
|
-
assert.equal(remediationToolAllowed(scope, cwd, "bash", { command: "pnpm test; touch outside" }), false);
|
|
91
|
-
for (const bad of [{ ...candidate, editPaths: [join(cwd, "alias.ts")] }, { ...candidate, editPaths: [cwd] }, { ...candidate, editPaths: [target, target] }]) await assert.rejects(confirmRemediationScope(bad, native, ui));
|
|
92
|
-
assert.equal(confirmations, 1);
|
|
93
|
-
for (const context of [undefined, { hasUI: false, ui: ui.ui }, { hasUI: true, ui: { confirm: async () => false } }, { hasUI: true, ui: { confirm: async () => undefined } }]) await assert.rejects(confirmRemediationScope(candidate, native, context as unknown as Pick<ExtensionContext, "hasUI" | "ui">), /authorization/);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
test("R1 child invokes only the exact confirmed command/cwd/count with distinct call IDs", async () => {
|
|
99
|
-
const { remediationBash } = await import("../extensions/gentle-agents.ts");
|
|
100
|
-
let executions = 0;
|
|
101
|
-
const shell = remediationBash(testCwd, { exec: async () => { executions++; return { exitCode: 0 }; } }, shellScope(testCwd, ["pnpm test", "pnpm test"]));
|
|
102
|
-
const execute = (id: string, command: string, cwd = testCwd) => shell.definition.execute(id, { command }, undefined, undefined, cwd === testCwd ? undefined : { cwd } as unknown as ExtensionContext);
|
|
103
|
-
await assert.rejects(execute("outside", "pnpm test; touch outside"), /authorization/);
|
|
104
|
-
await assert.rejects(execute("cwd", "pnpm test", "/other"), /authorization/);
|
|
105
|
-
assert.equal(executions, 0);
|
|
106
|
-
await execute("one", "pnpm test"); await assert.rejects(execute("one", "pnpm test"), /authorization/);
|
|
107
|
-
await execute("two", "pnpm test"); await assert.rejects(execute("three", "pnpm test"), /authorization/);
|
|
108
|
-
assert.equal(executions, 2);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test("remediation actor explains one-launch human authority and indexed command evidence", async () => {
|
|
112
|
-
const { readFileSync } = await import("node:fs");
|
|
113
|
-
const text = readFileSync("assets/agents/sdd-remediate.md", "utf8");
|
|
114
|
-
assert.match(text, /fresh host UI confirmation/); assert.match(text, /each repeated command.*separate execution/);
|
|
115
|
-
assert.match(text, /Inspect prior task\/artifact history/);
|
|
116
|
-
assert.match(text, /No attempt-ledger command is required/);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Runs only in the explicit producer verification lane; no default-suite skip is added.
|
|
121
|
-
if (process.env.SDD_TEST_PRODUCER) test("real native selection admits only its own remediation route without attempt subprocesses", async (t) => {
|
|
122
|
-
const { execFileSync } = await import("node:child_process");
|
|
123
|
-
const { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, realpathSync } = await import("node:fs");
|
|
124
|
-
const { tmpdir } = await import("node:os");
|
|
125
|
-
const { join, resolve } = await import("node:path");
|
|
126
|
-
const { NativeReviewCliV216, createNodeExecFileAdapter } = await import("../lib/native-review-cli.ts");
|
|
127
|
-
const { admitManagedRemediation } = await import("../extensions/gentle-agents.ts");
|
|
128
|
-
const { parseAgentDefinition } = await import("../lib/agents-config.ts");
|
|
129
|
-
const cwd = realpathSync(mkdtempSync(join(tmpdir(), "no-attempt-producer-")));
|
|
130
|
-
t.after(() => rmSync(cwd, { recursive: true, force: true }));
|
|
131
|
-
execFileSync("git", ["init", "--quiet", cwd]);
|
|
132
|
-
const change = join(cwd, "openspec/changes/fix");
|
|
133
|
-
mkdirSync(join(change, "specs/example"), { recursive: true });
|
|
134
|
-
for (const [path, bytes] of Object.entries({ "proposal.md": "# Proposal\n", "design.md": "# Design\n", "specs/example/spec.md": "# Spec\n", "tasks.md": "- [x] Fixture complete\n" })) writeFileSync(join(change, path), bytes);
|
|
135
|
-
const revision = `sha256:${"a".repeat(64)}`;
|
|
136
|
-
writeFileSync(join(change, "verify-report.md"), ["```yaml", "schema: gentle-ai.verify-result/v1", `evidence_revision: ${revision}`, "verdict: fail", "blockers: 1", "critical_findings: 0", "requirements: 1/1", "scenarios: 1/1", "test_command: false", "test_exit_code: 1", `test_output_hash: sha256:${"b".repeat(64)}`, "build_command: true", "build_exit_code: 0", `build_output_hash: sha256:${"b".repeat(64)}`, "```"].join("\n"));
|
|
137
|
-
const invocations: string[] = [], adapter = createNodeExecFileAdapter();
|
|
138
|
-
const native = new NativeReviewCliV216(async (request) => { invocations.push(request.arguments[0]!); return adapter(request); }, process.env.SDD_TEST_PRODUCER!);
|
|
139
|
-
const status = await native.sddStatus({ workspaceRoot: cwd, changeName: "fix" });
|
|
140
|
-
const path = resolve("assets/agents/sdd-remediate.md"), agent = parseAgentDefinition(readFileSync(path, "utf8"), path, "global");
|
|
141
|
-
assert.ok("instructions" in agent);
|
|
142
|
-
let confirmations = 0;
|
|
143
|
-
const context = { hasUI: true, ui: { confirm: async () => { confirmations++; return true; } } } as unknown as Pick<ExtensionContext, "hasUI" | "ui">;
|
|
144
|
-
const request = { agent, cwd, sddChange: { changeName: "fix", workspaceRoot: cwd, phase: "remediate", failedEvidenceRevision: revision } } as import("../lib/agents-runner.ts").TaskRequest;
|
|
145
|
-
const admission = admitManagedRemediation(request, { plan: { ...plan, cwd } }, native, context);
|
|
146
|
-
if (status.nextRecommended === "remediate") {
|
|
147
|
-
const admitted = await admission;
|
|
148
|
-
assert.equal(admitted.sddRemediation?.failedEvidenceRevision, revision);
|
|
149
|
-
assert.equal(confirmations, 1);
|
|
150
|
-
} else {
|
|
151
|
-
await assert.rejects(admission, /Stale remediation selection/);
|
|
152
|
-
assert.equal(confirmations, 0, "a classical provider is not assigned a fabricated remediation route");
|
|
153
|
-
}
|
|
154
|
-
assert.deepEqual(invocations, ["sdd-status", "sdd-status"]);
|
|
155
|
-
});
|