@mrciphersmith/keryx 0.4.26 → 0.4.28
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 +2 -2
- package/dist/cli.js +106917 -105655
- package/dist/core.js +28 -198
- package/dist/keryx-general-worker-entry.js +526 -421
- package/package.json +3 -3
- package/src/gdskills/bundled/agents/work-planner.md +1 -1
- package/src/gdskills/bundled/install-manifest.json +3 -26
- package/src/gdskills/bundled/rules/core/code-review-learned-profile.mdc +1 -2
- package/src/gdskills/bundled/rules/core/definition-of-done.mdc +0 -1
- package/src/gdskills/bundled/rules/core/implementation-doc-mandate.mdc +4 -5
- package/src/gdskills/bundled/rules/core/jobs-documentation.mdc +8 -8
- package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +7 -10
- package/src/gdskills/bundled/skills/core/reviewer-skill-creator/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.md +12 -21
- package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.md +3 -3
- package/src/gdskills/bundled/skills/orchestration/flow-orchestrator/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/orchestration/task-implementer/input-contract.schema.json +1 -1
- package/src/gdskills/bundled/skills/planning/autodoc-orchestrator/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/planning/interview/SKILL.md +3 -4
- package/src/gdskills/bundled/skills/planning/interviewer/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/quality/git-publish/SKILL.md +60 -0
- package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/code-learned-review/SKILL.md +3 -3
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +7 -7
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +22 -22
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +15 -15
- package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +7 -7
- package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +34 -30
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +64 -135
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +4 -4
- package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.detail.md +18 -20
- package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.md +12 -18
- package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-finding.schema.json +2 -2
- package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-input.schema.json +2 -10
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +35 -35
- package/src/gdskills/bundled/skills/review/review-pr-contract/SKILL.md +4 -5
- package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +2 -2
- package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +3 -5
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +14 -15
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +14 -13
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +11 -11
- package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +10 -11
- package/src/gdskills/bundled/skills/review/review-verifier/SKILL.md +5 -5
- package/src/gdskills/bundled/skills/shared/git-merge-base.md +1 -1
- package/src/gdskills/bundled/stacks/mobx/agent-refs.json +1 -1
- package/src/gdskills/bundled/stacks/mobx/governance/scout.json +2 -2
- package/src/gdskills/bundled/stacks/mobx/skills/mobx-store-implementation/SKILL.md +2 -2
- package/src/gdskills/bundled/stacks/vue/governance/scout.json +1 -1
- package/src/gdskills/contracts/review-finding.schema.json +2 -2
- package/src/gdskills/bundled/rules/core/code-review-ai-assistant.mdc +0 -49
- package/src/gdskills/bundled/rules/core/gproject-contracts.mdc +0 -198
- package/src/gdskills/bundled/skills/orchestration/feature-dev/SKILL.md +0 -177
- package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.md +0 -414
- package/src/gdskills/bundled/skills/orchestration/job-documenter/input-contract.schema.json +0 -55
- package/src/gdskills/bundled/skills/orchestration/job-documenter/output-contract.schema.json +0 -58
- package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.codex.md +0 -209
- package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.cursor.md +0 -209
- package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.md +0 -208
- package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.codex.md +0 -255
- package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.cursor.md +0 -255
- package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.md +0 -254
- package/src/gdskills/bundled/skills/planning/planner/SKILL.codex.md +0 -209
- package/src/gdskills/bundled/skills/planning/planner/SKILL.cursor.md +0 -209
- package/src/gdskills/bundled/skills/planning/planner/SKILL.md +0 -208
- package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.codex.md +0 -171
- package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.cursor.md +0 -171
- package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.md +0 -170
- package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.codex.md +0 -184
- package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.cursor.md +0 -184
- package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.md +0 -183
- package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.codex.md +0 -249
- package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.cursor.md +0 -249
- package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.md +0 -248
- package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.codex.md +0 -199
- package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.cursor.md +0 -199
- package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.md +0 -198
- package/src/gdskills/bundled/skills/quality/commit/SKILL.md +0 -87
- package/src/gdskills/bundled/skills/quality/pr/SKILL.md +0 -95
- package/src/gdskills/bundled/skills/quality/push/SKILL.md +0 -73
- package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.md +0 -238
- package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.md +0 -301
- package/src/gdskills/bundled/skills/review/code-style-review/SKILL.md +0 -208
|
@@ -70,6 +70,31 @@ function readConfigFile(file) {
|
|
|
70
70
|
function readTranscriptFile(file) {
|
|
71
71
|
return readBoundedFile(file, MAX_TRANSCRIPT_FILE_BYTES);
|
|
72
72
|
}
|
|
73
|
+
function ensureKeryxSubdir(segments, dir) {
|
|
74
|
+
const root = ensureKeryxConfigDir(dir);
|
|
75
|
+
let current = root;
|
|
76
|
+
for (const segment of segments) {
|
|
77
|
+
current = path.join(current, segment);
|
|
78
|
+
mkdirSync(current, { recursive: true, mode: 448 });
|
|
79
|
+
if (process.platform === "win32") {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
chmodSync(current, 448);
|
|
84
|
+
} catch {}
|
|
85
|
+
}
|
|
86
|
+
return current;
|
|
87
|
+
}
|
|
88
|
+
function appendOwnerOnlyLine(file, line) {
|
|
89
|
+
appendFileSync(file, `${line}
|
|
90
|
+
`, { mode: 384 });
|
|
91
|
+
if (process.platform === "win32") {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
chmodSync(file, 384);
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
73
98
|
function writeOwnerOnlyFileAtomic(file, body) {
|
|
74
99
|
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
75
100
|
try {
|
|
@@ -10827,23 +10852,7 @@ var init_catalog2 = __esm(() => {
|
|
|
10827
10852
|
"If the request asks to create, run, resume, track, or finish a managed flow and Task Manager is enabled, route implementation work to `gdskills/orchestration/flow-orchestrator/SKILL.md` before `job-orchestrator`.",
|
|
10828
10853
|
"Prefer project-local skills and module manifests before broad raw file search.",
|
|
10829
10854
|
"Route to the narrowest applicable skill and record unavailable modules explicitly."
|
|
10830
|
-
], ["any repository task", "route context", "which skill should be used", "ordinary product-development request", "agent should decide tools", "pick the module"], "Use when a request's routing to a Metaproject module, skill, or project-skill is unclear and needs deciding before any work starts. NOT for:
|
|
10831
|
-
renderedSkill("context-router", "core", ["minimal", "recommended", "full"], "Choose between gdgraph, gdctx, gdwiki, memory, health, and project-skills before raw file reads.", [
|
|
10832
|
-
"Start from the user's goal, not from command names.",
|
|
10833
|
-
"Use gdgraph for file relationships and affected context.",
|
|
10834
|
-
"Use gdctx for compact command, search, diff, log, and large-read output.",
|
|
10835
|
-
"Use gdwiki for architecture, domain, business rules, decisions, and scenarios.",
|
|
10836
|
-
"Use memory for historical decisions, known constraints, lessons, and repeated mistakes.",
|
|
10837
|
-
"Use health for normalized quality and gate status; use testing for test selection and test context.",
|
|
10838
|
-
"Prefer MCP tools/resources for these capabilities when connected; otherwise use the matching skill and CLI command.",
|
|
10839
|
-
"Use project-skills for known modules, components, stores, services, and domain entities."
|
|
10840
|
-
], ["find files", "understand code", "what should I inspect", "agent routing"], "Use when the Metaproject module or skill is already known and the next step is picking gdgraph, gdctx, gdwiki, memory, health, or project-skills before reading raw files. NOT for: deciding which top-level skill or module should handle a request (see metaproject-router)."),
|
|
10841
|
-
renderedSkill("entity-skill-router", "core", ["minimal", "recommended", "full"], "Select relevant project-skills for known modules, components, stores, services, and domain entities.", [
|
|
10842
|
-
"Check `.metaproject/project-skills` for matching module/entity skills.",
|
|
10843
|
-
"Use gdgraph affected context to find nearby entities when the target is a file.",
|
|
10844
|
-
"Load only the matching project-skill and directly referenced files.",
|
|
10845
|
-
"If no project-skill exists, suggest creating one with `keryx skills generate`."
|
|
10846
|
-
], ["project skill", "component pattern", "module-specific work"], "Use when a known module, component, store, service, or domain entity already has a project-skill that should be loaded instead of searched for from scratch. NOT for: scaffolding a project-skill that does not exist yet (see entity-skill-creator), checking one against current code (see entity-skill-verifier), or applying a finding to one (see entity-skill-learner)."),
|
|
10855
|
+
], ["any repository task", "route context", "which skill should be used", "ordinary product-development request", "agent should decide tools", "pick the module"], "Use when a request's routing to a Metaproject module, skill, or project-skill is unclear and needs deciding before any work starts. NOT for: a request whose owning module or skill is already known."),
|
|
10847
10856
|
renderedSkill("entity-skill-creator", "core", ["minimal", "recommended", "full"], "Create canonical project-skills from a path, symbol, wiki page, module, component, store, service, or domain entity.", [
|
|
10848
10857
|
"Normalize the target into module, entity, files, symbols, and wiki references.",
|
|
10849
10858
|
"Collect evidence from gdgraph, gdctx, gdwiki, health, and memory when available.",
|
|
@@ -10852,7 +10861,7 @@ var init_catalog2 = __esm(() => {
|
|
|
10852
10861
|
"To refresh a project-skill from its Origin (or a new file), run `keryx skills update <module>/<name> [--from <origin>]`.",
|
|
10853
10862
|
"Run `keryx skills route <target>` and `keryx skills inspect <module>/<skill-name>` to confirm registration and routing.",
|
|
10854
10863
|
"Run `keryx skills verify <module>/<skill-name>` and finish with `keryx skills status`."
|
|
10855
|
-
], ["create skill", "generate project skill", "new entity skill", "\u0441\u043E\u0437\u0434\u0430\u0439 \u0441\u043A\u0438\u043B", "\u0441\u043E\u0437\u0434\u0430\u0439 \u0441\u043A\u0438\u043B\u043B \u0434\u043B\u044F <path>", "import skill", "import skills from", "update skill from", "\u043F\u043E\u0434\u0442\u044F\u043D\u0438 \u0441\u043A\u0438\u043B\u044B", "\u043E\u0431\u043D\u043E\u0432\u0438 \u0441\u043A\u0438\u043B"], "Use when no project-skill exists yet for a target module, component, store, service, or domain entity, or one needs scaffolding, importing, or refreshing from its origin. NOT for: loading a project-skill that already exists
|
|
10864
|
+
], ["create skill", "generate project skill", "new entity skill", "\u0441\u043E\u0437\u0434\u0430\u0439 \u0441\u043A\u0438\u043B", "\u0441\u043E\u0437\u0434\u0430\u0439 \u0441\u043A\u0438\u043B\u043B \u0434\u043B\u044F <path>", "import skill", "import skills from", "update skill from", "\u043F\u043E\u0434\u0442\u044F\u043D\u0438 \u0441\u043A\u0438\u043B\u044B", "\u043E\u0431\u043D\u043E\u0432\u0438 \u0441\u043A\u0438\u043B"], "Use when no project-skill exists yet for a target module, component, store, service, or domain entity, or one needs scaffolding, importing, or refreshing from its origin. NOT for: loading a project-skill that already exists."),
|
|
10856
10865
|
skill("reviewer-skill-creator", "core", ["recommended", "full"], "Create a project-local reviewer for review-orchestrator from a rules file, review profile, or written team standard.", [
|
|
10857
10866
|
"Read the source in full and sort it into method, convention, and persona before writing anything.",
|
|
10858
10867
|
"Scaffold with `keryx skills create <target> --module review --name <reviewer> --note <gist> --origin <source file>`; the target is a routing key, the note is the prose.",
|
|
@@ -10866,14 +10875,8 @@ var init_catalog2 = __esm(() => {
|
|
|
10866
10875
|
"Resolve the target project-skill through gdgraph affected context or `keryx skills route <target>`.",
|
|
10867
10876
|
"Run `keryx skills verify <module>/<skill-name>` (`--dry-run` previews without writing).",
|
|
10868
10877
|
"The command checks required files, SKILL.md metadata (version, target, last-verified), manifest registration, target path existence, and evidence artifacts for gdgraph, gdctx, gdwiki, Code Health, and memory consultation, then classifies the skill fresh, needs-review, stale, or blocked and writes the JSON report plus `verification.md`.",
|
|
10869
|
-
"Manually read the skill and the code, wiki, and health evidence it points at to check its claims \u2014 the command does not do this comparison \u2014 then
|
|
10870
|
-
], ["verify skill", "skill-verify-skill", "stale skill"], "Use when an existing project-skill needs classifying \u2014 fresh, needs-review, stale, or blocked \u2014 from its required files, metadata, manifest registration, target-path existence, and evidence artifacts (gdgraph, gdctx, gdwiki, Code Health, memory), followed by a manual read of its claims against current code as this skill's next step. NOT for: applying a review, test, or health finding to update a skill (
|
|
10871
|
-
renderedSkill("entity-skill-learner", "core", ["minimal", "recommended", "full"], "Update project-skills from review findings, test failures, health reports, memory entries, and verifier reports.", [
|
|
10872
|
-
"Parse the source report and map findings to project-skills.",
|
|
10873
|
-
"Classify lessons as anti-patterns, checklist changes, template changes, workflow changes, or architecture rules.",
|
|
10874
|
-
"Respect manual sections and autonomy policy.",
|
|
10875
|
-
"Increment version and append `skill-changelog.md` entries with provenance."
|
|
10876
|
-
], ["learn from review", "update skill", "skill lesson"], "Use when a review finding, test failure, health report, memory entry, or verifier report points at a project-skill that needs updating. NOT for: checking a skill's current accuracy with no source report driving it (see entity-skill-verifier)."),
|
|
10878
|
+
"Manually read the skill and the code, wiki, and health evidence it points at to check its claims \u2014 the command does not do this comparison \u2014 then apply stale or blocked findings with `keryx skills learn`."
|
|
10879
|
+
], ["verify skill", "skill-verify-skill", "stale skill"], "Use when an existing project-skill needs classifying \u2014 fresh, needs-review, stale, or blocked \u2014 from its required files, metadata, manifest registration, target-path existence, and evidence artifacts (gdgraph, gdctx, gdwiki, Code Health, memory), followed by a manual read of its claims against current code as this skill's next step. NOT for: applying a review, test, or health finding to update a skill (use `keryx skills learn`)."),
|
|
10877
10880
|
skill("job-orchestrator", "orchestration", ["recommended", "full"], "Run full task pipelines: clarify, collect context, plan, implement, verify, review, and summarize.", [
|
|
10878
10881
|
"Clarify ambiguity with interviewer-style questions only when required.",
|
|
10879
10882
|
"Collect compact context through Metaproject modules before implementation.",
|
|
@@ -10886,12 +10889,6 @@ var init_catalog2 = __esm(() => {
|
|
|
10886
10889
|
"Delegate context, test, implementation, review, and docs work to existing gdskills while keeping flow state changes in the CLI.",
|
|
10887
10890
|
"After verification, ask the user whether to create a draft PR and complete the managed flow, finish with a verified handoff without PR, or keep the flow open."
|
|
10888
10891
|
]),
|
|
10889
|
-
skill("job-documenter", "orchestration", ["recommended", "full"], "Create and maintain persistent job documentation for orchestrated analysis, implementation, and review work.", [
|
|
10890
|
-
"Initialize job folders and state documents.",
|
|
10891
|
-
"Write analysis, context, implementation, verification, and review reports.",
|
|
10892
|
-
"Keep job README and status metadata current.",
|
|
10893
|
-
"Finalize traceable job documentation for the user and follow-up agents."
|
|
10894
|
-
]),
|
|
10895
10892
|
skill("context-collector", "orchestration", ["recommended", "full"], "Build compact task context from graph, ctx, wiki, memory, health, project-skills, and selected files.", [
|
|
10896
10893
|
"Start from the target question and list the minimum context needed.",
|
|
10897
10894
|
"Use gdgraph for relationships and gdctx for compact outputs.",
|
|
@@ -10922,12 +10919,6 @@ var init_catalog2 = __esm(() => {
|
|
|
10922
10919
|
"Rank files by importance and risk.",
|
|
10923
10920
|
"Produce a concise map of changes, dependencies, tests, and risks."
|
|
10924
10921
|
]),
|
|
10925
|
-
skill("feature-dev", "orchestration", ["full"], "Run a guided feature workflow from requirements to implementation, verification, and PR-ready summary.", [
|
|
10926
|
-
"Clarify requirements and implementation scope.",
|
|
10927
|
-
"Collect project context and relevant local patterns.",
|
|
10928
|
-
"Implement in small verified slices.",
|
|
10929
|
-
"Prepare review and PR-ready documentation."
|
|
10930
|
-
]),
|
|
10931
10922
|
skill("review-orchestrator", "review", ["recommended", "full"], "Route review requests to specialized reviewers and consolidate findings.", [
|
|
10932
10923
|
"Detect changed scope and relevant review domains.",
|
|
10933
10924
|
"Use gdgraph affected context for exported symbols and shared surfaces.",
|
|
@@ -11081,26 +11072,11 @@ var init_catalog2 = __esm(() => {
|
|
|
11081
11072
|
"Answer each comment once after the merge, in English, through `keryx review comments reply --final`.",
|
|
11082
11073
|
"Propose a learning update for configured authors; never apply it."
|
|
11083
11074
|
]),
|
|
11084
|
-
skill("code-ai-review", "review", ["full"], "Run the legacy strict AI review profile.", [
|
|
11085
|
-
"Load the AI review baseline rule.",
|
|
11086
|
-
"Review branch changes from merge-base.",
|
|
11087
|
-
"Report concrete findings first."
|
|
11088
|
-
]),
|
|
11089
11075
|
skill("code-learned-review", "review", ["full"], "Review against conventions this project learned from its own pull-request comments.", [
|
|
11090
11076
|
"Read .metaproject/review-learning.config.json and the project skill it names.",
|
|
11091
11077
|
"Apply that skill's learned lessons to the branch diff, citing the lesson behind each finding.",
|
|
11092
11078
|
"Stop and say so when the project has no learned skill \u2014 this reviewer has no conventions of its own."
|
|
11093
11079
|
]),
|
|
11094
|
-
skill("code-style-review", "review", ["full"], "Run the legacy code style and architecture review profile.", [
|
|
11095
|
-
"Load code-style rules and local conventions.",
|
|
11096
|
-
"Review naming, structure, boundaries, and TypeScript usage.",
|
|
11097
|
-
"Separate style issues from correctness defects."
|
|
11098
|
-
]),
|
|
11099
|
-
skill("code-mobx-store-review", "review", ["full"], "Run focused MobX store and state logic review.", [
|
|
11100
|
-
"Check actions, computed state, reactions, async boundaries, and view/store separation.",
|
|
11101
|
-
"Load MobX store template and local conventions.",
|
|
11102
|
-
"Report state bugs and maintainability risks."
|
|
11103
|
-
]),
|
|
11104
11080
|
skill("security-audit", "quality", ["recommended", "full"], "Run dependency and secret/security checks and normalize findings.", [
|
|
11105
11081
|
"Detect package manager and available audit commands.",
|
|
11106
11082
|
"Scan for dependency advisories and accidentally committed secrets.",
|
|
@@ -11172,20 +11148,10 @@ var init_catalog2 = __esm(() => {
|
|
|
11172
11148
|
"Run verification before deployment unless explicitly skipped.",
|
|
11173
11149
|
"Summarize deployment status, rollback path, and health checks."
|
|
11174
11150
|
]),
|
|
11175
|
-
skill("
|
|
11176
|
-
"
|
|
11177
|
-
"
|
|
11178
|
-
"
|
|
11179
|
-
]),
|
|
11180
|
-
skill("push", "quality", ["full"], "Push branches with safety checks, upstream handling, and concise result summary.", [
|
|
11181
|
-
"Check branch and remote state.",
|
|
11182
|
-
"Push the current branch with upstream when needed.",
|
|
11183
|
-
"Report remote branch and any follow-up needed."
|
|
11184
|
-
]),
|
|
11185
|
-
skill("pr", "quality", ["full"], "Prepare pull request creation or update context from local changes.", [
|
|
11186
|
-
"Collect branch, commits, diff summary, tests, and risks.",
|
|
11187
|
-
"Draft concise PR title and description.",
|
|
11188
|
-
"Use project issue links when available."
|
|
11151
|
+
skill("git-publish", "quality", ["full"], "Write commits, push branches and open pull requests with explicit staging, hook, upstream, force and PR-body rules.", [
|
|
11152
|
+
"Stage explicit paths and write a typed commit subject without trailers.",
|
|
11153
|
+
"Push with upstream, never force without being told, and ask on a dirty tree or main.",
|
|
11154
|
+
"Open the pull request over the whole branch and report its URL."
|
|
11189
11155
|
]),
|
|
11190
11156
|
skill("pr-issue-documenter", "quality", ["recommended", "full"], "Create PR descriptions and linked issue documentation from branch changes.", [
|
|
11191
11157
|
"Analyze commits and changed files.",
|
|
@@ -11222,36 +11188,6 @@ var init_catalog2 = __esm(() => {
|
|
|
11222
11188
|
"Test the idea sentence against the nearest competitor and the logo-swap test.",
|
|
11223
11189
|
"Plan palette with computed contrast, type, ASCII layout, motion, and exactly one signature element."
|
|
11224
11190
|
]),
|
|
11225
|
-
skill("project-discovery", "planning", ["full"], "Collect initial project facts, modules, constraints, stakeholders, and source references.", [
|
|
11226
|
-
"Inventory available docs, code modules, and entrypoints.",
|
|
11227
|
-
"Identify project purpose, users, constraints, and unknowns.",
|
|
11228
|
-
"Produce a structured discovery summary for PRD/spec work."
|
|
11229
|
-
]),
|
|
11230
|
-
skill("problem-definer", "planning", ["full"], "Define goals, non-goals, risks, constraints, and success metrics.", [
|
|
11231
|
-
"Separate problem, solution ideas, constraints, and open questions.",
|
|
11232
|
-
"Make goals and non-goals explicit.",
|
|
11233
|
-
"Define measurable success criteria."
|
|
11234
|
-
]),
|
|
11235
|
-
skill("stack-advisor", "planning", ["full"], "Recommend stack choices based on project level, constraints, team needs, and operational risk.", [
|
|
11236
|
-
"Classify project level and constraints.",
|
|
11237
|
-
"Compare stack options with trade-offs.",
|
|
11238
|
-
"Recommend a conservative default and explain risks."
|
|
11239
|
-
]),
|
|
11240
|
-
skill("patterns-researcher", "planning", ["full"], "Find architecture and implementation patterns for selected stack, domain, and project constraints.", [
|
|
11241
|
-
"Identify relevant existing local patterns first.",
|
|
11242
|
-
"Compare candidate patterns against constraints.",
|
|
11243
|
-
"Document chosen patterns and anti-patterns."
|
|
11244
|
-
]),
|
|
11245
|
-
skill("spec-writer", "planning", ["full"], "Write PRD, technical spec, or implementation plan constrained by decisions and evidence.", [
|
|
11246
|
-
"Collect source requirements and decisions.",
|
|
11247
|
-
"Write structured, testable sections.",
|
|
11248
|
-
"Link assumptions, open questions, and acceptance criteria."
|
|
11249
|
-
]),
|
|
11250
|
-
skill("consistency-checker", "planning", ["full"], "Check PRD, specs, plans, wiki, and decisions for contradictions or stale assumptions.", [
|
|
11251
|
-
"Compare documents against accepted decisions and current code context.",
|
|
11252
|
-
"Flag contradictions, missing constraints, and unsupported claims.",
|
|
11253
|
-
"Suggest minimal updates with provenance."
|
|
11254
|
-
]),
|
|
11255
11191
|
skill("docpack-orchestrator", "planning", ["recommended", "full"], "Create or update Metaproject requirements packages under docs/requirements with PRD, specification, README, optional protocols/schemas, verification, review, and roadmap updates. Use autodoc-orchestrator instead for reverse-engineering current codebase documentation.", [
|
|
11256
11192
|
"Design the required file set from requirements-package-standard.",
|
|
11257
11193
|
"Write or update README, PRD, specification, optional policies/protocols/schemas.",
|
|
@@ -11262,11 +11198,6 @@ var init_catalog2 = __esm(() => {
|
|
|
11262
11198
|
"Report blockers, warnings, and audit trail without rewriting docs.",
|
|
11263
11199
|
"Verify README/PRD/spec consistency and honest implementation status."
|
|
11264
11200
|
]),
|
|
11265
|
-
skill("planner", "planning", ["full"], "Produce roadmap, milestones, task breakdown, dependency graph, and sequencing.", [
|
|
11266
|
-
"Break goals into milestones and tasks.",
|
|
11267
|
-
"Identify dependencies, risks, and verification gates.",
|
|
11268
|
-
"Recommend execution order with small slices."
|
|
11269
|
-
]),
|
|
11270
11201
|
skill("autodoc-orchestrator", "planning", ["full"], "Coordinate reverse-engineering documentation for an existing codebase.", [
|
|
11271
11202
|
"Scan structure and identify documentation targets.",
|
|
11272
11203
|
"Analyze modules in small batches.",
|
|
@@ -11307,11 +11238,6 @@ var init_catalog2 = __esm(() => {
|
|
|
11307
11238
|
"Keep root entrypoints compact: non-project/highest-priority instructions plus `.metaproject/index.md` routing.",
|
|
11308
11239
|
"Verify `.metaproject/rules/entrypoints/index.md`, `.metaproject/rules/entrypoints/`, and `.metaproject/project-skills/entrypoints/` were updated."
|
|
11309
11240
|
]),
|
|
11310
|
-
renderedSkill("hook-manager", "platform", ["recommended", "full"], "Create and verify lightweight git hooks for graph, health, and skill verification.", [
|
|
11311
|
-
"Install hooks only when explicitly enabled.",
|
|
11312
|
-
"Keep hooks lightweight and idempotent.",
|
|
11313
|
-
"Avoid network and destructive behavior inside hooks."
|
|
11314
|
-
], ["install hook", "git hook", "post-commit"], "Use when a lightweight, explicitly-enabled git hook that runs graph, health, or skill verification after a commit, a checkout, or a merge needs installing or checking. NOT for: general hook design guidance not tied to these three (see hookify)."),
|
|
11315
11241
|
skill("scheduled-tasks", "platform", ["recommended", "full"], "Propose operator-confirmed scheduled background agent tasks with schedule_create.", [
|
|
11316
11242
|
"Pin down cadence, prompt, rates and ceiling; ask rather than guess.",
|
|
11317
11243
|
"Grant only the catalogue tools and repositories the task needs; keep the network off.",
|
|
@@ -11326,22 +11252,7 @@ var init_catalog2 = __esm(() => {
|
|
|
11326
11252
|
"Read existing agent entrypoints.",
|
|
11327
11253
|
"Patch managed guidance without deleting user-authored content.",
|
|
11328
11254
|
"Keep rule and skill links discoverable."
|
|
11329
|
-
])
|
|
11330
|
-
renderedSkill("skill-catalog-manager", "platform", ["minimal", "recommended", "full"], "Generate `.metaproject/skills/catalog.md` and machine-readable skill registry.", [
|
|
11331
|
-
"Read bundled and project-local skill metadata.",
|
|
11332
|
-
"Generate concise catalog entries grouped by category.",
|
|
11333
|
-
"Keep catalog deterministic and local-first."
|
|
11334
|
-
], ["skill catalog", "list skills", "skills registry"], "Use when `.metaproject/skills/catalog.md` or the machine-readable skill registry is missing or out of date with bundled and project-local skill metadata. NOT for: turning skills into runtime artifacts (see skill-runtime-exporter) or pushing them to local runtimes (see skill-sync)."),
|
|
11335
|
-
renderedSkill("skill-runtime-exporter", "platform", ["full"], "Export canonical skills to runtime-compatible Codex or Claude artifacts.", [
|
|
11336
|
-
"Read canonical skill packages.",
|
|
11337
|
-
"Remove management-only files from runtime exports.",
|
|
11338
|
-
"Keep runtime `SKILL.md` concise with references, scripts, and assets as needed."
|
|
11339
|
-
], ["export skill", "runtime skill", "codex skill"], "Use when canonical skill packages need turning into runtime-compatible Codex or Claude artifacts, stripped of management-only files. NOT for: regenerating the skill catalog (see skill-catalog-manager) or pushing the export to local runtimes (see skill-sync)."),
|
|
11340
|
-
renderedSkill("skill-sync", "platform", ["full"], "Sync exported runtime skills to configured local runtimes only when explicitly enabled.", [
|
|
11341
|
-
"Read configured runtime targets.",
|
|
11342
|
-
"Validate runtime skill packages before sync.",
|
|
11343
|
-
"Sync only selected skills and report changed files."
|
|
11344
|
-
], ["sync skills", "install runtime skills", "global skill sync"], "Use when already-exported runtime skills need pushing to configured local runtimes, and only when sync is explicitly enabled. NOT for: producing the runtime export itself (see skill-runtime-exporter).")
|
|
11255
|
+
])
|
|
11345
11256
|
];
|
|
11346
11257
|
BUNDLED_TREE_MARKER = path26.join("src", "gdskills", "bundled");
|
|
11347
11258
|
});
|
|
@@ -11377,12 +11288,10 @@ var init_skill_length_ceilings = __esm(() => {
|
|
|
11377
11288
|
CEILINGS_BY_KEY = {
|
|
11378
11289
|
"core/reviewer-skill-creator": 279,
|
|
11379
11290
|
"orchestration/code-verifier": 339,
|
|
11380
|
-
"orchestration/context-collector":
|
|
11291
|
+
"orchestration/context-collector": 662,
|
|
11381
11292
|
"orchestration/feature-analyzer": 447,
|
|
11382
|
-
"orchestration/feature-dev": 177,
|
|
11383
11293
|
"orchestration/flow-orchestrator": 682,
|
|
11384
11294
|
"orchestration/issue-analyzer": 373,
|
|
11385
|
-
"orchestration/job-documenter": 414,
|
|
11386
11295
|
"orchestration/job-orchestrator": 2197,
|
|
11387
11296
|
"orchestration/task-implementer": 661,
|
|
11388
11297
|
"planning/autodoc-analyst": 180,
|
|
@@ -11392,54 +11301,42 @@ var init_skill_length_ceilings = __esm(() => {
|
|
|
11392
11301
|
"planning/autodoc-scanner": 183,
|
|
11393
11302
|
"planning/autodoc-writer": 270,
|
|
11394
11303
|
"planning/brainstorm": 115,
|
|
11395
|
-
"planning/consistency-checker": 208,
|
|
11396
11304
|
"planning/docpack-orchestrator": 172,
|
|
11397
11305
|
"planning/docpack-review": 92,
|
|
11398
|
-
"planning/interview":
|
|
11306
|
+
"planning/interview": 208,
|
|
11399
11307
|
"planning/interviewer": 129,
|
|
11400
|
-
"planning/patterns-researcher": 254,
|
|
11401
|
-
"planning/planner": 208,
|
|
11402
11308
|
"planning/prd-creator": 210,
|
|
11403
11309
|
"planning/ui-direction": 177,
|
|
11404
|
-
"planning/problem-definer": 170,
|
|
11405
|
-
"planning/project-discovery": 183,
|
|
11406
|
-
"planning/spec-writer": 248,
|
|
11407
|
-
"planning/stack-advisor": 198,
|
|
11408
11310
|
"platform/agent-entrypoint-distiller": 78,
|
|
11409
11311
|
"platform/claude-md-management": 111,
|
|
11410
11312
|
"platform/hookify": 125,
|
|
11411
11313
|
"platform/scheduled-tasks": 96,
|
|
11412
11314
|
"quality/api-truth": 226,
|
|
11413
11315
|
"quality/changelog": 104,
|
|
11414
|
-
"quality/commit": 87,
|
|
11415
11316
|
"quality/db-migrate": 87,
|
|
11416
11317
|
"quality/dependency-update": 102,
|
|
11417
11318
|
"quality/deploy": 93,
|
|
11418
11319
|
"quality/deprecation-path": 268,
|
|
11419
11320
|
"quality/fresh-eyes": 190,
|
|
11321
|
+
"quality/git-publish": 60,
|
|
11420
11322
|
"quality/metaproject-security": 124,
|
|
11421
11323
|
"quality/perf-check": 104,
|
|
11422
|
-
"quality/pr": 95,
|
|
11423
11324
|
"quality/pr-issue-documenter": 401,
|
|
11424
|
-
"quality/push": 73,
|
|
11425
11325
|
"quality/root-cause": 204,
|
|
11426
11326
|
"quality/security-audit": 129,
|
|
11427
11327
|
"quality/test-gen": 101,
|
|
11428
11328
|
"quality/tests-creator": 360,
|
|
11429
11329
|
"quality/ui-craft": 173,
|
|
11430
|
-
"review/code-ai-review": 238,
|
|
11431
11330
|
"review/code-learned-review": 283,
|
|
11432
|
-
"review/code-mobx-store-review": 301,
|
|
11433
|
-
"review/code-style-review": 208,
|
|
11434
11331
|
"review/review-architecture": 373,
|
|
11435
11332
|
"review/review-backend": 361,
|
|
11436
11333
|
"review/review-clean-code": 538,
|
|
11437
11334
|
"review/review-core-boundaries": 158,
|
|
11438
11335
|
"review/review-degradation": 191,
|
|
11439
11336
|
"review/review-flow-graph": 183,
|
|
11440
|
-
"review/review-frontend":
|
|
11337
|
+
"review/review-frontend": 611,
|
|
11441
11338
|
"review/review-frontend-conventions": 206,
|
|
11442
|
-
"review/review-highload":
|
|
11339
|
+
"review/review-highload": 472,
|
|
11443
11340
|
"review/review-jev-comments": 179,
|
|
11444
11341
|
"review/review-jev-contract": 188,
|
|
11445
11342
|
"review/review-jev-docs": 184,
|
|
@@ -11448,16 +11345,16 @@ var init_skill_length_ceilings = __esm(() => {
|
|
|
11448
11345
|
"review/review-jev-scenarios": 182,
|
|
11449
11346
|
"review/review-layout": 237,
|
|
11450
11347
|
"review/review-logic": 365,
|
|
11451
|
-
"review/review-orchestrator":
|
|
11348
|
+
"review/review-orchestrator": 1565,
|
|
11452
11349
|
"review/review-performance": 354,
|
|
11453
|
-
"review/review-pr-contract":
|
|
11350
|
+
"review/review-pr-contract": 190,
|
|
11454
11351
|
"review/review-pr-feedback": 893,
|
|
11455
11352
|
"review/review-premise": 180,
|
|
11456
|
-
"review/review-regression":
|
|
11457
|
-
"review/review-security-code":
|
|
11458
|
-
"review/review-style":
|
|
11353
|
+
"review/review-regression": 212,
|
|
11354
|
+
"review/review-security-code": 358,
|
|
11355
|
+
"review/review-style": 354,
|
|
11459
11356
|
"review/review-testing-practices": 293,
|
|
11460
|
-
"review/review-ui-ux":
|
|
11357
|
+
"review/review-ui-ux": 267,
|
|
11461
11358
|
"review/review-verifier": 299
|
|
11462
11359
|
};
|
|
11463
11360
|
SKILL_LENGTH_CEILINGS = new Map(Object.entries(CEILINGS_BY_KEY));
|
|
@@ -11609,55 +11506,6 @@ var init_bundled_eval = __esm(() => {
|
|
|
11609
11506
|
sections: ["trigger-not-for"],
|
|
11610
11507
|
reason: "Phase 4 subagent dispatched only by autodoc-orchestrator, one instance per section; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11611
11508
|
}
|
|
11612
|
-
],
|
|
11613
|
-
[
|
|
11614
|
-
"planning/consistency-checker",
|
|
11615
|
-
{
|
|
11616
|
-
sections: ["trigger-not-for"],
|
|
11617
|
-
reason: "Phase 5 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11618
|
-
}
|
|
11619
|
-
],
|
|
11620
|
-
[
|
|
11621
|
-
"planning/planner",
|
|
11622
|
-
{
|
|
11623
|
-
sections: ["trigger-not-for"],
|
|
11624
|
-
reason: "Phase 6 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11625
|
-
}
|
|
11626
|
-
],
|
|
11627
|
-
[
|
|
11628
|
-
"planning/problem-definer",
|
|
11629
|
-
{
|
|
11630
|
-
sections: ["trigger-not-for"],
|
|
11631
|
-
reason: "Phase 1 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11632
|
-
}
|
|
11633
|
-
],
|
|
11634
|
-
[
|
|
11635
|
-
"planning/project-discovery",
|
|
11636
|
-
{
|
|
11637
|
-
sections: ["trigger-not-for"],
|
|
11638
|
-
reason: "Phase 0 subagent dispatched only by gproject-orchestrator, always called through it; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11639
|
-
}
|
|
11640
|
-
],
|
|
11641
|
-
[
|
|
11642
|
-
"planning/spec-writer",
|
|
11643
|
-
{
|
|
11644
|
-
sections: ["trigger-not-for"],
|
|
11645
|
-
reason: "Phase 4 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11646
|
-
}
|
|
11647
|
-
],
|
|
11648
|
-
[
|
|
11649
|
-
"planning/stack-advisor",
|
|
11650
|
-
{
|
|
11651
|
-
sections: ["trigger-not-for"],
|
|
11652
|
-
reason: "Phase 2 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11653
|
-
}
|
|
11654
|
-
],
|
|
11655
|
-
[
|
|
11656
|
-
"planning/patterns-researcher",
|
|
11657
|
-
{
|
|
11658
|
-
sections: ["trigger-not-for"],
|
|
11659
|
-
reason: "Phase 3 subagent dispatched only by gproject-orchestrator; never chosen by a user from a description. Its Iron Laws and Output Contract status enum substitute for a user-facing NOT-for clause."
|
|
11660
|
-
}
|
|
11661
11509
|
]
|
|
11662
11510
|
]);
|
|
11663
11511
|
PENDING_ANATOMY_BACKFILL = new Map([]);
|
|
@@ -20582,7 +20430,7 @@ var init_repomap = __esm(() => {
|
|
|
20582
20430
|
// src/session/preservation.ts
|
|
20583
20431
|
import { createHash as createHash10, randomUUID as randomUUID5 } from "crypto";
|
|
20584
20432
|
import { closeSync as closeSync4, fsyncSync, mkdirSync as mkdirSync4, openSync as openSync4, readdirSync as readdirSync5, readFileSync as readFileSync15, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
20585
|
-
import
|
|
20433
|
+
import path69 from "path";
|
|
20586
20434
|
function syncDir(dir) {
|
|
20587
20435
|
if (process.platform === "win32")
|
|
20588
20436
|
return;
|
|
@@ -20594,7 +20442,7 @@ function syncDir(dir) {
|
|
|
20594
20442
|
}
|
|
20595
20443
|
}
|
|
20596
20444
|
function writePreservationFile(file, body) {
|
|
20597
|
-
const dir =
|
|
20445
|
+
const dir = path69.dirname(file);
|
|
20598
20446
|
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
20599
20447
|
const tmp = `${file}.${randomUUID5()}.tmp`;
|
|
20600
20448
|
const fd = openSync4(tmp, "wx", 384);
|
|
@@ -20630,21 +20478,21 @@ function commitPreservation(dir, files, beforeSelect) {
|
|
|
20630
20478
|
throw new Error("preservation snapshot exceeds readable size limit");
|
|
20631
20479
|
}
|
|
20632
20480
|
const id = hash(body);
|
|
20633
|
-
const base =
|
|
20634
|
-
mkdirSync4(
|
|
20481
|
+
const base = path69.join(dir, "preservation");
|
|
20482
|
+
mkdirSync4(path69.join(base, "generations"), { recursive: true, mode: 448 });
|
|
20635
20483
|
syncDir(dir);
|
|
20636
20484
|
syncDir(base);
|
|
20637
|
-
writePreservationFile(
|
|
20485
|
+
writePreservationFile(path69.join(base, "generations", `${id}.json`), body);
|
|
20638
20486
|
beforeSelect?.();
|
|
20639
|
-
writePreservationFile(
|
|
20487
|
+
writePreservationFile(path69.join(base, "CURRENT"), id);
|
|
20640
20488
|
return id;
|
|
20641
20489
|
}
|
|
20642
20490
|
function readPreservation(dir, snapshotId) {
|
|
20643
|
-
const base =
|
|
20491
|
+
const base = path69.join(dir, "preservation");
|
|
20644
20492
|
let id = snapshotId;
|
|
20645
20493
|
if (id === undefined) {
|
|
20646
20494
|
try {
|
|
20647
|
-
id = readFileSync15(
|
|
20495
|
+
id = readFileSync15(path69.join(base, "CURRENT"), "utf8");
|
|
20648
20496
|
} catch (e) {
|
|
20649
20497
|
if (e.code === "ENOENT")
|
|
20650
20498
|
return;
|
|
@@ -20653,7 +20501,7 @@ function readPreservation(dir, snapshotId) {
|
|
|
20653
20501
|
}
|
|
20654
20502
|
if (!/^[a-f0-9]{64}$/.test(id))
|
|
20655
20503
|
throw new Error("invalid preservation identity");
|
|
20656
|
-
const read = readTranscriptFile(
|
|
20504
|
+
const read = readTranscriptFile(path69.join(base, "generations", `${id}.json`));
|
|
20657
20505
|
if (!read.ok)
|
|
20658
20506
|
throw new Error(`snapshot unreadable: ${read.reason}`);
|
|
20659
20507
|
if (hash(read.text) !== id)
|
|
@@ -20683,7 +20531,7 @@ function collectPreservationFiles(dir, rawSlate) {
|
|
|
20683
20531
|
for (const name of allowed) {
|
|
20684
20532
|
if (name === "slate.json")
|
|
20685
20533
|
continue;
|
|
20686
|
-
const read = readTranscriptFile(
|
|
20534
|
+
const read = readTranscriptFile(path69.join(dir, name));
|
|
20687
20535
|
if (read.ok)
|
|
20688
20536
|
files[name] = read.text;
|
|
20689
20537
|
else if (read.reason !== "absent")
|
|
@@ -20708,17 +20556,17 @@ function queuePreservedWrapUp(dir, rawSlate) {
|
|
|
20708
20556
|
...files["archive.jsonl"]?.trim() ? ["Transcript retained for evidence review"] : []
|
|
20709
20557
|
]
|
|
20710
20558
|
};
|
|
20711
|
-
const outbox =
|
|
20712
|
-
const target =
|
|
20559
|
+
const outbox = path69.join(dir, "preservation", "outbox");
|
|
20560
|
+
const target = path69.join(outbox, `${snapshot}.json`);
|
|
20713
20561
|
mkdirSync4(outbox, { recursive: true, mode: 448 });
|
|
20714
|
-
syncDir(
|
|
20562
|
+
syncDir(path69.dirname(outbox));
|
|
20715
20563
|
writePreservationFile(target, JSON.stringify(receipt));
|
|
20716
20564
|
return receipt;
|
|
20717
20565
|
}
|
|
20718
20566
|
function readPendingHistory(dir) {
|
|
20719
|
-
let read = readConfigFile(
|
|
20567
|
+
let read = readConfigFile(path69.join(dir, "preservation", "HISTORY"));
|
|
20720
20568
|
if (!read.ok && read.reason === "absent") {
|
|
20721
|
-
read = readConfigFile(
|
|
20569
|
+
read = readConfigFile(path69.join(dir, "preservation", "MIRRORING"));
|
|
20722
20570
|
}
|
|
20723
20571
|
if (!read.ok) {
|
|
20724
20572
|
if (read.reason === "absent")
|
|
@@ -20742,7 +20590,7 @@ var init_preservation = __esm(() => {
|
|
|
20742
20590
|
|
|
20743
20591
|
// src/session/slate.ts
|
|
20744
20592
|
import { mkdir as mkdir13, readFile as readFile32, readdir as readdir18, stat as stat12 } from "fs/promises";
|
|
20745
|
-
import
|
|
20593
|
+
import path70 from "path";
|
|
20746
20594
|
import { unlinkSync as unlinkSync3 } from "fs";
|
|
20747
20595
|
function isReservedNoteKey(key) {
|
|
20748
20596
|
return key.toLowerCase().startsWith(ASK_ANSWER_NOTE_PREFIX);
|
|
@@ -20753,7 +20601,7 @@ function modelNotesOf(notes) {
|
|
|
20753
20601
|
return Object.fromEntries(Object.entries(notes).filter(([key]) => !isReservedNoteKey(key)));
|
|
20754
20602
|
}
|
|
20755
20603
|
function slatePath(dir) {
|
|
20756
|
-
return
|
|
20604
|
+
return path70.join(dir, "slate.json");
|
|
20757
20605
|
}
|
|
20758
20606
|
function slateLockPath(dir) {
|
|
20759
20607
|
return `${slatePath(dir)}.lock`;
|
|
@@ -20777,14 +20625,14 @@ function workingMemoryOf(slate) {
|
|
|
20777
20625
|
};
|
|
20778
20626
|
}
|
|
20779
20627
|
async function readArchivedWorkingMemory(dir) {
|
|
20780
|
-
const archiveDir =
|
|
20628
|
+
const archiveDir = path70.join(dir, "slate-archive");
|
|
20781
20629
|
try {
|
|
20782
20630
|
const names = (await readdir18(archiveDir)).filter((n) => n.endsWith(".json"));
|
|
20783
|
-
const dated = await Promise.all(names.map(async (n) => ({ n, at: (await stat12(
|
|
20631
|
+
const dated = await Promise.all(names.map(async (n) => ({ n, at: (await stat12(path70.join(archiveDir, n))).mtimeMs })));
|
|
20784
20632
|
dated.sort((a, b) => b.at - a.at || (a.n < b.n ? 1 : -1));
|
|
20785
20633
|
for (const { n } of dated) {
|
|
20786
20634
|
try {
|
|
20787
|
-
const slate = JSON.parse(await readFile32(
|
|
20635
|
+
const slate = JSON.parse(await readFile32(path70.join(archiveDir, n), "utf8"));
|
|
20788
20636
|
const carry = workingMemoryOf(slate);
|
|
20789
20637
|
if (carry.trail !== undefined || carry.notes !== undefined || carry.answers !== undefined)
|
|
20790
20638
|
return carry;
|
|
@@ -20819,11 +20667,11 @@ async function archiveIfExistsLocked(dir, attemptId, signal) {
|
|
|
20819
20667
|
return;
|
|
20820
20668
|
throw error;
|
|
20821
20669
|
}
|
|
20822
|
-
const archiveDir =
|
|
20670
|
+
const archiveDir = path70.join(dir, "slate-archive");
|
|
20823
20671
|
await mkdir13(archiveDir, { recursive: true });
|
|
20824
20672
|
signal?.throwIfAborted();
|
|
20825
20673
|
queuePreservedWrapUp(dir, raw);
|
|
20826
|
-
writePreservationFile(
|
|
20674
|
+
writePreservationFile(path70.join(archiveDir, `${attemptId}.json`), raw);
|
|
20827
20675
|
unlinkSync3(slatePath(dir));
|
|
20828
20676
|
}
|
|
20829
20677
|
async function openSlateAtomic(dir, mintAttemptId, build, signal) {
|
|
@@ -20839,7 +20687,7 @@ async function openSlateAtomic(dir, mintAttemptId, build, signal) {
|
|
|
20839
20687
|
writePreservationFile(slatePath(dir), `${JSON.stringify(next, null, 2)}
|
|
20840
20688
|
`);
|
|
20841
20689
|
try {
|
|
20842
|
-
unlinkSync3(
|
|
20690
|
+
unlinkSync3(path70.join(dir, "terminal-state.json"));
|
|
20843
20691
|
} catch (error) {
|
|
20844
20692
|
if (!isNotFound(error))
|
|
20845
20693
|
throw error;
|
|
@@ -21241,9 +21089,9 @@ var init_validation = __esm(() => {
|
|
|
21241
21089
|
});
|
|
21242
21090
|
|
|
21243
21091
|
// src/memory/config.ts
|
|
21244
|
-
import
|
|
21092
|
+
import path80 from "path";
|
|
21245
21093
|
function memoryConfigPath(cwd) {
|
|
21246
|
-
return
|
|
21094
|
+
return path80.join(cwd, ".metaproject", "memory.config.json");
|
|
21247
21095
|
}
|
|
21248
21096
|
async function loadMemoryConfig(cwd) {
|
|
21249
21097
|
const file = memoryConfigPath(cwd);
|
|
@@ -21321,12 +21169,12 @@ var init_config4 = __esm(() => {
|
|
|
21321
21169
|
|
|
21322
21170
|
// src/memory/write.ts
|
|
21323
21171
|
import { mkdir as mkdir18, open as open6, readFile as readFile39, rename as rename4, rm as rm7, writeFile as writeFile9 } from "fs/promises";
|
|
21324
|
-
import
|
|
21172
|
+
import path83 from "path";
|
|
21325
21173
|
async function resolveCanonicalEntryPath(cwd, relativePath) {
|
|
21326
|
-
const root =
|
|
21327
|
-
const absolutePath =
|
|
21328
|
-
const normalized = toPosix2(
|
|
21329
|
-
if (!normalized || normalized.startsWith("../") ||
|
|
21174
|
+
const root = path83.resolve(memoryRoot(cwd));
|
|
21175
|
+
const absolutePath = path83.resolve(root, relativePath);
|
|
21176
|
+
const normalized = toPosix2(path83.relative(root, absolutePath));
|
|
21177
|
+
if (!normalized || normalized.startsWith("../") || path83.isAbsolute(normalized) || !normalized.endsWith(".md")) {
|
|
21330
21178
|
return null;
|
|
21331
21179
|
}
|
|
21332
21180
|
return { absolutePath, relativePath: normalized };
|
|
@@ -21379,9 +21227,9 @@ function validateNextEntry(relativePath, content) {
|
|
|
21379
21227
|
return null;
|
|
21380
21228
|
}
|
|
21381
21229
|
async function replaceAtomically(target, content) {
|
|
21382
|
-
const dir =
|
|
21230
|
+
const dir = path83.dirname(target);
|
|
21383
21231
|
await mkdir18(dir, { recursive: true });
|
|
21384
|
-
const tmp =
|
|
21232
|
+
const tmp = path83.join(dir, `.${path83.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
|
|
21385
21233
|
try {
|
|
21386
21234
|
await writeFile9(tmp, content, "utf8");
|
|
21387
21235
|
const file = await open6(tmp, "r");
|
|
@@ -21410,7 +21258,7 @@ function header(content, name) {
|
|
|
21410
21258
|
return content.match(new RegExp(`^${name}:\\s*(.+)$`, "mi"))?.[1]?.trim() ?? null;
|
|
21411
21259
|
}
|
|
21412
21260
|
function toPosix2(value) {
|
|
21413
|
-
return value.split(
|
|
21261
|
+
return value.split(path83.sep).join("/");
|
|
21414
21262
|
}
|
|
21415
21263
|
function message(cause) {
|
|
21416
21264
|
return cause instanceof Error ? cause.message : String(cause);
|
|
@@ -21522,9 +21370,9 @@ var init_evidence = __esm(() => {
|
|
|
21522
21370
|
});
|
|
21523
21371
|
|
|
21524
21372
|
// src/wiki/config.ts
|
|
21525
|
-
import
|
|
21373
|
+
import path84 from "path";
|
|
21526
21374
|
function wikiConfigPath(cwd) {
|
|
21527
|
-
return
|
|
21375
|
+
return path84.join(cwd, ".metaproject", "wiki.config.json");
|
|
21528
21376
|
}
|
|
21529
21377
|
function mergeWikiConfig(parsed) {
|
|
21530
21378
|
const base = DEFAULT_WIKI_CONFIG;
|
|
@@ -21602,12 +21450,12 @@ var init_config5 = __esm(() => {
|
|
|
21602
21450
|
// src/wiki/history.ts
|
|
21603
21451
|
import { createHash as createHash20, randomBytes as randomBytes4 } from "crypto";
|
|
21604
21452
|
import { appendFile as appendFile3, mkdir as mkdir19, open as open7, readFile as readFile41, rm as rm8, stat as stat13, writeFile as writeFile10 } from "fs/promises";
|
|
21605
|
-
import
|
|
21453
|
+
import path85 from "path";
|
|
21606
21454
|
function wikiRootPath(cwd) {
|
|
21607
|
-
return
|
|
21455
|
+
return path85.join(cwd, ".metaproject", "wiki");
|
|
21608
21456
|
}
|
|
21609
21457
|
function wikiHistoryRoot(cwd) {
|
|
21610
|
-
return
|
|
21458
|
+
return path85.join(cwd, ".metaproject", "data", "gdwiki", "history");
|
|
21611
21459
|
}
|
|
21612
21460
|
function newWikiRunId(now = new Date) {
|
|
21613
21461
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
@@ -21628,26 +21476,26 @@ async function openWikiWriteContext(cwd, command) {
|
|
|
21628
21476
|
return createWikiWriteContext(cwd, command, { keep: (await loadWikiConfig(cwd)).history.keep });
|
|
21629
21477
|
}
|
|
21630
21478
|
function wikiPageKey(cwd, absolutePath) {
|
|
21631
|
-
const relative =
|
|
21632
|
-
if (relative === "" || relative.startsWith("..") ||
|
|
21479
|
+
const relative = path85.relative(wikiRootPath(cwd), path85.resolve(absolutePath));
|
|
21480
|
+
if (relative === "" || relative.startsWith("..") || path85.isAbsolute(relative)) {
|
|
21633
21481
|
throw new Error(`not a wiki page: ${absolutePath}`);
|
|
21634
21482
|
}
|
|
21635
21483
|
return toPosix(relative);
|
|
21636
21484
|
}
|
|
21637
21485
|
function assertPageKey(page) {
|
|
21638
21486
|
const segments = page.split("/");
|
|
21639
|
-
if (page.length === 0 || page.includes("\\") ||
|
|
21487
|
+
if (page.length === 0 || page.includes("\\") || path85.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
21640
21488
|
throw new Error(`not a wiki page path: ${page}`);
|
|
21641
21489
|
}
|
|
21642
21490
|
return page;
|
|
21643
21491
|
}
|
|
21644
21492
|
function pageHistoryDir(cwd, page) {
|
|
21645
|
-
return
|
|
21493
|
+
return path85.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
|
|
21646
21494
|
}
|
|
21647
21495
|
function versionFilePath(cwd, page, file) {
|
|
21648
21496
|
const dir = pageHistoryDir(cwd, page);
|
|
21649
|
-
const target =
|
|
21650
|
-
if (!VERSION_FILE.test(file) ||
|
|
21497
|
+
const target = path85.join(dir, file);
|
|
21498
|
+
if (!VERSION_FILE.test(file) || path85.dirname(target) !== dir) {
|
|
21651
21499
|
throw new Error(`history index names an invalid version file for ${page}: ${file}`);
|
|
21652
21500
|
}
|
|
21653
21501
|
return target;
|
|
@@ -21714,7 +21562,7 @@ function parsePageHistoryIndex(markdown, page) {
|
|
|
21714
21562
|
return { page, rows };
|
|
21715
21563
|
}
|
|
21716
21564
|
async function readPageHistory(cwd, page) {
|
|
21717
|
-
const indexPath =
|
|
21565
|
+
const indexPath = path85.join(pageHistoryDir(cwd, page), INDEX_FILE);
|
|
21718
21566
|
const raw = await readBufferOrNull(indexPath);
|
|
21719
21567
|
if (raw === null)
|
|
21720
21568
|
return null;
|
|
@@ -21726,8 +21574,8 @@ async function readPageHistory(cwd, page) {
|
|
|
21726
21574
|
}
|
|
21727
21575
|
async function storeVersion(cwd, page, version, at, content) {
|
|
21728
21576
|
const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
|
|
21729
|
-
const target =
|
|
21730
|
-
await mkdir19(
|
|
21577
|
+
const target = path85.join(pageHistoryDir(cwd, page), fileName);
|
|
21578
|
+
await mkdir19(path85.dirname(target), { recursive: true });
|
|
21731
21579
|
await writeFile10(target, content);
|
|
21732
21580
|
if (sha2562(await readFile41(target)) !== sha2562(content)) {
|
|
21733
21581
|
throw new Error(`history: stored version does not match the page bytes: ${target}`);
|
|
@@ -21765,7 +21613,7 @@ function planPrune2(history, keep, maxRows = MAX_INDEX_ROWS) {
|
|
|
21765
21613
|
}
|
|
21766
21614
|
async function ensureHistoryRoot(cwd) {
|
|
21767
21615
|
const root = wikiHistoryRoot(cwd);
|
|
21768
|
-
const ignore =
|
|
21616
|
+
const ignore = path85.join(root, ".gitignore");
|
|
21769
21617
|
if (await readBufferOrNull(ignore))
|
|
21770
21618
|
return;
|
|
21771
21619
|
await mkdir19(root, { recursive: true });
|
|
@@ -21795,14 +21643,14 @@ async function endsWithoutNewline(file) {
|
|
|
21795
21643
|
}
|
|
21796
21644
|
async function appendRun(cwd, entry) {
|
|
21797
21645
|
const root = wikiHistoryRoot(cwd);
|
|
21798
|
-
const file =
|
|
21646
|
+
const file = path85.join(root, RUNS_FILE);
|
|
21799
21647
|
const lead = await endsWithoutNewline(file) ? `
|
|
21800
21648
|
` : "";
|
|
21801
21649
|
await appendFile3(file, `${lead}${JSON.stringify(entry)}
|
|
21802
21650
|
`, "utf8");
|
|
21803
21651
|
if ((await stat13(file)).size <= MAX_RUNS_BYTES)
|
|
21804
21652
|
return;
|
|
21805
|
-
await withFileLock2(
|
|
21653
|
+
await withFileLock2(path85.join(root, ".runs.lock"), async () => {
|
|
21806
21654
|
if ((await stat13(file)).size <= MAX_RUNS_BYTES)
|
|
21807
21655
|
return;
|
|
21808
21656
|
const lines = (await readFile41(file, "utf8")).split(`
|
|
@@ -21816,7 +21664,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
21816
21664
|
const page = wikiPageKey(ctx.cwd, absolutePath);
|
|
21817
21665
|
const dir = pageHistoryDir(ctx.cwd, page);
|
|
21818
21666
|
await ensureHistoryRoot(ctx.cwd);
|
|
21819
|
-
return withFileLock2(
|
|
21667
|
+
return withFileLock2(path85.join(path85.dirname(dir), `.${path85.basename(dir)}.lock`), async () => {
|
|
21820
21668
|
const live = await readBufferOrNull(absolutePath);
|
|
21821
21669
|
if (next === null ? live === null : live !== null && live.equals(next)) {
|
|
21822
21670
|
return { changed: false };
|
|
@@ -21840,7 +21688,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
21840
21688
|
if (next === null) {
|
|
21841
21689
|
await rm8(absolutePath, { force: true });
|
|
21842
21690
|
} else {
|
|
21843
|
-
await mkdir19(
|
|
21691
|
+
await mkdir19(path85.dirname(absolutePath), { recursive: true });
|
|
21844
21692
|
await writeFile10(absolutePath, next);
|
|
21845
21693
|
}
|
|
21846
21694
|
} catch (error) {
|
|
@@ -21848,7 +21696,7 @@ async function mutatePage(ctx, absolutePath, next) {
|
|
|
21848
21696
|
await rm8(versionFilePath(ctx.cwd, page, row.file), { force: true });
|
|
21849
21697
|
throw error;
|
|
21850
21698
|
}
|
|
21851
|
-
await writeFileAtomic(
|
|
21699
|
+
await writeFileAtomic(path85.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
|
|
21852
21700
|
for (const file of pruned)
|
|
21853
21701
|
await rm8(versionFilePath(ctx.cwd, page, file), { force: true });
|
|
21854
21702
|
return { changed: true, action };
|
|
@@ -28064,8 +27912,7 @@ var CORE_REVIEWERS = new Set([
|
|
|
28064
27912
|
"review-regression",
|
|
28065
27913
|
"review-degradation",
|
|
28066
27914
|
"review-core-boundaries",
|
|
28067
|
-
"code-boss-reviewer"
|
|
28068
|
-
"code-ai-review"
|
|
27915
|
+
"code-boss-reviewer"
|
|
28069
27916
|
]);
|
|
28070
27917
|
var SUPPORT_REVIEWERS = new Set([
|
|
28071
27918
|
"review-style",
|
|
@@ -28074,8 +27921,7 @@ var SUPPORT_REVIEWERS = new Set([
|
|
|
28074
27921
|
"review-vantage-testing",
|
|
28075
27922
|
"review-vantage-styling",
|
|
28076
27923
|
"review-layout",
|
|
28077
|
-
"review-ui-ux"
|
|
28078
|
-
"code-style-review"
|
|
27924
|
+
"review-ui-ux"
|
|
28079
27925
|
]);
|
|
28080
27926
|
|
|
28081
27927
|
// src/review/dedupe.ts
|
|
@@ -28896,8 +28742,228 @@ init_validator();
|
|
|
28896
28742
|
|
|
28897
28743
|
// src/lib/phase-trace.ts
|
|
28898
28744
|
import { appendFileSync as appendFileSync2 } from "fs";
|
|
28745
|
+
|
|
28746
|
+
// src/lib/call-diagnostics.ts
|
|
28747
|
+
init_config_dir();
|
|
28748
|
+
import { statSync as statSync5 } from "fs";
|
|
28749
|
+
import path65 from "path";
|
|
28750
|
+
var DEFAULT_WATCH_INTERVAL_MS = 30000;
|
|
28751
|
+
var DEFAULT_STALL_MS = 10 * 60000;
|
|
28752
|
+
var DEFAULT_REPEAT_MS = 15 * 60000;
|
|
28753
|
+
var DEFAULT_MAX_FILE_BYTES = 1e6;
|
|
28754
|
+
var SNAPSHOT_RECENT = 120;
|
|
28755
|
+
var HUMAN_STAGE_FACTOR = 3;
|
|
28756
|
+
var HUMAN_STAGES = new Set(["approval"]);
|
|
28757
|
+
function errText(e) {
|
|
28758
|
+
return e instanceof Error ? e.message : String(e);
|
|
28759
|
+
}
|
|
28760
|
+
function emptyMetrics() {
|
|
28761
|
+
return { callsStarted: 0, callsSettled: 0, callsByOutcome: {}, stages: {}, events: {}, dumps: 0, maxLoopLagMs: 0 };
|
|
28762
|
+
}
|
|
28763
|
+
function createCallDiagnostics(options = {}) {
|
|
28764
|
+
const now = options.now ?? (() => Date.now());
|
|
28765
|
+
const ringSize = options.ringSize ?? 300;
|
|
28766
|
+
let sink = options.sink;
|
|
28767
|
+
const bornAt = now();
|
|
28768
|
+
const calls = new Map;
|
|
28769
|
+
const probes = new Map;
|
|
28770
|
+
let ring = [];
|
|
28771
|
+
const metrics = emptyMetrics();
|
|
28772
|
+
let sessionId;
|
|
28773
|
+
let file;
|
|
28774
|
+
let lastLagMs = 0;
|
|
28775
|
+
let lastTickAt;
|
|
28776
|
+
let intervalMs = DEFAULT_WATCH_INTERVAL_MS;
|
|
28777
|
+
let stallMs = DEFAULT_STALL_MS;
|
|
28778
|
+
let repeatMs = DEFAULT_REPEAT_MS;
|
|
28779
|
+
let lastDumpAt;
|
|
28780
|
+
let lastDumpIds = new Set;
|
|
28781
|
+
const record = (label) => {
|
|
28782
|
+
ring.push(`${new Date(now()).toISOString()} ${label}`);
|
|
28783
|
+
if (ring.length > ringSize)
|
|
28784
|
+
ring = ring.slice(ring.length - ringSize);
|
|
28785
|
+
};
|
|
28786
|
+
const leaveStage = (call, at) => {
|
|
28787
|
+
const ms = Math.max(0, at - call.stageSince);
|
|
28788
|
+
const stat = metrics.stages[call.stage] ??= { count: 0, totalMs: 0, maxMs: 0 };
|
|
28789
|
+
stat.count += 1;
|
|
28790
|
+
stat.totalMs += ms;
|
|
28791
|
+
if (ms > stat.maxMs)
|
|
28792
|
+
stat.maxMs = ms;
|
|
28793
|
+
};
|
|
28794
|
+
const snapshot = (reason) => {
|
|
28795
|
+
const at = now();
|
|
28796
|
+
const probed = {};
|
|
28797
|
+
for (const [name, fn] of probes) {
|
|
28798
|
+
try {
|
|
28799
|
+
probed[name] = fn();
|
|
28800
|
+
} catch (e) {
|
|
28801
|
+
probed[name] = { probeError: errText(e) };
|
|
28802
|
+
}
|
|
28803
|
+
}
|
|
28804
|
+
let rssBytes;
|
|
28805
|
+
try {
|
|
28806
|
+
rssBytes = process.memoryUsage().rss;
|
|
28807
|
+
} catch {
|
|
28808
|
+
rssBytes = undefined;
|
|
28809
|
+
}
|
|
28810
|
+
let activeResources;
|
|
28811
|
+
try {
|
|
28812
|
+
const list = process.getActiveResourcesInfo?.();
|
|
28813
|
+
if (list !== undefined) {
|
|
28814
|
+
activeResources = {};
|
|
28815
|
+
for (const kind of list)
|
|
28816
|
+
activeResources[kind] = (activeResources[kind] ?? 0) + 1;
|
|
28817
|
+
}
|
|
28818
|
+
} catch {
|
|
28819
|
+
activeResources = undefined;
|
|
28820
|
+
}
|
|
28821
|
+
return {
|
|
28822
|
+
ts: new Date(at).toISOString(),
|
|
28823
|
+
reason,
|
|
28824
|
+
pid: process.pid,
|
|
28825
|
+
sessionId,
|
|
28826
|
+
uptimeMs: at - bornAt,
|
|
28827
|
+
calls: [...calls.values()].map((c) => ({
|
|
28828
|
+
id: c.id,
|
|
28829
|
+
name: c.name,
|
|
28830
|
+
ageMs: at - c.startedAt,
|
|
28831
|
+
stage: c.stage,
|
|
28832
|
+
stageAgeMs: at - c.stageSince,
|
|
28833
|
+
stageChanges: c.stageChanges
|
|
28834
|
+
})),
|
|
28835
|
+
metrics: structuredClone(metrics),
|
|
28836
|
+
probes: probed,
|
|
28837
|
+
loop: { lastLagMs, maxLagMs: metrics.maxLoopLagMs },
|
|
28838
|
+
process: { rssBytes, activeResources },
|
|
28839
|
+
recent: ring.slice(-SNAPSHOT_RECENT)
|
|
28840
|
+
};
|
|
28841
|
+
};
|
|
28842
|
+
const dump = (reason) => {
|
|
28843
|
+
let snap;
|
|
28844
|
+
try {
|
|
28845
|
+
snap = snapshot(reason);
|
|
28846
|
+
} catch {
|
|
28847
|
+
return;
|
|
28848
|
+
}
|
|
28849
|
+
if (sink === undefined)
|
|
28850
|
+
return snap;
|
|
28851
|
+
try {
|
|
28852
|
+
sink(JSON.stringify({ ...snap, metrics: { ...snap.metrics, dumps: metrics.dumps + 1 } }));
|
|
28853
|
+
} catch {
|
|
28854
|
+
return;
|
|
28855
|
+
}
|
|
28856
|
+
metrics.dumps += 1;
|
|
28857
|
+
return snap;
|
|
28858
|
+
};
|
|
28859
|
+
const tick = () => {
|
|
28860
|
+
const at = now();
|
|
28861
|
+
if (lastTickAt !== undefined) {
|
|
28862
|
+
const lag = Math.max(0, at - lastTickAt - intervalMs);
|
|
28863
|
+
lastLagMs = lag;
|
|
28864
|
+
if (lag > metrics.maxLoopLagMs)
|
|
28865
|
+
metrics.maxLoopLagMs = lag;
|
|
28866
|
+
}
|
|
28867
|
+
lastTickAt = at;
|
|
28868
|
+
const suspects = [...calls.values()].filter((c) => c.watched && at - c.stageSince >= (HUMAN_STAGES.has(c.stage) ? stallMs * HUMAN_STAGE_FACTOR : stallMs));
|
|
28869
|
+
if (suspects.length === 0) {
|
|
28870
|
+
lastDumpIds = new Set;
|
|
28871
|
+
return;
|
|
28872
|
+
}
|
|
28873
|
+
const ids = new Set(suspects.map((c) => c.id));
|
|
28874
|
+
const fresh = [...ids].some((id) => !lastDumpIds.has(id));
|
|
28875
|
+
const due = lastDumpAt === undefined || at - lastDumpAt >= repeatMs;
|
|
28876
|
+
if (!fresh && !due)
|
|
28877
|
+
return;
|
|
28878
|
+
lastDumpAt = at;
|
|
28879
|
+
lastDumpIds = ids;
|
|
28880
|
+
record(`diag stall suspected: ${suspects.map((c) => `${c.name}#${c.id}@${c.stage}`).join(", ")}`);
|
|
28881
|
+
dump("stall");
|
|
28882
|
+
};
|
|
28883
|
+
return {
|
|
28884
|
+
begin(id, name, opts) {
|
|
28885
|
+
const at = now();
|
|
28886
|
+
let key = id;
|
|
28887
|
+
for (let n = 2;calls.has(key); n += 1)
|
|
28888
|
+
key = `${id}~${n}`;
|
|
28889
|
+
calls.set(key, { id: key, name, startedAt: at, watched: opts?.watched !== false, stage: "start", stageSince: at, stageChanges: 0 });
|
|
28890
|
+
metrics.callsStarted += 1;
|
|
28891
|
+
return key;
|
|
28892
|
+
},
|
|
28893
|
+
stage(id, next) {
|
|
28894
|
+
const call = calls.get(id);
|
|
28895
|
+
if (call === undefined)
|
|
28896
|
+
return;
|
|
28897
|
+
const at = now();
|
|
28898
|
+
leaveStage(call, at);
|
|
28899
|
+
call.stage = next;
|
|
28900
|
+
call.stageSince = at;
|
|
28901
|
+
call.stageChanges += 1;
|
|
28902
|
+
},
|
|
28903
|
+
end(id, outcome) {
|
|
28904
|
+
const call = calls.get(id);
|
|
28905
|
+
if (call === undefined)
|
|
28906
|
+
return;
|
|
28907
|
+
leaveStage(call, now());
|
|
28908
|
+
calls.delete(id);
|
|
28909
|
+
metrics.callsSettled += 1;
|
|
28910
|
+
metrics.callsByOutcome[outcome] = (metrics.callsByOutcome[outcome] ?? 0) + 1;
|
|
28911
|
+
},
|
|
28912
|
+
event(kind, detail) {
|
|
28913
|
+
metrics.events[kind] = (metrics.events[kind] ?? 0) + 1;
|
|
28914
|
+
record(detail === undefined ? `event ${kind}` : `event ${kind} ${detail}`);
|
|
28915
|
+
},
|
|
28916
|
+
record,
|
|
28917
|
+
probe(name, fn) {
|
|
28918
|
+
probes.set(name, fn);
|
|
28919
|
+
return () => {
|
|
28920
|
+
if (probes.get(name) === fn)
|
|
28921
|
+
probes.delete(name);
|
|
28922
|
+
};
|
|
28923
|
+
},
|
|
28924
|
+
snapshot,
|
|
28925
|
+
dump,
|
|
28926
|
+
inFlight: () => [...calls.values()],
|
|
28927
|
+
dumpPath: () => file,
|
|
28928
|
+
tick,
|
|
28929
|
+
start(opts) {
|
|
28930
|
+
sessionId = opts.sessionId;
|
|
28931
|
+
intervalMs = opts.intervalMs ?? DEFAULT_WATCH_INTERVAL_MS;
|
|
28932
|
+
stallMs = opts.stallMs ?? DEFAULT_STALL_MS;
|
|
28933
|
+
repeatMs = opts.repeatMs ?? DEFAULT_REPEAT_MS;
|
|
28934
|
+
const cap = opts.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
28935
|
+
if (sink === undefined) {
|
|
28936
|
+
sink = (line) => {
|
|
28937
|
+
if (file === undefined) {
|
|
28938
|
+
const dir = ensureKeryxSubdir(["diagnostics"], opts.configDir);
|
|
28939
|
+
file = path65.join(dir, `${opts.sessionId.replace(/[^A-Za-z0-9._-]/g, "_")}.ndjson`);
|
|
28940
|
+
}
|
|
28941
|
+
let size = 0;
|
|
28942
|
+
try {
|
|
28943
|
+
size = statSync5(file).size;
|
|
28944
|
+
} catch {}
|
|
28945
|
+
if (size >= cap)
|
|
28946
|
+
throw new Error("diagnostics file is at its size cap");
|
|
28947
|
+
appendOwnerOnlyLine(file, line);
|
|
28948
|
+
};
|
|
28949
|
+
}
|
|
28950
|
+
lastTickAt = now();
|
|
28951
|
+
const timer = setInterval(() => {
|
|
28952
|
+
try {
|
|
28953
|
+
tick();
|
|
28954
|
+
} catch {}
|
|
28955
|
+
}, intervalMs);
|
|
28956
|
+
timer.unref?.();
|
|
28957
|
+
return () => clearInterval(timer);
|
|
28958
|
+
}
|
|
28959
|
+
};
|
|
28960
|
+
}
|
|
28961
|
+
var callDiagnostics = createCallDiagnostics();
|
|
28962
|
+
|
|
28963
|
+
// src/lib/phase-trace.ts
|
|
28899
28964
|
var ENV_PHASE_TRACE = "KERYX_PHASE_TRACE";
|
|
28900
28965
|
function tracePhase(label, env = process.env) {
|
|
28966
|
+
callDiagnostics.record(label);
|
|
28901
28967
|
const target = env[ENV_PHASE_TRACE];
|
|
28902
28968
|
if (target === undefined || target === "")
|
|
28903
28969
|
return;
|
|
@@ -28911,7 +28977,7 @@ function tracePhase(label, env = process.env) {
|
|
|
28911
28977
|
init_json();
|
|
28912
28978
|
init_shell_syntax();
|
|
28913
28979
|
import { readdir as readdir17, stat as stat11 } from "fs/promises";
|
|
28914
|
-
import
|
|
28980
|
+
import path66 from "path";
|
|
28915
28981
|
var PR_REF = /(?:github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+))|^#?(\d+)$/;
|
|
28916
28982
|
var REVIEW_ENDPOINT = /(?:^|\/)repos\/([^/]+\/[^/]+)\/pulls\/(\d+)\/reviews(?:\/\d+\/events)?\/?$/;
|
|
28917
28983
|
var PR_REVIEW_VALUE_FLAGS = new Set(["-R", "--repo", "-b", "--body", "-F", "--body-file"]);
|
|
@@ -28990,12 +29056,12 @@ async function boundPackages(cwd) {
|
|
|
28990
29056
|
}
|
|
28991
29057
|
const found = [];
|
|
28992
29058
|
for (const name of names) {
|
|
28993
|
-
const dir =
|
|
28994
|
-
const manifest = await readJsonFileOr(
|
|
29059
|
+
const dir = path66.join(reviewsRoot(cwd), name);
|
|
29060
|
+
const manifest = await readJsonFileOr(path66.join(dir, "manifest.json"), undefined);
|
|
28995
29061
|
if (manifest === undefined || !isPrBound(manifest.target))
|
|
28996
29062
|
continue;
|
|
28997
29063
|
const ref = parseRef(manifest.target.ref);
|
|
28998
|
-
const info = await stat11(
|
|
29064
|
+
const info = await stat11(path66.join(dir, "manifest.json")).catch(() => {
|
|
28999
29065
|
return;
|
|
29000
29066
|
});
|
|
29001
29067
|
found.push({ dir, id: manifest.reviewId, status: manifest.status, number: ref.number, repo: ref.repo, mtime: info?.mtimeMs ?? 0 });
|
|
@@ -29168,7 +29234,7 @@ init_command_risk();
|
|
|
29168
29234
|
init_contained_path();
|
|
29169
29235
|
import { createHash as createHash9 } from "crypto";
|
|
29170
29236
|
import { closeSync as closeSync3, constants as constants6, fstatSync as fstatSync3, openSync as openSync3, readSync } from "fs";
|
|
29171
|
-
import
|
|
29237
|
+
import path67 from "path";
|
|
29172
29238
|
|
|
29173
29239
|
// src/lib/review-path-flags.ts
|
|
29174
29240
|
init_args();
|
|
@@ -29326,7 +29392,7 @@ function carriesPreload(text) {
|
|
|
29326
29392
|
}
|
|
29327
29393
|
var MAX_BUNFIG_BYTES = 256 * 1024;
|
|
29328
29394
|
function readBunfig(root) {
|
|
29329
|
-
const file =
|
|
29395
|
+
const file = path67.join(root, "bunfig.toml");
|
|
29330
29396
|
let fd;
|
|
29331
29397
|
try {
|
|
29332
29398
|
fd = openSync3(file, constants6.O_RDONLY | constants6.O_NONBLOCK);
|
|
@@ -29407,10 +29473,10 @@ function movedTo(cwd, target) {
|
|
|
29407
29473
|
if (cwd === undefined || target === "" || target.startsWith("-") || isExpandable(target))
|
|
29408
29474
|
return;
|
|
29409
29475
|
const cdpath = process.env.CDPATH;
|
|
29410
|
-
if (cdpath !== undefined && cdpath !== "" && !
|
|
29476
|
+
if (cdpath !== undefined && cdpath !== "" && !path67.isAbsolute(target) && !target.startsWith("./") && !target.startsWith("../")) {
|
|
29411
29477
|
return;
|
|
29412
29478
|
}
|
|
29413
|
-
const lexical =
|
|
29479
|
+
const lexical = path67.resolve(cwd, target);
|
|
29414
29480
|
return realOrResolved(lexical) === lexical ? lexical : undefined;
|
|
29415
29481
|
}
|
|
29416
29482
|
function areReviewPathFlagsInside(sub, args, walk) {
|
|
@@ -29445,11 +29511,11 @@ function isOutsideReadFlag(word) {
|
|
|
29445
29511
|
return name.length >= 3 && name.startsWith("--") && GIT_OUTSIDE_READ_FLAGS.some((flag) => flag.startsWith(name));
|
|
29446
29512
|
}
|
|
29447
29513
|
function isOutsideRoot(projectRoot, target) {
|
|
29448
|
-
const relative =
|
|
29449
|
-
return relative === ".." || relative.startsWith(`..${
|
|
29514
|
+
const relative = path67.relative(projectRoot, target);
|
|
29515
|
+
return relative === ".." || relative.startsWith(`..${path67.sep}`) || path67.isAbsolute(relative);
|
|
29450
29516
|
}
|
|
29451
29517
|
function isEscapingOperand(word, cwd, projectRoot) {
|
|
29452
|
-
return isOutsideRoot(projectRoot, realOrResolved(
|
|
29518
|
+
return isOutsideRoot(projectRoot, realOrResolved(path67.resolve(cwd, word)));
|
|
29453
29519
|
}
|
|
29454
29520
|
function isGitReadConfined(words, walk) {
|
|
29455
29521
|
const cwd = walk.cwd;
|
|
@@ -29490,7 +29556,7 @@ function isTrustRoutineCommand(command, context = {}) {
|
|
|
29490
29556
|
const segments = splitSegments(command);
|
|
29491
29557
|
if (segments.length === 0 || segments.length > MAX_CHAIN_SEGMENTS)
|
|
29492
29558
|
return false;
|
|
29493
|
-
const cwd = realOrResolved(
|
|
29559
|
+
const cwd = realOrResolved(path67.resolve(context.cwd ?? process.cwd()));
|
|
29494
29560
|
const walk = { projectRoot: realOrResolved(resolveProjectRoot(cwd)), cwd, untrusted: context.untrustedContent === true };
|
|
29495
29561
|
return segments.every((seg) => (seg.precededBy === undefined || seg.precededBy === "&&") && !hasUnquotedMetacharacter(seg.raw) && !(isJudgedByWords(seg.words) && hasUnquotedExpansion(seg.raw)) && isRoutineSegment(seg.words, walk));
|
|
29496
29562
|
}
|
|
@@ -29527,7 +29593,7 @@ function resolveQuestionAnswerer(mode) {
|
|
|
29527
29593
|
// src/commands/automatic-review.ts
|
|
29528
29594
|
import { existsSync as existsSync17, lstatSync as lstatSync4, realpathSync as realpathSync4 } from "fs";
|
|
29529
29595
|
import { mkdir as mkdir12, writeFile as writeFile7 } from "fs/promises";
|
|
29530
|
-
import
|
|
29596
|
+
import path68 from "path";
|
|
29531
29597
|
|
|
29532
29598
|
// src/harness/tool/builtin/ask-user-tool.ts
|
|
29533
29599
|
var ASK_USER_DESCRIPTION = "Ask the user an interactive multiple-choice question (Claude-style interview). " + "Use when requirements are unclear, for interview steps, or to confirm a plan. " + "Provide 2\u20136 options with short descriptions; mark at most ONE option recommended when sensible (more than one is rejected). " + "Whenever you mark an option recommended, ALWAYS set recommendationReason: one sentence on why it is the better choice. " + "Input: { question: string, options: [{ id, label, description, recommended? }], recommendationReason?: string, allow_freeform?: boolean, action?: string, irreversible?: boolean, emergency?: string }. " + "Returns the chosen option id (or freeform text if allow_freeform). " + "irreversible: true means the question decides something that cannot be undone (release, publish, deploy, delete, push, merge to a shared branch, drop, force, reset, tag a version). " + 'action names that irreversible action (e.g. action: "release"). ' + "policy: { kind, facts } optionally tags a review question with its kind (scope, budget, option_choice, partial_coverage, smaller_slice, slice_order) " + "and numeric or boolean facts about the recommended option; only the automatic answerer reads it, as numbers and flags, never as text. " + `emergency: "gate-waiver" (a gate refusal needs the operator's quote) or "reduced-reviewer-set"; the only two cases an automatic review may put to the operator.`;
|
|
@@ -29749,20 +29815,20 @@ function realTarget(target) {
|
|
|
29749
29815
|
let existing = target;
|
|
29750
29816
|
const rest = [];
|
|
29751
29817
|
while (!entryExists(existing)) {
|
|
29752
|
-
const parent =
|
|
29818
|
+
const parent = path68.dirname(existing);
|
|
29753
29819
|
if (parent === existing)
|
|
29754
29820
|
return target;
|
|
29755
|
-
rest.unshift(
|
|
29821
|
+
rest.unshift(path68.basename(existing));
|
|
29756
29822
|
existing = parent;
|
|
29757
29823
|
}
|
|
29758
29824
|
try {
|
|
29759
|
-
return
|
|
29825
|
+
return path68.join(realpathSync4(existing), ...rest);
|
|
29760
29826
|
} catch {
|
|
29761
29827
|
return "";
|
|
29762
29828
|
}
|
|
29763
29829
|
}
|
|
29764
29830
|
function segmentsBelow(base, target) {
|
|
29765
|
-
return
|
|
29831
|
+
return path68.relative(base, target).split(/[\\/]/);
|
|
29766
29832
|
}
|
|
29767
29833
|
function hasOnlyPlainSegments(base, target) {
|
|
29768
29834
|
return segmentsBelow(base, target).every((segment) => PLAIN_SEGMENT.test(segment));
|
|
@@ -29771,7 +29837,7 @@ function touchesOperatorOnlyName(base, target) {
|
|
|
29771
29837
|
return segmentsBelow(base, target).some((segment) => OPERATOR_ONLY_NAMES.has(foldFileName(segment)));
|
|
29772
29838
|
}
|
|
29773
29839
|
function escapesPackage(realDir, real) {
|
|
29774
|
-
return !real.startsWith(`${realDir}${
|
|
29840
|
+
return !real.startsWith(`${realDir}${path68.sep}`);
|
|
29775
29841
|
}
|
|
29776
29842
|
|
|
29777
29843
|
class AutomaticReviewRun {
|
|
@@ -29809,11 +29875,11 @@ class AutomaticReviewRun {
|
|
|
29809
29875
|
return false;
|
|
29810
29876
|
}
|
|
29811
29877
|
const realDir = realTarget(dir);
|
|
29812
|
-
const isData = (file) => PACKAGE_DATA_EXTENSIONS.has(
|
|
29878
|
+
const isData = (file) => PACKAGE_DATA_EXTENSIONS.has(path68.extname(file).toLowerCase());
|
|
29813
29879
|
return targets.every((target) => {
|
|
29814
|
-
const resolved =
|
|
29880
|
+
const resolved = path68.resolve(this.cwd, target);
|
|
29815
29881
|
const real = realTarget(resolved);
|
|
29816
|
-
return resolved.startsWith(`${dir}${
|
|
29882
|
+
return resolved.startsWith(`${dir}${path68.sep}`) && !escapesPackage(realDir, real) && hasOnlyPlainSegments(dir, resolved) && hasOnlyPlainSegments(realDir, real) && isData(resolved) && isData(real) && !touchesOperatorOnlyName(dir, resolved) && !touchesOperatorOnlyName(realDir, real);
|
|
29817
29883
|
});
|
|
29818
29884
|
}
|
|
29819
29885
|
observe(command, result) {
|
|
@@ -29832,8 +29898,8 @@ class AutomaticReviewRun {
|
|
|
29832
29898
|
if (id === undefined || printed === undefined) {
|
|
29833
29899
|
return;
|
|
29834
29900
|
}
|
|
29835
|
-
const dir =
|
|
29836
|
-
const metaproject =
|
|
29901
|
+
const dir = path68.resolve(this.cwd, printed);
|
|
29902
|
+
const metaproject = path68.join(path68.resolve(this.cwd), ".metaproject") + path68.sep;
|
|
29837
29903
|
if (dir.startsWith(metaproject)) {
|
|
29838
29904
|
this.binding = { id, dir };
|
|
29839
29905
|
}
|
|
@@ -29878,13 +29944,13 @@ class AutomaticReviewRun {
|
|
|
29878
29944
|
}
|
|
29879
29945
|
summaryLine() {
|
|
29880
29946
|
const { manual, automatic } = this.disclosure();
|
|
29881
|
-
return `[automatic review] inputs: ${manual} manual, ${automatic} automatic${this.binding === undefined ? "" : ` (${
|
|
29947
|
+
return `[automatic review] inputs: ${manual} manual, ${automatic} automatic${this.binding === undefined ? "" : ` (${path68.relative(this.cwd, path68.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE))})`}`;
|
|
29882
29948
|
}
|
|
29883
29949
|
async writeDisclosure() {
|
|
29884
29950
|
if (this.binding === undefined) {
|
|
29885
29951
|
return;
|
|
29886
29952
|
}
|
|
29887
|
-
const file =
|
|
29953
|
+
const file = path68.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE);
|
|
29888
29954
|
await mkdir12(this.binding.dir, { recursive: true });
|
|
29889
29955
|
await writeFile7(file, `${JSON.stringify(this.disclosure(), null, 2)}
|
|
29890
29956
|
`, "utf8");
|
|
@@ -29945,27 +30011,27 @@ class AutomaticReviewRun {
|
|
|
29945
30011
|
if (this.binding !== undefined) {
|
|
29946
30012
|
return this.insidePackage(value);
|
|
29947
30013
|
}
|
|
29948
|
-
const resolved =
|
|
29949
|
-
return resolved.startsWith(reviewsRoot(
|
|
30014
|
+
const resolved = path68.resolve(this.cwd, value);
|
|
30015
|
+
return resolved.startsWith(reviewsRoot(path68.resolve(this.cwd)) + path68.sep);
|
|
29950
30016
|
}
|
|
29951
30017
|
insidePackage(value) {
|
|
29952
30018
|
const dir = this.binding?.dir;
|
|
29953
30019
|
if (dir === undefined) {
|
|
29954
30020
|
return false;
|
|
29955
30021
|
}
|
|
29956
|
-
const resolved =
|
|
29957
|
-
return resolved === dir || resolved.startsWith(`${dir}${
|
|
30022
|
+
const resolved = path68.resolve(this.cwd, value);
|
|
30023
|
+
return resolved === dir || resolved.startsWith(`${dir}${path68.sep}`);
|
|
29958
30024
|
}
|
|
29959
30025
|
insideCwd(value) {
|
|
29960
|
-
const resolved =
|
|
29961
|
-
const root =
|
|
29962
|
-
return resolved === root || resolved.startsWith(`${root}${
|
|
30026
|
+
const resolved = path68.resolve(this.cwd, value);
|
|
30027
|
+
const root = path68.resolve(this.cwd);
|
|
30028
|
+
return resolved === root || resolved.startsWith(`${root}${path68.sep}`);
|
|
29963
30029
|
}
|
|
29964
30030
|
namesReviewPackage(value) {
|
|
29965
30031
|
if (value === "" || value.startsWith("-"))
|
|
29966
30032
|
return false;
|
|
29967
|
-
const asPath =
|
|
29968
|
-
if (!/[\\/]/.test(value) && value !== "." && value !== ".." && !existsSync17(
|
|
30033
|
+
const asPath = path68.resolve(this.cwd, value);
|
|
30034
|
+
if (!/[\\/]/.test(value) && value !== "." && value !== ".." && !existsSync17(path68.join(asPath, "manifest.json")))
|
|
29969
30035
|
return true;
|
|
29970
30036
|
return this.insideCwd(value) && isReviewPackageDir(asPath, this.cwd);
|
|
29971
30037
|
}
|
|
@@ -29973,7 +30039,7 @@ class AutomaticReviewRun {
|
|
|
29973
30039
|
if (this.binding === undefined) {
|
|
29974
30040
|
return false;
|
|
29975
30041
|
}
|
|
29976
|
-
return ref === this.binding.id ||
|
|
30042
|
+
return ref === this.binding.id || path68.resolve(this.cwd, ref) === this.binding.dir;
|
|
29977
30043
|
}
|
|
29978
30044
|
}
|
|
29979
30045
|
|
|
@@ -30014,7 +30080,7 @@ function composeAbortSignals(external, internal) {
|
|
|
30014
30080
|
var ENV_CALL_WATCHDOG_MS = "KERYX_SPAWN_CALL_WATCHDOG_MS";
|
|
30015
30081
|
var DEFAULT_CALL_WATCHDOG_MS = 12 * 60000;
|
|
30016
30082
|
var ABORT_GRACE_MS = 1e4;
|
|
30017
|
-
var
|
|
30083
|
+
var HUMAN_STAGES2 = new Set(["approval"]);
|
|
30018
30084
|
function resolveCallWatchdogMs(env = process.env) {
|
|
30019
30085
|
const raw = env[ENV_CALL_WATCHDOG_MS];
|
|
30020
30086
|
if (raw === undefined || raw.trim() === "")
|
|
@@ -30024,33 +30090,53 @@ function resolveCallWatchdogMs(env = process.env) {
|
|
|
30024
30090
|
}
|
|
30025
30091
|
async function runWithCallWatchdog(name, run, options = {}) {
|
|
30026
30092
|
const capMs = options.capMs ?? resolveCallWatchdogMs();
|
|
30093
|
+
const callId = options.callId;
|
|
30094
|
+
const tag = callId === undefined ? name : `${name}#${callId}`;
|
|
30027
30095
|
let currentStage = "start";
|
|
30096
|
+
let diagKey;
|
|
30028
30097
|
const stage = {
|
|
30029
30098
|
get current() {
|
|
30030
30099
|
return currentStage;
|
|
30031
30100
|
},
|
|
30032
30101
|
set current(next) {
|
|
30033
30102
|
currentStage = next;
|
|
30034
|
-
tracePhase(`${
|
|
30103
|
+
tracePhase(`${tag} stage ${next}`);
|
|
30104
|
+
if (diagKey !== undefined)
|
|
30105
|
+
callDiagnostics.stage(diagKey, next);
|
|
30035
30106
|
}
|
|
30036
30107
|
};
|
|
30037
|
-
tracePhase(`${
|
|
30038
|
-
if (
|
|
30039
|
-
|
|
30108
|
+
tracePhase(`${tag} call start (watchdog ${capMs}ms)`);
|
|
30109
|
+
if (callId !== undefined)
|
|
30110
|
+
diagKey = callDiagnostics.begin(callId, name);
|
|
30111
|
+
if (capMs <= 0) {
|
|
30112
|
+
let kind = "error";
|
|
30113
|
+
try {
|
|
30114
|
+
const result = await run(options.signal, stage);
|
|
30115
|
+
kind = result.isError ? "error" : "ok";
|
|
30116
|
+
return result;
|
|
30117
|
+
} finally {
|
|
30118
|
+
if (diagKey !== undefined)
|
|
30119
|
+
callDiagnostics.end(diagKey, kind);
|
|
30120
|
+
}
|
|
30121
|
+
}
|
|
30040
30122
|
const graceMs = options.abortGraceMs ?? ABORT_GRACE_MS;
|
|
30041
30123
|
const inner = new AbortController;
|
|
30042
30124
|
const composed = composeAbortSignals(options.signal, inner.signal);
|
|
30043
30125
|
let timer;
|
|
30044
30126
|
let graceTimer;
|
|
30045
30127
|
let onAbort;
|
|
30128
|
+
let firedKind = undefined;
|
|
30046
30129
|
const stalled = new Promise((resolve) => {
|
|
30047
30130
|
const arm = () => {
|
|
30048
30131
|
timer = setTimeout(() => {
|
|
30049
|
-
if (
|
|
30132
|
+
if (HUMAN_STAGES2.has(stage.current)) {
|
|
30133
|
+
callDiagnostics.event("approval.rearm", tag);
|
|
30050
30134
|
arm();
|
|
30051
30135
|
return;
|
|
30052
30136
|
}
|
|
30053
|
-
tracePhase(`${
|
|
30137
|
+
tracePhase(`${tag} watchdog fired at stage ${stage.current}`);
|
|
30138
|
+
callDiagnostics.event("watchdog.fired", `${tag} stage=${stage.current}`);
|
|
30139
|
+
firedKind = "watchdog";
|
|
30054
30140
|
resolve({
|
|
30055
30141
|
output: `${name} did not finish within ${capMs}ms and was abandoned by the harness watchdog ` + `(stuck at stage "${stage.current}"; tune with ${ENV_CALL_WATCHDOG_MS}). Retry on a smaller slice instead of waiting.`,
|
|
30056
30142
|
isError: true
|
|
@@ -30063,10 +30149,14 @@ async function runWithCallWatchdog(name, run, options = {}) {
|
|
|
30063
30149
|
arm();
|
|
30064
30150
|
if (options.signal !== undefined) {
|
|
30065
30151
|
onAbort = () => {
|
|
30066
|
-
graceTimer = setTimeout(() =>
|
|
30067
|
-
|
|
30068
|
-
|
|
30069
|
-
|
|
30152
|
+
graceTimer = setTimeout(() => {
|
|
30153
|
+
firedKind = "aborted";
|
|
30154
|
+
callDiagnostics.event("abort.abandoned", `${tag} stage=${stage.current}`);
|
|
30155
|
+
resolve({
|
|
30156
|
+
output: `${name} was cancelled by the operator and did not stop on its own (stage "${stage.current}"); the call was abandoned.`,
|
|
30157
|
+
isError: true
|
|
30158
|
+
});
|
|
30159
|
+
}, graceMs);
|
|
30070
30160
|
};
|
|
30071
30161
|
if (options.signal.aborted)
|
|
30072
30162
|
onAbort();
|
|
@@ -30075,11 +30165,15 @@ async function runWithCallWatchdog(name, run, options = {}) {
|
|
|
30075
30165
|
}
|
|
30076
30166
|
});
|
|
30077
30167
|
const running = run(composed.signal, stage);
|
|
30168
|
+
let kind = "error";
|
|
30078
30169
|
try {
|
|
30079
30170
|
const outcome = await Promise.race([running, stalled]);
|
|
30080
|
-
|
|
30171
|
+
kind = firedKind ?? (outcome.isError ? "error" : "ok");
|
|
30172
|
+
tracePhase(`${tag} call settled`);
|
|
30081
30173
|
return outcome;
|
|
30082
30174
|
} finally {
|
|
30175
|
+
if (diagKey !== undefined)
|
|
30176
|
+
callDiagnostics.end(diagKey, kind);
|
|
30083
30177
|
if (timer !== undefined)
|
|
30084
30178
|
clearTimeout(timer);
|
|
30085
30179
|
if (graceTimer !== undefined)
|
|
@@ -30962,7 +31056,7 @@ function consolidateAnchors(removed) {
|
|
|
30962
31056
|
// src/harness/tool/output-spill.ts
|
|
30963
31057
|
import { createHash as createHash11 } from "crypto";
|
|
30964
31058
|
import { chmod as chmod4, mkdir as mkdir14, open as open5 } from "fs/promises";
|
|
30965
|
-
import
|
|
31059
|
+
import path71 from "path";
|
|
30966
31060
|
var TOOL_OUTPUT_SPILL_MAX_LINES = 2000;
|
|
30967
31061
|
var TOOL_OUTPUT_SPILL_MAX_BYTES = 50 * 1024;
|
|
30968
31062
|
var TOOL_OUTPUT_PREVIEW_CHARS = 16 * 1024;
|
|
@@ -31018,14 +31112,14 @@ var TOOL_OUTPUT_DIR_MODE = 448;
|
|
|
31018
31112
|
var TOOL_OUTPUT_FILE_MODE = 384;
|
|
31019
31113
|
var MAX_NAME_ATTEMPTS = 50;
|
|
31020
31114
|
async function writeUniqueOutputFile(sessionDir, toolCallId, text) {
|
|
31021
|
-
const dir =
|
|
31115
|
+
const dir = path71.join(sessionDir, TOOL_OUTPUT_DIRNAME);
|
|
31022
31116
|
try {
|
|
31023
31117
|
await mkdir14(dir, { recursive: true, mode: TOOL_OUTPUT_DIR_MODE });
|
|
31024
31118
|
await chmod4(dir, TOOL_OUTPUT_DIR_MODE);
|
|
31025
31119
|
const hash = createHash11("sha256").update(text).digest("hex").slice(0, 8);
|
|
31026
31120
|
const base = `${Date.now()}-${hash}-${safeFileStem(toolCallId)}`;
|
|
31027
31121
|
for (let attempt = 0;attempt < MAX_NAME_ATTEMPTS; attempt++) {
|
|
31028
|
-
const filePath =
|
|
31122
|
+
const filePath = path71.join(dir, `${base}${attempt === 0 ? "" : `-${attempt}`}.txt`);
|
|
31029
31123
|
let handle;
|
|
31030
31124
|
try {
|
|
31031
31125
|
handle = await open5(filePath, "wx", TOOL_OUTPUT_FILE_MODE);
|
|
@@ -31051,11 +31145,11 @@ async function writeToolOutputFile(sessionDir, toolCallId, text) {
|
|
|
31051
31145
|
return writeUniqueOutputFile(sessionDir, toolCallId, text);
|
|
31052
31146
|
}
|
|
31053
31147
|
function isInsideToolOutputDir(sessionDir, candidate) {
|
|
31054
|
-
if (!
|
|
31148
|
+
if (!path71.isAbsolute(candidate)) {
|
|
31055
31149
|
return false;
|
|
31056
31150
|
}
|
|
31057
|
-
const rel =
|
|
31058
|
-
return rel !== "" && rel !== ".." && !rel.startsWith(`..${
|
|
31151
|
+
const rel = path71.relative(path71.join(sessionDir, TOOL_OUTPUT_DIRNAME), path71.resolve(candidate));
|
|
31152
|
+
return rel !== "" && rel !== ".." && !rel.startsWith(`..${path71.sep}`) && !path71.isAbsolute(rel);
|
|
31059
31153
|
}
|
|
31060
31154
|
async function spillToolOutput(text, ctx) {
|
|
31061
31155
|
if (ctx.sessionDir === undefined || !exceedsSpillThreshold(text)) {
|
|
@@ -31377,12 +31471,12 @@ import {
|
|
|
31377
31471
|
renameSync as renameSync5,
|
|
31378
31472
|
writeFileSync as writeFileSync6
|
|
31379
31473
|
} from "fs";
|
|
31380
|
-
import
|
|
31474
|
+
import path73 from "path";
|
|
31381
31475
|
|
|
31382
31476
|
// src/session/paths.ts
|
|
31383
31477
|
import { existsSync as existsSync18 } from "fs";
|
|
31384
31478
|
import { homedir as homedir3 } from "os";
|
|
31385
|
-
import
|
|
31479
|
+
import path72 from "path";
|
|
31386
31480
|
function keryxDataDir(override) {
|
|
31387
31481
|
if (override !== undefined && override.length > 0) {
|
|
31388
31482
|
return override;
|
|
@@ -31394,22 +31488,22 @@ function keryxDataDir(override) {
|
|
|
31394
31488
|
const home = homedir3();
|
|
31395
31489
|
if (process.platform === "win32") {
|
|
31396
31490
|
const appData = process.env.APPDATA;
|
|
31397
|
-
const base = appData !== undefined && appData.length > 0 ? appData :
|
|
31398
|
-
return
|
|
31491
|
+
const base = appData !== undefined && appData.length > 0 ? appData : path72.join(home, "AppData", "Roaming");
|
|
31492
|
+
return path72.join(base, "keryx");
|
|
31399
31493
|
}
|
|
31400
31494
|
const xdg = process.env.XDG_DATA_HOME;
|
|
31401
|
-
const base = xdg !== undefined && xdg.length > 0 ? xdg :
|
|
31402
|
-
return
|
|
31495
|
+
const base = xdg !== undefined && xdg.length > 0 ? xdg : path72.join(home, ".local", "share");
|
|
31496
|
+
return path72.join(base, "keryx");
|
|
31403
31497
|
}
|
|
31404
31498
|
function resolveProjectRoot2(cwd) {
|
|
31405
|
-
const abs =
|
|
31499
|
+
const abs = path72.resolve(cwd);
|
|
31406
31500
|
let dir = abs;
|
|
31407
31501
|
for (;; ) {
|
|
31408
|
-
const gitPath =
|
|
31502
|
+
const gitPath = path72.join(dir, ".git");
|
|
31409
31503
|
if (existsSync18(gitPath)) {
|
|
31410
31504
|
return dir;
|
|
31411
31505
|
}
|
|
31412
|
-
const parent =
|
|
31506
|
+
const parent = path72.dirname(dir);
|
|
31413
31507
|
if (parent === dir) {
|
|
31414
31508
|
break;
|
|
31415
31509
|
}
|
|
@@ -31418,12 +31512,12 @@ function resolveProjectRoot2(cwd) {
|
|
|
31418
31512
|
return abs;
|
|
31419
31513
|
}
|
|
31420
31514
|
function projectKeyFromPath(projectPath) {
|
|
31421
|
-
const abs =
|
|
31515
|
+
const abs = path72.resolve(projectPath);
|
|
31422
31516
|
const encoded = encodeURIComponent(abs);
|
|
31423
31517
|
if (encoded.length <= 200) {
|
|
31424
31518
|
return encoded;
|
|
31425
31519
|
}
|
|
31426
|
-
const base =
|
|
31520
|
+
const base = path72.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
|
|
31427
31521
|
let h = 0;
|
|
31428
31522
|
for (let i = 0;i < abs.length; i++) {
|
|
31429
31523
|
h = Math.imul(31, h) + abs.charCodeAt(i) | 0;
|
|
@@ -31433,10 +31527,10 @@ function projectKeyFromPath(projectPath) {
|
|
|
31433
31527
|
}
|
|
31434
31528
|
function projectSessionsDir(projectPath, dataDir) {
|
|
31435
31529
|
const key = projectKeyFromPath(resolveProjectRoot2(projectPath));
|
|
31436
|
-
return
|
|
31530
|
+
return path72.join(keryxDataDir(dataDir), "sessions", key);
|
|
31437
31531
|
}
|
|
31438
31532
|
function sessionDir(projectPath, sessionId, dataDir) {
|
|
31439
|
-
return
|
|
31533
|
+
return path72.join(projectSessionsDir(projectPath, dataDir), sessionId);
|
|
31440
31534
|
}
|
|
31441
31535
|
|
|
31442
31536
|
// src/session/store.ts
|
|
@@ -31532,7 +31626,7 @@ function parseRemote(value) {
|
|
|
31532
31626
|
function readSummaryFile(file) {
|
|
31533
31627
|
let pending;
|
|
31534
31628
|
try {
|
|
31535
|
-
pending = readPendingHistory(
|
|
31629
|
+
pending = readPendingHistory(path73.dirname(file));
|
|
31536
31630
|
} catch {
|
|
31537
31631
|
pending = undefined;
|
|
31538
31632
|
}
|
|
@@ -31584,11 +31678,11 @@ class TranscriptUnreadableError extends Error {
|
|
|
31584
31678
|
}
|
|
31585
31679
|
}
|
|
31586
31680
|
function readJsonl(file) {
|
|
31587
|
-
const pending = readPendingHistory(
|
|
31681
|
+
const pending = readPendingHistory(path73.dirname(file));
|
|
31588
31682
|
if (pending === undefined && !existsSync19(file)) {
|
|
31589
31683
|
return [];
|
|
31590
31684
|
}
|
|
31591
|
-
const read = pending !== undefined ? { ok: true, text: pending.files[
|
|
31685
|
+
const read = pending !== undefined ? { ok: true, text: pending.files[path73.basename(file)] } : readTranscriptFile(file);
|
|
31592
31686
|
if (!read.ok) {
|
|
31593
31687
|
throw new TranscriptUnreadableError(file, read.reason);
|
|
31594
31688
|
}
|
|
@@ -31639,11 +31733,11 @@ function listSessions(cwd, dataDir) {
|
|
|
31639
31733
|
if (name.startsWith(".")) {
|
|
31640
31734
|
continue;
|
|
31641
31735
|
}
|
|
31642
|
-
const summary = readSummaryFile(
|
|
31736
|
+
const summary = readSummaryFile(path73.join(root, name, "summary.json"));
|
|
31643
31737
|
if (summary === undefined) {
|
|
31644
31738
|
continue;
|
|
31645
31739
|
}
|
|
31646
|
-
if (
|
|
31740
|
+
if (path73.resolve(summary.projectPath) !== path73.resolve(projectPath)) {
|
|
31647
31741
|
continue;
|
|
31648
31742
|
}
|
|
31649
31743
|
out.push(summary);
|
|
@@ -31676,15 +31770,15 @@ async function readSessionSlate(cwd, sessionId, dataDir) {
|
|
|
31676
31770
|
}
|
|
31677
31771
|
function loadContext(cwd, sessionId, dataDir) {
|
|
31678
31772
|
const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
|
|
31679
|
-
const contextPath =
|
|
31773
|
+
const contextPath = path73.join(dir, "context.jsonl");
|
|
31680
31774
|
if (readPendingHistory(dir) !== undefined || existsSync19(contextPath)) {
|
|
31681
31775
|
return readJsonl(contextPath);
|
|
31682
31776
|
}
|
|
31683
|
-
return readJsonl(
|
|
31777
|
+
return readJsonl(path73.join(dir, "transcript.jsonl"));
|
|
31684
31778
|
}
|
|
31685
31779
|
function loadArchive(cwd, sessionId, dataDir, onDegraded) {
|
|
31686
31780
|
const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
|
|
31687
|
-
const archivePath =
|
|
31781
|
+
const archivePath = path73.join(dir, "archive.jsonl");
|
|
31688
31782
|
if (readPendingHistory(dir) !== undefined || existsSync19(archivePath)) {
|
|
31689
31783
|
try {
|
|
31690
31784
|
const archive = readJsonl(archivePath);
|
|
@@ -32778,13 +32872,13 @@ async function executeWaves(tasks, waves, deps) {
|
|
|
32778
32872
|
init_fs();
|
|
32779
32873
|
init_slate();
|
|
32780
32874
|
import { mkdir as mkdir15, readFile as readFile33 } from "fs/promises";
|
|
32781
|
-
import
|
|
32875
|
+
import path74 from "path";
|
|
32782
32876
|
var listeners = new Set;
|
|
32783
32877
|
function clonePlan(plan) {
|
|
32784
32878
|
return { revision: plan.revision, items: plan.items.map((item) => ({ ...item })) };
|
|
32785
32879
|
}
|
|
32786
32880
|
function executionPlanPath(dir) {
|
|
32787
|
-
return
|
|
32881
|
+
return path74.join(dir, "plan.json");
|
|
32788
32882
|
}
|
|
32789
32883
|
async function readPlanFile(dir) {
|
|
32790
32884
|
let raw;
|
|
@@ -32921,7 +33015,7 @@ init_fs();
|
|
|
32921
33015
|
init_slate();
|
|
32922
33016
|
import { createHash as createHash23, randomUUID as randomUUID11 } from "crypto";
|
|
32923
33017
|
import { mkdir as mkdir21 } from "fs/promises";
|
|
32924
|
-
import
|
|
33018
|
+
import path88 from "path";
|
|
32925
33019
|
|
|
32926
33020
|
// src/sac/trusted-wrap-up.ts
|
|
32927
33021
|
import { createHash as createHash13, randomUUID as randomUUID6 } from "crypto";
|
|
@@ -32965,12 +33059,12 @@ function digest(value) {
|
|
|
32965
33059
|
init_fs();
|
|
32966
33060
|
import { createHash as createHash22, randomUUID as randomUUID9 } from "crypto";
|
|
32967
33061
|
import { appendFile as appendFile4, mkdir as mkdir20, readdir as readdir21, readFile as readFile44 } from "fs/promises";
|
|
32968
|
-
import
|
|
33062
|
+
import path87 from "path";
|
|
32969
33063
|
|
|
32970
33064
|
// src/sac/index.ts
|
|
32971
33065
|
import { access as access2, readFile as readFile34, realpath as realpath10 } from "fs/promises";
|
|
32972
33066
|
import { createHash as createHash14 } from "crypto";
|
|
32973
|
-
import
|
|
33067
|
+
import path75 from "path";
|
|
32974
33068
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
32975
33069
|
|
|
32976
33070
|
// src/sac/workspace-reference.ts
|
|
@@ -32993,21 +33087,21 @@ var normativeSchemaFiles = {
|
|
|
32993
33087
|
"review-decision": "review-decision.schema.json"
|
|
32994
33088
|
};
|
|
32995
33089
|
var normativeSchemas = new Map;
|
|
32996
|
-
var NORMATIVE_SCHEMA_DIR =
|
|
33090
|
+
var NORMATIVE_SCHEMA_DIR = path75.join("docs", "requirements", "shared-agent-context", "schemas");
|
|
32997
33091
|
async function resolveSacNormativeSchemaPath(fileName, searchFrom = [fileURLToPath3(new URL(".", import.meta.url)), process.cwd()]) {
|
|
32998
33092
|
const seen = new Set;
|
|
32999
33093
|
for (const start of searchFrom) {
|
|
33000
|
-
let dir =
|
|
33094
|
+
let dir = path75.resolve(start);
|
|
33001
33095
|
for (let i = 0;i < 10; i++) {
|
|
33002
33096
|
if (seen.has(dir))
|
|
33003
33097
|
break;
|
|
33004
33098
|
seen.add(dir);
|
|
33005
|
-
const candidate =
|
|
33099
|
+
const candidate = path75.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
|
|
33006
33100
|
try {
|
|
33007
33101
|
await access2(candidate);
|
|
33008
33102
|
return candidate;
|
|
33009
33103
|
} catch {}
|
|
33010
|
-
const parent =
|
|
33104
|
+
const parent = path75.dirname(dir);
|
|
33011
33105
|
if (parent === dir)
|
|
33012
33106
|
break;
|
|
33013
33107
|
dir = parent;
|
|
@@ -33669,12 +33763,12 @@ class SacReferenceError extends Error {
|
|
|
33669
33763
|
code = "unsafe_workspace_reference";
|
|
33670
33764
|
}
|
|
33671
33765
|
async function resolveWorkspaceReference(input) {
|
|
33672
|
-
if (!workspacePathPattern.test(input.uri) ||
|
|
33766
|
+
if (!workspacePathPattern.test(input.uri) || path75.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
|
|
33673
33767
|
throw new SacReferenceError("unsafe workspace reference");
|
|
33674
|
-
const lexicalRoot =
|
|
33768
|
+
const lexicalRoot = path75.resolve(input.workspaceRoot);
|
|
33675
33769
|
const root = await realpath10(lexicalRoot);
|
|
33676
|
-
const candidate =
|
|
33677
|
-
if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${
|
|
33770
|
+
const candidate = path75.resolve(lexicalRoot, input.uri.slice(2));
|
|
33771
|
+
if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path75.sep}`))
|
|
33678
33772
|
throw new SacReferenceError("workspace reference escapes root");
|
|
33679
33773
|
let resolved;
|
|
33680
33774
|
try {
|
|
@@ -33682,7 +33776,7 @@ async function resolveWorkspaceReference(input) {
|
|
|
33682
33776
|
} catch {
|
|
33683
33777
|
throw new SacReferenceError("workspace reference is not resolvable");
|
|
33684
33778
|
}
|
|
33685
|
-
if (resolved !== root && !resolved.startsWith(`${root}${
|
|
33779
|
+
if (resolved !== root && !resolved.startsWith(`${root}${path75.sep}`))
|
|
33686
33780
|
throw new SacReferenceError("workspace reference escapes root after realpath");
|
|
33687
33781
|
return candidate;
|
|
33688
33782
|
}
|
|
@@ -33738,16 +33832,16 @@ async function evaluateStrictSacGuard(input) {
|
|
|
33738
33832
|
init_fs();
|
|
33739
33833
|
import { mkdir as mkdir16, readdir as readdir19, readFile as readFile35 } from "fs/promises";
|
|
33740
33834
|
import { createHash as createHash15, randomUUID as randomUUID7 } from "crypto";
|
|
33741
|
-
import
|
|
33835
|
+
import path77 from "path";
|
|
33742
33836
|
|
|
33743
33837
|
// src/sac/secure-resource-read.ts
|
|
33744
33838
|
init_contained_read();
|
|
33745
33839
|
init_descriptor_read();
|
|
33746
|
-
import
|
|
33840
|
+
import path76 from "path";
|
|
33747
33841
|
function readWorkspaceFileNoFollow(workspaceRoot, absolutePath) {
|
|
33748
|
-
const relativePath =
|
|
33749
|
-
const components = relativePath.split(
|
|
33750
|
-
if (!relativePath ||
|
|
33842
|
+
const relativePath = path76.relative(workspaceRoot, absolutePath);
|
|
33843
|
+
const components = relativePath.split(path76.sep);
|
|
33844
|
+
if (!relativePath || path76.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
|
|
33751
33845
|
throw new Error("safe source path is not workspace-relative");
|
|
33752
33846
|
}
|
|
33753
33847
|
return readDescriptorChain(workspaceRoot, absolutePath, {
|
|
@@ -33774,8 +33868,8 @@ class WorkspaceService {
|
|
|
33774
33868
|
now;
|
|
33775
33869
|
constructor(options) {
|
|
33776
33870
|
this.options = options;
|
|
33777
|
-
this.root =
|
|
33778
|
-
this.storageRoot =
|
|
33871
|
+
this.root = path77.resolve(options.workspaceRoot);
|
|
33872
|
+
this.storageRoot = path77.resolve(options.storageRoot ?? path77.join(this.root, ".metaproject", "workspaces"));
|
|
33779
33873
|
this.now = options.now ?? (() => new Date);
|
|
33780
33874
|
}
|
|
33781
33875
|
async create(input) {
|
|
@@ -34101,13 +34195,13 @@ class WorkspaceService {
|
|
|
34101
34195
|
return parsed;
|
|
34102
34196
|
}
|
|
34103
34197
|
workspaceDir(id) {
|
|
34104
|
-
return
|
|
34198
|
+
return path77.join(this.storageRoot, id);
|
|
34105
34199
|
}
|
|
34106
34200
|
manifestPath(id) {
|
|
34107
|
-
return
|
|
34201
|
+
return path77.join(this.workspaceDir(id), "workspace.json");
|
|
34108
34202
|
}
|
|
34109
34203
|
lockPath(id) {
|
|
34110
|
-
return
|
|
34204
|
+
return path77.join(this.storageRoot, `.${id}.lock`);
|
|
34111
34205
|
}
|
|
34112
34206
|
timestamp() {
|
|
34113
34207
|
return this.now().toISOString();
|
|
@@ -34162,7 +34256,7 @@ function bindingHash(owner, intent) {
|
|
|
34162
34256
|
// src/sac/session-wrap-up.ts
|
|
34163
34257
|
import { createHash as createHash17 } from "crypto";
|
|
34164
34258
|
import { mkdir as mkdir17, writeFile as writeFile8 } from "fs/promises";
|
|
34165
|
-
import
|
|
34259
|
+
import path78 from "path";
|
|
34166
34260
|
init_wrap_up_evidence();
|
|
34167
34261
|
var WRAP_UP_TTL_MS = 60 * 60 * 1000;
|
|
34168
34262
|
|
|
@@ -34178,7 +34272,7 @@ function sessionEvidenceRef(workspaceId, sessionId) {
|
|
|
34178
34272
|
}
|
|
34179
34273
|
async function resolveSessionWrapUp(input) {
|
|
34180
34274
|
const now = input.now ?? (() => new Date);
|
|
34181
|
-
const sessionId =
|
|
34275
|
+
const sessionId = path78.posix.basename(input.sourceRef, ".md");
|
|
34182
34276
|
const summary = findSession(input.cwd, sessionId);
|
|
34183
34277
|
if (summary === undefined || input.sourceRef !== sessionEvidenceRef(input.workspaceId, summary.id)) {
|
|
34184
34278
|
throw new SessionWrapUpError("session_not_found", `no session matching "${input.sourceRef}" in this project \u2014 use \`keryx sessions list\``);
|
|
@@ -34195,7 +34289,7 @@ async function resolveSessionWrapUp(input) {
|
|
|
34195
34289
|
throw new SessionWrapUpError("session_unreadable", `session "${summary.id}" could not be read: ${cause.message}`);
|
|
34196
34290
|
}
|
|
34197
34291
|
const relPath = sessionEvidenceRef(input.workspaceId, summary.id).slice(2);
|
|
34198
|
-
const evidenceDir =
|
|
34292
|
+
const evidenceDir = path78.dirname(relPath);
|
|
34199
34293
|
const slate = await readSessionSlate(input.cwd, summary.id);
|
|
34200
34294
|
const diff = await gitDiff(input.cwd);
|
|
34201
34295
|
const diffBody = diff.kind === "measured" ? diff.text : unmeasurableDiffBody(diff.detail);
|
|
@@ -34217,23 +34311,23 @@ async function resolveSessionWrapUp(input) {
|
|
|
34217
34311
|
""
|
|
34218
34312
|
].join(`
|
|
34219
34313
|
`);
|
|
34220
|
-
const wrapUpRelPath =
|
|
34221
|
-
const diffRelPath =
|
|
34222
|
-
const noticeRelPath =
|
|
34314
|
+
const wrapUpRelPath = path78.join(evidenceDir, `${summary.id}.wrap-up.md`);
|
|
34315
|
+
const diffRelPath = path78.join(evidenceDir, `${summary.id}.diff.txt`);
|
|
34316
|
+
const noticeRelPath = path78.join(evidenceDir, `${summary.id}.redaction.md`);
|
|
34223
34317
|
const floor = await applyEvidenceRedactionFloor(input.cwd, [
|
|
34224
|
-
{ name:
|
|
34225
|
-
{ name:
|
|
34226
|
-
{ name:
|
|
34318
|
+
{ name: path78.basename(relPath), content: markdown, path: relPath, source: "generated" },
|
|
34319
|
+
{ name: path78.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
|
|
34320
|
+
{ name: path78.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
|
|
34227
34321
|
]);
|
|
34228
34322
|
if (!floor.ok)
|
|
34229
34323
|
throw new SessionWrapUpError("security_denied", floor.reason);
|
|
34230
34324
|
const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
|
|
34231
|
-
await mkdir17(
|
|
34232
|
-
await writeFile8(
|
|
34233
|
-
await writeFile8(
|
|
34234
|
-
await writeFile8(
|
|
34325
|
+
await mkdir17(path78.join(input.cwd, evidenceDir), { recursive: true });
|
|
34326
|
+
await writeFile8(path78.join(input.cwd, relPath), safeSession.content, "utf8");
|
|
34327
|
+
await writeFile8(path78.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
|
|
34328
|
+
await writeFile8(path78.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
|
|
34235
34329
|
if (floor.notice !== undefined)
|
|
34236
|
-
await writeFile8(
|
|
34330
|
+
await writeFile8(path78.join(input.cwd, noticeRelPath), floor.notice, "utf8");
|
|
34237
34331
|
const observedAt = now().toISOString();
|
|
34238
34332
|
const evidence = [
|
|
34239
34333
|
{ kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash17("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
|
|
@@ -34256,13 +34350,13 @@ async function resolveSessionWrapUp(input) {
|
|
|
34256
34350
|
init_fs();
|
|
34257
34351
|
import { createHash as createHash18, randomBytes as randomBytes3 } from "crypto";
|
|
34258
34352
|
import { readFile as readFile36 } from "fs/promises";
|
|
34259
|
-
import
|
|
34353
|
+
import path79 from "path";
|
|
34260
34354
|
var CONFIRM_TOKEN_TTL_MS = 2 * 60000;
|
|
34261
34355
|
function confirmTokenPath(cwd, workspaceId, proposalId) {
|
|
34262
|
-
return
|
|
34356
|
+
return path79.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
|
|
34263
34357
|
}
|
|
34264
34358
|
function confirmReceiptPath(cwd, workspaceId, proposalId, idempotencyKey) {
|
|
34265
|
-
return
|
|
34359
|
+
return path79.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha256(idempotencyKey)}.confirm-receipt.json`);
|
|
34266
34360
|
}
|
|
34267
34361
|
function sha256(text) {
|
|
34268
34362
|
return createHash18("sha256").update(text).digest("hex");
|
|
@@ -34303,21 +34397,21 @@ init_store();
|
|
|
34303
34397
|
init_config4();
|
|
34304
34398
|
import { readFile as readFile38, readdir as readdir20 } from "fs/promises";
|
|
34305
34399
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
34306
|
-
import
|
|
34400
|
+
import path82 from "path";
|
|
34307
34401
|
|
|
34308
34402
|
// src/sac/proposal-evidence.ts
|
|
34309
34403
|
init_fs();
|
|
34310
34404
|
import { createHash as createHash19 } from "crypto";
|
|
34311
34405
|
import { readFile as readFile37, rm as rm6 } from "fs/promises";
|
|
34312
|
-
import
|
|
34406
|
+
import path81 from "path";
|
|
34313
34407
|
function proposalPath(cwd, workspaceId, proposalId) {
|
|
34314
|
-
return
|
|
34408
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
|
|
34315
34409
|
}
|
|
34316
34410
|
function ownerReceiptPath(cwd, owner, workspaceId, idempotencyKey) {
|
|
34317
|
-
return
|
|
34411
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
|
|
34318
34412
|
}
|
|
34319
34413
|
function proposalNotePath(cwd, workspaceId, proposalId) {
|
|
34320
|
-
return
|
|
34414
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
|
|
34321
34415
|
}
|
|
34322
34416
|
async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
|
|
34323
34417
|
let proposal;
|
|
@@ -34331,7 +34425,7 @@ async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
|
|
|
34331
34425
|
return { ok: false, code: "no_evidence_to_write" };
|
|
34332
34426
|
let content;
|
|
34333
34427
|
try {
|
|
34334
|
-
content = await readFile37(
|
|
34428
|
+
content = await readFile37(path81.join(cwd, evidence.uri), "utf8");
|
|
34335
34429
|
} catch {
|
|
34336
34430
|
return { ok: false, code: "evidence_file_unreadable" };
|
|
34337
34431
|
}
|
|
@@ -34361,22 +34455,22 @@ function targetRelPath(targetRef) {
|
|
|
34361
34455
|
return targetRef.replace(/^\.\//, "");
|
|
34362
34456
|
}
|
|
34363
34457
|
function targetAbsolutePath(cwd, targetRef) {
|
|
34364
|
-
return
|
|
34458
|
+
return path81.join(cwd, ".metaproject", targetRelPath(targetRef));
|
|
34365
34459
|
}
|
|
34366
34460
|
function targetKey(targetRef) {
|
|
34367
34461
|
return digestOf(targetRelPath(targetRef)).slice(0, 32);
|
|
34368
34462
|
}
|
|
34369
34463
|
function ownerTargetVersionPath(cwd, owner, workspaceId, targetRef) {
|
|
34370
|
-
return
|
|
34464
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
|
|
34371
34465
|
}
|
|
34372
34466
|
function ownerTargetLockPath(cwd, owner, targetRef) {
|
|
34373
|
-
return
|
|
34467
|
+
return path81.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
|
|
34374
34468
|
}
|
|
34375
34469
|
function ownerStagingDir(cwd, owner, workspaceId, idempotencyKey) {
|
|
34376
|
-
return
|
|
34470
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf(idempotencyKey).slice(0, 32));
|
|
34377
34471
|
}
|
|
34378
34472
|
function ownerConflictDir(cwd, owner, workspaceId, idempotencyKey) {
|
|
34379
|
-
return
|
|
34473
|
+
return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf(idempotencyKey).slice(0, 32));
|
|
34380
34474
|
}
|
|
34381
34475
|
async function readJson7(file) {
|
|
34382
34476
|
try {
|
|
@@ -34447,7 +34541,7 @@ async function applyGuardedTargetWrite(input) {
|
|
|
34447
34541
|
staged: input.staged,
|
|
34448
34542
|
stagedAt: receipt.completedAt
|
|
34449
34543
|
};
|
|
34450
|
-
await writeFileAtomic(
|
|
34544
|
+
await writeFileAtomic(path81.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
|
|
34451
34545
|
`);
|
|
34452
34546
|
const applied = await input.apply(input.staged);
|
|
34453
34547
|
if (!applied.ok) {
|
|
@@ -34473,15 +34567,15 @@ async function recoverStagedOwnerWrite(input) {
|
|
|
34473
34567
|
});
|
|
34474
34568
|
}
|
|
34475
34569
|
async function readStagedOwnerWrite(cwd, owner, workspaceId, idempotencyKey) {
|
|
34476
|
-
return readJson7(
|
|
34570
|
+
return readJson7(path81.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
|
|
34477
34571
|
}
|
|
34478
34572
|
async function recordConflict(input) {
|
|
34479
34573
|
const base = { targetRef: input.targetRef, expectedVersion: input.expectedVersion, currentVersion: input.currentVersion };
|
|
34480
34574
|
if (input.proposedContent === undefined)
|
|
34481
34575
|
return base;
|
|
34482
34576
|
const dir = ownerConflictDir(input.cwd, input.owner, input.intent.workspaceId, input.intent.idempotencyKey);
|
|
34483
|
-
await writeFileAtomic(
|
|
34484
|
-
const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${
|
|
34577
|
+
await writeFileAtomic(path81.join(dir, "proposed"), input.proposedContent);
|
|
34578
|
+
const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path81.basename(dir)}/proposed`;
|
|
34485
34579
|
return { ...base, diffRef };
|
|
34486
34580
|
}
|
|
34487
34581
|
|
|
@@ -34531,7 +34625,7 @@ async function resolveWorkspaceModule(cwd, workspaceId) {
|
|
|
34531
34625
|
}
|
|
34532
34626
|
}
|
|
34533
34627
|
async function collectWikiDecisionEntries(cwd) {
|
|
34534
|
-
const dir =
|
|
34628
|
+
const dir = path82.join(cwd, ".metaproject", "wiki", "decisions");
|
|
34535
34629
|
let files;
|
|
34536
34630
|
try {
|
|
34537
34631
|
files = (await readdir20(dir)).filter((name) => name.endsWith(".md"));
|
|
@@ -34540,12 +34634,12 @@ async function collectWikiDecisionEntries(cwd) {
|
|
|
34540
34634
|
}
|
|
34541
34635
|
const entries = [];
|
|
34542
34636
|
for (const file of files) {
|
|
34543
|
-
const absolutePath =
|
|
34637
|
+
const absolutePath = path82.join(dir, file);
|
|
34544
34638
|
try {
|
|
34545
34639
|
const content = await readFile38(absolutePath, "utf8");
|
|
34546
34640
|
entries.push({
|
|
34547
34641
|
absolutePath,
|
|
34548
|
-
relativePath:
|
|
34642
|
+
relativePath: path82.posix.join("decisions", file),
|
|
34549
34643
|
type: extractHeaderField(content, "Type") ?? "decision",
|
|
34550
34644
|
title: extractTitle(content),
|
|
34551
34645
|
version: extractHeaderField(content, "Version") ?? null,
|
|
@@ -34767,7 +34861,7 @@ function createRealMemoryOwnerWriter(cwd, opts) {
|
|
|
34767
34861
|
init_service4();
|
|
34768
34862
|
init_guard2();
|
|
34769
34863
|
import { readFile as readFile42 } from "fs/promises";
|
|
34770
|
-
import
|
|
34864
|
+
import path86 from "path";
|
|
34771
34865
|
function renderWrapUpDecisionPage(input) {
|
|
34772
34866
|
const note = input.note?.trim();
|
|
34773
34867
|
return `# ${input.title}
|
|
@@ -34808,7 +34902,7 @@ export is the source of truth for what actually happened.
|
|
|
34808
34902
|
`;
|
|
34809
34903
|
}
|
|
34810
34904
|
function wikiPageRelativePath(proposalId) {
|
|
34811
|
-
return
|
|
34905
|
+
return path86.posix.join("decisions", `sac-${proposalId}.md`);
|
|
34812
34906
|
}
|
|
34813
34907
|
function createRealWikiOwnerWriter(cwd, opts) {
|
|
34814
34908
|
const now = opts?.now ?? (() => new Date);
|
|
@@ -34816,7 +34910,7 @@ function createRealWikiOwnerWriter(cwd, opts) {
|
|
|
34816
34910
|
const relativePath = staged.relativePath;
|
|
34817
34911
|
const content = staged.content;
|
|
34818
34912
|
const history = await openWikiWriteContext(cwd, "sac proposal accept");
|
|
34819
|
-
await writeWikiPage(history,
|
|
34913
|
+
await writeWikiPage(history, path86.join(cwd, ".metaproject", "wiki", relativePath), content);
|
|
34820
34914
|
return { ok: true };
|
|
34821
34915
|
};
|
|
34822
34916
|
return {
|
|
@@ -34965,7 +35059,7 @@ class ProposalLifecycleService {
|
|
|
34965
35059
|
now;
|
|
34966
35060
|
constructor(options) {
|
|
34967
35061
|
this.options = options;
|
|
34968
|
-
this.root =
|
|
35062
|
+
this.root = path87.resolve(options.workspaceRoot);
|
|
34969
35063
|
this.now = options.now ?? (() => new Date);
|
|
34970
35064
|
}
|
|
34971
35065
|
async create(input) {
|
|
@@ -34985,7 +35079,7 @@ class ProposalLifecycleService {
|
|
|
34985
35079
|
if (manifest.status === "archived")
|
|
34986
35080
|
throw new ProposalLifecycleError("guard_denied", "workspace is archived");
|
|
34987
35081
|
const file = this.proposalPath(workspaceId, proposal.id);
|
|
34988
|
-
await mkdir20(
|
|
35082
|
+
await mkdir20(path87.dirname(file), { recursive: true, mode: 448 });
|
|
34989
35083
|
return withFileLock2(`${file}.lock`, async () => {
|
|
34990
35084
|
const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
|
|
34991
35085
|
if (consume !== "ok")
|
|
@@ -35013,7 +35107,7 @@ class ProposalLifecycleService {
|
|
|
35013
35107
|
return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
|
|
35014
35108
|
const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
|
|
35015
35109
|
const ledger = this.ledgerPath(input.workspaceId);
|
|
35016
|
-
await mkdir20(
|
|
35110
|
+
await mkdir20(path87.dirname(ledger), { recursive: true, mode: 448 });
|
|
35017
35111
|
return withFileLock2(`${ledger}.lock`, async () => {
|
|
35018
35112
|
const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
|
|
35019
35113
|
const events = records.filter((record) => record.recordType === "proposal-transition");
|
|
@@ -35055,7 +35149,7 @@ class ProposalLifecycleService {
|
|
|
35055
35149
|
} });
|
|
35056
35150
|
}
|
|
35057
35151
|
async listProposedProposals(workspaceId) {
|
|
35058
|
-
const proposalsDir =
|
|
35152
|
+
const proposalsDir = path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
|
|
35059
35153
|
let entries;
|
|
35060
35154
|
try {
|
|
35061
35155
|
entries = (await readdir21(proposalsDir)).filter((name) => name.endsWith(".json"));
|
|
@@ -35067,7 +35161,7 @@ class ProposalLifecycleService {
|
|
|
35067
35161
|
const proposals = [];
|
|
35068
35162
|
for (const entry of entries) {
|
|
35069
35163
|
try {
|
|
35070
|
-
const parsed = JSON.parse(await readFile44(
|
|
35164
|
+
const parsed = JSON.parse(await readFile44(path87.join(proposalsDir, entry), "utf8"));
|
|
35071
35165
|
if (parsed.recordType === "proposal-created")
|
|
35072
35166
|
proposals.push(parsed);
|
|
35073
35167
|
} catch {}
|
|
@@ -35333,31 +35427,31 @@ class ProposalLifecycleService {
|
|
|
35333
35427
|
}
|
|
35334
35428
|
}
|
|
35335
35429
|
proposalPath(workspaceId, proposalId) {
|
|
35336
|
-
return
|
|
35430
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
|
|
35337
35431
|
}
|
|
35338
35432
|
decisionRef(proposalId, key) {
|
|
35339
35433
|
return `./proposals/${proposalId}.${hash2(key)}.decision.json`;
|
|
35340
35434
|
}
|
|
35341
35435
|
decisionPath(workspaceId, proposalId, key) {
|
|
35342
|
-
return
|
|
35436
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
|
|
35343
35437
|
}
|
|
35344
35438
|
approvalRef(proposalId, key) {
|
|
35345
35439
|
return `./proposals/${proposalId}.${hash2(key)}.approval.json`;
|
|
35346
35440
|
}
|
|
35347
35441
|
approvalPath(workspaceId, proposalId, key) {
|
|
35348
|
-
return
|
|
35442
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
|
|
35349
35443
|
}
|
|
35350
35444
|
writeResultPath(workspaceId, proposalId, key) {
|
|
35351
|
-
return
|
|
35445
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
|
|
35352
35446
|
}
|
|
35353
35447
|
intentRef(proposalId, key) {
|
|
35354
35448
|
return `./proposals/${proposalId}.${hash2(key)}.write-intent.json`;
|
|
35355
35449
|
}
|
|
35356
35450
|
intentPath(workspaceId, proposalId, key) {
|
|
35357
|
-
return
|
|
35451
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
|
|
35358
35452
|
}
|
|
35359
35453
|
attemptPath(workspaceId, proposalId, key) {
|
|
35360
|
-
return
|
|
35454
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
|
|
35361
35455
|
}
|
|
35362
35456
|
async loadWriteResult(workspaceId, proposalId, key) {
|
|
35363
35457
|
try {
|
|
@@ -35384,7 +35478,7 @@ class ProposalLifecycleService {
|
|
|
35384
35478
|
}
|
|
35385
35479
|
}
|
|
35386
35480
|
ledgerPath(workspaceId) {
|
|
35387
|
-
return
|
|
35481
|
+
return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
|
|
35388
35482
|
}
|
|
35389
35483
|
timestamp() {
|
|
35390
35484
|
return this.now().toISOString();
|
|
@@ -35613,11 +35707,11 @@ async function resolveMachineWrapUp(input) {
|
|
|
35613
35707
|
`;
|
|
35614
35708
|
const seedsJson = `${JSON.stringify(seedsForKind.map((seed) => ({ text: seed.text, source: describeSource(seed.source) })), null, 2)}
|
|
35615
35709
|
`;
|
|
35616
|
-
const evidenceRelBase =
|
|
35710
|
+
const evidenceRelBase = path88.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
|
|
35617
35711
|
const floor = await applyEvidenceRedactionFloor(input.cwd, [
|
|
35618
|
-
{ name: `${input.kind}.diff.txt`, content: diffBody, path:
|
|
35619
|
-
{ name: `${input.kind}.flow.json`, content: flowSnapshotJson, path:
|
|
35620
|
-
{ name: `${input.kind}.seeds.json`, content: seedsJson, path:
|
|
35712
|
+
{ name: `${input.kind}.diff.txt`, content: diffBody, path: path88.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
|
|
35713
|
+
{ name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path88.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
|
|
35714
|
+
{ name: `${input.kind}.seeds.json`, content: seedsJson, path: path88.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
|
|
35621
35715
|
]);
|
|
35622
35716
|
if (!floor.ok)
|
|
35623
35717
|
return { ok: false, code: "security_denied", detail: floor.reason };
|
|
@@ -35671,14 +35765,14 @@ ${safeSeeds.content}`;
|
|
|
35671
35765
|
}
|
|
35672
35766
|
summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
|
|
35673
35767
|
}
|
|
35674
|
-
const evidenceDir =
|
|
35768
|
+
const evidenceDir = path88.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
|
|
35675
35769
|
await mkdir21(evidenceDir, { recursive: true });
|
|
35676
35770
|
const diffFile = `${input.kind}.${shortHash}.diff.txt`;
|
|
35677
35771
|
const flowFile = `${input.kind}.${shortHash}.flow.json`;
|
|
35678
35772
|
const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
|
|
35679
|
-
await writeFileAtomic(
|
|
35680
|
-
await writeFileAtomic(
|
|
35681
|
-
await writeFileAtomic(
|
|
35773
|
+
await writeFileAtomic(path88.join(evidenceDir, diffFile), safeDiff.content);
|
|
35774
|
+
await writeFileAtomic(path88.join(evidenceDir, flowFile), safeFlow.content);
|
|
35775
|
+
await writeFileAtomic(path88.join(evidenceDir, seedsFile), safeSeeds.content);
|
|
35682
35776
|
const observedAt = now().toISOString();
|
|
35683
35777
|
const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
|
|
35684
35778
|
const evidence = [
|
|
@@ -35688,7 +35782,7 @@ ${safeSeeds.content}`;
|
|
|
35688
35782
|
];
|
|
35689
35783
|
if (floor.notice !== undefined) {
|
|
35690
35784
|
const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
|
|
35691
|
-
await writeFileAtomic(
|
|
35785
|
+
await writeFileAtomic(path88.join(evidenceDir, noticeFile), floor.notice);
|
|
35692
35786
|
evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2563(floor.notice), observedAt });
|
|
35693
35787
|
}
|
|
35694
35788
|
return {
|
|
@@ -35707,18 +35801,18 @@ async function writeFlooredArchiveArtifact(params) {
|
|
|
35707
35801
|
{
|
|
35708
35802
|
name: params.filename,
|
|
35709
35803
|
content: params.content,
|
|
35710
|
-
path:
|
|
35804
|
+
path: path88.posix.join("slate-archive", params.filename),
|
|
35711
35805
|
source: "generated"
|
|
35712
35806
|
}
|
|
35713
35807
|
]);
|
|
35714
35808
|
if (!floor.ok)
|
|
35715
35809
|
return { ok: false, code: "security_denied", detail: floor.reason };
|
|
35716
35810
|
const body = floor.bodies[0];
|
|
35717
|
-
const archiveDir =
|
|
35811
|
+
const archiveDir = path88.join(params.dir, "slate-archive");
|
|
35718
35812
|
await mkdir21(archiveDir, { recursive: true });
|
|
35719
|
-
await writeFileAtomic(
|
|
35813
|
+
await writeFileAtomic(path88.join(archiveDir, params.filename), body.content);
|
|
35720
35814
|
if (floor.notice !== undefined) {
|
|
35721
|
-
await writeFileAtomic(
|
|
35815
|
+
await writeFileAtomic(path88.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
|
|
35722
35816
|
}
|
|
35723
35817
|
return { ok: true, altered: body.altered };
|
|
35724
35818
|
}
|
|
@@ -35754,9 +35848,9 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
|
|
|
35754
35848
|
return;
|
|
35755
35849
|
const refusalIso = now().toISOString();
|
|
35756
35850
|
const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
|
|
35757
|
-
const archiveDir =
|
|
35851
|
+
const archiveDir = path88.join(dir, "slate-archive");
|
|
35758
35852
|
await mkdir21(archiveDir, { recursive: true });
|
|
35759
|
-
await writeFileAtomic(
|
|
35853
|
+
await writeFileAtomic(path88.join(archiveDir, refusalFilename), `${JSON.stringify({
|
|
35760
35854
|
recordType: "wrap-up-outcome",
|
|
35761
35855
|
trigger,
|
|
35762
35856
|
generatedAt: refusalIso,
|
|
@@ -36091,7 +36185,7 @@ init_fs();
|
|
|
36091
36185
|
init_repomap();
|
|
36092
36186
|
init_redact();
|
|
36093
36187
|
init_slate();
|
|
36094
|
-
import
|
|
36188
|
+
import path89 from "path";
|
|
36095
36189
|
var DEFAULT_TERMINAL_STATE_MAX_TOKENS = 2000;
|
|
36096
36190
|
function boundedRedactedAnchorsSnapshot(anchors, maxTokens) {
|
|
36097
36191
|
const fence = anchors.fence?.map((entry) => redactSensitiveText(entry));
|
|
@@ -36126,7 +36220,7 @@ function renderTerminalStateBlock(state, opts) {
|
|
|
36126
36220
|
`);
|
|
36127
36221
|
}
|
|
36128
36222
|
async function writeTerminalState(dir, state) {
|
|
36129
|
-
await writeFileAtomic(
|
|
36223
|
+
await writeFileAtomic(path89.join(dir, "terminal-state.json"), `${JSON.stringify(state, null, 2)}
|
|
36130
36224
|
`);
|
|
36131
36225
|
}
|
|
36132
36226
|
|
|
@@ -38625,13 +38719,24 @@ async function executeCall(...args) {
|
|
|
38625
38719
|
function executeCallTraced(...args) {
|
|
38626
38720
|
const call = args[0];
|
|
38627
38721
|
if (call.name !== "spawn_subagent")
|
|
38628
|
-
return executeCallUnbounded(...args);
|
|
38722
|
+
return executeCallRegistered(call.id, call.name, () => executeCallUnbounded(...args));
|
|
38629
38723
|
return runWithCallWatchdog(call.name, (signal, stage) => {
|
|
38630
38724
|
const next = [...args];
|
|
38631
38725
|
next[9] = signal;
|
|
38632
38726
|
next[18] = stage;
|
|
38633
38727
|
return executeCallUnbounded(...next);
|
|
38634
|
-
}, { signal: args[9] });
|
|
38728
|
+
}, { signal: args[9], callId: call.id });
|
|
38729
|
+
}
|
|
38730
|
+
async function executeCallRegistered(id, name, run) {
|
|
38731
|
+
const key = callDiagnostics.begin(id, name, { watched: false });
|
|
38732
|
+
let kind = "error";
|
|
38733
|
+
try {
|
|
38734
|
+
const result = await run();
|
|
38735
|
+
kind = result.isError === true ? "error" : "ok";
|
|
38736
|
+
return result;
|
|
38737
|
+
} finally {
|
|
38738
|
+
callDiagnostics.end(key, kind);
|
|
38739
|
+
}
|
|
38635
38740
|
}
|
|
38636
38741
|
function personRefused(approver, signal) {
|
|
38637
38742
|
const { attended, current } = approver;
|