@mrciphersmith/keryx 0.4.27 → 0.4.29

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.
Files changed (97) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +105640 -105242
  3. package/dist/core.js +24 -200
  4. package/dist/keryx-general-worker-entry.js +355 -418
  5. package/package.json +3 -3
  6. package/src/gdskills/bundled/agents/work-planner.md +1 -1
  7. package/src/gdskills/bundled/install-manifest.json +4 -26
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +25 -153
  9. package/src/gdskills/bundled/rules/core/code-review-learned-profile.mdc +1 -2
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +1 -0
  11. package/src/gdskills/bundled/rules/core/definition-of-done.mdc +0 -1
  12. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -108
  13. package/src/gdskills/bundled/rules/core/implementation-doc-mandate.mdc +4 -5
  14. package/src/gdskills/bundled/rules/core/jobs-documentation.mdc +8 -8
  15. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  16. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +12 -10
  17. package/src/gdskills/bundled/rules/core/solid-principles.mdc +48 -123
  18. package/src/gdskills/bundled/skills/core/reviewer-skill-creator/SKILL.md +1 -1
  19. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.md +12 -21
  20. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.md +3 -3
  21. package/src/gdskills/bundled/skills/orchestration/flow-orchestrator/SKILL.md +1 -1
  22. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.md +1 -1
  23. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  24. package/src/gdskills/bundled/skills/orchestration/task-implementer/input-contract.schema.json +1 -1
  25. package/src/gdskills/bundled/skills/planning/autodoc-orchestrator/SKILL.md +1 -1
  26. package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.md +1 -1
  27. package/src/gdskills/bundled/skills/planning/interview/SKILL.md +3 -4
  28. package/src/gdskills/bundled/skills/planning/interviewer/SKILL.md +1 -1
  29. package/src/gdskills/bundled/skills/quality/git-publish/SKILL.md +60 -0
  30. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.md +1 -1
  31. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  32. package/src/gdskills/bundled/skills/review/code-learned-review/SKILL.md +3 -3
  33. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +6 -6
  34. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +23 -25
  35. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +100 -421
  36. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  37. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +6 -6
  38. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  39. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +36 -33
  40. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +1 -1
  41. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +63 -134
  42. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +4 -5
  43. package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.detail.md +18 -20
  44. package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.md +12 -18
  45. package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-finding.schema.json +2 -2
  46. package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-input.schema.json +2 -10
  47. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +35 -35
  48. package/src/gdskills/bundled/skills/review/review-pr-contract/SKILL.md +4 -5
  49. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +2 -2
  50. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +2 -4
  51. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +13 -14
  52. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +41 -44
  53. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +10 -10
  54. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +10 -11
  55. package/src/gdskills/bundled/skills/review/review-verifier/SKILL.md +5 -5
  56. package/src/gdskills/bundled/skills/shared/git-merge-base.md +1 -1
  57. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +4 -3
  58. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +3 -3
  59. package/src/gdskills/bundled/stacks/mobx/agent-refs.json +1 -1
  60. package/src/gdskills/bundled/stacks/mobx/governance/scout.json +2 -2
  61. package/src/gdskills/bundled/stacks/mobx/skills/mobx-store-implementation/SKILL.md +2 -2
  62. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +4 -4
  63. package/src/gdskills/bundled/stacks/vue/governance/scout.json +1 -1
  64. package/src/gdskills/contracts/review-finding.schema.json +2 -2
  65. package/src/gdskills/bundled/rules/core/code-review-ai-assistant.mdc +0 -49
  66. package/src/gdskills/bundled/rules/core/gproject-contracts.mdc +0 -198
  67. package/src/gdskills/bundled/skills/orchestration/feature-dev/SKILL.md +0 -177
  68. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.md +0 -414
  69. package/src/gdskills/bundled/skills/orchestration/job-documenter/input-contract.schema.json +0 -55
  70. package/src/gdskills/bundled/skills/orchestration/job-documenter/output-contract.schema.json +0 -58
  71. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.codex.md +0 -209
  72. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.cursor.md +0 -209
  73. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.md +0 -208
  74. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.codex.md +0 -255
  75. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.cursor.md +0 -255
  76. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.md +0 -254
  77. package/src/gdskills/bundled/skills/planning/planner/SKILL.codex.md +0 -209
  78. package/src/gdskills/bundled/skills/planning/planner/SKILL.cursor.md +0 -209
  79. package/src/gdskills/bundled/skills/planning/planner/SKILL.md +0 -208
  80. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.codex.md +0 -171
  81. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.cursor.md +0 -171
  82. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.md +0 -170
  83. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.codex.md +0 -184
  84. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.cursor.md +0 -184
  85. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.md +0 -183
  86. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.codex.md +0 -249
  87. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.cursor.md +0 -249
  88. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.md +0 -248
  89. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.codex.md +0 -199
  90. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.cursor.md +0 -199
  91. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.md +0 -198
  92. package/src/gdskills/bundled/skills/quality/commit/SKILL.md +0 -87
  93. package/src/gdskills/bundled/skills/quality/pr/SKILL.md +0 -95
  94. package/src/gdskills/bundled/skills/quality/push/SKILL.md +0 -73
  95. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.md +0 -238
  96. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.md +0 -301
  97. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.md +0 -208
@@ -95,6 +95,21 @@ function appendOwnerOnlyLine(file, line) {
95
95
  chmodSync(file, 384);
96
96
  } catch {}
97
97
  }
98
+ function appendPrivateRecord(file, line) {
99
+ const fd = openSync(file, constants.O_WRONLY | constants.O_CREAT | constants.O_APPEND | constants.O_NOFOLLOW | constants.O_NONBLOCK, 384);
100
+ try {
101
+ const info = fstatSync(fd);
102
+ if (!info.isFile() || process.platform !== "win32" && (info.mode & 63) !== 0 || info.nlink !== 1) {
103
+ throw new Error("Private journal requires an owner-only regular file.");
104
+ }
105
+ const bytes = Buffer.from(`${line}
106
+ `);
107
+ if (writeSync(fd, bytes) !== bytes.length)
108
+ throw new Error("Incomplete private journal write.");
109
+ } finally {
110
+ closeSync(fd);
111
+ }
112
+ }
98
113
  function writeOwnerOnlyFileAtomic(file, body) {
99
114
  const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
100
115
  try {
@@ -10852,23 +10867,7 @@ var init_catalog2 = __esm(() => {
10852
10867
  "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`.",
10853
10868
  "Prefer project-local skills and module manifests before broad raw file search.",
10854
10869
  "Route to the narrowest applicable skill and record unavailable modules explicitly."
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: picking between gdgraph, gdctx, gdwiki, memory, and health once the module is already known (see context-router)."),
10856
- renderedSkill("context-router", "core", ["minimal", "recommended", "full"], "Choose between gdgraph, gdctx, gdwiki, memory, health, and project-skills before raw file reads.", [
10857
- "Start from the user's goal, not from command names.",
10858
- "Use gdgraph for file relationships and affected context.",
10859
- "Use gdctx for compact command, search, diff, log, and large-read output.",
10860
- "Use gdwiki for architecture, domain, business rules, decisions, and scenarios.",
10861
- "Use memory for historical decisions, known constraints, lessons, and repeated mistakes.",
10862
- "Use health for normalized quality and gate status; use testing for test selection and test context.",
10863
- "Prefer MCP tools/resources for these capabilities when connected; otherwise use the matching skill and CLI command.",
10864
- "Use project-skills for known modules, components, stores, services, and domain entities."
10865
- ], ["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)."),
10866
- renderedSkill("entity-skill-router", "core", ["minimal", "recommended", "full"], "Select relevant project-skills for known modules, components, stores, services, and domain entities.", [
10867
- "Check `.metaproject/project-skills` for matching module/entity skills.",
10868
- "Use gdgraph affected context to find nearby entities when the target is a file.",
10869
- "Load only the matching project-skill and directly referenced files.",
10870
- "If no project-skill exists, suggest creating one with `keryx skills generate`."
10871
- ], ["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)."),
10870
+ ], ["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."),
10872
10871
  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.", [
10873
10872
  "Normalize the target into module, entity, files, symbols, and wiki references.",
10874
10873
  "Collect evidence from gdgraph, gdctx, gdwiki, health, and memory when available.",
@@ -10877,7 +10876,7 @@ var init_catalog2 = __esm(() => {
10877
10876
  "To refresh a project-skill from its Origin (or a new file), run `keryx skills update <module>/<name> [--from <origin>]`.",
10878
10877
  "Run `keryx skills route <target>` and `keryx skills inspect <module>/<skill-name>` to confirm registration and routing.",
10879
10878
  "Run `keryx skills verify <module>/<skill-name>` and finish with `keryx skills status`."
10880
- ], ["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 (see entity-skill-router)."),
10879
+ ], ["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."),
10881
10880
  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.", [
10882
10881
  "Read the source in full and sort it into method, convention, and persona before writing anything.",
10883
10882
  "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.",
@@ -10891,14 +10890,8 @@ var init_catalog2 = __esm(() => {
10891
10890
  "Resolve the target project-skill through gdgraph affected context or `keryx skills route <target>`.",
10892
10891
  "Run `keryx skills verify <module>/<skill-name>` (`--dry-run` previews without writing).",
10893
10892
  "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`.",
10894
- "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 route stale or blocked findings to entity-skill-learner."
10895
- ], ["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 (see entity-skill-learner)."),
10896
- renderedSkill("entity-skill-learner", "core", ["minimal", "recommended", "full"], "Update project-skills from review findings, test failures, health reports, memory entries, and verifier reports.", [
10897
- "Parse the source report and map findings to project-skills.",
10898
- "Classify lessons as anti-patterns, checklist changes, template changes, workflow changes, or architecture rules.",
10899
- "Respect manual sections and autonomy policy.",
10900
- "Increment version and append `skill-changelog.md` entries with provenance."
10901
- ], ["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)."),
10893
+ "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`."
10894
+ ], ["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`)."),
10902
10895
  skill("job-orchestrator", "orchestration", ["recommended", "full"], "Run full task pipelines: clarify, collect context, plan, implement, verify, review, and summarize.", [
10903
10896
  "Clarify ambiguity with interviewer-style questions only when required.",
10904
10897
  "Collect compact context through Metaproject modules before implementation.",
@@ -10911,12 +10904,6 @@ var init_catalog2 = __esm(() => {
10911
10904
  "Delegate context, test, implementation, review, and docs work to existing gdskills while keeping flow state changes in the CLI.",
10912
10905
  "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."
10913
10906
  ]),
10914
- skill("job-documenter", "orchestration", ["recommended", "full"], "Create and maintain persistent job documentation for orchestrated analysis, implementation, and review work.", [
10915
- "Initialize job folders and state documents.",
10916
- "Write analysis, context, implementation, verification, and review reports.",
10917
- "Keep job README and status metadata current.",
10918
- "Finalize traceable job documentation for the user and follow-up agents."
10919
- ]),
10920
10907
  skill("context-collector", "orchestration", ["recommended", "full"], "Build compact task context from graph, ctx, wiki, memory, health, project-skills, and selected files.", [
10921
10908
  "Start from the target question and list the minimum context needed.",
10922
10909
  "Use gdgraph for relationships and gdctx for compact outputs.",
@@ -10947,12 +10934,6 @@ var init_catalog2 = __esm(() => {
10947
10934
  "Rank files by importance and risk.",
10948
10935
  "Produce a concise map of changes, dependencies, tests, and risks."
10949
10936
  ]),
10950
- skill("feature-dev", "orchestration", ["full"], "Run a guided feature workflow from requirements to implementation, verification, and PR-ready summary.", [
10951
- "Clarify requirements and implementation scope.",
10952
- "Collect project context and relevant local patterns.",
10953
- "Implement in small verified slices.",
10954
- "Prepare review and PR-ready documentation."
10955
- ]),
10956
10937
  skill("review-orchestrator", "review", ["recommended", "full"], "Route review requests to specialized reviewers and consolidate findings.", [
10957
10938
  "Detect changed scope and relevant review domains.",
10958
10939
  "Use gdgraph affected context for exported symbols and shared surfaces.",
@@ -11106,26 +11087,11 @@ var init_catalog2 = __esm(() => {
11106
11087
  "Answer each comment once after the merge, in English, through `keryx review comments reply --final`.",
11107
11088
  "Propose a learning update for configured authors; never apply it."
11108
11089
  ]),
11109
- skill("code-ai-review", "review", ["full"], "Run the legacy strict AI review profile.", [
11110
- "Load the AI review baseline rule.",
11111
- "Review branch changes from merge-base.",
11112
- "Report concrete findings first."
11113
- ]),
11114
11090
  skill("code-learned-review", "review", ["full"], "Review against conventions this project learned from its own pull-request comments.", [
11115
11091
  "Read .metaproject/review-learning.config.json and the project skill it names.",
11116
11092
  "Apply that skill's learned lessons to the branch diff, citing the lesson behind each finding.",
11117
11093
  "Stop and say so when the project has no learned skill \u2014 this reviewer has no conventions of its own."
11118
11094
  ]),
11119
- skill("code-style-review", "review", ["full"], "Run the legacy code style and architecture review profile.", [
11120
- "Load code-style rules and local conventions.",
11121
- "Review naming, structure, boundaries, and TypeScript usage.",
11122
- "Separate style issues from correctness defects."
11123
- ]),
11124
- skill("code-mobx-store-review", "review", ["full"], "Run focused MobX store and state logic review.", [
11125
- "Check actions, computed state, reactions, async boundaries, and view/store separation.",
11126
- "Load MobX store template and local conventions.",
11127
- "Report state bugs and maintainability risks."
11128
- ]),
11129
11095
  skill("security-audit", "quality", ["recommended", "full"], "Run dependency and secret/security checks and normalize findings.", [
11130
11096
  "Detect package manager and available audit commands.",
11131
11097
  "Scan for dependency advisories and accidentally committed secrets.",
@@ -11197,20 +11163,10 @@ var init_catalog2 = __esm(() => {
11197
11163
  "Run verification before deployment unless explicitly skipped.",
11198
11164
  "Summarize deployment status, rollback path, and health checks."
11199
11165
  ]),
11200
- skill("commit", "quality", ["full"], "Prepare conventional commits with scope, summary, and verification notes.", [
11201
- "Inspect staged and unstaged changes.",
11202
- "Group related changes without staging unrelated work.",
11203
- "Create a conventional commit message with verification summary."
11204
- ]),
11205
- skill("push", "quality", ["full"], "Push branches with safety checks, upstream handling, and concise result summary.", [
11206
- "Check branch and remote state.",
11207
- "Push the current branch with upstream when needed.",
11208
- "Report remote branch and any follow-up needed."
11209
- ]),
11210
- skill("pr", "quality", ["full"], "Prepare pull request creation or update context from local changes.", [
11211
- "Collect branch, commits, diff summary, tests, and risks.",
11212
- "Draft concise PR title and description.",
11213
- "Use project issue links when available."
11166
+ skill("git-publish", "quality", ["full"], "Write commits, push branches and open pull requests with explicit staging, hook, upstream, force and PR-body rules.", [
11167
+ "Stage explicit paths and write a typed commit subject without trailers.",
11168
+ "Push with upstream, never force without being told, and ask on a dirty tree or main.",
11169
+ "Open the pull request over the whole branch and report its URL."
11214
11170
  ]),
11215
11171
  skill("pr-issue-documenter", "quality", ["recommended", "full"], "Create PR descriptions and linked issue documentation from branch changes.", [
11216
11172
  "Analyze commits and changed files.",
@@ -11247,36 +11203,6 @@ var init_catalog2 = __esm(() => {
11247
11203
  "Test the idea sentence against the nearest competitor and the logo-swap test.",
11248
11204
  "Plan palette with computed contrast, type, ASCII layout, motion, and exactly one signature element."
11249
11205
  ]),
11250
- skill("project-discovery", "planning", ["full"], "Collect initial project facts, modules, constraints, stakeholders, and source references.", [
11251
- "Inventory available docs, code modules, and entrypoints.",
11252
- "Identify project purpose, users, constraints, and unknowns.",
11253
- "Produce a structured discovery summary for PRD/spec work."
11254
- ]),
11255
- skill("problem-definer", "planning", ["full"], "Define goals, non-goals, risks, constraints, and success metrics.", [
11256
- "Separate problem, solution ideas, constraints, and open questions.",
11257
- "Make goals and non-goals explicit.",
11258
- "Define measurable success criteria."
11259
- ]),
11260
- skill("stack-advisor", "planning", ["full"], "Recommend stack choices based on project level, constraints, team needs, and operational risk.", [
11261
- "Classify project level and constraints.",
11262
- "Compare stack options with trade-offs.",
11263
- "Recommend a conservative default and explain risks."
11264
- ]),
11265
- skill("patterns-researcher", "planning", ["full"], "Find architecture and implementation patterns for selected stack, domain, and project constraints.", [
11266
- "Identify relevant existing local patterns first.",
11267
- "Compare candidate patterns against constraints.",
11268
- "Document chosen patterns and anti-patterns."
11269
- ]),
11270
- skill("spec-writer", "planning", ["full"], "Write PRD, technical spec, or implementation plan constrained by decisions and evidence.", [
11271
- "Collect source requirements and decisions.",
11272
- "Write structured, testable sections.",
11273
- "Link assumptions, open questions, and acceptance criteria."
11274
- ]),
11275
- skill("consistency-checker", "planning", ["full"], "Check PRD, specs, plans, wiki, and decisions for contradictions or stale assumptions.", [
11276
- "Compare documents against accepted decisions and current code context.",
11277
- "Flag contradictions, missing constraints, and unsupported claims.",
11278
- "Suggest minimal updates with provenance."
11279
- ]),
11280
11206
  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.", [
11281
11207
  "Design the required file set from requirements-package-standard.",
11282
11208
  "Write or update README, PRD, specification, optional policies/protocols/schemas.",
@@ -11287,11 +11213,6 @@ var init_catalog2 = __esm(() => {
11287
11213
  "Report blockers, warnings, and audit trail without rewriting docs.",
11288
11214
  "Verify README/PRD/spec consistency and honest implementation status."
11289
11215
  ]),
11290
- skill("planner", "planning", ["full"], "Produce roadmap, milestones, task breakdown, dependency graph, and sequencing.", [
11291
- "Break goals into milestones and tasks.",
11292
- "Identify dependencies, risks, and verification gates.",
11293
- "Recommend execution order with small slices."
11294
- ]),
11295
11216
  skill("autodoc-orchestrator", "planning", ["full"], "Coordinate reverse-engineering documentation for an existing codebase.", [
11296
11217
  "Scan structure and identify documentation targets.",
11297
11218
  "Analyze modules in small batches.",
@@ -11332,11 +11253,6 @@ var init_catalog2 = __esm(() => {
11332
11253
  "Keep root entrypoints compact: non-project/highest-priority instructions plus `.metaproject/index.md` routing.",
11333
11254
  "Verify `.metaproject/rules/entrypoints/index.md`, `.metaproject/rules/entrypoints/`, and `.metaproject/project-skills/entrypoints/` were updated."
11334
11255
  ]),
11335
- renderedSkill("hook-manager", "platform", ["recommended", "full"], "Create and verify lightweight git hooks for graph, health, and skill verification.", [
11336
- "Install hooks only when explicitly enabled.",
11337
- "Keep hooks lightweight and idempotent.",
11338
- "Avoid network and destructive behavior inside hooks."
11339
- ], ["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)."),
11340
11256
  skill("scheduled-tasks", "platform", ["recommended", "full"], "Propose operator-confirmed scheduled background agent tasks with schedule_create.", [
11341
11257
  "Pin down cadence, prompt, rates and ceiling; ask rather than guess.",
11342
11258
  "Grant only the catalogue tools and repositories the task needs; keep the network off.",
@@ -11351,22 +11267,7 @@ var init_catalog2 = __esm(() => {
11351
11267
  "Read existing agent entrypoints.",
11352
11268
  "Patch managed guidance without deleting user-authored content.",
11353
11269
  "Keep rule and skill links discoverable."
11354
- ]),
11355
- renderedSkill("skill-catalog-manager", "platform", ["minimal", "recommended", "full"], "Generate `.metaproject/skills/catalog.md` and machine-readable skill registry.", [
11356
- "Read bundled and project-local skill metadata.",
11357
- "Generate concise catalog entries grouped by category.",
11358
- "Keep catalog deterministic and local-first."
11359
- ], ["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)."),
11360
- renderedSkill("skill-runtime-exporter", "platform", ["full"], "Export canonical skills to runtime-compatible Codex or Claude artifacts.", [
11361
- "Read canonical skill packages.",
11362
- "Remove management-only files from runtime exports.",
11363
- "Keep runtime `SKILL.md` concise with references, scripts, and assets as needed."
11364
- ], ["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)."),
11365
- renderedSkill("skill-sync", "platform", ["full"], "Sync exported runtime skills to configured local runtimes only when explicitly enabled.", [
11366
- "Read configured runtime targets.",
11367
- "Validate runtime skill packages before sync.",
11368
- "Sync only selected skills and report changed files."
11369
- ], ["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).")
11270
+ ])
11370
11271
  ];
11371
11272
  BUNDLED_TREE_MARKER = path26.join("src", "gdskills", "bundled");
11372
11273
  });
@@ -11402,12 +11303,10 @@ var init_skill_length_ceilings = __esm(() => {
11402
11303
  CEILINGS_BY_KEY = {
11403
11304
  "core/reviewer-skill-creator": 279,
11404
11305
  "orchestration/code-verifier": 339,
11405
- "orchestration/context-collector": 671,
11306
+ "orchestration/context-collector": 662,
11406
11307
  "orchestration/feature-analyzer": 447,
11407
- "orchestration/feature-dev": 177,
11408
11308
  "orchestration/flow-orchestrator": 682,
11409
11309
  "orchestration/issue-analyzer": 373,
11410
- "orchestration/job-documenter": 414,
11411
11310
  "orchestration/job-orchestrator": 2197,
11412
11311
  "orchestration/task-implementer": 661,
11413
11312
  "planning/autodoc-analyst": 180,
@@ -11417,54 +11316,42 @@ var init_skill_length_ceilings = __esm(() => {
11417
11316
  "planning/autodoc-scanner": 183,
11418
11317
  "planning/autodoc-writer": 270,
11419
11318
  "planning/brainstorm": 115,
11420
- "planning/consistency-checker": 208,
11421
11319
  "planning/docpack-orchestrator": 172,
11422
11320
  "planning/docpack-review": 92,
11423
- "planning/interview": 209,
11321
+ "planning/interview": 208,
11424
11322
  "planning/interviewer": 129,
11425
- "planning/patterns-researcher": 254,
11426
- "planning/planner": 208,
11427
11323
  "planning/prd-creator": 210,
11428
11324
  "planning/ui-direction": 177,
11429
- "planning/problem-definer": 170,
11430
- "planning/project-discovery": 183,
11431
- "planning/spec-writer": 248,
11432
- "planning/stack-advisor": 198,
11433
11325
  "platform/agent-entrypoint-distiller": 78,
11434
11326
  "platform/claude-md-management": 111,
11435
11327
  "platform/hookify": 125,
11436
11328
  "platform/scheduled-tasks": 96,
11437
11329
  "quality/api-truth": 226,
11438
11330
  "quality/changelog": 104,
11439
- "quality/commit": 87,
11440
11331
  "quality/db-migrate": 87,
11441
11332
  "quality/dependency-update": 102,
11442
11333
  "quality/deploy": 93,
11443
11334
  "quality/deprecation-path": 268,
11444
11335
  "quality/fresh-eyes": 190,
11336
+ "quality/git-publish": 60,
11445
11337
  "quality/metaproject-security": 124,
11446
11338
  "quality/perf-check": 104,
11447
- "quality/pr": 95,
11448
11339
  "quality/pr-issue-documenter": 401,
11449
- "quality/push": 73,
11450
11340
  "quality/root-cause": 204,
11451
11341
  "quality/security-audit": 129,
11452
11342
  "quality/test-gen": 101,
11453
11343
  "quality/tests-creator": 360,
11454
11344
  "quality/ui-craft": 173,
11455
- "review/code-ai-review": 238,
11456
11345
  "review/code-learned-review": 283,
11457
- "review/code-mobx-store-review": 301,
11458
- "review/code-style-review": 208,
11459
11346
  "review/review-architecture": 373,
11460
- "review/review-backend": 361,
11461
- "review/review-clean-code": 538,
11347
+ "review/review-backend": 359,
11348
+ "review/review-clean-code": 217,
11462
11349
  "review/review-core-boundaries": 158,
11463
11350
  "review/review-degradation": 191,
11464
11351
  "review/review-flow-graph": 183,
11465
- "review/review-frontend": 607,
11352
+ "review/review-frontend": 610,
11466
11353
  "review/review-frontend-conventions": 206,
11467
- "review/review-highload": 543,
11354
+ "review/review-highload": 472,
11468
11355
  "review/review-jev-comments": 179,
11469
11356
  "review/review-jev-contract": 188,
11470
11357
  "review/review-jev-docs": 184,
@@ -11472,17 +11359,17 @@ var init_skill_length_ceilings = __esm(() => {
11472
11359
  "review/review-jev-rules": 262,
11473
11360
  "review/review-jev-scenarios": 182,
11474
11361
  "review/review-layout": 237,
11475
- "review/review-logic": 365,
11476
- "review/review-orchestrator": 1571,
11362
+ "review/review-logic": 364,
11363
+ "review/review-orchestrator": 1565,
11477
11364
  "review/review-performance": 354,
11478
- "review/review-pr-contract": 191,
11365
+ "review/review-pr-contract": 190,
11479
11366
  "review/review-pr-feedback": 893,
11480
11367
  "review/review-premise": 180,
11481
- "review/review-regression": 214,
11482
- "review/review-security-code": 359,
11483
- "review/review-style": 353,
11368
+ "review/review-regression": 212,
11369
+ "review/review-security-code": 358,
11370
+ "review/review-style": 350,
11484
11371
  "review/review-testing-practices": 293,
11485
- "review/review-ui-ux": 268,
11372
+ "review/review-ui-ux": 267,
11486
11373
  "review/review-verifier": 299
11487
11374
  };
11488
11375
  SKILL_LENGTH_CEILINGS = new Map(Object.entries(CEILINGS_BY_KEY));
@@ -11634,55 +11521,6 @@ var init_bundled_eval = __esm(() => {
11634
11521
  sections: ["trigger-not-for"],
11635
11522
  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."
11636
11523
  }
11637
- ],
11638
- [
11639
- "planning/consistency-checker",
11640
- {
11641
- sections: ["trigger-not-for"],
11642
- 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."
11643
- }
11644
- ],
11645
- [
11646
- "planning/planner",
11647
- {
11648
- sections: ["trigger-not-for"],
11649
- 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."
11650
- }
11651
- ],
11652
- [
11653
- "planning/problem-definer",
11654
- {
11655
- sections: ["trigger-not-for"],
11656
- 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."
11657
- }
11658
- ],
11659
- [
11660
- "planning/project-discovery",
11661
- {
11662
- sections: ["trigger-not-for"],
11663
- 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."
11664
- }
11665
- ],
11666
- [
11667
- "planning/spec-writer",
11668
- {
11669
- sections: ["trigger-not-for"],
11670
- 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."
11671
- }
11672
- ],
11673
- [
11674
- "planning/stack-advisor",
11675
- {
11676
- sections: ["trigger-not-for"],
11677
- 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."
11678
- }
11679
- ],
11680
- [
11681
- "planning/patterns-researcher",
11682
- {
11683
- sections: ["trigger-not-for"],
11684
- 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."
11685
- }
11686
11524
  ]
11687
11525
  ]);
11688
11526
  PENDING_ANATOMY_BACKFILL = new Map([]);
@@ -20606,8 +20444,8 @@ var init_repomap = __esm(() => {
20606
20444
 
20607
20445
  // src/session/preservation.ts
20608
20446
  import { createHash as createHash10, randomUUID as randomUUID5 } from "crypto";
20609
- 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";
20610
- import path69 from "path";
20447
+ import { closeSync as closeSync4, fsyncSync, mkdirSync as mkdirSync4, openSync as openSync4, readdirSync as readdirSync5, readFileSync as readFileSync15, renameSync as renameSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync5 } from "fs";
20448
+ import path70 from "path";
20611
20449
  function syncDir(dir) {
20612
20450
  if (process.platform === "win32")
20613
20451
  return;
@@ -20619,7 +20457,7 @@ function syncDir(dir) {
20619
20457
  }
20620
20458
  }
20621
20459
  function writePreservationFile(file, body) {
20622
- const dir = path69.dirname(file);
20460
+ const dir = path70.dirname(file);
20623
20461
  mkdirSync4(dir, { recursive: true, mode: 448 });
20624
20462
  const tmp = `${file}.${randomUUID5()}.tmp`;
20625
20463
  const fd = openSync4(tmp, "wx", 384);
@@ -20630,7 +20468,7 @@ function writePreservationFile(file, body) {
20630
20468
  closeSync4(fd);
20631
20469
  }
20632
20470
  try {
20633
- renameSync4(tmp, file);
20471
+ renameSync5(tmp, file);
20634
20472
  syncDir(dir);
20635
20473
  } catch (error) {
20636
20474
  try {
@@ -20655,21 +20493,21 @@ function commitPreservation(dir, files, beforeSelect) {
20655
20493
  throw new Error("preservation snapshot exceeds readable size limit");
20656
20494
  }
20657
20495
  const id = hash(body);
20658
- const base = path69.join(dir, "preservation");
20659
- mkdirSync4(path69.join(base, "generations"), { recursive: true, mode: 448 });
20496
+ const base = path70.join(dir, "preservation");
20497
+ mkdirSync4(path70.join(base, "generations"), { recursive: true, mode: 448 });
20660
20498
  syncDir(dir);
20661
20499
  syncDir(base);
20662
- writePreservationFile(path69.join(base, "generations", `${id}.json`), body);
20500
+ writePreservationFile(path70.join(base, "generations", `${id}.json`), body);
20663
20501
  beforeSelect?.();
20664
- writePreservationFile(path69.join(base, "CURRENT"), id);
20502
+ writePreservationFile(path70.join(base, "CURRENT"), id);
20665
20503
  return id;
20666
20504
  }
20667
20505
  function readPreservation(dir, snapshotId) {
20668
- const base = path69.join(dir, "preservation");
20506
+ const base = path70.join(dir, "preservation");
20669
20507
  let id = snapshotId;
20670
20508
  if (id === undefined) {
20671
20509
  try {
20672
- id = readFileSync15(path69.join(base, "CURRENT"), "utf8");
20510
+ id = readFileSync15(path70.join(base, "CURRENT"), "utf8");
20673
20511
  } catch (e) {
20674
20512
  if (e.code === "ENOENT")
20675
20513
  return;
@@ -20678,7 +20516,7 @@ function readPreservation(dir, snapshotId) {
20678
20516
  }
20679
20517
  if (!/^[a-f0-9]{64}$/.test(id))
20680
20518
  throw new Error("invalid preservation identity");
20681
- const read = readTranscriptFile(path69.join(base, "generations", `${id}.json`));
20519
+ const read = readTranscriptFile(path70.join(base, "generations", `${id}.json`));
20682
20520
  if (!read.ok)
20683
20521
  throw new Error(`snapshot unreadable: ${read.reason}`);
20684
20522
  if (hash(read.text) !== id)
@@ -20708,7 +20546,7 @@ function collectPreservationFiles(dir, rawSlate) {
20708
20546
  for (const name of allowed) {
20709
20547
  if (name === "slate.json")
20710
20548
  continue;
20711
- const read = readTranscriptFile(path69.join(dir, name));
20549
+ const read = readTranscriptFile(path70.join(dir, name));
20712
20550
  if (read.ok)
20713
20551
  files[name] = read.text;
20714
20552
  else if (read.reason !== "absent")
@@ -20733,17 +20571,17 @@ function queuePreservedWrapUp(dir, rawSlate) {
20733
20571
  ...files["archive.jsonl"]?.trim() ? ["Transcript retained for evidence review"] : []
20734
20572
  ]
20735
20573
  };
20736
- const outbox = path69.join(dir, "preservation", "outbox");
20737
- const target = path69.join(outbox, `${snapshot}.json`);
20574
+ const outbox = path70.join(dir, "preservation", "outbox");
20575
+ const target = path70.join(outbox, `${snapshot}.json`);
20738
20576
  mkdirSync4(outbox, { recursive: true, mode: 448 });
20739
- syncDir(path69.dirname(outbox));
20577
+ syncDir(path70.dirname(outbox));
20740
20578
  writePreservationFile(target, JSON.stringify(receipt));
20741
20579
  return receipt;
20742
20580
  }
20743
20581
  function readPendingHistory(dir) {
20744
- let read = readConfigFile(path69.join(dir, "preservation", "HISTORY"));
20582
+ let read = readConfigFile(path70.join(dir, "preservation", "HISTORY"));
20745
20583
  if (!read.ok && read.reason === "absent") {
20746
- read = readConfigFile(path69.join(dir, "preservation", "MIRRORING"));
20584
+ read = readConfigFile(path70.join(dir, "preservation", "MIRRORING"));
20747
20585
  }
20748
20586
  if (!read.ok) {
20749
20587
  if (read.reason === "absent")
@@ -20767,7 +20605,7 @@ var init_preservation = __esm(() => {
20767
20605
 
20768
20606
  // src/session/slate.ts
20769
20607
  import { mkdir as mkdir13, readFile as readFile32, readdir as readdir18, stat as stat12 } from "fs/promises";
20770
- import path70 from "path";
20608
+ import path71 from "path";
20771
20609
  import { unlinkSync as unlinkSync3 } from "fs";
20772
20610
  function isReservedNoteKey(key) {
20773
20611
  return key.toLowerCase().startsWith(ASK_ANSWER_NOTE_PREFIX);
@@ -20778,7 +20616,7 @@ function modelNotesOf(notes) {
20778
20616
  return Object.fromEntries(Object.entries(notes).filter(([key]) => !isReservedNoteKey(key)));
20779
20617
  }
20780
20618
  function slatePath(dir) {
20781
- return path70.join(dir, "slate.json");
20619
+ return path71.join(dir, "slate.json");
20782
20620
  }
20783
20621
  function slateLockPath(dir) {
20784
20622
  return `${slatePath(dir)}.lock`;
@@ -20802,14 +20640,14 @@ function workingMemoryOf(slate) {
20802
20640
  };
20803
20641
  }
20804
20642
  async function readArchivedWorkingMemory(dir) {
20805
- const archiveDir = path70.join(dir, "slate-archive");
20643
+ const archiveDir = path71.join(dir, "slate-archive");
20806
20644
  try {
20807
20645
  const names = (await readdir18(archiveDir)).filter((n) => n.endsWith(".json"));
20808
- const dated = await Promise.all(names.map(async (n) => ({ n, at: (await stat12(path70.join(archiveDir, n))).mtimeMs })));
20646
+ const dated = await Promise.all(names.map(async (n) => ({ n, at: (await stat12(path71.join(archiveDir, n))).mtimeMs })));
20809
20647
  dated.sort((a, b) => b.at - a.at || (a.n < b.n ? 1 : -1));
20810
20648
  for (const { n } of dated) {
20811
20649
  try {
20812
- const slate = JSON.parse(await readFile32(path70.join(archiveDir, n), "utf8"));
20650
+ const slate = JSON.parse(await readFile32(path71.join(archiveDir, n), "utf8"));
20813
20651
  const carry = workingMemoryOf(slate);
20814
20652
  if (carry.trail !== undefined || carry.notes !== undefined || carry.answers !== undefined)
20815
20653
  return carry;
@@ -20844,11 +20682,11 @@ async function archiveIfExistsLocked(dir, attemptId, signal) {
20844
20682
  return;
20845
20683
  throw error;
20846
20684
  }
20847
- const archiveDir = path70.join(dir, "slate-archive");
20685
+ const archiveDir = path71.join(dir, "slate-archive");
20848
20686
  await mkdir13(archiveDir, { recursive: true });
20849
20687
  signal?.throwIfAborted();
20850
20688
  queuePreservedWrapUp(dir, raw);
20851
- writePreservationFile(path70.join(archiveDir, `${attemptId}.json`), raw);
20689
+ writePreservationFile(path71.join(archiveDir, `${attemptId}.json`), raw);
20852
20690
  unlinkSync3(slatePath(dir));
20853
20691
  }
20854
20692
  async function openSlateAtomic(dir, mintAttemptId, build, signal) {
@@ -20864,7 +20702,7 @@ async function openSlateAtomic(dir, mintAttemptId, build, signal) {
20864
20702
  writePreservationFile(slatePath(dir), `${JSON.stringify(next, null, 2)}
20865
20703
  `);
20866
20704
  try {
20867
- unlinkSync3(path70.join(dir, "terminal-state.json"));
20705
+ unlinkSync3(path71.join(dir, "terminal-state.json"));
20868
20706
  } catch (error) {
20869
20707
  if (!isNotFound(error))
20870
20708
  throw error;
@@ -21266,9 +21104,9 @@ var init_validation = __esm(() => {
21266
21104
  });
21267
21105
 
21268
21106
  // src/memory/config.ts
21269
- import path80 from "path";
21107
+ import path81 from "path";
21270
21108
  function memoryConfigPath(cwd) {
21271
- return path80.join(cwd, ".metaproject", "memory.config.json");
21109
+ return path81.join(cwd, ".metaproject", "memory.config.json");
21272
21110
  }
21273
21111
  async function loadMemoryConfig(cwd) {
21274
21112
  const file = memoryConfigPath(cwd);
@@ -21346,12 +21184,12 @@ var init_config4 = __esm(() => {
21346
21184
 
21347
21185
  // src/memory/write.ts
21348
21186
  import { mkdir as mkdir18, open as open6, readFile as readFile39, rename as rename4, rm as rm7, writeFile as writeFile9 } from "fs/promises";
21349
- import path83 from "path";
21187
+ import path84 from "path";
21350
21188
  async function resolveCanonicalEntryPath(cwd, relativePath) {
21351
- const root = path83.resolve(memoryRoot(cwd));
21352
- const absolutePath = path83.resolve(root, relativePath);
21353
- const normalized = toPosix2(path83.relative(root, absolutePath));
21354
- if (!normalized || normalized.startsWith("../") || path83.isAbsolute(normalized) || !normalized.endsWith(".md")) {
21189
+ const root = path84.resolve(memoryRoot(cwd));
21190
+ const absolutePath = path84.resolve(root, relativePath);
21191
+ const normalized = toPosix2(path84.relative(root, absolutePath));
21192
+ if (!normalized || normalized.startsWith("../") || path84.isAbsolute(normalized) || !normalized.endsWith(".md")) {
21355
21193
  return null;
21356
21194
  }
21357
21195
  return { absolutePath, relativePath: normalized };
@@ -21404,9 +21242,9 @@ function validateNextEntry(relativePath, content) {
21404
21242
  return null;
21405
21243
  }
21406
21244
  async function replaceAtomically(target, content) {
21407
- const dir = path83.dirname(target);
21245
+ const dir = path84.dirname(target);
21408
21246
  await mkdir18(dir, { recursive: true });
21409
- const tmp = path83.join(dir, `.${path83.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
21247
+ const tmp = path84.join(dir, `.${path84.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
21410
21248
  try {
21411
21249
  await writeFile9(tmp, content, "utf8");
21412
21250
  const file = await open6(tmp, "r");
@@ -21435,7 +21273,7 @@ function header(content, name) {
21435
21273
  return content.match(new RegExp(`^${name}:\\s*(.+)$`, "mi"))?.[1]?.trim() ?? null;
21436
21274
  }
21437
21275
  function toPosix2(value) {
21438
- return value.split(path83.sep).join("/");
21276
+ return value.split(path84.sep).join("/");
21439
21277
  }
21440
21278
  function message(cause) {
21441
21279
  return cause instanceof Error ? cause.message : String(cause);
@@ -21547,9 +21385,9 @@ var init_evidence = __esm(() => {
21547
21385
  });
21548
21386
 
21549
21387
  // src/wiki/config.ts
21550
- import path84 from "path";
21388
+ import path85 from "path";
21551
21389
  function wikiConfigPath(cwd) {
21552
- return path84.join(cwd, ".metaproject", "wiki.config.json");
21390
+ return path85.join(cwd, ".metaproject", "wiki.config.json");
21553
21391
  }
21554
21392
  function mergeWikiConfig(parsed) {
21555
21393
  const base = DEFAULT_WIKI_CONFIG;
@@ -21627,12 +21465,12 @@ var init_config5 = __esm(() => {
21627
21465
  // src/wiki/history.ts
21628
21466
  import { createHash as createHash20, randomBytes as randomBytes4 } from "crypto";
21629
21467
  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";
21630
- import path85 from "path";
21468
+ import path86 from "path";
21631
21469
  function wikiRootPath(cwd) {
21632
- return path85.join(cwd, ".metaproject", "wiki");
21470
+ return path86.join(cwd, ".metaproject", "wiki");
21633
21471
  }
21634
21472
  function wikiHistoryRoot(cwd) {
21635
- return path85.join(cwd, ".metaproject", "data", "gdwiki", "history");
21473
+ return path86.join(cwd, ".metaproject", "data", "gdwiki", "history");
21636
21474
  }
21637
21475
  function newWikiRunId(now = new Date) {
21638
21476
  const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
@@ -21653,26 +21491,26 @@ async function openWikiWriteContext(cwd, command) {
21653
21491
  return createWikiWriteContext(cwd, command, { keep: (await loadWikiConfig(cwd)).history.keep });
21654
21492
  }
21655
21493
  function wikiPageKey(cwd, absolutePath) {
21656
- const relative = path85.relative(wikiRootPath(cwd), path85.resolve(absolutePath));
21657
- if (relative === "" || relative.startsWith("..") || path85.isAbsolute(relative)) {
21494
+ const relative = path86.relative(wikiRootPath(cwd), path86.resolve(absolutePath));
21495
+ if (relative === "" || relative.startsWith("..") || path86.isAbsolute(relative)) {
21658
21496
  throw new Error(`not a wiki page: ${absolutePath}`);
21659
21497
  }
21660
21498
  return toPosix(relative);
21661
21499
  }
21662
21500
  function assertPageKey(page) {
21663
21501
  const segments = page.split("/");
21664
- if (page.length === 0 || page.includes("\\") || path85.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
21502
+ if (page.length === 0 || page.includes("\\") || path86.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
21665
21503
  throw new Error(`not a wiki page path: ${page}`);
21666
21504
  }
21667
21505
  return page;
21668
21506
  }
21669
21507
  function pageHistoryDir(cwd, page) {
21670
- return path85.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
21508
+ return path86.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
21671
21509
  }
21672
21510
  function versionFilePath(cwd, page, file) {
21673
21511
  const dir = pageHistoryDir(cwd, page);
21674
- const target = path85.join(dir, file);
21675
- if (!VERSION_FILE.test(file) || path85.dirname(target) !== dir) {
21512
+ const target = path86.join(dir, file);
21513
+ if (!VERSION_FILE.test(file) || path86.dirname(target) !== dir) {
21676
21514
  throw new Error(`history index names an invalid version file for ${page}: ${file}`);
21677
21515
  }
21678
21516
  return target;
@@ -21739,7 +21577,7 @@ function parsePageHistoryIndex(markdown, page) {
21739
21577
  return { page, rows };
21740
21578
  }
21741
21579
  async function readPageHistory(cwd, page) {
21742
- const indexPath = path85.join(pageHistoryDir(cwd, page), INDEX_FILE);
21580
+ const indexPath = path86.join(pageHistoryDir(cwd, page), INDEX_FILE);
21743
21581
  const raw = await readBufferOrNull(indexPath);
21744
21582
  if (raw === null)
21745
21583
  return null;
@@ -21751,8 +21589,8 @@ async function readPageHistory(cwd, page) {
21751
21589
  }
21752
21590
  async function storeVersion(cwd, page, version, at, content) {
21753
21591
  const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
21754
- const target = path85.join(pageHistoryDir(cwd, page), fileName);
21755
- await mkdir19(path85.dirname(target), { recursive: true });
21592
+ const target = path86.join(pageHistoryDir(cwd, page), fileName);
21593
+ await mkdir19(path86.dirname(target), { recursive: true });
21756
21594
  await writeFile10(target, content);
21757
21595
  if (sha2562(await readFile41(target)) !== sha2562(content)) {
21758
21596
  throw new Error(`history: stored version does not match the page bytes: ${target}`);
@@ -21790,7 +21628,7 @@ function planPrune2(history, keep, maxRows = MAX_INDEX_ROWS) {
21790
21628
  }
21791
21629
  async function ensureHistoryRoot(cwd) {
21792
21630
  const root = wikiHistoryRoot(cwd);
21793
- const ignore = path85.join(root, ".gitignore");
21631
+ const ignore = path86.join(root, ".gitignore");
21794
21632
  if (await readBufferOrNull(ignore))
21795
21633
  return;
21796
21634
  await mkdir19(root, { recursive: true });
@@ -21820,14 +21658,14 @@ async function endsWithoutNewline(file) {
21820
21658
  }
21821
21659
  async function appendRun(cwd, entry) {
21822
21660
  const root = wikiHistoryRoot(cwd);
21823
- const file = path85.join(root, RUNS_FILE);
21661
+ const file = path86.join(root, RUNS_FILE);
21824
21662
  const lead = await endsWithoutNewline(file) ? `
21825
21663
  ` : "";
21826
21664
  await appendFile3(file, `${lead}${JSON.stringify(entry)}
21827
21665
  `, "utf8");
21828
21666
  if ((await stat13(file)).size <= MAX_RUNS_BYTES)
21829
21667
  return;
21830
- await withFileLock2(path85.join(root, ".runs.lock"), async () => {
21668
+ await withFileLock2(path86.join(root, ".runs.lock"), async () => {
21831
21669
  if ((await stat13(file)).size <= MAX_RUNS_BYTES)
21832
21670
  return;
21833
21671
  const lines = (await readFile41(file, "utf8")).split(`
@@ -21841,7 +21679,7 @@ async function mutatePage(ctx, absolutePath, next) {
21841
21679
  const page = wikiPageKey(ctx.cwd, absolutePath);
21842
21680
  const dir = pageHistoryDir(ctx.cwd, page);
21843
21681
  await ensureHistoryRoot(ctx.cwd);
21844
- return withFileLock2(path85.join(path85.dirname(dir), `.${path85.basename(dir)}.lock`), async () => {
21682
+ return withFileLock2(path86.join(path86.dirname(dir), `.${path86.basename(dir)}.lock`), async () => {
21845
21683
  const live = await readBufferOrNull(absolutePath);
21846
21684
  if (next === null ? live === null : live !== null && live.equals(next)) {
21847
21685
  return { changed: false };
@@ -21865,7 +21703,7 @@ async function mutatePage(ctx, absolutePath, next) {
21865
21703
  if (next === null) {
21866
21704
  await rm8(absolutePath, { force: true });
21867
21705
  } else {
21868
- await mkdir19(path85.dirname(absolutePath), { recursive: true });
21706
+ await mkdir19(path86.dirname(absolutePath), { recursive: true });
21869
21707
  await writeFile10(absolutePath, next);
21870
21708
  }
21871
21709
  } catch (error) {
@@ -21873,7 +21711,7 @@ async function mutatePage(ctx, absolutePath, next) {
21873
21711
  await rm8(versionFilePath(ctx.cwd, page, row.file), { force: true });
21874
21712
  throw error;
21875
21713
  }
21876
- await writeFileAtomic(path85.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
21714
+ await writeFileAtomic(path86.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
21877
21715
  for (const file of pruned)
21878
21716
  await rm8(versionFilePath(ctx.cwd, page, file), { force: true });
21879
21717
  return { changed: true, action };
@@ -28089,8 +27927,7 @@ var CORE_REVIEWERS = new Set([
28089
27927
  "review-regression",
28090
27928
  "review-degradation",
28091
27929
  "review-core-boundaries",
28092
- "code-boss-reviewer",
28093
- "code-ai-review"
27930
+ "code-boss-reviewer"
28094
27931
  ]);
28095
27932
  var SUPPORT_REVIEWERS = new Set([
28096
27933
  "review-style",
@@ -28099,8 +27936,7 @@ var SUPPORT_REVIEWERS = new Set([
28099
27936
  "review-vantage-testing",
28100
27937
  "review-vantage-styling",
28101
27938
  "review-layout",
28102
- "review-ui-ux",
28103
- "code-style-review"
27939
+ "review-ui-ux"
28104
27940
  ]);
28105
27941
 
28106
27942
  // src/review/dedupe.ts
@@ -28923,9 +28759,52 @@ init_validator();
28923
28759
  import { appendFileSync as appendFileSync2 } from "fs";
28924
28760
 
28925
28761
  // src/lib/call-diagnostics.ts
28926
- init_config_dir();
28927
28762
  import { statSync as statSync5 } from "fs";
28763
+ import path66 from "path";
28764
+
28765
+ // src/lib/diagnostics-journal.ts
28766
+ init_config_dir();
28767
+ import { lstatSync as lstatSync4, renameSync as renameSync4 } from "fs";
28928
28768
  import path65 from "path";
28769
+ function createDiagnosticsJournal(opts) {
28770
+ const name = opts.sessionId.replace(/[^A-Za-z0-9._-]/g, "_") || "session";
28771
+ const file = path65.join(keryxConfigDir(opts.configDir), "diagnostics", `${name}.events.ndjson`);
28772
+ const cap = opts.maxFileBytes ?? 1e6;
28773
+ return {
28774
+ path: () => file,
28775
+ write(row) {
28776
+ try {
28777
+ const line = JSON.stringify(row);
28778
+ if (line === undefined || Buffer.byteLength(line) + 1 > cap)
28779
+ return { ok: false, error: "ROW_TOO_LARGE" };
28780
+ ensureKeryxSubdir(["diagnostics"], opts.configDir);
28781
+ let size = 0;
28782
+ try {
28783
+ const info = lstatSync4(file);
28784
+ if (!info.isFile() || info.nlink !== 1)
28785
+ return { ok: false, error: "UNSAFE_FILE" };
28786
+ size = info.size;
28787
+ } catch (error) {
28788
+ if (error.code !== "ENOENT")
28789
+ throw error;
28790
+ }
28791
+ if (size + Buffer.byteLength(line) + 1 > cap)
28792
+ renameSync4(file, `${file}.1`);
28793
+ appendPrivateRecord(file, line);
28794
+ return { ok: true };
28795
+ } catch (error) {
28796
+ const code = error?.code;
28797
+ return { ok: false, error: typeof code === "string" && /^[A-Z0-9_]+$/.test(code) ? code : "JOURNAL_WRITE_FAILED" };
28798
+ }
28799
+ }
28800
+ };
28801
+ }
28802
+ function diagnosticMeasurements(input) {
28803
+ return Object.fromEntries(Object.entries(input).filter(([key, value]) => /^[a-zA-Z][a-zA-Z0-9]{0,39}$/.test(key) && (typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))));
28804
+ }
28805
+
28806
+ // src/lib/call-diagnostics.ts
28807
+ init_config_dir();
28929
28808
  var DEFAULT_WATCH_INTERVAL_MS = 30000;
28930
28809
  var DEFAULT_STALL_MS = 10 * 60000;
28931
28810
  var DEFAULT_REPEAT_MS = 15 * 60000;
@@ -28957,6 +28836,39 @@ function createCallDiagnostics(options = {}) {
28957
28836
  let repeatMs = DEFAULT_REPEAT_MS;
28958
28837
  let lastDumpAt;
28959
28838
  let lastDumpIds = new Set;
28839
+ let journal;
28840
+ let journalFailure;
28841
+ let warnJournal;
28842
+ let warningDelivered = false;
28843
+ const persist = (kind, fields = {}) => {
28844
+ if (journal === undefined)
28845
+ return;
28846
+ const result = journal.write({ ts: new Date(now()).toISOString(), kind, ...fields });
28847
+ if (result.ok)
28848
+ return;
28849
+ journalFailure = result.error;
28850
+ if (!warningDelivered) {
28851
+ warningDelivered = true;
28852
+ try {
28853
+ warnJournal?.(result.error);
28854
+ } catch {
28855
+ journalFailure = "JOURNAL_WARNING_FAILED";
28856
+ }
28857
+ }
28858
+ };
28859
+ const persistSnapshot = () => persist("snapshot", {
28860
+ calls: [...calls.values()].map((c) => ({
28861
+ id: c.id,
28862
+ name: c.name,
28863
+ stage: c.stage,
28864
+ ageMs: now() - c.startedAt,
28865
+ stageAgeMs: now() - c.stageSince,
28866
+ stageChanges: c.stageChanges
28867
+ })),
28868
+ callsStarted: metrics.callsStarted,
28869
+ callsSettled: metrics.callsSettled,
28870
+ lastLagMs
28871
+ });
28960
28872
  const record = (label) => {
28961
28873
  ring.push(`${new Date(now()).toISOString()} ${label}`);
28962
28874
  if (ring.length > ringSize)
@@ -29044,6 +28956,7 @@ function createCallDiagnostics(options = {}) {
29044
28956
  metrics.maxLoopLagMs = lag;
29045
28957
  }
29046
28958
  lastTickAt = at;
28959
+ persistSnapshot();
29047
28960
  const suspects = [...calls.values()].filter((c) => c.watched && at - c.stageSince >= (HUMAN_STAGES.has(c.stage) ? stallMs * HUMAN_STAGE_FACTOR : stallMs));
29048
28961
  if (suspects.length === 0) {
29049
28962
  lastDumpIds = new Set;
@@ -29067,6 +28980,7 @@ function createCallDiagnostics(options = {}) {
29067
28980
  key = `${id}~${n}`;
29068
28981
  calls.set(key, { id: key, name, startedAt: at, watched: opts?.watched !== false, stage: "start", stageSince: at, stageChanges: 0 });
29069
28982
  metrics.callsStarted += 1;
28983
+ persist("call.begin", { id: key, name });
29070
28984
  return key;
29071
28985
  },
29072
28986
  stage(id, next) {
@@ -29078,6 +28992,7 @@ function createCallDiagnostics(options = {}) {
29078
28992
  call.stage = next;
29079
28993
  call.stageSince = at;
29080
28994
  call.stageChanges += 1;
28995
+ persist("call.stage", { id, stage: next });
29081
28996
  },
29082
28997
  end(id, outcome) {
29083
28998
  const call = calls.get(id);
@@ -29087,10 +29002,12 @@ function createCallDiagnostics(options = {}) {
29087
29002
  calls.delete(id);
29088
29003
  metrics.callsSettled += 1;
29089
29004
  metrics.callsByOutcome[outcome] = (metrics.callsByOutcome[outcome] ?? 0) + 1;
29005
+ persist("call.end", { id, outcome, ageMs: now() - call.startedAt });
29090
29006
  },
29091
29007
  event(kind, detail) {
29092
29008
  metrics.events[kind] = (metrics.events[kind] ?? 0) + 1;
29093
29009
  record(detail === undefined ? `event ${kind}` : `event ${kind} ${detail}`);
29010
+ persist(kind);
29094
29011
  },
29095
29012
  record,
29096
29013
  probe(name, fn) {
@@ -29104,6 +29021,9 @@ function createCallDiagnostics(options = {}) {
29104
29021
  dump,
29105
29022
  inFlight: () => [...calls.values()],
29106
29023
  dumpPath: () => file,
29024
+ journalPath: () => journal?.path(),
29025
+ journalError: () => journalFailure,
29026
+ observe: (kind, measurements) => persist(kind, diagnosticMeasurements(measurements)),
29107
29027
  tick,
29108
29028
  start(opts) {
29109
29029
  sessionId = opts.sessionId;
@@ -29111,11 +29031,19 @@ function createCallDiagnostics(options = {}) {
29111
29031
  stallMs = opts.stallMs ?? DEFAULT_STALL_MS;
29112
29032
  repeatMs = opts.repeatMs ?? DEFAULT_REPEAT_MS;
29113
29033
  const cap = opts.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
29034
+ journal = opts.continuous ? createDiagnosticsJournal(opts) : undefined;
29035
+ journalFailure = undefined;
29036
+ warningDelivered = false;
29037
+ warnJournal = opts.onJournalError ?? ((code) => {
29038
+ process.stderr.write(`keryx: diagnostics journal unavailable (${code}).
29039
+ `);
29040
+ });
29041
+ persist("session.start", { pid: process.pid, sessionId });
29114
29042
  if (sink === undefined) {
29115
29043
  sink = (line) => {
29116
29044
  if (file === undefined) {
29117
29045
  const dir = ensureKeryxSubdir(["diagnostics"], opts.configDir);
29118
- file = path65.join(dir, `${opts.sessionId.replace(/[^A-Za-z0-9._-]/g, "_")}.ndjson`);
29046
+ file = path66.join(dir, `${opts.sessionId.replace(/[^A-Za-z0-9._-]/g, "_")}.ndjson`);
29119
29047
  }
29120
29048
  let size = 0;
29121
29049
  try {
@@ -29133,7 +29061,16 @@ function createCallDiagnostics(options = {}) {
29133
29061
  } catch {}
29134
29062
  }, intervalMs);
29135
29063
  timer.unref?.();
29136
- return () => clearInterval(timer);
29064
+ let stopped = false;
29065
+ return () => {
29066
+ if (stopped)
29067
+ return;
29068
+ stopped = true;
29069
+ clearInterval(timer);
29070
+ persistSnapshot();
29071
+ persist("session.stop");
29072
+ journal = undefined;
29073
+ };
29137
29074
  }
29138
29075
  };
29139
29076
  }
@@ -29156,7 +29093,7 @@ function tracePhase(label, env = process.env) {
29156
29093
  init_json();
29157
29094
  init_shell_syntax();
29158
29095
  import { readdir as readdir17, stat as stat11 } from "fs/promises";
29159
- import path66 from "path";
29096
+ import path67 from "path";
29160
29097
  var PR_REF = /(?:github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+))|^#?(\d+)$/;
29161
29098
  var REVIEW_ENDPOINT = /(?:^|\/)repos\/([^/]+\/[^/]+)\/pulls\/(\d+)\/reviews(?:\/\d+\/events)?\/?$/;
29162
29099
  var PR_REVIEW_VALUE_FLAGS = new Set(["-R", "--repo", "-b", "--body", "-F", "--body-file"]);
@@ -29235,12 +29172,12 @@ async function boundPackages(cwd) {
29235
29172
  }
29236
29173
  const found = [];
29237
29174
  for (const name of names) {
29238
- const dir = path66.join(reviewsRoot(cwd), name);
29239
- const manifest = await readJsonFileOr(path66.join(dir, "manifest.json"), undefined);
29175
+ const dir = path67.join(reviewsRoot(cwd), name);
29176
+ const manifest = await readJsonFileOr(path67.join(dir, "manifest.json"), undefined);
29240
29177
  if (manifest === undefined || !isPrBound(manifest.target))
29241
29178
  continue;
29242
29179
  const ref = parseRef(manifest.target.ref);
29243
- const info = await stat11(path66.join(dir, "manifest.json")).catch(() => {
29180
+ const info = await stat11(path67.join(dir, "manifest.json")).catch(() => {
29244
29181
  return;
29245
29182
  });
29246
29183
  found.push({ dir, id: manifest.reviewId, status: manifest.status, number: ref.number, repo: ref.repo, mtime: info?.mtimeMs ?? 0 });
@@ -29413,7 +29350,7 @@ init_command_risk();
29413
29350
  init_contained_path();
29414
29351
  import { createHash as createHash9 } from "crypto";
29415
29352
  import { closeSync as closeSync3, constants as constants6, fstatSync as fstatSync3, openSync as openSync3, readSync } from "fs";
29416
- import path67 from "path";
29353
+ import path68 from "path";
29417
29354
 
29418
29355
  // src/lib/review-path-flags.ts
29419
29356
  init_args();
@@ -29571,7 +29508,7 @@ function carriesPreload(text) {
29571
29508
  }
29572
29509
  var MAX_BUNFIG_BYTES = 256 * 1024;
29573
29510
  function readBunfig(root) {
29574
- const file = path67.join(root, "bunfig.toml");
29511
+ const file = path68.join(root, "bunfig.toml");
29575
29512
  let fd;
29576
29513
  try {
29577
29514
  fd = openSync3(file, constants6.O_RDONLY | constants6.O_NONBLOCK);
@@ -29652,10 +29589,10 @@ function movedTo(cwd, target) {
29652
29589
  if (cwd === undefined || target === "" || target.startsWith("-") || isExpandable(target))
29653
29590
  return;
29654
29591
  const cdpath = process.env.CDPATH;
29655
- if (cdpath !== undefined && cdpath !== "" && !path67.isAbsolute(target) && !target.startsWith("./") && !target.startsWith("../")) {
29592
+ if (cdpath !== undefined && cdpath !== "" && !path68.isAbsolute(target) && !target.startsWith("./") && !target.startsWith("../")) {
29656
29593
  return;
29657
29594
  }
29658
- const lexical = path67.resolve(cwd, target);
29595
+ const lexical = path68.resolve(cwd, target);
29659
29596
  return realOrResolved(lexical) === lexical ? lexical : undefined;
29660
29597
  }
29661
29598
  function areReviewPathFlagsInside(sub, args, walk) {
@@ -29690,11 +29627,11 @@ function isOutsideReadFlag(word) {
29690
29627
  return name.length >= 3 && name.startsWith("--") && GIT_OUTSIDE_READ_FLAGS.some((flag) => flag.startsWith(name));
29691
29628
  }
29692
29629
  function isOutsideRoot(projectRoot, target) {
29693
- const relative = path67.relative(projectRoot, target);
29694
- return relative === ".." || relative.startsWith(`..${path67.sep}`) || path67.isAbsolute(relative);
29630
+ const relative = path68.relative(projectRoot, target);
29631
+ return relative === ".." || relative.startsWith(`..${path68.sep}`) || path68.isAbsolute(relative);
29695
29632
  }
29696
29633
  function isEscapingOperand(word, cwd, projectRoot) {
29697
- return isOutsideRoot(projectRoot, realOrResolved(path67.resolve(cwd, word)));
29634
+ return isOutsideRoot(projectRoot, realOrResolved(path68.resolve(cwd, word)));
29698
29635
  }
29699
29636
  function isGitReadConfined(words, walk) {
29700
29637
  const cwd = walk.cwd;
@@ -29735,7 +29672,7 @@ function isTrustRoutineCommand(command, context = {}) {
29735
29672
  const segments = splitSegments(command);
29736
29673
  if (segments.length === 0 || segments.length > MAX_CHAIN_SEGMENTS)
29737
29674
  return false;
29738
- const cwd = realOrResolved(path67.resolve(context.cwd ?? process.cwd()));
29675
+ const cwd = realOrResolved(path68.resolve(context.cwd ?? process.cwd()));
29739
29676
  const walk = { projectRoot: realOrResolved(resolveProjectRoot(cwd)), cwd, untrusted: context.untrustedContent === true };
29740
29677
  return segments.every((seg) => (seg.precededBy === undefined || seg.precededBy === "&&") && !hasUnquotedMetacharacter(seg.raw) && !(isJudgedByWords(seg.words) && hasUnquotedExpansion(seg.raw)) && isRoutineSegment(seg.words, walk));
29741
29678
  }
@@ -29770,9 +29707,9 @@ function resolveQuestionAnswerer(mode) {
29770
29707
  }
29771
29708
 
29772
29709
  // src/commands/automatic-review.ts
29773
- import { existsSync as existsSync17, lstatSync as lstatSync4, realpathSync as realpathSync4 } from "fs";
29710
+ import { existsSync as existsSync17, lstatSync as lstatSync5, realpathSync as realpathSync4 } from "fs";
29774
29711
  import { mkdir as mkdir12, writeFile as writeFile7 } from "fs/promises";
29775
- import path68 from "path";
29712
+ import path69 from "path";
29776
29713
 
29777
29714
  // src/harness/tool/builtin/ask-user-tool.ts
29778
29715
  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.`;
@@ -29984,7 +29921,7 @@ var OPERATOR_ONLY_NAMES = new Set([foldFileName(OPERATOR_DECISIONS_FILE), foldFi
29984
29921
  var PLAIN_SEGMENT = /^[A-Za-z0-9._-]+$/;
29985
29922
  function entryExists(file) {
29986
29923
  try {
29987
- lstatSync4(file);
29924
+ lstatSync5(file);
29988
29925
  return true;
29989
29926
  } catch {
29990
29927
  return false;
@@ -29994,20 +29931,20 @@ function realTarget(target) {
29994
29931
  let existing = target;
29995
29932
  const rest = [];
29996
29933
  while (!entryExists(existing)) {
29997
- const parent = path68.dirname(existing);
29934
+ const parent = path69.dirname(existing);
29998
29935
  if (parent === existing)
29999
29936
  return target;
30000
- rest.unshift(path68.basename(existing));
29937
+ rest.unshift(path69.basename(existing));
30001
29938
  existing = parent;
30002
29939
  }
30003
29940
  try {
30004
- return path68.join(realpathSync4(existing), ...rest);
29941
+ return path69.join(realpathSync4(existing), ...rest);
30005
29942
  } catch {
30006
29943
  return "";
30007
29944
  }
30008
29945
  }
30009
29946
  function segmentsBelow(base, target) {
30010
- return path68.relative(base, target).split(/[\\/]/);
29947
+ return path69.relative(base, target).split(/[\\/]/);
30011
29948
  }
30012
29949
  function hasOnlyPlainSegments(base, target) {
30013
29950
  return segmentsBelow(base, target).every((segment) => PLAIN_SEGMENT.test(segment));
@@ -30016,7 +29953,7 @@ function touchesOperatorOnlyName(base, target) {
30016
29953
  return segmentsBelow(base, target).some((segment) => OPERATOR_ONLY_NAMES.has(foldFileName(segment)));
30017
29954
  }
30018
29955
  function escapesPackage(realDir, real) {
30019
- return !real.startsWith(`${realDir}${path68.sep}`);
29956
+ return !real.startsWith(`${realDir}${path69.sep}`);
30020
29957
  }
30021
29958
 
30022
29959
  class AutomaticReviewRun {
@@ -30054,11 +29991,11 @@ class AutomaticReviewRun {
30054
29991
  return false;
30055
29992
  }
30056
29993
  const realDir = realTarget(dir);
30057
- const isData = (file) => PACKAGE_DATA_EXTENSIONS.has(path68.extname(file).toLowerCase());
29994
+ const isData = (file) => PACKAGE_DATA_EXTENSIONS.has(path69.extname(file).toLowerCase());
30058
29995
  return targets.every((target) => {
30059
- const resolved = path68.resolve(this.cwd, target);
29996
+ const resolved = path69.resolve(this.cwd, target);
30060
29997
  const real = realTarget(resolved);
30061
- 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);
29998
+ return resolved.startsWith(`${dir}${path69.sep}`) && !escapesPackage(realDir, real) && hasOnlyPlainSegments(dir, resolved) && hasOnlyPlainSegments(realDir, real) && isData(resolved) && isData(real) && !touchesOperatorOnlyName(dir, resolved) && !touchesOperatorOnlyName(realDir, real);
30062
29999
  });
30063
30000
  }
30064
30001
  observe(command, result) {
@@ -30077,8 +30014,8 @@ class AutomaticReviewRun {
30077
30014
  if (id === undefined || printed === undefined) {
30078
30015
  return;
30079
30016
  }
30080
- const dir = path68.resolve(this.cwd, printed);
30081
- const metaproject = path68.join(path68.resolve(this.cwd), ".metaproject") + path68.sep;
30017
+ const dir = path69.resolve(this.cwd, printed);
30018
+ const metaproject = path69.join(path69.resolve(this.cwd), ".metaproject") + path69.sep;
30082
30019
  if (dir.startsWith(metaproject)) {
30083
30020
  this.binding = { id, dir };
30084
30021
  }
@@ -30123,13 +30060,13 @@ class AutomaticReviewRun {
30123
30060
  }
30124
30061
  summaryLine() {
30125
30062
  const { manual, automatic } = this.disclosure();
30126
- return `[automatic review] inputs: ${manual} manual, ${automatic} automatic${this.binding === undefined ? "" : ` (${path68.relative(this.cwd, path68.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE))})`}`;
30063
+ return `[automatic review] inputs: ${manual} manual, ${automatic} automatic${this.binding === undefined ? "" : ` (${path69.relative(this.cwd, path69.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE))})`}`;
30127
30064
  }
30128
30065
  async writeDisclosure() {
30129
30066
  if (this.binding === undefined) {
30130
30067
  return;
30131
30068
  }
30132
- const file = path68.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE);
30069
+ const file = path69.join(this.binding.dir, AUTOMATIC_REVIEW_DISCLOSURE_FILE);
30133
30070
  await mkdir12(this.binding.dir, { recursive: true });
30134
30071
  await writeFile7(file, `${JSON.stringify(this.disclosure(), null, 2)}
30135
30072
  `, "utf8");
@@ -30190,27 +30127,27 @@ class AutomaticReviewRun {
30190
30127
  if (this.binding !== undefined) {
30191
30128
  return this.insidePackage(value);
30192
30129
  }
30193
- const resolved = path68.resolve(this.cwd, value);
30194
- return resolved.startsWith(reviewsRoot(path68.resolve(this.cwd)) + path68.sep);
30130
+ const resolved = path69.resolve(this.cwd, value);
30131
+ return resolved.startsWith(reviewsRoot(path69.resolve(this.cwd)) + path69.sep);
30195
30132
  }
30196
30133
  insidePackage(value) {
30197
30134
  const dir = this.binding?.dir;
30198
30135
  if (dir === undefined) {
30199
30136
  return false;
30200
30137
  }
30201
- const resolved = path68.resolve(this.cwd, value);
30202
- return resolved === dir || resolved.startsWith(`${dir}${path68.sep}`);
30138
+ const resolved = path69.resolve(this.cwd, value);
30139
+ return resolved === dir || resolved.startsWith(`${dir}${path69.sep}`);
30203
30140
  }
30204
30141
  insideCwd(value) {
30205
- const resolved = path68.resolve(this.cwd, value);
30206
- const root = path68.resolve(this.cwd);
30207
- return resolved === root || resolved.startsWith(`${root}${path68.sep}`);
30142
+ const resolved = path69.resolve(this.cwd, value);
30143
+ const root = path69.resolve(this.cwd);
30144
+ return resolved === root || resolved.startsWith(`${root}${path69.sep}`);
30208
30145
  }
30209
30146
  namesReviewPackage(value) {
30210
30147
  if (value === "" || value.startsWith("-"))
30211
30148
  return false;
30212
- const asPath = path68.resolve(this.cwd, value);
30213
- if (!/[\\/]/.test(value) && value !== "." && value !== ".." && !existsSync17(path68.join(asPath, "manifest.json")))
30149
+ const asPath = path69.resolve(this.cwd, value);
30150
+ if (!/[\\/]/.test(value) && value !== "." && value !== ".." && !existsSync17(path69.join(asPath, "manifest.json")))
30214
30151
  return true;
30215
30152
  return this.insideCwd(value) && isReviewPackageDir(asPath, this.cwd);
30216
30153
  }
@@ -30218,7 +30155,7 @@ class AutomaticReviewRun {
30218
30155
  if (this.binding === undefined) {
30219
30156
  return false;
30220
30157
  }
30221
- return ref === this.binding.id || path68.resolve(this.cwd, ref) === this.binding.dir;
30158
+ return ref === this.binding.id || path69.resolve(this.cwd, ref) === this.binding.dir;
30222
30159
  }
30223
30160
  }
30224
30161
 
@@ -31235,7 +31172,7 @@ function consolidateAnchors(removed) {
31235
31172
  // src/harness/tool/output-spill.ts
31236
31173
  import { createHash as createHash11 } from "crypto";
31237
31174
  import { chmod as chmod4, mkdir as mkdir14, open as open5 } from "fs/promises";
31238
- import path71 from "path";
31175
+ import path72 from "path";
31239
31176
  var TOOL_OUTPUT_SPILL_MAX_LINES = 2000;
31240
31177
  var TOOL_OUTPUT_SPILL_MAX_BYTES = 50 * 1024;
31241
31178
  var TOOL_OUTPUT_PREVIEW_CHARS = 16 * 1024;
@@ -31291,14 +31228,14 @@ var TOOL_OUTPUT_DIR_MODE = 448;
31291
31228
  var TOOL_OUTPUT_FILE_MODE = 384;
31292
31229
  var MAX_NAME_ATTEMPTS = 50;
31293
31230
  async function writeUniqueOutputFile(sessionDir, toolCallId, text) {
31294
- const dir = path71.join(sessionDir, TOOL_OUTPUT_DIRNAME);
31231
+ const dir = path72.join(sessionDir, TOOL_OUTPUT_DIRNAME);
31295
31232
  try {
31296
31233
  await mkdir14(dir, { recursive: true, mode: TOOL_OUTPUT_DIR_MODE });
31297
31234
  await chmod4(dir, TOOL_OUTPUT_DIR_MODE);
31298
31235
  const hash = createHash11("sha256").update(text).digest("hex").slice(0, 8);
31299
31236
  const base = `${Date.now()}-${hash}-${safeFileStem(toolCallId)}`;
31300
31237
  for (let attempt = 0;attempt < MAX_NAME_ATTEMPTS; attempt++) {
31301
- const filePath = path71.join(dir, `${base}${attempt === 0 ? "" : `-${attempt}`}.txt`);
31238
+ const filePath = path72.join(dir, `${base}${attempt === 0 ? "" : `-${attempt}`}.txt`);
31302
31239
  let handle;
31303
31240
  try {
31304
31241
  handle = await open5(filePath, "wx", TOOL_OUTPUT_FILE_MODE);
@@ -31324,11 +31261,11 @@ async function writeToolOutputFile(sessionDir, toolCallId, text) {
31324
31261
  return writeUniqueOutputFile(sessionDir, toolCallId, text);
31325
31262
  }
31326
31263
  function isInsideToolOutputDir(sessionDir, candidate) {
31327
- if (!path71.isAbsolute(candidate)) {
31264
+ if (!path72.isAbsolute(candidate)) {
31328
31265
  return false;
31329
31266
  }
31330
- const rel = path71.relative(path71.join(sessionDir, TOOL_OUTPUT_DIRNAME), path71.resolve(candidate));
31331
- return rel !== "" && rel !== ".." && !rel.startsWith(`..${path71.sep}`) && !path71.isAbsolute(rel);
31267
+ const rel = path72.relative(path72.join(sessionDir, TOOL_OUTPUT_DIRNAME), path72.resolve(candidate));
31268
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${path72.sep}`) && !path72.isAbsolute(rel);
31332
31269
  }
31333
31270
  async function spillToolOutput(text, ctx) {
31334
31271
  if (ctx.sessionDir === undefined || !exceedsSpillThreshold(text)) {
@@ -31647,15 +31584,15 @@ import {
31647
31584
  existsSync as existsSync19,
31648
31585
  mkdirSync as mkdirSync5,
31649
31586
  readdirSync as readdirSync6,
31650
- renameSync as renameSync5,
31587
+ renameSync as renameSync6,
31651
31588
  writeFileSync as writeFileSync6
31652
31589
  } from "fs";
31653
- import path73 from "path";
31590
+ import path74 from "path";
31654
31591
 
31655
31592
  // src/session/paths.ts
31656
31593
  import { existsSync as existsSync18 } from "fs";
31657
31594
  import { homedir as homedir3 } from "os";
31658
- import path72 from "path";
31595
+ import path73 from "path";
31659
31596
  function keryxDataDir(override) {
31660
31597
  if (override !== undefined && override.length > 0) {
31661
31598
  return override;
@@ -31667,22 +31604,22 @@ function keryxDataDir(override) {
31667
31604
  const home = homedir3();
31668
31605
  if (process.platform === "win32") {
31669
31606
  const appData = process.env.APPDATA;
31670
- const base = appData !== undefined && appData.length > 0 ? appData : path72.join(home, "AppData", "Roaming");
31671
- return path72.join(base, "keryx");
31607
+ const base = appData !== undefined && appData.length > 0 ? appData : path73.join(home, "AppData", "Roaming");
31608
+ return path73.join(base, "keryx");
31672
31609
  }
31673
31610
  const xdg = process.env.XDG_DATA_HOME;
31674
- const base = xdg !== undefined && xdg.length > 0 ? xdg : path72.join(home, ".local", "share");
31675
- return path72.join(base, "keryx");
31611
+ const base = xdg !== undefined && xdg.length > 0 ? xdg : path73.join(home, ".local", "share");
31612
+ return path73.join(base, "keryx");
31676
31613
  }
31677
31614
  function resolveProjectRoot2(cwd) {
31678
- const abs = path72.resolve(cwd);
31615
+ const abs = path73.resolve(cwd);
31679
31616
  let dir = abs;
31680
31617
  for (;; ) {
31681
- const gitPath = path72.join(dir, ".git");
31618
+ const gitPath = path73.join(dir, ".git");
31682
31619
  if (existsSync18(gitPath)) {
31683
31620
  return dir;
31684
31621
  }
31685
- const parent = path72.dirname(dir);
31622
+ const parent = path73.dirname(dir);
31686
31623
  if (parent === dir) {
31687
31624
  break;
31688
31625
  }
@@ -31691,12 +31628,12 @@ function resolveProjectRoot2(cwd) {
31691
31628
  return abs;
31692
31629
  }
31693
31630
  function projectKeyFromPath(projectPath) {
31694
- const abs = path72.resolve(projectPath);
31631
+ const abs = path73.resolve(projectPath);
31695
31632
  const encoded = encodeURIComponent(abs);
31696
31633
  if (encoded.length <= 200) {
31697
31634
  return encoded;
31698
31635
  }
31699
- const base = path72.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
31636
+ const base = path73.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
31700
31637
  let h = 0;
31701
31638
  for (let i = 0;i < abs.length; i++) {
31702
31639
  h = Math.imul(31, h) + abs.charCodeAt(i) | 0;
@@ -31706,10 +31643,10 @@ function projectKeyFromPath(projectPath) {
31706
31643
  }
31707
31644
  function projectSessionsDir(projectPath, dataDir) {
31708
31645
  const key = projectKeyFromPath(resolveProjectRoot2(projectPath));
31709
- return path72.join(keryxDataDir(dataDir), "sessions", key);
31646
+ return path73.join(keryxDataDir(dataDir), "sessions", key);
31710
31647
  }
31711
31648
  function sessionDir(projectPath, sessionId, dataDir) {
31712
- return path72.join(projectSessionsDir(projectPath, dataDir), sessionId);
31649
+ return path73.join(projectSessionsDir(projectPath, dataDir), sessionId);
31713
31650
  }
31714
31651
 
31715
31652
  // src/session/store.ts
@@ -31805,7 +31742,7 @@ function parseRemote(value) {
31805
31742
  function readSummaryFile(file) {
31806
31743
  let pending;
31807
31744
  try {
31808
- pending = readPendingHistory(path73.dirname(file));
31745
+ pending = readPendingHistory(path74.dirname(file));
31809
31746
  } catch {
31810
31747
  pending = undefined;
31811
31748
  }
@@ -31857,11 +31794,11 @@ class TranscriptUnreadableError extends Error {
31857
31794
  }
31858
31795
  }
31859
31796
  function readJsonl(file) {
31860
- const pending = readPendingHistory(path73.dirname(file));
31797
+ const pending = readPendingHistory(path74.dirname(file));
31861
31798
  if (pending === undefined && !existsSync19(file)) {
31862
31799
  return [];
31863
31800
  }
31864
- const read = pending !== undefined ? { ok: true, text: pending.files[path73.basename(file)] } : readTranscriptFile(file);
31801
+ const read = pending !== undefined ? { ok: true, text: pending.files[path74.basename(file)] } : readTranscriptFile(file);
31865
31802
  if (!read.ok) {
31866
31803
  throw new TranscriptUnreadableError(file, read.reason);
31867
31804
  }
@@ -31912,11 +31849,11 @@ function listSessions(cwd, dataDir) {
31912
31849
  if (name.startsWith(".")) {
31913
31850
  continue;
31914
31851
  }
31915
- const summary = readSummaryFile(path73.join(root, name, "summary.json"));
31852
+ const summary = readSummaryFile(path74.join(root, name, "summary.json"));
31916
31853
  if (summary === undefined) {
31917
31854
  continue;
31918
31855
  }
31919
- if (path73.resolve(summary.projectPath) !== path73.resolve(projectPath)) {
31856
+ if (path74.resolve(summary.projectPath) !== path74.resolve(projectPath)) {
31920
31857
  continue;
31921
31858
  }
31922
31859
  out.push(summary);
@@ -31949,15 +31886,15 @@ async function readSessionSlate(cwd, sessionId, dataDir) {
31949
31886
  }
31950
31887
  function loadContext(cwd, sessionId, dataDir) {
31951
31888
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
31952
- const contextPath = path73.join(dir, "context.jsonl");
31889
+ const contextPath = path74.join(dir, "context.jsonl");
31953
31890
  if (readPendingHistory(dir) !== undefined || existsSync19(contextPath)) {
31954
31891
  return readJsonl(contextPath);
31955
31892
  }
31956
- return readJsonl(path73.join(dir, "transcript.jsonl"));
31893
+ return readJsonl(path74.join(dir, "transcript.jsonl"));
31957
31894
  }
31958
31895
  function loadArchive(cwd, sessionId, dataDir, onDegraded) {
31959
31896
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
31960
- const archivePath = path73.join(dir, "archive.jsonl");
31897
+ const archivePath = path74.join(dir, "archive.jsonl");
31961
31898
  if (readPendingHistory(dir) !== undefined || existsSync19(archivePath)) {
31962
31899
  try {
31963
31900
  const archive = readJsonl(archivePath);
@@ -33051,13 +32988,13 @@ async function executeWaves(tasks, waves, deps) {
33051
32988
  init_fs();
33052
32989
  init_slate();
33053
32990
  import { mkdir as mkdir15, readFile as readFile33 } from "fs/promises";
33054
- import path74 from "path";
32991
+ import path75 from "path";
33055
32992
  var listeners = new Set;
33056
32993
  function clonePlan(plan) {
33057
32994
  return { revision: plan.revision, items: plan.items.map((item) => ({ ...item })) };
33058
32995
  }
33059
32996
  function executionPlanPath(dir) {
33060
- return path74.join(dir, "plan.json");
32997
+ return path75.join(dir, "plan.json");
33061
32998
  }
33062
32999
  async function readPlanFile(dir) {
33063
33000
  let raw;
@@ -33194,7 +33131,7 @@ init_fs();
33194
33131
  init_slate();
33195
33132
  import { createHash as createHash23, randomUUID as randomUUID11 } from "crypto";
33196
33133
  import { mkdir as mkdir21 } from "fs/promises";
33197
- import path88 from "path";
33134
+ import path89 from "path";
33198
33135
 
33199
33136
  // src/sac/trusted-wrap-up.ts
33200
33137
  import { createHash as createHash13, randomUUID as randomUUID6 } from "crypto";
@@ -33238,12 +33175,12 @@ function digest(value) {
33238
33175
  init_fs();
33239
33176
  import { createHash as createHash22, randomUUID as randomUUID9 } from "crypto";
33240
33177
  import { appendFile as appendFile4, mkdir as mkdir20, readdir as readdir21, readFile as readFile44 } from "fs/promises";
33241
- import path87 from "path";
33178
+ import path88 from "path";
33242
33179
 
33243
33180
  // src/sac/index.ts
33244
33181
  import { access as access2, readFile as readFile34, realpath as realpath10 } from "fs/promises";
33245
33182
  import { createHash as createHash14 } from "crypto";
33246
- import path75 from "path";
33183
+ import path76 from "path";
33247
33184
  import { fileURLToPath as fileURLToPath3 } from "url";
33248
33185
 
33249
33186
  // src/sac/workspace-reference.ts
@@ -33266,21 +33203,21 @@ var normativeSchemaFiles = {
33266
33203
  "review-decision": "review-decision.schema.json"
33267
33204
  };
33268
33205
  var normativeSchemas = new Map;
33269
- var NORMATIVE_SCHEMA_DIR = path75.join("docs", "requirements", "shared-agent-context", "schemas");
33206
+ var NORMATIVE_SCHEMA_DIR = path76.join("docs", "requirements", "shared-agent-context", "schemas");
33270
33207
  async function resolveSacNormativeSchemaPath(fileName, searchFrom = [fileURLToPath3(new URL(".", import.meta.url)), process.cwd()]) {
33271
33208
  const seen = new Set;
33272
33209
  for (const start of searchFrom) {
33273
- let dir = path75.resolve(start);
33210
+ let dir = path76.resolve(start);
33274
33211
  for (let i = 0;i < 10; i++) {
33275
33212
  if (seen.has(dir))
33276
33213
  break;
33277
33214
  seen.add(dir);
33278
- const candidate = path75.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
33215
+ const candidate = path76.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
33279
33216
  try {
33280
33217
  await access2(candidate);
33281
33218
  return candidate;
33282
33219
  } catch {}
33283
- const parent = path75.dirname(dir);
33220
+ const parent = path76.dirname(dir);
33284
33221
  if (parent === dir)
33285
33222
  break;
33286
33223
  dir = parent;
@@ -33942,12 +33879,12 @@ class SacReferenceError extends Error {
33942
33879
  code = "unsafe_workspace_reference";
33943
33880
  }
33944
33881
  async function resolveWorkspaceReference(input) {
33945
- if (!workspacePathPattern.test(input.uri) || path75.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
33882
+ if (!workspacePathPattern.test(input.uri) || path76.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
33946
33883
  throw new SacReferenceError("unsafe workspace reference");
33947
- const lexicalRoot = path75.resolve(input.workspaceRoot);
33884
+ const lexicalRoot = path76.resolve(input.workspaceRoot);
33948
33885
  const root = await realpath10(lexicalRoot);
33949
- const candidate = path75.resolve(lexicalRoot, input.uri.slice(2));
33950
- if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path75.sep}`))
33886
+ const candidate = path76.resolve(lexicalRoot, input.uri.slice(2));
33887
+ if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path76.sep}`))
33951
33888
  throw new SacReferenceError("workspace reference escapes root");
33952
33889
  let resolved;
33953
33890
  try {
@@ -33955,7 +33892,7 @@ async function resolveWorkspaceReference(input) {
33955
33892
  } catch {
33956
33893
  throw new SacReferenceError("workspace reference is not resolvable");
33957
33894
  }
33958
- if (resolved !== root && !resolved.startsWith(`${root}${path75.sep}`))
33895
+ if (resolved !== root && !resolved.startsWith(`${root}${path76.sep}`))
33959
33896
  throw new SacReferenceError("workspace reference escapes root after realpath");
33960
33897
  return candidate;
33961
33898
  }
@@ -34011,16 +33948,16 @@ async function evaluateStrictSacGuard(input) {
34011
33948
  init_fs();
34012
33949
  import { mkdir as mkdir16, readdir as readdir19, readFile as readFile35 } from "fs/promises";
34013
33950
  import { createHash as createHash15, randomUUID as randomUUID7 } from "crypto";
34014
- import path77 from "path";
33951
+ import path78 from "path";
34015
33952
 
34016
33953
  // src/sac/secure-resource-read.ts
34017
33954
  init_contained_read();
34018
33955
  init_descriptor_read();
34019
- import path76 from "path";
33956
+ import path77 from "path";
34020
33957
  function readWorkspaceFileNoFollow(workspaceRoot, absolutePath) {
34021
- const relativePath = path76.relative(workspaceRoot, absolutePath);
34022
- const components = relativePath.split(path76.sep);
34023
- if (!relativePath || path76.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
33958
+ const relativePath = path77.relative(workspaceRoot, absolutePath);
33959
+ const components = relativePath.split(path77.sep);
33960
+ if (!relativePath || path77.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
34024
33961
  throw new Error("safe source path is not workspace-relative");
34025
33962
  }
34026
33963
  return readDescriptorChain(workspaceRoot, absolutePath, {
@@ -34047,8 +33984,8 @@ class WorkspaceService {
34047
33984
  now;
34048
33985
  constructor(options) {
34049
33986
  this.options = options;
34050
- this.root = path77.resolve(options.workspaceRoot);
34051
- this.storageRoot = path77.resolve(options.storageRoot ?? path77.join(this.root, ".metaproject", "workspaces"));
33987
+ this.root = path78.resolve(options.workspaceRoot);
33988
+ this.storageRoot = path78.resolve(options.storageRoot ?? path78.join(this.root, ".metaproject", "workspaces"));
34052
33989
  this.now = options.now ?? (() => new Date);
34053
33990
  }
34054
33991
  async create(input) {
@@ -34374,13 +34311,13 @@ class WorkspaceService {
34374
34311
  return parsed;
34375
34312
  }
34376
34313
  workspaceDir(id) {
34377
- return path77.join(this.storageRoot, id);
34314
+ return path78.join(this.storageRoot, id);
34378
34315
  }
34379
34316
  manifestPath(id) {
34380
- return path77.join(this.workspaceDir(id), "workspace.json");
34317
+ return path78.join(this.workspaceDir(id), "workspace.json");
34381
34318
  }
34382
34319
  lockPath(id) {
34383
- return path77.join(this.storageRoot, `.${id}.lock`);
34320
+ return path78.join(this.storageRoot, `.${id}.lock`);
34384
34321
  }
34385
34322
  timestamp() {
34386
34323
  return this.now().toISOString();
@@ -34435,7 +34372,7 @@ function bindingHash(owner, intent) {
34435
34372
  // src/sac/session-wrap-up.ts
34436
34373
  import { createHash as createHash17 } from "crypto";
34437
34374
  import { mkdir as mkdir17, writeFile as writeFile8 } from "fs/promises";
34438
- import path78 from "path";
34375
+ import path79 from "path";
34439
34376
  init_wrap_up_evidence();
34440
34377
  var WRAP_UP_TTL_MS = 60 * 60 * 1000;
34441
34378
 
@@ -34451,7 +34388,7 @@ function sessionEvidenceRef(workspaceId, sessionId) {
34451
34388
  }
34452
34389
  async function resolveSessionWrapUp(input) {
34453
34390
  const now = input.now ?? (() => new Date);
34454
- const sessionId = path78.posix.basename(input.sourceRef, ".md");
34391
+ const sessionId = path79.posix.basename(input.sourceRef, ".md");
34455
34392
  const summary = findSession(input.cwd, sessionId);
34456
34393
  if (summary === undefined || input.sourceRef !== sessionEvidenceRef(input.workspaceId, summary.id)) {
34457
34394
  throw new SessionWrapUpError("session_not_found", `no session matching "${input.sourceRef}" in this project \u2014 use \`keryx sessions list\``);
@@ -34468,7 +34405,7 @@ async function resolveSessionWrapUp(input) {
34468
34405
  throw new SessionWrapUpError("session_unreadable", `session "${summary.id}" could not be read: ${cause.message}`);
34469
34406
  }
34470
34407
  const relPath = sessionEvidenceRef(input.workspaceId, summary.id).slice(2);
34471
- const evidenceDir = path78.dirname(relPath);
34408
+ const evidenceDir = path79.dirname(relPath);
34472
34409
  const slate = await readSessionSlate(input.cwd, summary.id);
34473
34410
  const diff = await gitDiff(input.cwd);
34474
34411
  const diffBody = diff.kind === "measured" ? diff.text : unmeasurableDiffBody(diff.detail);
@@ -34490,23 +34427,23 @@ async function resolveSessionWrapUp(input) {
34490
34427
  ""
34491
34428
  ].join(`
34492
34429
  `);
34493
- const wrapUpRelPath = path78.join(evidenceDir, `${summary.id}.wrap-up.md`);
34494
- const diffRelPath = path78.join(evidenceDir, `${summary.id}.diff.txt`);
34495
- const noticeRelPath = path78.join(evidenceDir, `${summary.id}.redaction.md`);
34430
+ const wrapUpRelPath = path79.join(evidenceDir, `${summary.id}.wrap-up.md`);
34431
+ const diffRelPath = path79.join(evidenceDir, `${summary.id}.diff.txt`);
34432
+ const noticeRelPath = path79.join(evidenceDir, `${summary.id}.redaction.md`);
34496
34433
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
34497
- { name: path78.basename(relPath), content: markdown, path: relPath, source: "generated" },
34498
- { name: path78.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
34499
- { name: path78.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
34434
+ { name: path79.basename(relPath), content: markdown, path: relPath, source: "generated" },
34435
+ { name: path79.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
34436
+ { name: path79.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
34500
34437
  ]);
34501
34438
  if (!floor.ok)
34502
34439
  throw new SessionWrapUpError("security_denied", floor.reason);
34503
34440
  const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
34504
- await mkdir17(path78.join(input.cwd, evidenceDir), { recursive: true });
34505
- await writeFile8(path78.join(input.cwd, relPath), safeSession.content, "utf8");
34506
- await writeFile8(path78.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
34507
- await writeFile8(path78.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
34441
+ await mkdir17(path79.join(input.cwd, evidenceDir), { recursive: true });
34442
+ await writeFile8(path79.join(input.cwd, relPath), safeSession.content, "utf8");
34443
+ await writeFile8(path79.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
34444
+ await writeFile8(path79.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
34508
34445
  if (floor.notice !== undefined)
34509
- await writeFile8(path78.join(input.cwd, noticeRelPath), floor.notice, "utf8");
34446
+ await writeFile8(path79.join(input.cwd, noticeRelPath), floor.notice, "utf8");
34510
34447
  const observedAt = now().toISOString();
34511
34448
  const evidence = [
34512
34449
  { kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash17("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
@@ -34529,13 +34466,13 @@ async function resolveSessionWrapUp(input) {
34529
34466
  init_fs();
34530
34467
  import { createHash as createHash18, randomBytes as randomBytes3 } from "crypto";
34531
34468
  import { readFile as readFile36 } from "fs/promises";
34532
- import path79 from "path";
34469
+ import path80 from "path";
34533
34470
  var CONFIRM_TOKEN_TTL_MS = 2 * 60000;
34534
34471
  function confirmTokenPath(cwd, workspaceId, proposalId) {
34535
- return path79.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
34472
+ return path80.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
34536
34473
  }
34537
34474
  function confirmReceiptPath(cwd, workspaceId, proposalId, idempotencyKey) {
34538
- return path79.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha256(idempotencyKey)}.confirm-receipt.json`);
34475
+ return path80.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha256(idempotencyKey)}.confirm-receipt.json`);
34539
34476
  }
34540
34477
  function sha256(text) {
34541
34478
  return createHash18("sha256").update(text).digest("hex");
@@ -34576,21 +34513,21 @@ init_store();
34576
34513
  init_config4();
34577
34514
  import { readFile as readFile38, readdir as readdir20 } from "fs/promises";
34578
34515
  import { randomUUID as randomUUID8 } from "crypto";
34579
- import path82 from "path";
34516
+ import path83 from "path";
34580
34517
 
34581
34518
  // src/sac/proposal-evidence.ts
34582
34519
  init_fs();
34583
34520
  import { createHash as createHash19 } from "crypto";
34584
34521
  import { readFile as readFile37, rm as rm6 } from "fs/promises";
34585
- import path81 from "path";
34522
+ import path82 from "path";
34586
34523
  function proposalPath(cwd, workspaceId, proposalId) {
34587
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
34524
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
34588
34525
  }
34589
34526
  function ownerReceiptPath(cwd, owner, workspaceId, idempotencyKey) {
34590
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
34527
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
34591
34528
  }
34592
34529
  function proposalNotePath(cwd, workspaceId, proposalId) {
34593
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
34530
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
34594
34531
  }
34595
34532
  async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
34596
34533
  let proposal;
@@ -34604,7 +34541,7 @@ async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
34604
34541
  return { ok: false, code: "no_evidence_to_write" };
34605
34542
  let content;
34606
34543
  try {
34607
- content = await readFile37(path81.join(cwd, evidence.uri), "utf8");
34544
+ content = await readFile37(path82.join(cwd, evidence.uri), "utf8");
34608
34545
  } catch {
34609
34546
  return { ok: false, code: "evidence_file_unreadable" };
34610
34547
  }
@@ -34634,22 +34571,22 @@ function targetRelPath(targetRef) {
34634
34571
  return targetRef.replace(/^\.\//, "");
34635
34572
  }
34636
34573
  function targetAbsolutePath(cwd, targetRef) {
34637
- return path81.join(cwd, ".metaproject", targetRelPath(targetRef));
34574
+ return path82.join(cwd, ".metaproject", targetRelPath(targetRef));
34638
34575
  }
34639
34576
  function targetKey(targetRef) {
34640
34577
  return digestOf(targetRelPath(targetRef)).slice(0, 32);
34641
34578
  }
34642
34579
  function ownerTargetVersionPath(cwd, owner, workspaceId, targetRef) {
34643
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
34580
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
34644
34581
  }
34645
34582
  function ownerTargetLockPath(cwd, owner, targetRef) {
34646
- return path81.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
34583
+ return path82.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
34647
34584
  }
34648
34585
  function ownerStagingDir(cwd, owner, workspaceId, idempotencyKey) {
34649
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf(idempotencyKey).slice(0, 32));
34586
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf(idempotencyKey).slice(0, 32));
34650
34587
  }
34651
34588
  function ownerConflictDir(cwd, owner, workspaceId, idempotencyKey) {
34652
- return path81.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf(idempotencyKey).slice(0, 32));
34589
+ return path82.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf(idempotencyKey).slice(0, 32));
34653
34590
  }
34654
34591
  async function readJson7(file) {
34655
34592
  try {
@@ -34720,7 +34657,7 @@ async function applyGuardedTargetWrite(input) {
34720
34657
  staged: input.staged,
34721
34658
  stagedAt: receipt.completedAt
34722
34659
  };
34723
- await writeFileAtomic(path81.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
34660
+ await writeFileAtomic(path82.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
34724
34661
  `);
34725
34662
  const applied = await input.apply(input.staged);
34726
34663
  if (!applied.ok) {
@@ -34746,15 +34683,15 @@ async function recoverStagedOwnerWrite(input) {
34746
34683
  });
34747
34684
  }
34748
34685
  async function readStagedOwnerWrite(cwd, owner, workspaceId, idempotencyKey) {
34749
- return readJson7(path81.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
34686
+ return readJson7(path82.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
34750
34687
  }
34751
34688
  async function recordConflict(input) {
34752
34689
  const base = { targetRef: input.targetRef, expectedVersion: input.expectedVersion, currentVersion: input.currentVersion };
34753
34690
  if (input.proposedContent === undefined)
34754
34691
  return base;
34755
34692
  const dir = ownerConflictDir(input.cwd, input.owner, input.intent.workspaceId, input.intent.idempotencyKey);
34756
- await writeFileAtomic(path81.join(dir, "proposed"), input.proposedContent);
34757
- const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path81.basename(dir)}/proposed`;
34693
+ await writeFileAtomic(path82.join(dir, "proposed"), input.proposedContent);
34694
+ const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path82.basename(dir)}/proposed`;
34758
34695
  return { ...base, diffRef };
34759
34696
  }
34760
34697
 
@@ -34804,7 +34741,7 @@ async function resolveWorkspaceModule(cwd, workspaceId) {
34804
34741
  }
34805
34742
  }
34806
34743
  async function collectWikiDecisionEntries(cwd) {
34807
- const dir = path82.join(cwd, ".metaproject", "wiki", "decisions");
34744
+ const dir = path83.join(cwd, ".metaproject", "wiki", "decisions");
34808
34745
  let files;
34809
34746
  try {
34810
34747
  files = (await readdir20(dir)).filter((name) => name.endsWith(".md"));
@@ -34813,12 +34750,12 @@ async function collectWikiDecisionEntries(cwd) {
34813
34750
  }
34814
34751
  const entries = [];
34815
34752
  for (const file of files) {
34816
- const absolutePath = path82.join(dir, file);
34753
+ const absolutePath = path83.join(dir, file);
34817
34754
  try {
34818
34755
  const content = await readFile38(absolutePath, "utf8");
34819
34756
  entries.push({
34820
34757
  absolutePath,
34821
- relativePath: path82.posix.join("decisions", file),
34758
+ relativePath: path83.posix.join("decisions", file),
34822
34759
  type: extractHeaderField(content, "Type") ?? "decision",
34823
34760
  title: extractTitle(content),
34824
34761
  version: extractHeaderField(content, "Version") ?? null,
@@ -35040,7 +34977,7 @@ function createRealMemoryOwnerWriter(cwd, opts) {
35040
34977
  init_service4();
35041
34978
  init_guard2();
35042
34979
  import { readFile as readFile42 } from "fs/promises";
35043
- import path86 from "path";
34980
+ import path87 from "path";
35044
34981
  function renderWrapUpDecisionPage(input) {
35045
34982
  const note = input.note?.trim();
35046
34983
  return `# ${input.title}
@@ -35081,7 +35018,7 @@ export is the source of truth for what actually happened.
35081
35018
  `;
35082
35019
  }
35083
35020
  function wikiPageRelativePath(proposalId) {
35084
- return path86.posix.join("decisions", `sac-${proposalId}.md`);
35021
+ return path87.posix.join("decisions", `sac-${proposalId}.md`);
35085
35022
  }
35086
35023
  function createRealWikiOwnerWriter(cwd, opts) {
35087
35024
  const now = opts?.now ?? (() => new Date);
@@ -35089,7 +35026,7 @@ function createRealWikiOwnerWriter(cwd, opts) {
35089
35026
  const relativePath = staged.relativePath;
35090
35027
  const content = staged.content;
35091
35028
  const history = await openWikiWriteContext(cwd, "sac proposal accept");
35092
- await writeWikiPage(history, path86.join(cwd, ".metaproject", "wiki", relativePath), content);
35029
+ await writeWikiPage(history, path87.join(cwd, ".metaproject", "wiki", relativePath), content);
35093
35030
  return { ok: true };
35094
35031
  };
35095
35032
  return {
@@ -35238,7 +35175,7 @@ class ProposalLifecycleService {
35238
35175
  now;
35239
35176
  constructor(options) {
35240
35177
  this.options = options;
35241
- this.root = path87.resolve(options.workspaceRoot);
35178
+ this.root = path88.resolve(options.workspaceRoot);
35242
35179
  this.now = options.now ?? (() => new Date);
35243
35180
  }
35244
35181
  async create(input) {
@@ -35258,7 +35195,7 @@ class ProposalLifecycleService {
35258
35195
  if (manifest.status === "archived")
35259
35196
  throw new ProposalLifecycleError("guard_denied", "workspace is archived");
35260
35197
  const file = this.proposalPath(workspaceId, proposal.id);
35261
- await mkdir20(path87.dirname(file), { recursive: true, mode: 448 });
35198
+ await mkdir20(path88.dirname(file), { recursive: true, mode: 448 });
35262
35199
  return withFileLock2(`${file}.lock`, async () => {
35263
35200
  const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
35264
35201
  if (consume !== "ok")
@@ -35286,7 +35223,7 @@ class ProposalLifecycleService {
35286
35223
  return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
35287
35224
  const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
35288
35225
  const ledger = this.ledgerPath(input.workspaceId);
35289
- await mkdir20(path87.dirname(ledger), { recursive: true, mode: 448 });
35226
+ await mkdir20(path88.dirname(ledger), { recursive: true, mode: 448 });
35290
35227
  return withFileLock2(`${ledger}.lock`, async () => {
35291
35228
  const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
35292
35229
  const events = records.filter((record) => record.recordType === "proposal-transition");
@@ -35328,7 +35265,7 @@ class ProposalLifecycleService {
35328
35265
  } });
35329
35266
  }
35330
35267
  async listProposedProposals(workspaceId) {
35331
- const proposalsDir = path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
35268
+ const proposalsDir = path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
35332
35269
  let entries;
35333
35270
  try {
35334
35271
  entries = (await readdir21(proposalsDir)).filter((name) => name.endsWith(".json"));
@@ -35340,7 +35277,7 @@ class ProposalLifecycleService {
35340
35277
  const proposals = [];
35341
35278
  for (const entry of entries) {
35342
35279
  try {
35343
- const parsed = JSON.parse(await readFile44(path87.join(proposalsDir, entry), "utf8"));
35280
+ const parsed = JSON.parse(await readFile44(path88.join(proposalsDir, entry), "utf8"));
35344
35281
  if (parsed.recordType === "proposal-created")
35345
35282
  proposals.push(parsed);
35346
35283
  } catch {}
@@ -35606,31 +35543,31 @@ class ProposalLifecycleService {
35606
35543
  }
35607
35544
  }
35608
35545
  proposalPath(workspaceId, proposalId) {
35609
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
35546
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
35610
35547
  }
35611
35548
  decisionRef(proposalId, key) {
35612
35549
  return `./proposals/${proposalId}.${hash2(key)}.decision.json`;
35613
35550
  }
35614
35551
  decisionPath(workspaceId, proposalId, key) {
35615
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
35552
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
35616
35553
  }
35617
35554
  approvalRef(proposalId, key) {
35618
35555
  return `./proposals/${proposalId}.${hash2(key)}.approval.json`;
35619
35556
  }
35620
35557
  approvalPath(workspaceId, proposalId, key) {
35621
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
35558
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
35622
35559
  }
35623
35560
  writeResultPath(workspaceId, proposalId, key) {
35624
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
35561
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
35625
35562
  }
35626
35563
  intentRef(proposalId, key) {
35627
35564
  return `./proposals/${proposalId}.${hash2(key)}.write-intent.json`;
35628
35565
  }
35629
35566
  intentPath(workspaceId, proposalId, key) {
35630
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
35567
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
35631
35568
  }
35632
35569
  attemptPath(workspaceId, proposalId, key) {
35633
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
35570
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
35634
35571
  }
35635
35572
  async loadWriteResult(workspaceId, proposalId, key) {
35636
35573
  try {
@@ -35657,7 +35594,7 @@ class ProposalLifecycleService {
35657
35594
  }
35658
35595
  }
35659
35596
  ledgerPath(workspaceId) {
35660
- return path87.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
35597
+ return path88.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
35661
35598
  }
35662
35599
  timestamp() {
35663
35600
  return this.now().toISOString();
@@ -35886,11 +35823,11 @@ async function resolveMachineWrapUp(input) {
35886
35823
  `;
35887
35824
  const seedsJson = `${JSON.stringify(seedsForKind.map((seed) => ({ text: seed.text, source: describeSource(seed.source) })), null, 2)}
35888
35825
  `;
35889
- const evidenceRelBase = path88.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
35826
+ const evidenceRelBase = path89.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
35890
35827
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
35891
- { name: `${input.kind}.diff.txt`, content: diffBody, path: path88.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
35892
- { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path88.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
35893
- { name: `${input.kind}.seeds.json`, content: seedsJson, path: path88.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
35828
+ { name: `${input.kind}.diff.txt`, content: diffBody, path: path89.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
35829
+ { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path89.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
35830
+ { name: `${input.kind}.seeds.json`, content: seedsJson, path: path89.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
35894
35831
  ]);
35895
35832
  if (!floor.ok)
35896
35833
  return { ok: false, code: "security_denied", detail: floor.reason };
@@ -35944,14 +35881,14 @@ ${safeSeeds.content}`;
35944
35881
  }
35945
35882
  summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
35946
35883
  }
35947
- const evidenceDir = path88.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
35884
+ const evidenceDir = path89.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
35948
35885
  await mkdir21(evidenceDir, { recursive: true });
35949
35886
  const diffFile = `${input.kind}.${shortHash}.diff.txt`;
35950
35887
  const flowFile = `${input.kind}.${shortHash}.flow.json`;
35951
35888
  const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
35952
- await writeFileAtomic(path88.join(evidenceDir, diffFile), safeDiff.content);
35953
- await writeFileAtomic(path88.join(evidenceDir, flowFile), safeFlow.content);
35954
- await writeFileAtomic(path88.join(evidenceDir, seedsFile), safeSeeds.content);
35889
+ await writeFileAtomic(path89.join(evidenceDir, diffFile), safeDiff.content);
35890
+ await writeFileAtomic(path89.join(evidenceDir, flowFile), safeFlow.content);
35891
+ await writeFileAtomic(path89.join(evidenceDir, seedsFile), safeSeeds.content);
35955
35892
  const observedAt = now().toISOString();
35956
35893
  const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
35957
35894
  const evidence = [
@@ -35961,7 +35898,7 @@ ${safeSeeds.content}`;
35961
35898
  ];
35962
35899
  if (floor.notice !== undefined) {
35963
35900
  const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
35964
- await writeFileAtomic(path88.join(evidenceDir, noticeFile), floor.notice);
35901
+ await writeFileAtomic(path89.join(evidenceDir, noticeFile), floor.notice);
35965
35902
  evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2563(floor.notice), observedAt });
35966
35903
  }
35967
35904
  return {
@@ -35980,18 +35917,18 @@ async function writeFlooredArchiveArtifact(params) {
35980
35917
  {
35981
35918
  name: params.filename,
35982
35919
  content: params.content,
35983
- path: path88.posix.join("slate-archive", params.filename),
35920
+ path: path89.posix.join("slate-archive", params.filename),
35984
35921
  source: "generated"
35985
35922
  }
35986
35923
  ]);
35987
35924
  if (!floor.ok)
35988
35925
  return { ok: false, code: "security_denied", detail: floor.reason };
35989
35926
  const body = floor.bodies[0];
35990
- const archiveDir = path88.join(params.dir, "slate-archive");
35927
+ const archiveDir = path89.join(params.dir, "slate-archive");
35991
35928
  await mkdir21(archiveDir, { recursive: true });
35992
- await writeFileAtomic(path88.join(archiveDir, params.filename), body.content);
35929
+ await writeFileAtomic(path89.join(archiveDir, params.filename), body.content);
35993
35930
  if (floor.notice !== undefined) {
35994
- await writeFileAtomic(path88.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
35931
+ await writeFileAtomic(path89.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
35995
35932
  }
35996
35933
  return { ok: true, altered: body.altered };
35997
35934
  }
@@ -36027,9 +35964,9 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
36027
35964
  return;
36028
35965
  const refusalIso = now().toISOString();
36029
35966
  const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
36030
- const archiveDir = path88.join(dir, "slate-archive");
35967
+ const archiveDir = path89.join(dir, "slate-archive");
36031
35968
  await mkdir21(archiveDir, { recursive: true });
36032
- await writeFileAtomic(path88.join(archiveDir, refusalFilename), `${JSON.stringify({
35969
+ await writeFileAtomic(path89.join(archiveDir, refusalFilename), `${JSON.stringify({
36033
35970
  recordType: "wrap-up-outcome",
36034
35971
  trigger,
36035
35972
  generatedAt: refusalIso,
@@ -36364,7 +36301,7 @@ init_fs();
36364
36301
  init_repomap();
36365
36302
  init_redact();
36366
36303
  init_slate();
36367
- import path89 from "path";
36304
+ import path90 from "path";
36368
36305
  var DEFAULT_TERMINAL_STATE_MAX_TOKENS = 2000;
36369
36306
  function boundedRedactedAnchorsSnapshot(anchors, maxTokens) {
36370
36307
  const fence = anchors.fence?.map((entry) => redactSensitiveText(entry));
@@ -36399,7 +36336,7 @@ function renderTerminalStateBlock(state, opts) {
36399
36336
  `);
36400
36337
  }
36401
36338
  async function writeTerminalState(dir, state) {
36402
- await writeFileAtomic(path89.join(dir, "terminal-state.json"), `${JSON.stringify(state, null, 2)}
36339
+ await writeFileAtomic(path90.join(dir, "terminal-state.json"), `${JSON.stringify(state, null, 2)}
36403
36340
  `);
36404
36341
  }
36405
36342