@ttfw/envoi 1.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 +238 -0
- package/dist/commands/app.d.ts +2 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +31 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/autonomy.d.ts +6 -0
- package/dist/commands/autonomy.d.ts.map +1 -0
- package/dist/commands/autonomy.js +89 -0
- package/dist/commands/autonomy.js.map +1 -0
- package/dist/commands/builder.d.ts +13 -0
- package/dist/commands/builder.d.ts.map +1 -0
- package/dist/commands/builder.js +142 -0
- package/dist/commands/builder.js.map +1 -0
- package/dist/commands/idea.d.ts +12 -0
- package/dist/commands/idea.d.ts.map +1 -0
- package/dist/commands/idea.js +79 -0
- package/dist/commands/idea.js.map +1 -0
- package/dist/commands/init.d.ts +18 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +423 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mode.d.ts +13 -0
- package/dist/commands/mode.d.ts.map +1 -0
- package/dist/commands/mode.js +96 -0
- package/dist/commands/mode.js.map +1 -0
- package/dist/commands/onboard.d.ts +37 -0
- package/dist/commands/onboard.d.ts.map +1 -0
- package/dist/commands/onboard.js +743 -0
- package/dist/commands/onboard.js.map +1 -0
- package/dist/commands/pr-note.d.ts +8 -0
- package/dist/commands/pr-note.d.ts.map +1 -0
- package/dist/commands/pr-note.js +27 -0
- package/dist/commands/pr-note.js.map +1 -0
- package/dist/commands/undo.d.ts +7 -0
- package/dist/commands/undo.d.ts.map +1 -0
- package/dist/commands/undo.js +59 -0
- package/dist/commands/undo.js.map +1 -0
- package/dist/commands/update.d.ts +24 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +248 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/constants/report_codes.d.ts +29 -0
- package/dist/constants/report_codes.d.ts.map +1 -0
- package/dist/constants/report_codes.js +69 -0
- package/dist/constants/report_codes.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +675 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/autonomy.d.ts +16 -0
- package/dist/lib/autonomy.d.ts.map +1 -0
- package/dist/lib/autonomy.js +38 -0
- package/dist/lib/autonomy.js.map +1 -0
- package/dist/lib/blocked.d.ts +87 -0
- package/dist/lib/blocked.d.ts.map +1 -0
- package/dist/lib/blocked.js +134 -0
- package/dist/lib/blocked.js.map +1 -0
- package/dist/lib/branding.d.ts +13 -0
- package/dist/lib/branding.d.ts.map +1 -0
- package/dist/lib/branding.js +19 -0
- package/dist/lib/branding.js.map +1 -0
- package/dist/lib/claude.d.ts +42 -0
- package/dist/lib/claude.d.ts.map +1 -0
- package/dist/lib/claude.js +291 -0
- package/dist/lib/claude.js.map +1 -0
- package/dist/lib/config.d.ts +71 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +410 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/diff.d.ts +150 -0
- package/dist/lib/diff.d.ts.map +1 -0
- package/dist/lib/diff.js +257 -0
- package/dist/lib/diff.js.map +1 -0
- package/dist/lib/doctor.d.ts +67 -0
- package/dist/lib/doctor.d.ts.map +1 -0
- package/dist/lib/doctor.js +211 -0
- package/dist/lib/doctor.js.map +1 -0
- package/dist/lib/fingerprint.d.ts +27 -0
- package/dist/lib/fingerprint.d.ts.map +1 -0
- package/dist/lib/fingerprint.js +116 -0
- package/dist/lib/fingerprint.js.map +1 -0
- package/dist/lib/fs.d.ts +93 -0
- package/dist/lib/fs.d.ts.map +1 -0
- package/dist/lib/fs.js +179 -0
- package/dist/lib/fs.js.map +1 -0
- package/dist/lib/git.d.ts +177 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +355 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/git_branching.d.ts +84 -0
- package/dist/lib/git_branching.d.ts.map +1 -0
- package/dist/lib/git_branching.js +327 -0
- package/dist/lib/git_branching.js.map +1 -0
- package/dist/lib/gitignore.d.ts +26 -0
- package/dist/lib/gitignore.d.ts.map +1 -0
- package/dist/lib/gitignore.js +119 -0
- package/dist/lib/gitignore.js.map +1 -0
- package/dist/lib/guardrails.d.ts +232 -0
- package/dist/lib/guardrails.d.ts.map +1 -0
- package/dist/lib/guardrails.js +323 -0
- package/dist/lib/guardrails.js.map +1 -0
- package/dist/lib/history.d.ts +110 -0
- package/dist/lib/history.d.ts.map +1 -0
- package/dist/lib/history.js +236 -0
- package/dist/lib/history.js.map +1 -0
- package/dist/lib/index.d.ts +29 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +29 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/json-extract.d.ts +42 -0
- package/dist/lib/json-extract.d.ts.map +1 -0
- package/dist/lib/json-extract.js +201 -0
- package/dist/lib/json-extract.js.map +1 -0
- package/dist/lib/judge.d.ts +237 -0
- package/dist/lib/judge.d.ts.map +1 -0
- package/dist/lib/judge.js +501 -0
- package/dist/lib/judge.js.map +1 -0
- package/dist/lib/lock.d.ts +79 -0
- package/dist/lib/lock.d.ts.map +1 -0
- package/dist/lib/lock.js +254 -0
- package/dist/lib/lock.js.map +1 -0
- package/dist/lib/migration.d.ts +9 -0
- package/dist/lib/migration.d.ts.map +1 -0
- package/dist/lib/migration.js +74 -0
- package/dist/lib/migration.js.map +1 -0
- package/dist/lib/paths.d.ts +18 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/paths.js +27 -0
- package/dist/lib/paths.js.map +1 -0
- package/dist/lib/preflight.d.ts +33 -0
- package/dist/lib/preflight.d.ts.map +1 -0
- package/dist/lib/preflight.js +177 -0
- package/dist/lib/preflight.js.map +1 -0
- package/dist/lib/prompt_budget.d.ts +18 -0
- package/dist/lib/prompt_budget.d.ts.map +1 -0
- package/dist/lib/prompt_budget.js +36 -0
- package/dist/lib/prompt_budget.js.map +1 -0
- package/dist/lib/report.d.ts +102 -0
- package/dist/lib/report.d.ts.map +1 -0
- package/dist/lib/report.js +347 -0
- package/dist/lib/report.js.map +1 -0
- package/dist/lib/reviewer-flow.d.ts +80 -0
- package/dist/lib/reviewer-flow.d.ts.map +1 -0
- package/dist/lib/reviewer-flow.js +138 -0
- package/dist/lib/reviewer-flow.js.map +1 -0
- package/dist/lib/reviewer.d.ts +53 -0
- package/dist/lib/reviewer.d.ts.map +1 -0
- package/dist/lib/reviewer.js +199 -0
- package/dist/lib/reviewer.js.map +1 -0
- package/dist/lib/risk.d.ts +127 -0
- package/dist/lib/risk.d.ts.map +1 -0
- package/dist/lib/risk.js +192 -0
- package/dist/lib/risk.js.map +1 -0
- package/dist/lib/rollback.d.ts +143 -0
- package/dist/lib/rollback.d.ts.map +1 -0
- package/dist/lib/rollback.js +244 -0
- package/dist/lib/rollback.js.map +1 -0
- package/dist/lib/schema.d.ts +47 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/schema.js +91 -0
- package/dist/lib/schema.js.map +1 -0
- package/dist/lib/scope.d.ts +89 -0
- package/dist/lib/scope.d.ts.map +1 -0
- package/dist/lib/scope.js +135 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lib/self_update.d.ts +13 -0
- package/dist/lib/self_update.d.ts.map +1 -0
- package/dist/lib/self_update.js +172 -0
- package/dist/lib/self_update.js.map +1 -0
- package/dist/lib/state.d.ts +143 -0
- package/dist/lib/state.d.ts.map +1 -0
- package/dist/lib/state.js +258 -0
- package/dist/lib/state.js.map +1 -0
- package/dist/lib/tick.d.ts +310 -0
- package/dist/lib/tick.d.ts.map +1 -0
- package/dist/lib/tick.js +424 -0
- package/dist/lib/tick.js.map +1 -0
- package/dist/lib/transport.d.ts +145 -0
- package/dist/lib/transport.d.ts.map +1 -0
- package/dist/lib/transport.js +237 -0
- package/dist/lib/transport.js.map +1 -0
- package/dist/lib/verdict_labels.d.ts +5 -0
- package/dist/lib/verdict_labels.d.ts.map +1 -0
- package/dist/lib/verdict_labels.js +25 -0
- package/dist/lib/verdict_labels.js.map +1 -0
- package/dist/lib/verify-safety.d.ts +63 -0
- package/dist/lib/verify-safety.d.ts.map +1 -0
- package/dist/lib/verify-safety.js +123 -0
- package/dist/lib/verify-safety.js.map +1 -0
- package/dist/lib/verify.d.ts +139 -0
- package/dist/lib/verify.d.ts.map +1 -0
- package/dist/lib/verify.js +311 -0
- package/dist/lib/verify.js.map +1 -0
- package/dist/lib/workspace_state.d.ts +79 -0
- package/dist/lib/workspace_state.d.ts.map +1 -0
- package/dist/lib/workspace_state.js +283 -0
- package/dist/lib/workspace_state.js.map +1 -0
- package/dist/runner/builder.d.ts +58 -0
- package/dist/runner/builder.d.ts.map +1 -0
- package/dist/runner/builder.js +775 -0
- package/dist/runner/builder.js.map +1 -0
- package/dist/runner/builder_parse.d.ts +37 -0
- package/dist/runner/builder_parse.d.ts.map +1 -0
- package/dist/runner/builder_parse.js +76 -0
- package/dist/runner/builder_parse.js.map +1 -0
- package/dist/runner/index.d.ts +9 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +7 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/loop.d.ts +51 -0
- package/dist/runner/loop.d.ts.map +1 -0
- package/dist/runner/loop.js +221 -0
- package/dist/runner/loop.js.map +1 -0
- package/dist/runner/orchestrator.d.ts +67 -0
- package/dist/runner/orchestrator.d.ts.map +1 -0
- package/dist/runner/orchestrator.js +376 -0
- package/dist/runner/orchestrator.js.map +1 -0
- package/dist/runner/tick.d.ts +10 -0
- package/dist/runner/tick.d.ts.map +1 -0
- package/dist/runner/tick.js +1639 -0
- package/dist/runner/tick.js.map +1 -0
- package/dist/types/blocked.d.ts +52 -0
- package/dist/types/blocked.d.ts.map +1 -0
- package/dist/types/blocked.js +8 -0
- package/dist/types/blocked.js.map +1 -0
- package/dist/types/builder.d.ts +25 -0
- package/dist/types/builder.d.ts.map +1 -0
- package/dist/types/builder.js +7 -0
- package/dist/types/builder.js.map +1 -0
- package/dist/types/claude.d.ts +86 -0
- package/dist/types/claude.d.ts.map +1 -0
- package/dist/types/claude.js +48 -0
- package/dist/types/claude.js.map +1 -0
- package/dist/types/config.d.ts +384 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +7 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lock.d.ts +21 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +8 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/preflight.d.ts +49 -0
- package/dist/types/preflight.d.ts.map +1 -0
- package/dist/types/preflight.js +8 -0
- package/dist/types/preflight.js.map +1 -0
- package/dist/types/report.d.ts +161 -0
- package/dist/types/report.d.ts.map +1 -0
- package/dist/types/report.js +8 -0
- package/dist/types/report.js.map +1 -0
- package/dist/types/reviewer.d.ts +66 -0
- package/dist/types/reviewer.d.ts.map +1 -0
- package/dist/types/reviewer.js +5 -0
- package/dist/types/reviewer.js.map +1 -0
- package/dist/types/state.d.ts +124 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/state.js +20 -0
- package/dist/types/state.js.map +1 -0
- package/dist/types/task.d.ts +117 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +7 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/workspace_state.d.ts +125 -0
- package/dist/types/workspace_state.d.ts.map +1 -0
- package/dist/types/workspace_state.js +10 -0
- package/dist/types/workspace_state.js.map +1 -0
- package/envoi.config.json +191 -0
- package/package.json +52 -0
- package/relais/prompts/.gitkeep +0 -0
- package/relais/prompts/builder.system.txt +13 -0
- package/relais/prompts/builder.user.txt +15 -0
- package/relais/prompts/orchestrator.system.txt +37 -0
- package/relais/prompts/orchestrator.user.txt +34 -0
- package/relais/prompts/reviewer.system.txt +33 -0
- package/relais/prompts/reviewer.user.txt +35 -0
- package/relais/schemas/.gitkeep +0 -0
- package/relais/schemas/builder_result.schema.json +29 -0
- package/relais/schemas/report.schema.json +195 -0
- package/relais/schemas/reviewer_result.schema.json +70 -0
- package/relais/schemas/task.schema.json +155 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema validation utilities using Ajv.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to load and validate data against JSON schemas.
|
|
5
|
+
*/
|
|
6
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
7
|
+
import { readFile } from 'node:fs/promises';
|
|
8
|
+
// Cache for compiled schemas
|
|
9
|
+
const schemaCache = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Loads and parses a JSON schema file.
|
|
12
|
+
*
|
|
13
|
+
* @param schemaPath - Path to the JSON schema file
|
|
14
|
+
* @returns Parsed schema object
|
|
15
|
+
* @throws Error if the schema file cannot be read or parsed
|
|
16
|
+
*/
|
|
17
|
+
export async function loadSchema(schemaPath) {
|
|
18
|
+
try {
|
|
19
|
+
const content = await readFile(schemaPath, 'utf-8');
|
|
20
|
+
return JSON.parse(content);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Failed to load schema from ${schemaPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates data against a JSON schema using Ajv.
|
|
28
|
+
*
|
|
29
|
+
* Uses draft-2020-12 schema support and caches compiled schemas for performance.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Data to validate
|
|
32
|
+
* @param schema - JSON schema object
|
|
33
|
+
* @returns ValidationResult with typed data or error messages
|
|
34
|
+
*/
|
|
35
|
+
export function validateWithSchema(data, schema) {
|
|
36
|
+
// Create Ajv instance with draft-2020-12 support
|
|
37
|
+
const ajv = new Ajv2020({
|
|
38
|
+
strict: true,
|
|
39
|
+
strictRequired: false, // Allow required in 'not' subschemas
|
|
40
|
+
allowUnionTypes: true, // Allow type: [...] union syntax
|
|
41
|
+
allErrors: true,
|
|
42
|
+
verbose: true,
|
|
43
|
+
});
|
|
44
|
+
// Use schema ID or stringified schema as cache key
|
|
45
|
+
const schemaId = schema.$id || JSON.stringify(schema);
|
|
46
|
+
let validate;
|
|
47
|
+
// Check cache first
|
|
48
|
+
if (schemaCache.has(schemaId)) {
|
|
49
|
+
validate = schemaCache.get(schemaId);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Compile and cache schema
|
|
53
|
+
validate = ajv.compile(schema);
|
|
54
|
+
schemaCache.set(schemaId, validate);
|
|
55
|
+
}
|
|
56
|
+
// Validate data
|
|
57
|
+
const valid = validate(data);
|
|
58
|
+
if (valid) {
|
|
59
|
+
return {
|
|
60
|
+
valid: true,
|
|
61
|
+
data: data,
|
|
62
|
+
errors: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Collect error messages
|
|
66
|
+
const errors = [];
|
|
67
|
+
if (validate.errors) {
|
|
68
|
+
for (const error of validate.errors) {
|
|
69
|
+
const path = error.instancePath || error.schemaPath || '';
|
|
70
|
+
const message = error.message || 'Validation error';
|
|
71
|
+
errors.push(`${path ? `${path}: ` : ''}${message}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Extract raw errors for diagnostics
|
|
75
|
+
const rawErrors = validate.errors
|
|
76
|
+
? validate.errors.map((e) => ({
|
|
77
|
+
instancePath: e.instancePath || '',
|
|
78
|
+
schemaPath: e.schemaPath || '',
|
|
79
|
+
keyword: e.keyword || '',
|
|
80
|
+
params: e.params,
|
|
81
|
+
message: e.message,
|
|
82
|
+
}))
|
|
83
|
+
: [];
|
|
84
|
+
return {
|
|
85
|
+
valid: false,
|
|
86
|
+
data: null,
|
|
87
|
+
errors,
|
|
88
|
+
rawErrors,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=schema.js.map
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C3C,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;QACL,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI;QACV,MAAM;QACN,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope enforcement utilities for validating file access against task scope.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to check if touched paths comply with task scope rules:
|
|
5
|
+
* - Forbidden glob patterns
|
|
6
|
+
* - Allowed glob patterns
|
|
7
|
+
* - New file creation restrictions
|
|
8
|
+
* - Lockfile change restrictions
|
|
9
|
+
*/
|
|
10
|
+
import type { TaskScope } from '../types/task.js';
|
|
11
|
+
import type { EnvoiConfig } from '../types/config.js';
|
|
12
|
+
/**
|
|
13
|
+
* Violation type identifiers.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SCOPE_VIOLATION_FORBIDDEN = "SCOPE_VIOLATION_FORBIDDEN";
|
|
16
|
+
export declare const SCOPE_VIOLATION_OUTSIDE_ALLOWED = "SCOPE_VIOLATION_OUTSIDE_ALLOWED";
|
|
17
|
+
export declare const NEW_FILE_FORBIDDEN = "NEW_FILE_FORBIDDEN";
|
|
18
|
+
export declare const LOCKFILE_CHANGE_FORBIDDEN = "LOCKFILE_CHANGE_FORBIDDEN";
|
|
19
|
+
/**
|
|
20
|
+
* Represents a single scope violation.
|
|
21
|
+
*/
|
|
22
|
+
export interface ScopeViolation {
|
|
23
|
+
/** Violation type identifier */
|
|
24
|
+
type: string;
|
|
25
|
+
/** The path that violated scope */
|
|
26
|
+
path: string;
|
|
27
|
+
/** Human-readable explanation */
|
|
28
|
+
detail: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of scope checking operation.
|
|
32
|
+
*/
|
|
33
|
+
export interface ScopeCheckResult {
|
|
34
|
+
/** True if no violations found */
|
|
35
|
+
ok: boolean;
|
|
36
|
+
/** List of violations found */
|
|
37
|
+
violations: ScopeViolation[];
|
|
38
|
+
/** All paths that were checked */
|
|
39
|
+
touched_paths: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a path matches any of the given glob patterns.
|
|
43
|
+
*
|
|
44
|
+
* @param path - The file path to check
|
|
45
|
+
* @param patterns - Array of glob patterns to match against
|
|
46
|
+
* @returns True if path matches any pattern, false otherwise
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* matchesGlob('src/utils.ts', ['src/**', '*.ts']); // true
|
|
51
|
+
* matchesGlob('test/file.js', ['src/**']); // false
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function matchesGlob(path: string, patterns: string[]): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Checks all touched paths against task scope rules and returns violations.
|
|
57
|
+
*
|
|
58
|
+
* Validates:
|
|
59
|
+
* - No paths match forbidden_globs
|
|
60
|
+
* - All paths match at least one allowed_globs pattern
|
|
61
|
+
* - No new files when allow_new_files=false
|
|
62
|
+
* - No lockfile changes when allow_lockfile_changes=false
|
|
63
|
+
*
|
|
64
|
+
* @param touchedPaths - All file paths that were touched (modified or created)
|
|
65
|
+
* @param untrackedPaths - Subset of touchedPaths that are new/untracked files
|
|
66
|
+
* @param taskScope - Scope configuration from the task
|
|
67
|
+
* @param config - Full Envoi configuration (for lockfiles list)
|
|
68
|
+
* @returns ScopeCheckResult with violations and status
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = checkScopeViolations(
|
|
73
|
+
* ['src/utils.ts', 'src/new.ts'],
|
|
74
|
+
* ['src/new.ts'],
|
|
75
|
+
* {
|
|
76
|
+
* allowed_globs: ['src/**'],
|
|
77
|
+
* forbidden_globs: ['*.key'],
|
|
78
|
+
* allow_new_files: false,
|
|
79
|
+
* allow_lockfile_changes: true
|
|
80
|
+
* },
|
|
81
|
+
* config
|
|
82
|
+
* );
|
|
83
|
+
* if (!result.ok) {
|
|
84
|
+
* console.error('Scope violations:', result.violations);
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function checkScopeViolations(touchedPaths: string[], untrackedPaths: string[], taskScope: TaskScope, config: EnvoiConfig): ScopeCheckResult;
|
|
89
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/lib/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,+BAA+B,oCAAoC,CAAC;AACjF,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,+BAA+B;IAC/B,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,kCAAkC;IAClC,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAKrE;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EAAE,EACtB,cAAc,EAAE,MAAM,EAAE,EACxB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,GAClB,gBAAgB,CAgDlB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope enforcement utilities for validating file access against task scope.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to check if touched paths comply with task scope rules:
|
|
5
|
+
* - Forbidden glob patterns
|
|
6
|
+
* - Allowed glob patterns
|
|
7
|
+
* - New file creation restrictions
|
|
8
|
+
* - Lockfile change restrictions
|
|
9
|
+
*/
|
|
10
|
+
import micromatch from 'micromatch';
|
|
11
|
+
/**
|
|
12
|
+
* Violation type identifiers.
|
|
13
|
+
*/
|
|
14
|
+
export const SCOPE_VIOLATION_FORBIDDEN = 'SCOPE_VIOLATION_FORBIDDEN';
|
|
15
|
+
export const SCOPE_VIOLATION_OUTSIDE_ALLOWED = 'SCOPE_VIOLATION_OUTSIDE_ALLOWED';
|
|
16
|
+
export const NEW_FILE_FORBIDDEN = 'NEW_FILE_FORBIDDEN';
|
|
17
|
+
export const LOCKFILE_CHANGE_FORBIDDEN = 'LOCKFILE_CHANGE_FORBIDDEN';
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a path matches any of the given glob patterns.
|
|
20
|
+
*
|
|
21
|
+
* @param path - The file path to check
|
|
22
|
+
* @param patterns - Array of glob patterns to match against
|
|
23
|
+
* @returns True if path matches any pattern, false otherwise
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* matchesGlob('src/utils.ts', ['src/**', '*.ts']); // true
|
|
28
|
+
* matchesGlob('test/file.js', ['src/**']); // false
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function matchesGlob(path, patterns) {
|
|
32
|
+
if (patterns.length === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return micromatch.isMatch(path, patterns);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a path is a lockfile based on config.scope.lockfiles list.
|
|
39
|
+
*
|
|
40
|
+
* @param path - The file path to check
|
|
41
|
+
* @param lockfiles - Array of lockfile names/patterns
|
|
42
|
+
* @returns True if path matches any lockfile pattern
|
|
43
|
+
*/
|
|
44
|
+
function isLockfile(path, lockfiles) {
|
|
45
|
+
if (lockfiles.length === 0) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Check if path ends with any lockfile name, or matches lockfile globs
|
|
49
|
+
return lockfiles.some((lockfile) => {
|
|
50
|
+
// If lockfile is a simple name (e.g., "package-lock.json"), check if path ends with it
|
|
51
|
+
if (!lockfile.includes('/') && !lockfile.includes('*')) {
|
|
52
|
+
return path.endsWith(lockfile);
|
|
53
|
+
}
|
|
54
|
+
// Otherwise, treat as glob pattern
|
|
55
|
+
return micromatch.isMatch(path, [lockfile]);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks all touched paths against task scope rules and returns violations.
|
|
60
|
+
*
|
|
61
|
+
* Validates:
|
|
62
|
+
* - No paths match forbidden_globs
|
|
63
|
+
* - All paths match at least one allowed_globs pattern
|
|
64
|
+
* - No new files when allow_new_files=false
|
|
65
|
+
* - No lockfile changes when allow_lockfile_changes=false
|
|
66
|
+
*
|
|
67
|
+
* @param touchedPaths - All file paths that were touched (modified or created)
|
|
68
|
+
* @param untrackedPaths - Subset of touchedPaths that are new/untracked files
|
|
69
|
+
* @param taskScope - Scope configuration from the task
|
|
70
|
+
* @param config - Full Envoi configuration (for lockfiles list)
|
|
71
|
+
* @returns ScopeCheckResult with violations and status
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const result = checkScopeViolations(
|
|
76
|
+
* ['src/utils.ts', 'src/new.ts'],
|
|
77
|
+
* ['src/new.ts'],
|
|
78
|
+
* {
|
|
79
|
+
* allowed_globs: ['src/**'],
|
|
80
|
+
* forbidden_globs: ['*.key'],
|
|
81
|
+
* allow_new_files: false,
|
|
82
|
+
* allow_lockfile_changes: true
|
|
83
|
+
* },
|
|
84
|
+
* config
|
|
85
|
+
* );
|
|
86
|
+
* if (!result.ok) {
|
|
87
|
+
* console.error('Scope violations:', result.violations);
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function checkScopeViolations(touchedPaths, untrackedPaths, taskScope, config) {
|
|
92
|
+
const violations = [];
|
|
93
|
+
const untrackedSet = new Set(untrackedPaths);
|
|
94
|
+
for (const path of touchedPaths) {
|
|
95
|
+
// Check forbidden globs
|
|
96
|
+
if (matchesGlob(path, taskScope.forbidden_globs)) {
|
|
97
|
+
violations.push({
|
|
98
|
+
type: SCOPE_VIOLATION_FORBIDDEN,
|
|
99
|
+
path,
|
|
100
|
+
detail: `Path "${path}" matches forbidden glob pattern(s): ${taskScope.forbidden_globs.join(', ')}`,
|
|
101
|
+
});
|
|
102
|
+
continue; // Don't check other rules for forbidden paths
|
|
103
|
+
}
|
|
104
|
+
// Check allowed globs (path must match at least one)
|
|
105
|
+
if (taskScope.allowed_globs.length > 0 && !matchesGlob(path, taskScope.allowed_globs)) {
|
|
106
|
+
violations.push({
|
|
107
|
+
type: SCOPE_VIOLATION_OUTSIDE_ALLOWED,
|
|
108
|
+
path,
|
|
109
|
+
detail: `Path "${path}" does not match any allowed glob pattern(s): ${taskScope.allowed_globs.join(', ')}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// Check new file restrictions
|
|
113
|
+
if (!taskScope.allow_new_files && untrackedSet.has(path)) {
|
|
114
|
+
violations.push({
|
|
115
|
+
type: NEW_FILE_FORBIDDEN,
|
|
116
|
+
path,
|
|
117
|
+
detail: `New file "${path}" created but allow_new_files is false`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// Check lockfile change restrictions
|
|
121
|
+
if (!taskScope.allow_lockfile_changes && isLockfile(path, config.scope.lockfiles)) {
|
|
122
|
+
violations.push({
|
|
123
|
+
type: LOCKFILE_CHANGE_FORBIDDEN,
|
|
124
|
+
path,
|
|
125
|
+
detail: `Lockfile "${path}" was modified but allow_lockfile_changes is false`,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
ok: violations.length === 0,
|
|
131
|
+
violations,
|
|
132
|
+
touched_paths: touchedPaths,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/lib/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AACrE,MAAM,CAAC,MAAM,+BAA+B,GAAG,iCAAiC,CAAC;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AA0BrE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,QAAkB;IAC1D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,IAAY,EAAE,SAAmB;IACnD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uEAAuE;IACvE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACjC,uFAAuF;QACvF,IAAI,CAAC,QA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,IAAI,CAAC,SAAS,CAAC,eAAe,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,kBAAkB;gBACxB,IAAI;gBACJ,MAAM,EAAE,aAAa,IAAI,wCAAwC;aAClE,CAAC,CAAC;QACL,CAAC;QAED,qCAAqC;QACrC,IAAI,CAAC,SAAS,CAAC,sBAAsB,IAAI,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YAClF,UAAU,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,yBAAyB;gBAC/B,IAAI;gBACJ,MAAM,EAAE,aAAa,IAAI,oDAAoD;aAC9E,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC;QAC3B,UAAU;QACV,aAAa,EAAE,YAAY;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
2
|
+
export interface LinkedRefreshResult {
|
|
3
|
+
linkedRoot: string | null;
|
|
4
|
+
stale: boolean;
|
|
5
|
+
refreshed: boolean;
|
|
6
|
+
manager?: PackageManager;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function detectLinkedInstallRoot(entrypointArg?: string): string | null;
|
|
10
|
+
export declare function isLinkedInstallStale(linkedRoot: string): boolean;
|
|
11
|
+
export declare function refreshLinkedInstallIfStale(): LinkedRefreshResult;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=self_update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self_update.d.ts","sourceRoot":"","sources":["../../src/lib/self_update.ts"],"names":[],"mappings":"AAKA,KAAK,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA4BD,wBAAgB,uBAAuB,CAAC,aAAa,SAAkB,GAAG,MAAM,GAAG,IAAI,CAkBtF;AAyFD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,wBAAgB,2BAA2B,IAAI,mBAAmB,CAgCjE"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { isKnownPackageName } from './branding.js';
|
|
5
|
+
function isTestRuntime() {
|
|
6
|
+
return process.env.VITEST === 'true' || process.env.NODE_ENV === 'test';
|
|
7
|
+
}
|
|
8
|
+
function findNearestEnvoiPackageRoot(entrypointPath) {
|
|
9
|
+
let cursor = dirname(entrypointPath);
|
|
10
|
+
const root = resolve('/');
|
|
11
|
+
while (true) {
|
|
12
|
+
const packageJsonPath = join(cursor, 'package.json');
|
|
13
|
+
if (existsSync(packageJsonPath)) {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
16
|
+
if (isKnownPackageName(parsed.name)) {
|
|
17
|
+
return cursor;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Ignore parse failures and continue walking up.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (cursor === root || cursor === dirname(cursor))
|
|
25
|
+
return null;
|
|
26
|
+
cursor = dirname(cursor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function detectLinkedInstallRoot(entrypointArg = process.argv[1]) {
|
|
30
|
+
if (isTestRuntime())
|
|
31
|
+
return null;
|
|
32
|
+
if (!entrypointArg)
|
|
33
|
+
return null;
|
|
34
|
+
let resolvedEntrypoint;
|
|
35
|
+
try {
|
|
36
|
+
resolvedEntrypoint = realpathSync(entrypointArg);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const packageRoot = findNearestEnvoiPackageRoot(resolvedEntrypoint);
|
|
42
|
+
if (!packageRoot)
|
|
43
|
+
return null;
|
|
44
|
+
const looksLinked = existsSync(join(packageRoot, '.git')) &&
|
|
45
|
+
existsSync(join(packageRoot, 'src', 'index.ts')) &&
|
|
46
|
+
existsSync(join(packageRoot, 'dist', 'index.js'));
|
|
47
|
+
return looksLinked ? packageRoot : null;
|
|
48
|
+
}
|
|
49
|
+
function newestMtimeInTree(root) {
|
|
50
|
+
if (!existsSync(root))
|
|
51
|
+
return 0;
|
|
52
|
+
let newest = 0;
|
|
53
|
+
const stack = [root];
|
|
54
|
+
while (stack.length > 0) {
|
|
55
|
+
const current = stack.pop();
|
|
56
|
+
let stats;
|
|
57
|
+
try {
|
|
58
|
+
stats = statSync(current);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
newest = Math.max(newest, stats.mtimeMs);
|
|
64
|
+
if (!stats.isDirectory())
|
|
65
|
+
continue;
|
|
66
|
+
let entries;
|
|
67
|
+
try {
|
|
68
|
+
entries = readdirSync(current);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (entry === '.git' || entry === 'node_modules' || entry === 'dist')
|
|
75
|
+
continue;
|
|
76
|
+
stack.push(join(current, entry));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return newest;
|
|
80
|
+
}
|
|
81
|
+
function latestSourceMtime(linkedRoot) {
|
|
82
|
+
const candidates = [
|
|
83
|
+
join(linkedRoot, 'src'),
|
|
84
|
+
join(linkedRoot, 'relais'),
|
|
85
|
+
join(linkedRoot, 'README.md'),
|
|
86
|
+
join(linkedRoot, 'envoi.config.json'),
|
|
87
|
+
join(linkedRoot, 'relais.config.json'),
|
|
88
|
+
join(linkedRoot, 'package.json'),
|
|
89
|
+
];
|
|
90
|
+
let newest = 0;
|
|
91
|
+
for (const candidate of candidates) {
|
|
92
|
+
newest = Math.max(newest, newestMtimeInTree(candidate));
|
|
93
|
+
}
|
|
94
|
+
return newest;
|
|
95
|
+
}
|
|
96
|
+
function distMtime(linkedRoot) {
|
|
97
|
+
const distEntry = join(linkedRoot, 'dist', 'index.js');
|
|
98
|
+
if (!existsSync(distEntry))
|
|
99
|
+
return 0;
|
|
100
|
+
try {
|
|
101
|
+
return statSync(distEntry).mtimeMs;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function detectManager(linkedRoot) {
|
|
108
|
+
const packageJsonPath = join(linkedRoot, 'package.json');
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
111
|
+
const value = parsed.packageManager ?? '';
|
|
112
|
+
if (value.startsWith('pnpm@'))
|
|
113
|
+
return 'pnpm';
|
|
114
|
+
if (value.startsWith('npm@'))
|
|
115
|
+
return 'npm';
|
|
116
|
+
if (value.startsWith('yarn@'))
|
|
117
|
+
return 'yarn';
|
|
118
|
+
if (value.startsWith('bun@'))
|
|
119
|
+
return 'bun';
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Fall through.
|
|
123
|
+
}
|
|
124
|
+
return 'pnpm';
|
|
125
|
+
}
|
|
126
|
+
function runBuild(linkedRoot, manager) {
|
|
127
|
+
const commandMap = {
|
|
128
|
+
pnpm: { cmd: 'pnpm', args: ['-C', linkedRoot, 'build'] },
|
|
129
|
+
npm: { cmd: 'npm', args: ['--prefix', linkedRoot, 'run', 'build'] },
|
|
130
|
+
yarn: { cmd: 'yarn', args: ['--cwd', linkedRoot, 'build'] },
|
|
131
|
+
bun: { cmd: 'bun', args: ['--cwd', linkedRoot, 'run', 'build'] },
|
|
132
|
+
};
|
|
133
|
+
const command = commandMap[manager];
|
|
134
|
+
const result = spawnSync(command.cmd, command.args, { stdio: 'inherit' });
|
|
135
|
+
if (result.status === 0)
|
|
136
|
+
return { ok: true };
|
|
137
|
+
return { ok: false, error: `Build command failed (${result.status ?? 'unknown'}): ${command.cmd} ${command.args.join(' ')}` };
|
|
138
|
+
}
|
|
139
|
+
export function isLinkedInstallStale(linkedRoot) {
|
|
140
|
+
return latestSourceMtime(linkedRoot) > distMtime(linkedRoot);
|
|
141
|
+
}
|
|
142
|
+
export function refreshLinkedInstallIfStale() {
|
|
143
|
+
if (isTestRuntime()) {
|
|
144
|
+
return { linkedRoot: null, stale: false, refreshed: false };
|
|
145
|
+
}
|
|
146
|
+
const linkedRoot = detectLinkedInstallRoot();
|
|
147
|
+
if (!linkedRoot) {
|
|
148
|
+
return { linkedRoot: null, stale: false, refreshed: false };
|
|
149
|
+
}
|
|
150
|
+
const stale = isLinkedInstallStale(linkedRoot);
|
|
151
|
+
if (!stale) {
|
|
152
|
+
return { linkedRoot, stale: false, refreshed: false };
|
|
153
|
+
}
|
|
154
|
+
const manager = detectManager(linkedRoot);
|
|
155
|
+
const build = runBuild(linkedRoot, manager);
|
|
156
|
+
if (!build.ok) {
|
|
157
|
+
return {
|
|
158
|
+
linkedRoot,
|
|
159
|
+
stale: true,
|
|
160
|
+
refreshed: false,
|
|
161
|
+
manager,
|
|
162
|
+
error: build.error,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
linkedRoot,
|
|
167
|
+
stale: true,
|
|
168
|
+
refreshed: true,
|
|
169
|
+
manager,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=self_update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self_update.js","sourceRoot":"","sources":["../../src/lib/self_update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAYnD,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC1E,CAAC;AAED,SAAS,2BAA2B,CAAC,cAAsB;IACzD,IAAI,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1B,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACrD,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAsB,CAAC;gBACvF,IAAI,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACpC,OAAO,MAAM,CAAC;gBAChB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iDAAiD;YACnD,CAAC;QACH,CAAC;QAED,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QAC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K,EAAE,CAAC;QACX,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;QACd,OAAO;YACL,UAAU;YACV,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,KAAK;YAChB,OAAO;YACP,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU;QACV,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State management utilities for tick execution.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to create and update tick state during execution.
|
|
5
|
+
*/
|
|
6
|
+
import type { EnvoiConfig } from '../types/config.js';
|
|
7
|
+
import { TickPhase } from '../types/state.js';
|
|
8
|
+
import type { TickState, StopHistoryEntry, VerifyHistoryEntry } from '../types/state.js';
|
|
9
|
+
/**
|
|
10
|
+
* Generates a unique run ID for a tick.
|
|
11
|
+
*
|
|
12
|
+
* @returns A unique identifier string
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateRunId(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Creates initial tick state.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Envoi configuration
|
|
19
|
+
* @param baseCommit - Git HEAD commit SHA at start
|
|
20
|
+
* @returns Initial tick state
|
|
21
|
+
*/
|
|
22
|
+
export declare function createInitialState(config: EnvoiConfig, baseCommit: string): TickState;
|
|
23
|
+
/**
|
|
24
|
+
* Transitions tick state to a new phase.
|
|
25
|
+
*
|
|
26
|
+
* @param state - Current tick state
|
|
27
|
+
* @param newPhase - Phase to transition to
|
|
28
|
+
* @returns Updated tick state
|
|
29
|
+
*/
|
|
30
|
+
export declare function transitionPhase(state: TickState, newPhase: TickPhase): TickState;
|
|
31
|
+
/**
|
|
32
|
+
* Adds an error to the tick state.
|
|
33
|
+
*
|
|
34
|
+
* @param state - Current tick state
|
|
35
|
+
* @param error - Error message to add
|
|
36
|
+
* @returns Updated tick state
|
|
37
|
+
*/
|
|
38
|
+
export declare function addError(state: TickState, error: string): TickState;
|
|
39
|
+
/**
|
|
40
|
+
* Updates task in tick state.
|
|
41
|
+
*
|
|
42
|
+
* @param state - Current tick state
|
|
43
|
+
* @param task - Task to set
|
|
44
|
+
* @returns Updated tick state
|
|
45
|
+
*/
|
|
46
|
+
export declare function setTask(state: TickState, task: TickState['task']): TickState;
|
|
47
|
+
/**
|
|
48
|
+
* Updates builder result in tick state.
|
|
49
|
+
*
|
|
50
|
+
* @param state - Current tick state
|
|
51
|
+
* @param builderResult - Builder result to set
|
|
52
|
+
* @returns Updated tick state
|
|
53
|
+
*/
|
|
54
|
+
export declare function setBuilderResult(state: TickState, builderResult: TickState['builder_result']): TickState;
|
|
55
|
+
/**
|
|
56
|
+
* Appends a stop history entry to guardrail state, capping at 50 entries.
|
|
57
|
+
*
|
|
58
|
+
* @param state - Current tick state
|
|
59
|
+
* @param entry - Stop history entry to add
|
|
60
|
+
* @returns Updated tick state
|
|
61
|
+
*/
|
|
62
|
+
export declare function appendStopHistory(state: TickState, entry: StopHistoryEntry): TickState;
|
|
63
|
+
/**
|
|
64
|
+
* Clears force patch flag (sets force_patch_until_success to false).
|
|
65
|
+
*
|
|
66
|
+
* Called when a patch succeeds to reset escalation state.
|
|
67
|
+
*
|
|
68
|
+
* @param state - Current tick state
|
|
69
|
+
* @returns Updated tick state
|
|
70
|
+
*/
|
|
71
|
+
export declare function clearForcePatch(state: TickState): TickState;
|
|
72
|
+
/**
|
|
73
|
+
* Sets force patch flag (sets force_patch_until_success to true).
|
|
74
|
+
*
|
|
75
|
+
* Called to enable escalation mode when guardrails trigger.
|
|
76
|
+
*
|
|
77
|
+
* @param state - Current tick state
|
|
78
|
+
* @returns Updated tick state
|
|
79
|
+
*/
|
|
80
|
+
export declare function setForcePatch(state: TickState): TickState;
|
|
81
|
+
/**
|
|
82
|
+
* Updates the task fingerprint in tick state.
|
|
83
|
+
*
|
|
84
|
+
* @param state - Current tick state
|
|
85
|
+
* @param fingerprint - SHA256 fingerprint of the current task
|
|
86
|
+
* @returns Updated tick state
|
|
87
|
+
*/
|
|
88
|
+
export declare function updateTaskFingerprint(state: TickState, fingerprint: string): TickState;
|
|
89
|
+
/**
|
|
90
|
+
* Updates failure tracking when a task fails.
|
|
91
|
+
*
|
|
92
|
+
* Increments failure_streak and updates last_failed_fingerprint.
|
|
93
|
+
*
|
|
94
|
+
* @param state - Current tick state
|
|
95
|
+
* @param fingerprint - SHA256 fingerprint of the failed task
|
|
96
|
+
* @returns Updated tick state
|
|
97
|
+
*/
|
|
98
|
+
export declare function recordTaskFailure(state: TickState, fingerprint: string): TickState;
|
|
99
|
+
/**
|
|
100
|
+
* Resets failure streak when a task succeeds.
|
|
101
|
+
*
|
|
102
|
+
* @param state - Current tick state
|
|
103
|
+
* @returns Updated tick state
|
|
104
|
+
*/
|
|
105
|
+
export declare function resetFailureStreak(state: TickState): TickState;
|
|
106
|
+
/**
|
|
107
|
+
* Appends a verify history entry, capping at 50 entries.
|
|
108
|
+
*
|
|
109
|
+
* @param state - Current tick state
|
|
110
|
+
* @param entry - Verify history entry to add
|
|
111
|
+
* @returns Updated tick state
|
|
112
|
+
*/
|
|
113
|
+
export declare function appendVerifyHistory(state: TickState, entry: VerifyHistoryEntry): TickState;
|
|
114
|
+
/**
|
|
115
|
+
* Increments the retry count for transport stall recovery.
|
|
116
|
+
*
|
|
117
|
+
* @param state - Current tick state
|
|
118
|
+
* @returns Updated tick state with incremented retry_count
|
|
119
|
+
*/
|
|
120
|
+
export declare function incrementRetryCount(state: TickState): TickState;
|
|
121
|
+
/**
|
|
122
|
+
* Records a transport stall error in state.
|
|
123
|
+
*
|
|
124
|
+
* Used to track the last error kind and request ID for debugging
|
|
125
|
+
* and retry policy decisions.
|
|
126
|
+
*
|
|
127
|
+
* @param state - Current tick state
|
|
128
|
+
* @param errorKind - Kind of error (e.g., 'transport_stalled')
|
|
129
|
+
* @param requestId - Request ID from the stall (for debugging)
|
|
130
|
+
* @returns Updated tick state
|
|
131
|
+
*/
|
|
132
|
+
export declare function recordTransportStall(state: TickState, errorKind: string, requestId: string | null): TickState;
|
|
133
|
+
/**
|
|
134
|
+
* Resets retry state after a successful tick.
|
|
135
|
+
*
|
|
136
|
+
* Clears retry_count, last_error_kind, and last_request_id.
|
|
137
|
+
* Called when a tick completes successfully to reset recovery state.
|
|
138
|
+
*
|
|
139
|
+
* @param state - Current tick state
|
|
140
|
+
* @returns Updated tick state with cleared retry fields
|
|
141
|
+
*/
|
|
142
|
+
export declare function resetRetryState(state: TickState): TickState;
|
|
143
|
+
//# sourceMappingURL=state.d.ts.map
|