diffpact 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +19 -10
- package/bin/diffpact.mjs +5 -0
- package/dist/adapters/claude-code.d.ts +21 -0
- package/dist/adapters/codex.d.ts +31 -0
- package/dist/adapters/gemini-agy.d.ts +26 -0
- package/dist/adapters/vercel-board.d.ts +30 -0
- package/dist/amend.d.ts +46 -0
- package/dist/amend.js +9 -3
- package/dist/boundaries.d.ts +43 -0
- package/dist/canonical-json.d.ts +6 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +395 -124
- package/dist/delegate.d.ts +22 -0
- package/dist/doctor.d.ts +36 -0
- package/dist/git.d.ts +27 -0
- package/dist/git.js +15 -0
- package/dist/index.d.ts +19 -0
- package/dist/merge-verify.d.ts +31 -0
- package/dist/report.d.ts +25 -0
- package/dist/report.js +1 -1
- package/dist/review.d.ts +46 -0
- package/dist/runner.d.ts +45 -0
- package/dist/schema.d.ts +6 -0
- package/dist/types.d.ts +190 -0
- package/dist/verify.d.ts +45 -0
- package/dist/worktree.d.ts +82 -0
- package/package.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ExitCode, type SessionIdentity, type TaskContractV01 } from './types.ts';
|
|
2
|
+
export interface DelegateOptions {
|
|
3
|
+
parentContractPath: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
subtaskId: string;
|
|
6
|
+
mission: string;
|
|
7
|
+
allowedPaths: string[];
|
|
8
|
+
reservedBudgetUsd?: number;
|
|
9
|
+
implementer: SessionIdentity;
|
|
10
|
+
branch?: string;
|
|
11
|
+
worktreePath?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a monotonically narrowed child subcontract under `.diffpact/subcontracts/<subtaskId>.json`,
|
|
15
|
+
* enforcing path subset containment, depth bounds, and shared root budget conservation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createDelegatedSubcontract(options: DelegateOptions): {
|
|
18
|
+
exitCode: ExitCode;
|
|
19
|
+
subcontractPath?: string;
|
|
20
|
+
subcontract?: TaskContractV01;
|
|
21
|
+
error?: string;
|
|
22
|
+
};
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ProbedHarnessId = 'claude-code' | 'codex' | 'crush' | 'agy' | 'agy-worker' | 'gemini-cli' | 'vercel-board' | 'vercel-cli';
|
|
2
|
+
export interface HarnessProbeResult {
|
|
3
|
+
id: ProbedHarnessId;
|
|
4
|
+
binary: string;
|
|
5
|
+
installed: boolean;
|
|
6
|
+
resolvedPath?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DoctorReport {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
nodeVersion: string;
|
|
12
|
+
gitAvailable: boolean;
|
|
13
|
+
insideGitRepo: boolean;
|
|
14
|
+
repoRoot?: string;
|
|
15
|
+
workingTreeClean?: boolean;
|
|
16
|
+
diffpactExcludedInGit?: boolean;
|
|
17
|
+
runningAsRoot: boolean;
|
|
18
|
+
harnesses: HarnessProbeResult[];
|
|
19
|
+
warnings: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface InstallHooksOptions {
|
|
22
|
+
target: 'claude-code' | 'codex' | 'gemini' | 'agy';
|
|
23
|
+
contractPath?: string;
|
|
24
|
+
cwd?: string;
|
|
25
|
+
excludeInGitInfo?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function runDoctor(options?: {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
env?: NodeJS.ProcessEnv;
|
|
30
|
+
isRoot?: boolean;
|
|
31
|
+
}): DoctorReport;
|
|
32
|
+
export declare function installHarnessHooks(options: InstallHooksOptions): {
|
|
33
|
+
configPath: string;
|
|
34
|
+
created: boolean;
|
|
35
|
+
merged: boolean;
|
|
36
|
+
};
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChangedFileEntry } from './types.ts';
|
|
2
|
+
export declare function runGitBuffer(cwd: string, args: readonly string[]): Buffer;
|
|
3
|
+
export declare function runGitText(cwd: string, args: readonly string[]): string;
|
|
4
|
+
export declare function resolveRepoRoot(cwd: string): string;
|
|
5
|
+
export declare function resolveHeadSha(cwd: string): string;
|
|
6
|
+
export declare function resolveCurrentBranch(cwd: string): string;
|
|
7
|
+
export declare function ensureGitInfoExclude(cwd: string, entry?: string): void;
|
|
8
|
+
export declare function commitExists(cwd: string, sha: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a full SHA, abbreviated short SHA (e.g. 7 chars), or Git ref (e.g. HEAD~1, main)
|
|
11
|
+
* to its canonical 40-character lowercase commit SHA-1, or returns null if unresolvable.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveCommitSha(cwd: string, refOrSha: string): string | null;
|
|
14
|
+
export declare function isAncestor(cwd: string, ancestorSha: string, descendantSha: string): boolean;
|
|
15
|
+
export interface RepoChangeSnapshot {
|
|
16
|
+
changedFiles: ChangedFileEntry[];
|
|
17
|
+
untrackedFiles: string[];
|
|
18
|
+
workingTreeClean: boolean;
|
|
19
|
+
trackedTreeClean: boolean;
|
|
20
|
+
rawDiffSha256: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Collects all file changes between `startingSha` and the current repository state
|
|
24
|
+
* (`startingSha..HEAD`, staged changes, unstaged changes, and untracked files),
|
|
25
|
+
* excluding internal `.diffpact/` state files from dirty-worktree accounting.
|
|
26
|
+
*/
|
|
27
|
+
export declare function collectRepoChanges(repoRoot: string, startingSha: string, headSha: string): RepoChangeSnapshot;
|
package/dist/git.js
CHANGED
|
@@ -52,6 +52,21 @@ export function commitExists(cwd , sha ) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Resolves a full SHA, abbreviated short SHA (e.g. 7 chars), or Git ref (e.g. HEAD~1, main)
|
|
57
|
+
* to its canonical 40-character lowercase commit SHA-1, or returns null if unresolvable.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveCommitSha(cwd , refOrSha ) {
|
|
60
|
+
const trimmed = refOrSha.trim();
|
|
61
|
+
if (!trimmed || trimmed.includes('\0') || trimmed.startsWith('-')) return null;
|
|
62
|
+
try {
|
|
63
|
+
const resolved = runGitText(cwd, ['rev-parse', '--verify', '--quiet', `${trimmed}^{commit}`]).trim();
|
|
64
|
+
return /^[0-9a-f]{40}$/.test(resolved) ? resolved : null;
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
55
70
|
export function isAncestor(cwd , ancestorSha , descendantSha ) {
|
|
56
71
|
try {
|
|
57
72
|
runGitBuffer(cwd, ['merge-base', '--is-ancestor', ancestorSha, descendantSha]);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './types.ts';
|
|
2
|
+
export * from './canonical-json.ts';
|
|
3
|
+
export * from './schema.ts';
|
|
4
|
+
export * from './boundaries.ts';
|
|
5
|
+
export * from './git.ts';
|
|
6
|
+
export * from './verify.ts';
|
|
7
|
+
export * from './merge-verify.ts';
|
|
8
|
+
export * from './review.ts';
|
|
9
|
+
export * from './delegate.ts';
|
|
10
|
+
export * from './amend.ts';
|
|
11
|
+
export * from './doctor.ts';
|
|
12
|
+
export * from './report.ts';
|
|
13
|
+
export * from './worktree.ts';
|
|
14
|
+
export * from './runner.ts';
|
|
15
|
+
export * from './adapters/claude-code.ts';
|
|
16
|
+
export * from './adapters/codex.ts';
|
|
17
|
+
export * from './adapters/gemini-agy.ts';
|
|
18
|
+
export * from './adapters/vercel-board.ts';
|
|
19
|
+
export * from './cli.ts';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ExitCode, type MergeVerificationReceiptV01 } from './types.ts';
|
|
2
|
+
export interface MergeVerifyOptions {
|
|
3
|
+
fromPaths: string[];
|
|
4
|
+
cwd?: string;
|
|
5
|
+
baseSha?: string;
|
|
6
|
+
allowIntegrationPaths?: string[];
|
|
7
|
+
integrationReason?: string;
|
|
8
|
+
allowUntracked?: boolean;
|
|
9
|
+
writeReceipt?: boolean;
|
|
10
|
+
receiptPath?: string;
|
|
11
|
+
shellPath?: string;
|
|
12
|
+
heartbeatSec?: number;
|
|
13
|
+
onHeartbeat?: (message: string) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface MergeVerifyResult {
|
|
16
|
+
exitCode: ExitCode;
|
|
17
|
+
receipt?: MergeVerificationReceiptV01;
|
|
18
|
+
receiptPath?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function resolveSourceContractPath(inputPath: string, cwd: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Post-merge verification gate across two or more merged task contracts (or archived
|
|
24
|
+
* `.diffpact/archive/...` bundles). Verifies that:
|
|
25
|
+
* 1. The merged working tree is clean and every changed file since `base_sha` is authorized
|
|
26
|
+
* by at least one participating contract (catching unauthorized conflict-resolution edits).
|
|
27
|
+
* 2. The deduplicated UNION of all contracts' `required_checks`, `version_assertions`, and
|
|
28
|
+
* `interfacedelta_lockfile` pins passes on the joined tree (with No Silent Zero enforcement).
|
|
29
|
+
* 3. A canonical SHA-256 signed `merge-receipt.json` is written durably under `.diffpact/merges/`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runMergeVerify(options: MergeVerifyOptions): Promise<MergeVerifyResult>;
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExitCode } from './types.ts';
|
|
2
|
+
export type LedgerEventKind = 'verify' | 'review' | 'amend' | 'delegate' | 'status';
|
|
3
|
+
export interface LedgerEventRecord {
|
|
4
|
+
timestamp: string;
|
|
5
|
+
kind: LedgerEventKind;
|
|
6
|
+
task_id: string;
|
|
7
|
+
exit_code: ExitCode;
|
|
8
|
+
summary: string;
|
|
9
|
+
artifact_sha256?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ReportOptions {
|
|
12
|
+
contractPath: string;
|
|
13
|
+
cwd?: string;
|
|
14
|
+
format: 'markdown' | 'json' | 'sarif';
|
|
15
|
+
}
|
|
16
|
+
export declare function appendLedgerEvent(contractPath: string, event: Omit<LedgerEventRecord, 'timestamp'> & {
|
|
17
|
+
timestamp?: string;
|
|
18
|
+
}, cwd?: string): LedgerEventRecord;
|
|
19
|
+
export declare function readLedgerEvents(contractPath: string, cwd?: string): LedgerEventRecord[];
|
|
20
|
+
/** Summarize persisted evidence; this does not rerun verification or the live Git status gate. */
|
|
21
|
+
export declare function generateTaskReport(options: ReportOptions): {
|
|
22
|
+
exitCode: ExitCode;
|
|
23
|
+
output: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
package/dist/report.js
CHANGED
|
@@ -149,7 +149,7 @@ export function generateTaskReport(options )
|
|
|
149
149
|
$schema: 'https://json.schemastore.org/sarif-2.1.0.json',
|
|
150
150
|
version: '2.1.0',
|
|
151
151
|
runs: [{
|
|
152
|
-
tool: { driver: { name: 'diffpact', version: '0.4.
|
|
152
|
+
tool: { driver: { name: 'diffpact', version: '0.4.3', rules: ruleIds.map((id) => ({ id })) } },
|
|
153
153
|
results: violations.map((v) => ({
|
|
154
154
|
ruleId: v.code,
|
|
155
155
|
level: exitCode === 1 ? 'error' : 'warning',
|
package/dist/review.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ExitCode, type ReviewAttestationMode, type ReviewAttestationV01, type SessionIdentity } from './types.ts';
|
|
2
|
+
export declare function computeReviewHmac(reviewSha256: string, secret: string): string;
|
|
3
|
+
export interface ReviewOptions {
|
|
4
|
+
contractPath: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
reviewer: SessionIdentity;
|
|
7
|
+
verdict: 'approve' | 'reject';
|
|
8
|
+
summary: string;
|
|
9
|
+
findings?: string[];
|
|
10
|
+
inspectedRawDiff?: boolean;
|
|
11
|
+
expectedRawDiffSha256?: string;
|
|
12
|
+
attestationMode?: ReviewAttestationMode;
|
|
13
|
+
reviewerSecret?: string;
|
|
14
|
+
evidenceLineageId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function runReview(options: ReviewOptions): {
|
|
17
|
+
exitCode: ExitCode;
|
|
18
|
+
review?: ReviewAttestationV01;
|
|
19
|
+
error?: string;
|
|
20
|
+
};
|
|
21
|
+
export interface StatusCheckOptions {
|
|
22
|
+
contractPath: string;
|
|
23
|
+
cwd?: string;
|
|
24
|
+
requireReview?: boolean;
|
|
25
|
+
integratorAgentId?: string;
|
|
26
|
+
reviewerSecret?: string;
|
|
27
|
+
}
|
|
28
|
+
export type ReviewStatusKind = 'approved' | 'missing' | 'stale' | 'rejected' | 'incomplete' | 'invalid';
|
|
29
|
+
export interface StatusReport {
|
|
30
|
+
exit_code: ExitCode;
|
|
31
|
+
status: 'pass' | 'violation' | 'incomplete' | 'stale';
|
|
32
|
+
reason: string;
|
|
33
|
+
task_id?: string;
|
|
34
|
+
candidate_sha?: string;
|
|
35
|
+
contract_sha256?: string;
|
|
36
|
+
receipt_sha256?: string;
|
|
37
|
+
review_sha256?: string;
|
|
38
|
+
review_status?: ReviewStatusKind;
|
|
39
|
+
required_reviews?: number;
|
|
40
|
+
valid_reviews_count?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Fast, stateless read-only gate check against live Git HEAD, receipt, reviews,
|
|
44
|
+
* and optional canonical integrator / role_substitution policy.
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkStatus(options: StatusCheckOptions): StatusReport;
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type DoctorReport } from './doctor.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves external Git metadata directories (`--git-dir` and `--git-common-dir`) that live
|
|
4
|
+
* outside `repoRoot` (e.g. linked Git worktrees) so sandboxed agents like Codex CLI can write
|
|
5
|
+
* `index.lock`, objects, and branch refs cleanly during `git add && git commit`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveExternalGitAddDirs(repoRoot: string): string[];
|
|
8
|
+
export type RunnableHarnessId = 'codex' | 'claude' | 'crush' | 'agy' | 'gemini';
|
|
9
|
+
export interface BuildHarnessCommandOptions {
|
|
10
|
+
harness: RunnableHarnessId;
|
|
11
|
+
repoRoot: string;
|
|
12
|
+
prompt: string;
|
|
13
|
+
model?: string;
|
|
14
|
+
reasoningEffort?: string;
|
|
15
|
+
dataDir?: string;
|
|
16
|
+
isRoot?: boolean;
|
|
17
|
+
doctorReport?: DoctorReport;
|
|
18
|
+
}
|
|
19
|
+
export interface BuiltHarnessCommand {
|
|
20
|
+
harness: RunnableHarnessId;
|
|
21
|
+
bin: string;
|
|
22
|
+
args: string[];
|
|
23
|
+
notes: string[];
|
|
24
|
+
dataDir?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generates a known-good, non-interactive command line for the target agent CLI,
|
|
28
|
+
* accounting for root execution (Claude Code) and modern CLI flags (Codex 0.172+).
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildHarnessCommand(options: BuildHarnessCommandOptions): BuiltHarnessCommand;
|
|
31
|
+
export interface SpawnWithHeartbeatOptions {
|
|
32
|
+
bin: string;
|
|
33
|
+
args: string[];
|
|
34
|
+
cwd: string;
|
|
35
|
+
env: NodeJS.ProcessEnv;
|
|
36
|
+
heartbeatSec: number;
|
|
37
|
+
label: string;
|
|
38
|
+
onHeartbeat?: (message: string) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare function spawnCommandWithHeartbeat(options: SpawnWithHeartbeatOptions): Promise<{
|
|
41
|
+
status: number | null;
|
|
42
|
+
signal: NodeJS.Signals | null;
|
|
43
|
+
error?: Error;
|
|
44
|
+
durationMs: number;
|
|
45
|
+
}>;
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionIdentity, TaskContractV01, VerificationReceiptV01, ReviewAttestationV01 } from './types.ts';
|
|
2
|
+
export declare function assertSafeRelativePath(v: unknown, field: string): string;
|
|
3
|
+
export declare function validateSessionIdentity(v: unknown, ctx: string): SessionIdentity;
|
|
4
|
+
export declare function validateContract(raw: unknown): TaskContractV01;
|
|
5
|
+
export declare function validateReceiptBasic(raw: unknown): VerificationReceiptV01;
|
|
6
|
+
export declare function validateReviewBasic(raw: unknown): ReviewAttestationV01;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export declare const EXIT_PASS = 0;
|
|
2
|
+
export declare const EXIT_VIOLATION = 1;
|
|
3
|
+
export declare const EXIT_INCOMPLETE = 2;
|
|
4
|
+
export declare const EXIT_STALE = 3;
|
|
5
|
+
export type ExitCode = 0 | 1 | 2 | 3;
|
|
6
|
+
export type HarnessKind = 'claude-code' | 'codex' | 'crush' | 'gemini-cli' | 'agy' | 'vercel-board' | 'manual' | 'other';
|
|
7
|
+
export interface SessionIdentity {
|
|
8
|
+
agent_id: string;
|
|
9
|
+
session_id: string;
|
|
10
|
+
harness: HarnessKind;
|
|
11
|
+
model?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface VersionAssertion {
|
|
14
|
+
path: string;
|
|
15
|
+
kind: 'sha256' | 'json_pointer' | 'regex_exact';
|
|
16
|
+
key: string;
|
|
17
|
+
expected: string;
|
|
18
|
+
}
|
|
19
|
+
export interface InterfaceDeltaLockfilePin {
|
|
20
|
+
path: string;
|
|
21
|
+
sha256: string;
|
|
22
|
+
must_remain_unmodified?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface RequiredCheck {
|
|
25
|
+
id: string;
|
|
26
|
+
command: string;
|
|
27
|
+
cwd?: string;
|
|
28
|
+
timeout_sec?: number;
|
|
29
|
+
forbid_skipped?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface WorktreePolicy {
|
|
32
|
+
branch?: string;
|
|
33
|
+
path?: string;
|
|
34
|
+
require_clean_start?: boolean;
|
|
35
|
+
require_clean_end?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface BudgetPolicy {
|
|
38
|
+
max_budget_usd?: number;
|
|
39
|
+
reserved_budget_usd?: number;
|
|
40
|
+
delegation_depth?: number;
|
|
41
|
+
max_delegation_depth?: number;
|
|
42
|
+
parent_contract_sha256?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ReviewPolicy {
|
|
45
|
+
required_reviews?: number;
|
|
46
|
+
require_non_self_certified?: boolean;
|
|
47
|
+
require_distinct_harness?: boolean;
|
|
48
|
+
require_raw_diff_inspection?: boolean;
|
|
49
|
+
canonical_integrator_agent_id?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface RoleSubstitutionGrant {
|
|
52
|
+
substitute_agent_id: string;
|
|
53
|
+
authorized_by: string;
|
|
54
|
+
task_id: string;
|
|
55
|
+
active: boolean;
|
|
56
|
+
spent: boolean;
|
|
57
|
+
reason?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TaskContractV01 {
|
|
60
|
+
schema_version: 'diffpact-contract-v0.1';
|
|
61
|
+
task_id: string;
|
|
62
|
+
task_type: 'coding' | 'research';
|
|
63
|
+
mission: string;
|
|
64
|
+
starting_sha: string;
|
|
65
|
+
candidate_sha?: string | null;
|
|
66
|
+
worktree: WorktreePolicy;
|
|
67
|
+
allowed_paths: string[];
|
|
68
|
+
read_only_paths?: string[];
|
|
69
|
+
forbidden_paths: string[];
|
|
70
|
+
version_assertions?: VersionAssertion[];
|
|
71
|
+
interfacedelta_lockfile?: InterfaceDeltaLockfilePin | null;
|
|
72
|
+
budget?: BudgetPolicy;
|
|
73
|
+
required_checks: RequiredCheck[];
|
|
74
|
+
advisory_checks?: RequiredCheck[];
|
|
75
|
+
allow_no_checks?: boolean;
|
|
76
|
+
allow_no_commit?: boolean;
|
|
77
|
+
implementer_session: SessionIdentity;
|
|
78
|
+
review_policy?: ReviewPolicy;
|
|
79
|
+
role_substitution?: RoleSubstitutionGrant | null;
|
|
80
|
+
}
|
|
81
|
+
export interface ViolationItem {
|
|
82
|
+
code: string;
|
|
83
|
+
message: string;
|
|
84
|
+
path?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ChangedFileEntry {
|
|
87
|
+
status: string;
|
|
88
|
+
path: string;
|
|
89
|
+
old_path?: string;
|
|
90
|
+
is_symlink?: boolean;
|
|
91
|
+
is_submodule?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface CheckRunResult {
|
|
94
|
+
id: string;
|
|
95
|
+
command: string;
|
|
96
|
+
exit_code: number;
|
|
97
|
+
skipped_count: number;
|
|
98
|
+
duration_ms: number;
|
|
99
|
+
stdout_sha256: string;
|
|
100
|
+
stderr_sha256: string;
|
|
101
|
+
timed_out?: boolean;
|
|
102
|
+
spawn_error_code?: string;
|
|
103
|
+
spawn_error_message?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface VerificationReceiptV01 {
|
|
106
|
+
schema_version: 'diffpact-receipt-v0.1';
|
|
107
|
+
receipt_sha256: string;
|
|
108
|
+
contract_sha256: string;
|
|
109
|
+
task_id: string;
|
|
110
|
+
verified_at: string;
|
|
111
|
+
starting_sha: string;
|
|
112
|
+
candidate_sha: string;
|
|
113
|
+
raw_diff_sha256: string;
|
|
114
|
+
branch: string;
|
|
115
|
+
worktree_path: string;
|
|
116
|
+
working_tree_clean: boolean;
|
|
117
|
+
status: 'pass' | 'violation' | 'incomplete' | 'stale';
|
|
118
|
+
exit_code: ExitCode;
|
|
119
|
+
diff_summary: {
|
|
120
|
+
changed_files: ChangedFileEntry[];
|
|
121
|
+
untracked_files: string[];
|
|
122
|
+
out_of_bounds_files: string[];
|
|
123
|
+
};
|
|
124
|
+
version_assertions_ok: boolean;
|
|
125
|
+
interfacedelta_lockfile_ok: boolean | null;
|
|
126
|
+
subcontracts_checked: number;
|
|
127
|
+
checks: CheckRunResult[];
|
|
128
|
+
advisory_checks?: CheckRunResult[];
|
|
129
|
+
violations: ViolationItem[];
|
|
130
|
+
}
|
|
131
|
+
export type ReviewAttestationMode = 'wrapper-verified' | 'diff-sha-bound' | 'cli-explicit' | 'api';
|
|
132
|
+
export interface ReviewAttestationV01 {
|
|
133
|
+
schema_version: 'diffpact-review-v0.1';
|
|
134
|
+
review_sha256: string;
|
|
135
|
+
contract_sha256: string;
|
|
136
|
+
receipt_sha256: string;
|
|
137
|
+
task_id: string;
|
|
138
|
+
starting_sha: string;
|
|
139
|
+
candidate_sha: string;
|
|
140
|
+
raw_diff_sha256: string;
|
|
141
|
+
evidence_lineage_id: string;
|
|
142
|
+
inspected_raw_diff: boolean;
|
|
143
|
+
attestation_mode?: ReviewAttestationMode;
|
|
144
|
+
attestation_hmac_sha256?: string;
|
|
145
|
+
implementer_session: SessionIdentity;
|
|
146
|
+
reviewer_session: SessionIdentity;
|
|
147
|
+
verdict: 'approve' | 'reject';
|
|
148
|
+
findings: string[];
|
|
149
|
+
summary: string;
|
|
150
|
+
reviewed_at: string;
|
|
151
|
+
}
|
|
152
|
+
export interface MergeVerificationReceiptV01 {
|
|
153
|
+
schema_version: 'diffpact-merge-receipt-v0.1';
|
|
154
|
+
merge_receipt_sha256: string;
|
|
155
|
+
verified_at: string;
|
|
156
|
+
base_sha: string;
|
|
157
|
+
merged_sha: string;
|
|
158
|
+
raw_diff_sha256: string;
|
|
159
|
+
branch: string;
|
|
160
|
+
repo_root: string;
|
|
161
|
+
working_tree_clean: boolean;
|
|
162
|
+
status: 'pass' | 'violation' | 'incomplete' | 'stale';
|
|
163
|
+
exit_code: ExitCode;
|
|
164
|
+
source_contracts: Array<{
|
|
165
|
+
path: string;
|
|
166
|
+
task_id: string;
|
|
167
|
+
contract_sha256: string;
|
|
168
|
+
starting_sha: string;
|
|
169
|
+
}>;
|
|
170
|
+
merged_policy: {
|
|
171
|
+
allowed_paths: string[];
|
|
172
|
+
global_forbidden_paths: string[];
|
|
173
|
+
integration_allowed_paths?: string[];
|
|
174
|
+
integration_reason?: string;
|
|
175
|
+
allow_untracked?: boolean;
|
|
176
|
+
required_checks_count: number;
|
|
177
|
+
advisory_checks_count: number;
|
|
178
|
+
};
|
|
179
|
+
diff_summary: {
|
|
180
|
+
changed_files: ChangedFileEntry[];
|
|
181
|
+
untracked_files: string[];
|
|
182
|
+
ignored_untracked_files?: string[];
|
|
183
|
+
out_of_bounds_files: string[];
|
|
184
|
+
};
|
|
185
|
+
version_assertions_ok: boolean;
|
|
186
|
+
lockfiles_ok: boolean | null;
|
|
187
|
+
checks: CheckRunResult[];
|
|
188
|
+
advisory_checks?: CheckRunResult[];
|
|
189
|
+
violations: ViolationItem[];
|
|
190
|
+
}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ExitCode, type VerificationReceiptV01 } from './types.ts';
|
|
2
|
+
export interface ClassifiedCheckOutcome {
|
|
3
|
+
exitCode: number;
|
|
4
|
+
timedOut: boolean;
|
|
5
|
+
spawnErrorCode?: string;
|
|
6
|
+
spawnErrorMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Classifies child process outcomes accurately so sandbox/spawn errors (EPERM, EACCES, ENOENT)
|
|
10
|
+
* are NEVER masked as exit code 124 (timeout).
|
|
11
|
+
*/
|
|
12
|
+
export declare function classifyCheckProcessOutcome(input: {
|
|
13
|
+
error?: Error | null;
|
|
14
|
+
status: number | null;
|
|
15
|
+
signal?: NodeJS.Signals | null;
|
|
16
|
+
timedOut?: boolean;
|
|
17
|
+
}): ClassifiedCheckOutcome;
|
|
18
|
+
/**
|
|
19
|
+
* Parses skipped test counts from common runners (Vitest, Node --test / TAP, Jest, Pytest)
|
|
20
|
+
* so skipped suites cannot silently masquerade as complete verification ("No Silent Zero").
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseSkippedTestCount(combinedOutput: string): number;
|
|
23
|
+
export interface VerifyOptions {
|
|
24
|
+
contractPath: string;
|
|
25
|
+
cwd?: string;
|
|
26
|
+
writeReceipt?: boolean;
|
|
27
|
+
shellPath?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface VerifyAsyncOptions extends VerifyOptions {
|
|
30
|
+
heartbeatSec?: number;
|
|
31
|
+
onHeartbeat?: (message: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function runVerify(options: VerifyOptions): {
|
|
34
|
+
exitCode: ExitCode;
|
|
35
|
+
receipt?: VerificationReceiptV01;
|
|
36
|
+
error?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Async variant of `runVerify` that emits periodic stderr heartbeats during long-running checks.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runVerifyAsync(options: VerifyAsyncOptions): Promise<{
|
|
42
|
+
exitCode: ExitCode;
|
|
43
|
+
receipt?: VerificationReceiptV01;
|
|
44
|
+
error?: string;
|
|
45
|
+
}>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ExitCode, TaskContractV01, ViolationItem } from './types.ts';
|
|
2
|
+
export interface DirtyTreeDiagnostics {
|
|
3
|
+
clean: boolean;
|
|
4
|
+
dirtyEntries: Array<{
|
|
5
|
+
status: string;
|
|
6
|
+
path: string;
|
|
7
|
+
isSymlink: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
outOfBoundsViolations: ViolationItem[];
|
|
10
|
+
symlinkGitignoreHints: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Inspects dirty/untracked paths in `repoRoot` against `contract`, producing:
|
|
14
|
+
* - Human-readable dirty file entries (`?? path`, `M path`, etc.)
|
|
15
|
+
* - Out-of-bounds violations for `--resume` pre-flight validation
|
|
16
|
+
* - Actionable hints when an untracked symlink matches a trailing-slash `.gitignore` pattern
|
|
17
|
+
* (e.g. `ln -s .../node_modules node_modules` vs `.gitignore` containing `node_modules/`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function inspectDirtyTreeDiagnostics(repoRoot: string, contract: Pick<TaskContractV01, 'allowed_paths' | 'read_only_paths' | 'forbidden_paths'>): DirtyTreeDiagnostics;
|
|
20
|
+
export interface CreateWorktreeOptions {
|
|
21
|
+
cwd?: string;
|
|
22
|
+
dir: string;
|
|
23
|
+
branch: string;
|
|
24
|
+
fromRef?: string;
|
|
25
|
+
shareNodeModules?: boolean;
|
|
26
|
+
nodeModulesDirs?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface CreateWorktreeResult {
|
|
29
|
+
worktreePath: string;
|
|
30
|
+
branch: string;
|
|
31
|
+
sharedNodeModules: boolean;
|
|
32
|
+
nodeModulesTarget?: string;
|
|
33
|
+
sharedNodeModulesPaths?: string[];
|
|
34
|
+
workspaceMode?: 'symlink' | 'workspace-overlay';
|
|
35
|
+
workspacePackagesLinked?: string[];
|
|
36
|
+
nodeModulesNote?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Discovers local npm/pnpm workspace packages inside `worktreeRoot`, returning
|
|
40
|
+
* a map of `<package-name>` -> `<absolute path inside worktreeRoot>`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function discoverLocalWorkspaces(worktreeRoot: string): Map<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a linked Git worktree with `.diffpact/` pre-excluded and optional clean
|
|
45
|
+
* `node_modules` sharing:
|
|
46
|
+
* - For standard repos: symlinks `<main>/node_modules` and excludes `node_modules` in `.git/info/exclude`.
|
|
47
|
+
* - For npm/pnpm workspace monorepos: creates a real `<worktree>/node_modules` directory that
|
|
48
|
+
* symlinks third-party dependencies from `<main>/node_modules` while pointing every local
|
|
49
|
+
* workspace package (`@scope/pkg` or unscoped) to the worktree's own directory.
|
|
50
|
+
* - For subdirectory apps (e.g. `site/package.json` + `site/node_modules`): auto-discovers
|
|
51
|
+
* depth 1-2 package subdirectories or honors explicit `nodeModulesDirs` (`--node-modules-dir`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function createManagedWorktree(options: CreateWorktreeOptions): CreateWorktreeResult;
|
|
54
|
+
export interface RemoveWorktreeOptions {
|
|
55
|
+
cwd?: string;
|
|
56
|
+
dir: string;
|
|
57
|
+
deleteBranch?: boolean;
|
|
58
|
+
forceDeleteBranch?: boolean;
|
|
59
|
+
force?: boolean;
|
|
60
|
+
requireVerified?: boolean;
|
|
61
|
+
contractPath?: string;
|
|
62
|
+
archiveDir?: string;
|
|
63
|
+
noArchive?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface RemoveWorktreeResult {
|
|
66
|
+
ok: boolean;
|
|
67
|
+
exitCode: ExitCode;
|
|
68
|
+
worktreePath: string;
|
|
69
|
+
branch?: string;
|
|
70
|
+
branchDeleted: boolean;
|
|
71
|
+
branchDeleteMode?: '-d' | '-D';
|
|
72
|
+
archivedTo?: string;
|
|
73
|
+
error?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Removes a linked Git worktree cleanly (companion to `createManagedWorktree`),
|
|
77
|
+
* archiving `.diffpact/` evidence (contract, receipt, reviews, amendments, ledger, and reports)
|
|
78
|
+
* into `<main>/.diffpact/archive/` by default before removal, optionally verifying
|
|
79
|
+
* `diffpact status --require-review` passes first and deleting the worktree's feature branch
|
|
80
|
+
* (never deleting `main` or `master`).
|
|
81
|
+
*/
|
|
82
|
+
export declare function removeManagedWorktree(options: RemoveWorktreeOptions): RemoveWorktreeResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffpact",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Local, stateless Git task contracts, deterministic diff boundaries, and cross-harness review gates for multi-agent coding workflows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "InterfaceDelta, Inc. (https://interfacedelta.com)",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"main": "./dist/index.js",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"bin": {
|
|
34
|
-
"diffpact": "
|
|
34
|
+
"diffpact": "bin/diffpact.mjs"
|
|
35
35
|
},
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|