@deftai/directive-core 0.92.0 → 0.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/cache/fetch.d.ts +29 -0
  2. package/dist/cache/fetch.js +131 -4
  3. package/dist/cache/operations.d.ts +8 -0
  4. package/dist/cache/operations.js +67 -4
  5. package/dist/check/cached-orchestrator.js +11 -0
  6. package/dist/check/consumer-gate-integrity.d.ts +68 -0
  7. package/dist/check/consumer-gate-integrity.js +265 -0
  8. package/dist/check/index.d.ts +1 -0
  9. package/dist/check/index.js +1 -0
  10. package/dist/check/orchestrator.js +10 -0
  11. package/dist/content-contracts/skills/greptile-detector.d.ts +9 -0
  12. package/dist/content-contracts/skills/greptile-detector.js +9 -2
  13. package/dist/doctor/index.d.ts +1 -0
  14. package/dist/doctor/index.js +1 -0
  15. package/dist/doctor/main.js +69 -0
  16. package/dist/doctor/openclaw-l2-adapter.d.ts +26 -0
  17. package/dist/doctor/openclaw-l2-adapter.js +199 -0
  18. package/dist/finish-loop/pr-finish-loop.js +1 -0
  19. package/dist/hooks/dispatcher.d.ts +24 -2
  20. package/dist/hooks/dispatcher.js +122 -11
  21. package/dist/hooks/readonly.d.ts +14 -0
  22. package/dist/hooks/readonly.js +126 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +2 -0
  25. package/dist/init-deposit/hygiene.js +22 -0
  26. package/dist/init-deposit/index.d.ts +3 -0
  27. package/dist/init-deposit/index.js +3 -0
  28. package/dist/init-deposit/init-deposit.js +10 -0
  29. package/dist/init-deposit/refresh.js +11 -0
  30. package/dist/init-deposit/scaffold.js +3 -133
  31. package/dist/init-deposit/skill-discovery-deposit.d.ts +65 -0
  32. package/dist/init-deposit/skill-discovery-deposit.js +287 -0
  33. package/dist/init-deposit/skill-discovery-hosts.d.ts +94 -0
  34. package/dist/init-deposit/skill-discovery-hosts.js +217 -0
  35. package/dist/init-deposit/slash-deposit.d.ts +46 -0
  36. package/dist/init-deposit/slash-deposit.js +174 -0
  37. package/dist/intake/issue-ingest.d.ts +20 -0
  38. package/dist/intake/issue-ingest.js +58 -0
  39. package/dist/policy/host-slash-commands.d.ts +28 -0
  40. package/dist/policy/host-slash-commands.js +103 -0
  41. package/dist/policy/index.d.ts +2 -0
  42. package/dist/policy/index.js +61 -7
  43. package/dist/policy/min-greptile-confidence.d.ts +57 -0
  44. package/dist/policy/min-greptile-confidence.js +123 -0
  45. package/dist/pr-merge-readiness/compute.d.ts +11 -1
  46. package/dist/pr-merge-readiness/compute.js +17 -4
  47. package/dist/pr-merge-readiness/evaluate.d.ts +8 -1
  48. package/dist/pr-merge-readiness/evaluate.js +7 -4
  49. package/dist/pr-merge-readiness/mergeability.d.ts +7 -1
  50. package/dist/pr-merge-readiness/mergeability.js +14 -2
  51. package/dist/pr-monitor/main.d.ts +2 -0
  52. package/dist/pr-monitor/main.js +31 -1
  53. package/dist/pr-monitor/monitor.js +5 -1
  54. package/dist/pr-monitor/readiness.js +3 -1
  55. package/dist/pr-monitor/types.d.ts +8 -0
  56. package/dist/pr-wait-mergeable/cascade.d.ts +8 -0
  57. package/dist/pr-wait-mergeable/cascade.js +28 -1
  58. package/dist/pr-wait-mergeable/main.d.ts +2 -0
  59. package/dist/pr-wait-mergeable/main.js +16 -0
  60. package/dist/pr-wait-mergeable/types.d.ts +3 -1
  61. package/dist/pr-wait-mergeable/wrappers.d.ts +6 -0
  62. package/dist/pr-wait-mergeable/wrappers.js +3 -0
  63. package/dist/pr-watch/constants.d.ts +4 -1
  64. package/dist/pr-watch/constants.js +5 -2
  65. package/dist/pr-watch/main.js +1 -0
  66. package/dist/pr-watch/probe.d.ts +1 -1
  67. package/dist/pr-watch/probe.js +4 -1
  68. package/dist/pr-watch/types.d.ts +7 -1
  69. package/dist/pr-watch/watch.js +3 -2
  70. package/dist/review-monitor/index.d.ts +1 -0
  71. package/dist/review-monitor/index.js +1 -0
  72. package/dist/review-monitor/l4-owner.d.ts +46 -0
  73. package/dist/review-monitor/l4-owner.js +262 -0
  74. package/dist/slash/emitters.d.ts +102 -0
  75. package/dist/slash/emitters.js +148 -0
  76. package/dist/slash/generator.d.ts +98 -0
  77. package/dist/slash/generator.js +145 -0
  78. package/dist/slash/index.d.ts +16 -0
  79. package/dist/slash/index.js +16 -0
  80. package/dist/slash/openclaw-adapter.d.ts +64 -0
  81. package/dist/slash/openclaw-adapter.js +198 -0
  82. package/dist/slash/openclaw-deposit.d.ts +73 -0
  83. package/dist/slash/openclaw-deposit.js +279 -0
  84. package/dist/slash/openclaw-slugs.d.ts +52 -0
  85. package/dist/slash/openclaw-slugs.js +126 -0
  86. package/dist/slash/product-set.d.ts +50 -0
  87. package/dist/slash/product-set.js +142 -0
  88. package/dist/tool-events/classify.js +1 -0
  89. package/dist/triage/welcome/writers.js +16 -7
  90. package/dist/umbrella-current-shape/index.d.ts +45 -0
  91. package/dist/umbrella-current-shape/index.js +162 -8
  92. package/dist/vbrief-reconcile/index.d.ts +2 -2
  93. package/dist/vbrief-reconcile/index.js +1 -1
  94. package/dist/vbrief-reconcile/types.d.ts +14 -0
  95. package/dist/vbrief-reconcile/umbrellas.d.ts +31 -2
  96. package/dist/vbrief-reconcile/umbrellas.js +231 -19
  97. package/dist/vbrief-validate/plan-hooks.d.ts +4 -0
  98. package/dist/vbrief-validate/plan-hooks.js +50 -0
  99. package/dist/xbrief/create.d.ts +36 -0
  100. package/dist/xbrief/create.js +285 -0
  101. package/dist/xbrief/index.d.ts +14 -0
  102. package/dist/xbrief/index.js +42 -0
  103. package/dist/xbrief/paths.d.ts +37 -0
  104. package/dist/xbrief/paths.js +123 -0
  105. package/dist/xbrief/styles.d.ts +36 -0
  106. package/dist/xbrief/styles.js +235 -0
  107. package/dist/xbrief/types.d.ts +50 -0
  108. package/dist/xbrief/types.js +17 -0
  109. package/dist/xbrief/verify.d.ts +30 -0
  110. package/dist/xbrief/verify.js +251 -0
  111. package/package.json +11 -3
@@ -16,6 +16,9 @@ import { readdir, rm, stat } from "node:fs/promises";
16
16
  import { dirname, join, relative } from "node:path";
17
17
  import { gitPorcelain } from "../story-ready/git.js";
18
18
  import { CANONICAL_INSTALL_ROOT } from "./constants.js";
19
+ import { CONSUMER_SKILL_DISCOVERY_INVENTORY } from "./skill-discovery-deposit.js";
20
+ import { hostSkillRelativePath, listSkillDiscoveryHosts } from "./skill-discovery-hosts.js";
21
+ import { slashCommandManagedExactPaths } from "./slash-deposit.js";
19
22
  export const CODEQL_CONFIG_REL = ".github/codeql/codeql-config.yml";
20
23
  export const CORE_GUARD_WORKFLOW_REL = ".github/workflows/deft-core-guard.yml";
21
24
  // The lifecycle dir names are identical across the legacy `vbrief/` tree and the
@@ -41,16 +44,35 @@ export const CONSUMER_GUARD_MUST_FIRE = [
41
44
  "xbrief/proposed/example-scope.xbrief.json",
42
45
  "vbrief/pending/example-scope.vbrief.json",
43
46
  ];
47
+ /** Exact managed multi-host skill pointer paths only (#75 Greptile P1). */
48
+ function multiHostSkillDiscoveryManagedMatchers() {
49
+ // Exact SKILL.md paths only so consumer-authored siblings under the same
50
+ // host skills tree stay app-owned (not staged / not guard-exempt).
51
+ const matchers = [];
52
+ for (const host of listSkillDiscoveryHosts()) {
53
+ for (const skill of CONSUMER_SKILL_DISCOVERY_INVENTORY) {
54
+ matchers.push({ exact: hostSkillRelativePath(host, skill.dir) });
55
+ }
56
+ }
57
+ return matchers;
58
+ }
44
59
  /** Single source of truth for installer-managed paths (#1440 / #1576). */
45
60
  export function installerManagedMatchers() {
46
61
  return [
47
62
  { exact: "AGENTS.md" },
48
63
  { prefix: ".agents/" },
64
+ // Multi-host skill discovery thin pointers (#75 residual) — not slash commands (#55).
65
+ // Exact inventory paths only; never claim the whole host skills tree.
66
+ ...multiHostSkillDiscoveryManagedMatchers(),
49
67
  { prefix: ".githooks/" },
50
68
  { exact: ".claude/settings.json" },
51
69
  { exact: ".grok/hooks/deft.json" },
52
70
  { exact: ".cursor/hooks.json" },
53
71
  { exact: ".codex/hooks.json" },
72
+ // Multi-host slash product files only (#3054 / L8 prefer commit).
73
+ // Exact paths — not directory prefixes — so consumer custom commands under
74
+ // the same host dirs stay app-owned for staging + no-mixed-core-and-app.
75
+ ...slashCommandManagedExactPaths().map((exact) => ({ exact })),
54
76
  { exact: ".gitattributes" },
55
77
  { exact: ".gitignore" },
56
78
  // Installer-deposited Prettier gate exclusion (#2534); must be allowlisted or
@@ -6,5 +6,8 @@ export * from "./legacy-detect.js";
6
6
  export * from "./migrate.js";
7
7
  export * from "./refresh.js";
8
8
  export * from "./scaffold.js";
9
+ export * from "./skill-discovery-deposit.js";
10
+ export * from "./skill-discovery-hosts.js";
11
+ export * from "./slash-deposit.js";
9
12
  export * from "./untrack-core.js";
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -6,5 +6,8 @@ export * from "./legacy-detect.js";
6
6
  export * from "./migrate.js";
7
7
  export * from "./refresh.js";
8
8
  export * from "./scaffold.js";
9
+ export * from "./skill-discovery-deposit.js";
10
+ export * from "./skill-discovery-hosts.js";
11
+ export * from "./slash-deposit.js";
9
12
  export * from "./untrack-core.js";
10
13
  //# sourceMappingURL=index.js.map
@@ -14,6 +14,7 @@ import { prunePythonArtifactsFromDeposit } from "../deposit/python-free.js";
14
14
  import { resolveInstalledContentRoot } from "../deposit/resolve-content.js";
15
15
  import { readCorePackageVersion } from "../engine-version.js";
16
16
  import { renderProjectDefinition } from "../render/project-render.js";
17
+ import { depositOpenClawL2ProductCommands } from "../slash/openclaw-deposit.js";
17
18
  import { removeStaleMigratedFrameworkNarrative } from "../xbrief-migrate/migrate-project.js";
18
19
  import { writeAgentHookDeposit } from "./agent-hooks.js";
19
20
  import { ensureInitGitignoreLines, reconstituteDepositFromContent } from "./gitignore.js";
@@ -22,6 +23,8 @@ import { buildLegacyRefusalJson, buildLegacyRefusalMessage, detectLegacyLayout,
22
23
  import { printMigrateNudgeIfNeeded } from "./migrate.js";
23
24
  import { ensurePrettierIgnoreLines } from "./prettierignore.js";
24
25
  import { CANONICAL_INSTALL_ROOT, depositNeutralization, ensureTaskfile, writeAgentsMd, writeAgentsSkills, writeConsumerGitHooks, writeConsumerVbrief, writeInstallManifest, } from "./scaffold.js";
26
+ import { writeMultiHostSkillDiscovery } from "./skill-discovery-deposit.js";
27
+ import { writeSlashCommandDeposit } from "./slash-deposit.js";
25
28
  import { syncBareVersionMarker } from "./xbrief-projections.js";
26
29
  export function parseInitArgv(canonicalArgv, userArgv = []) {
27
30
  const args = [...canonicalArgv, ...userArgv];
@@ -181,6 +184,7 @@ export async function runInitDeposit(args, io, seams = {}) {
181
184
  writeInstallManifest(projectDir, deftDir, manifestFields);
182
185
  writeAgentsMd(projectDir, deftDir, io);
183
186
  const skillsCreated = writeAgentsSkills(projectDir, io);
187
+ writeMultiHostSkillDiscovery(projectDir, io);
184
188
  await depositNeutralization(projectDir, io);
185
189
  await writeConsumerVbrief(projectDir, deftDir, io);
186
190
  seedMinimalProjectDefinition(projectDir, io);
@@ -191,6 +195,12 @@ export async function runInitDeposit(args, io, seams = {}) {
191
195
  removeStaleMigratedFrameworkNarrative(projectDir);
192
196
  writeConsumerGitHooks(projectDir, deftDir, io, seams.gitHooks);
193
197
  writeAgentHookDeposit(projectDir, io);
198
+ writeSlashCommandDeposit(projectDir, io);
199
+ // #3064: OpenClaw L2 product-command skills when OC signals present (fail-closed otherwise).
200
+ depositOpenClawL2ProductCommands({
201
+ projectRoot: projectDir,
202
+ printf: (t) => io.printf(t),
203
+ });
194
204
  let taskfileWired = false;
195
205
  if (args.nonInteractive) {
196
206
  taskfileWired = ensureTaskfile(projectDir, io);
@@ -21,6 +21,7 @@ import { resolveLifecycleRoot } from "../layout/resolve.js";
21
21
  import { detectNoDeftDirective, NO_DEFT_DIRECTIVE_DISABLED_MESSAGE, NO_DEFT_DIRECTIVE_FLAG_NAME, NO_DEFT_DIRECTIVE_INCONSISTENT_MESSAGE, NO_DEFT_DIRECTIVE_INCONSISTENT_POLICY, } from "../policy/no-deft-directive.js";
22
22
  import { runOrgForceOnMigration } from "../policy/org-force-on-migration.js";
23
23
  import { checkLocalEngineIntegrity, classify, ENGINE_PACKAGE, plan, renderGlobalInstall, resolveEngine, } from "../resolution/index.js";
24
+ import { depositOpenClawL2ProductCommands } from "../slash/openclaw-deposit.js";
24
25
  import { gitPorcelain } from "../story-ready/git.js";
25
26
  import { removeStaleMigratedFrameworkNarrative } from "../xbrief-migrate/migrate-project.js";
26
27
  import { writeAgentHookDeposit } from "./agent-hooks.js";
@@ -31,6 +32,8 @@ import { buildLegacyRefusalJson, buildLegacyRefusalMessage, detectLegacyLayout,
31
32
  import { printMigrateNudgeIfNeeded } from "./migrate.js";
32
33
  import { ensurePrettierIgnoreLines } from "./prettierignore.js";
33
34
  import { CANONICAL_INSTALL_ROOT, depositNeutralization, ensureTaskfile, writeAgentsMd, writeConsumerGitHooks, writeInstallManifest, } from "./scaffold.js";
35
+ import { writeMultiHostSkillDiscovery } from "./skill-discovery-deposit.js";
36
+ import { writeSlashCommandDeposit } from "./slash-deposit.js";
34
37
  import { syncBareVersionMarker, syncConsumerXbriefSchemas, syncExistingBareVersionMarker, } from "./xbrief-projections.js";
35
38
  function hasCanonicalXbriefLifecycle(projectDir) {
36
39
  try {
@@ -464,6 +467,14 @@ export async function runRefreshDeposit(args, io, seams = {}) {
464
467
  }
465
468
  const agentsMdUpdated = writeAgentsMd(projectDir, deftDir, io);
466
469
  writeAgentHookDeposit(projectDir, io);
470
+ // #75 residual: multi-host thin skill discovery (mirror `.agents/skills` inventory).
471
+ writeMultiHostSkillDiscovery(projectDir, io);
472
+ writeSlashCommandDeposit(projectDir, io);
473
+ // #3064: OpenClaw L2 product-command skills when OC signals present (fail-closed otherwise).
474
+ depositOpenClawL2ProductCommands({
475
+ projectRoot: projectDir,
476
+ printf: (t) => io.printf(t),
477
+ });
467
478
  // #2530: root `.githooks/` is a consumer derivative like #2595 marker/schemas —
468
479
  // repair on every refresh, including the already-current no-op path.
469
480
  writeConsumerGitHooks(projectDir, deftDir, io, seams.gitHooks);
@@ -15,6 +15,7 @@ import { agentsRefreshPlan } from "../platform/agents-md.js";
15
15
  import { MIGRATED_ARTIFACT_DIR } from "../xbrief-migrate/constants.js";
16
16
  import { CANONICAL_INSTALL_ROOT } from "./constants.js";
17
17
  import { assertInstallerAllowlistHonors1430, installerManagedGuardEre } from "./hygiene.js";
18
+ import { writeAgentsSkillsFromInventory } from "./skill-discovery-deposit.js";
18
19
  import { syncConsumerXbriefSchemas } from "./xbrief-projections.js";
19
20
  export { CANONICAL_INSTALL_ROOT };
20
21
  export const CORE_GLOB = ".deft/core/**";
@@ -90,125 +91,6 @@ const DEFT_INCLUDE_CHILD_BLOCK = " # Added by deft-install --yes (Epic-4)\n" +
90
91
  " deft:\n" +
91
92
  " taskfile: ./.deft/core/Taskfile.yml\n" +
92
93
  " optional: true\n";
93
- const AGENTS_SKILLS = [
94
- {
95
- dir: "deft",
96
- content: `---
97
- name: deft
98
- description: Apply deft framework standards for AI-assisted development. Use when starting projects, writing code, running tests, making commits, or when the user references deft, project standards, or coding guidelines.
99
- ---
100
-
101
- Read and follow: .deft/core/SKILL.md
102
- `,
103
- },
104
- {
105
- dir: "deft-directive-setup",
106
- content: `---
107
- name: deft-directive-setup
108
- description: >-
109
- Set up a new project with Deft framework standards. Use when the user wants
110
- to bootstrap user preferences, configure a project, or generate a project
111
- specification. Walks through setup conversationally — no separate CLI needed.
112
- ---
113
-
114
- Read and follow: .deft/core/skills/deft-directive-setup/SKILL.md
115
- `,
116
- },
117
- {
118
- dir: "deft-directive-build",
119
- content: `---
120
- name: deft-directive-build
121
- description: >-
122
- Build a project from scope vBRIEFs following Deft framework standards.
123
- Use after deft-directive-setup has generated the project definition, or when
124
- the user has scope vBRIEFs ready to implement. Handles scaffolding,
125
- implementation, testing, and quality checks phase by phase.
126
- ---
127
-
128
- Read and follow: .deft/core/skills/deft-directive-build/SKILL.md
129
- `,
130
- },
131
- {
132
- dir: "deft-directive-review-cycle",
133
- content: `---
134
- name: deft-directive-review-cycle
135
- description: >-
136
- Greptile bot reviewer response workflow. Use when running a review cycle
137
- on a PR — to audit process prerequisites, fetch bot findings, fix all
138
- issues in a single batch commit, and exit cleanly when no P0/P1 issues
139
- remain. Enables cloud agents to run autonomous PR review cycles.
140
- ---
141
-
142
- Read and follow: .deft/core/skills/deft-directive-review-cycle/SKILL.md
143
- `,
144
- },
145
- {
146
- dir: "deft-directive-refinement",
147
- content: `---
148
- name: deft-directive-refinement
149
- description: >-
150
- Structured refinement workflow. Compares open GitHub issues against
151
- the roadmap, triages new issues one-at-a-time with human review, and updates
152
- the roadmap with phase placement, analysis comments, and index entries.
153
- ---
154
-
155
- Read and follow: .deft/core/skills/deft-directive-refinement/SKILL.md
156
- `,
157
- },
158
- {
159
- dir: "deft-directive-swarm",
160
- content: `---
161
- name: deft-directive-swarm
162
- description: >-
163
- Parallel local agent orchestration. Use when running multiple agents
164
- on roadmap items simultaneously — to select non-overlapping tasks, set up
165
- isolated worktrees, launch agents with proven prompts, monitor progress,
166
- handle stalled review cycles, and close out PRs cleanly.
167
- ---
168
-
169
- Read and follow: .deft/core/skills/deft-directive-swarm/SKILL.md
170
- `,
171
- },
172
- {
173
- dir: "deft-directive-interview",
174
- content: `---
175
- name: deft-directive-interview
176
- description: >-
177
- Deterministic structured Q&A interview skill. Use when a skill or workflow
178
- needs to collect structured answers from the user — one question per turn,
179
- numbered options, default acceptance, and a confirmation gate.
180
- ---
181
-
182
- Read and follow: .deft/core/skills/deft-directive-interview/SKILL.md
183
- `,
184
- },
185
- {
186
- dir: "deft-directive-pre-pr",
187
- content: `---
188
- name: deft-directive-pre-pr
189
- description: >-
190
- Iterative pre-PR quality loop (Read-Write-Lint-Diff-Loop). Use before
191
- pushing a branch for PR creation — structured self-review that agents run
192
- to catch issues before they reach the bot reviewer.
193
- ---
194
-
195
- Read and follow: .deft/core/skills/deft-directive-pre-pr/SKILL.md
196
- `,
197
- },
198
- {
199
- dir: "deft-directive-sync",
200
- content: `---
201
- name: deft-directive-sync
202
- description: >-
203
- Session-start framework sync skill. Use at the beginning of a session to
204
- pull latest framework updates, validate project files, and confirm alignment
205
- before starting work.
206
- ---
207
-
208
- Read and follow: .deft/core/skills/deft-directive-sync/SKILL.md
209
- `,
210
- },
211
- ];
212
94
  const BARE_SEMVER = /^\d+\.\d+\.\d+([-+][0-9A-Za-z.-]+)?$/;
213
95
  export function buildInstallManifestText(fields) {
214
96
  let effectiveTag = fields.tag;
@@ -376,20 +258,8 @@ export async function writeConsumerVbrief(projectDir, deftDir, io) {
376
258
  return true;
377
259
  }
378
260
  export function writeAgentsSkills(projectDir, io) {
379
- projectionTarget(projectDir, ".agents");
380
- const allExist = AGENTS_SKILLS.every((skill) => existsSync(join(projectDir, ".agents", "skills", skill.dir, "SKILL.md")));
381
- if (allExist) {
382
- io.printf(".agents/skills/ already present — skipping.\n");
383
- return false;
384
- }
385
- for (const skill of AGENTS_SKILLS) {
386
- const path = projectionTarget(projectDir, ".agents", "skills", skill.dir, "SKILL.md");
387
- if (existsSync(path))
388
- continue;
389
- containedProjectWrite(projectDir, path, skill.content);
390
- }
391
- io.printf(".agents/skills/ created — deft skills will be auto-discovered.\n");
392
- return true;
261
+ // Shared inventory with multi-host skill discovery (#75 residual).
262
+ return writeAgentsSkillsFromInventory(projectDir, io);
393
263
  }
394
264
  function hasTopLevelIncludes(content) {
395
265
  if (!content)
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Multi-host thin skill discovery deposit (#75 residual).
3
+ *
4
+ * Mirrors the consumer skill inventory already written to `.agents/skills/`
5
+ * into additional host paths (`.claude/skills/`, `.codex/skills/`,
6
+ * `.github/skills/`, `.cursor/skills/`). Thin pointers only — no full skill
7
+ * body copies. Windows-safe file writes (no elevated symlink requirement).
8
+ *
9
+ * Distinct from epic #55 slash-command deposit (#3054).
10
+ */
11
+ import type { InitDepositIo } from "./constants.js";
12
+ import { type HostSkillDiscoveryPolicy, type SkillDiscoveryHostId } from "./skill-discovery-hosts.js";
13
+ export type { InitDepositIo };
14
+ /**
15
+ * Consumer skill discovery inventory shared by `.agents/skills/` and multi-host
16
+ * deposit. Each entry is a thin SKILL.md pointer into `.deft/core/…` — never a
17
+ * full skill body. Keep this list the single SoT for install-time discovery.
18
+ */
19
+ export declare const CONSUMER_SKILL_DISCOVERY_INVENTORY: ReadonlyArray<{
20
+ dir: string;
21
+ content: string;
22
+ }>;
23
+ /** Max bytes for a thin pointer body — fat full-skill copies fail this guard. */
24
+ export declare const MAX_THIN_SKILL_POINTER_BYTES = 1200;
25
+ /**
26
+ * True when content is a thin discovery pointer (not an inlined skill body).
27
+ * Managed deposit must stay pointer-shaped so updates do not rot full copies.
28
+ */
29
+ export declare function isThinSkillPointer(content: string): boolean;
30
+ export interface MultiHostSkillDiscoveryDepositResult {
31
+ readonly changed: boolean;
32
+ /** Repo-relative posix paths written or rewritten. */
33
+ readonly changedPaths: string[];
34
+ /** Hosts that received at least one write. */
35
+ readonly hostsTouched: SkillDiscoveryHostId[];
36
+ /** Hosts skipped because `plan.policy.hostSkillDiscovery.<host>` is false. */
37
+ readonly hostsSkipped: SkillDiscoveryHostId[];
38
+ }
39
+ export interface WriteMultiHostSkillDiscoveryOptions {
40
+ /** Override policy (tests); default loads from PROJECT-DEFINITION. */
41
+ policy?: HostSkillDiscoveryPolicy;
42
+ /**
43
+ * Skill inventory to deposit. Defaults to the shared consumer inventory
44
+ * (same set as `.agents/skills/`).
45
+ */
46
+ inventory?: ReadonlyArray<{
47
+ dir: string;
48
+ content: string;
49
+ }>;
50
+ }
51
+ /**
52
+ * Deposit thin skill discovery pointers into enabled multi-host paths.
53
+ * Idempotent: skips write when on-disk content already matches. Never creates
54
+ * symlinks (Windows-safe without elevation).
55
+ */
56
+ export declare function writeMultiHostSkillDiscovery(projectDir: string, io: InitDepositIo, options?: WriteMultiHostSkillDiscoveryOptions): MultiHostSkillDiscoveryDepositResult;
57
+ /**
58
+ * Shared inventory helper for `.agents/skills/` (canonical) deposit.
59
+ * Returns true when any pointer was created (matching writeAgentsSkills).
60
+ */
61
+ export declare function writeAgentsSkillsFromInventory(projectDir: string, io: InitDepositIo, inventory?: ReadonlyArray<{
62
+ dir: string;
63
+ content: string;
64
+ }>): boolean;
65
+ //# sourceMappingURL=skill-discovery-deposit.d.ts.map
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Multi-host thin skill discovery deposit (#75 residual).
3
+ *
4
+ * Mirrors the consumer skill inventory already written to `.agents/skills/`
5
+ * into additional host paths (`.claude/skills/`, `.codex/skills/`,
6
+ * `.github/skills/`, `.cursor/skills/`). Thin pointers only — no full skill
7
+ * body copies. Windows-safe file writes (no elevated symlink requirement).
8
+ *
9
+ * Distinct from epic #55 slash-command deposit (#3054).
10
+ */
11
+ import { existsSync, readFileSync } from "node:fs";
12
+ import { join, resolve } from "node:path";
13
+ import { containedWrite } from "../fs/contained-write.js";
14
+ import { assertDestinationNotSymlink } from "../fs/projection-containment.js";
15
+ import { hostSkillRelativePath, isHostSkillDiscoveryEnabled, listSkillDiscoveryHosts, loadHostSkillDiscoveryPolicyFromProject, loadHostSkillDiscoveryRawFromProject, resolveHostSkillDiscoveryPolicyDetailed, SKILL_DISCOVERY_HOSTS, validateHostSkillDiscovery, } from "./skill-discovery-hosts.js";
16
+ /**
17
+ * Consumer skill discovery inventory shared by `.agents/skills/` and multi-host
18
+ * deposit. Each entry is a thin SKILL.md pointer into `.deft/core/…` — never a
19
+ * full skill body. Keep this list the single SoT for install-time discovery.
20
+ */
21
+ export const CONSUMER_SKILL_DISCOVERY_INVENTORY = [
22
+ {
23
+ dir: "deft",
24
+ content: `---
25
+ name: deft
26
+ description: Apply deft framework standards for AI-assisted development. Use when starting projects, writing code, running tests, making commits, or when the user references deft, project standards, or coding guidelines.
27
+ ---
28
+
29
+ Read and follow: .deft/core/SKILL.md
30
+ `,
31
+ },
32
+ {
33
+ dir: "deft-directive-setup",
34
+ content: `---
35
+ name: deft-directive-setup
36
+ description: >-
37
+ Set up a new project with Deft framework standards. Use when the user wants
38
+ to bootstrap user preferences, configure a project, or generate a project
39
+ specification. Walks through setup conversationally — no separate CLI needed.
40
+ ---
41
+
42
+ Read and follow: .deft/core/skills/deft-directive-setup/SKILL.md
43
+ `,
44
+ },
45
+ {
46
+ dir: "deft-directive-build",
47
+ content: `---
48
+ name: deft-directive-build
49
+ description: >-
50
+ Build a project from scope vBRIEFs following Deft framework standards.
51
+ Use after deft-directive-setup has generated the project definition, or when
52
+ the user has scope vBRIEFs ready to implement. Handles scaffolding,
53
+ implementation, testing, and quality checks phase by phase.
54
+ ---
55
+
56
+ Read and follow: .deft/core/skills/deft-directive-build/SKILL.md
57
+ `,
58
+ },
59
+ {
60
+ dir: "deft-directive-review-cycle",
61
+ content: `---
62
+ name: deft-directive-review-cycle
63
+ description: >-
64
+ Greptile bot reviewer response workflow. Use when running a review cycle
65
+ on a PR — to audit process prerequisites, fetch bot findings, fix all
66
+ issues in a single batch commit, and exit cleanly when no P0/P1 issues
67
+ remain. Enables cloud agents to run autonomous PR review cycles.
68
+ ---
69
+
70
+ Read and follow: .deft/core/skills/deft-directive-review-cycle/SKILL.md
71
+ `,
72
+ },
73
+ {
74
+ dir: "deft-directive-refinement",
75
+ content: `---
76
+ name: deft-directive-refinement
77
+ description: >-
78
+ Structured refinement workflow. Compares open GitHub issues against
79
+ the roadmap, triages new issues one-at-a-time with human review, and updates
80
+ the roadmap with phase placement, analysis comments, and index entries.
81
+ ---
82
+
83
+ Read and follow: .deft/core/skills/deft-directive-refinement/SKILL.md
84
+ `,
85
+ },
86
+ {
87
+ dir: "deft-directive-swarm",
88
+ content: `---
89
+ name: deft-directive-swarm
90
+ description: >-
91
+ Parallel local agent orchestration. Use when running multiple agents
92
+ on roadmap items simultaneously — to select non-overlapping tasks, set up
93
+ isolated worktrees, launch agents with proven prompts, monitor progress,
94
+ handle stalled review cycles, and close out PRs cleanly.
95
+ ---
96
+
97
+ Read and follow: .deft/core/skills/deft-directive-swarm/SKILL.md
98
+ `,
99
+ },
100
+ {
101
+ dir: "deft-directive-interview",
102
+ content: `---
103
+ name: deft-directive-interview
104
+ description: >-
105
+ Deterministic structured Q&A interview skill. Use when a skill or workflow
106
+ needs to collect structured answers from the user — one question per turn,
107
+ numbered options, default acceptance, and a confirmation gate.
108
+ ---
109
+
110
+ Read and follow: .deft/core/skills/deft-directive-interview/SKILL.md
111
+ `,
112
+ },
113
+ {
114
+ dir: "deft-directive-pre-pr",
115
+ content: `---
116
+ name: deft-directive-pre-pr
117
+ description: >-
118
+ Iterative pre-PR quality loop (Read-Write-Lint-Diff-Loop). Use before
119
+ pushing a branch for PR creation — structured self-review that agents run
120
+ to catch issues before they reach the bot reviewer.
121
+ ---
122
+
123
+ Read and follow: .deft/core/skills/deft-directive-pre-pr/SKILL.md
124
+ `,
125
+ },
126
+ {
127
+ dir: "deft-directive-sync",
128
+ content: `---
129
+ name: deft-directive-sync
130
+ description: >-
131
+ Session-start framework sync skill. Use at the beginning of a session to
132
+ pull latest framework updates, validate project files, and confirm alignment
133
+ before starting work.
134
+ ---
135
+
136
+ Read and follow: .deft/core/skills/deft-directive-sync/SKILL.md
137
+ `,
138
+ },
139
+ ];
140
+ /** Max bytes for a thin pointer body — fat full-skill copies fail this guard. */
141
+ export const MAX_THIN_SKILL_POINTER_BYTES = 1200;
142
+ /**
143
+ * True when content is a thin discovery pointer (not an inlined skill body).
144
+ * Managed deposit must stay pointer-shaped so updates do not rot full copies.
145
+ */
146
+ export function isThinSkillPointer(content) {
147
+ if (content.length > MAX_THIN_SKILL_POINTER_BYTES)
148
+ return false;
149
+ if (!content.includes("Read and follow:"))
150
+ return false;
151
+ // Canonical consumer target lives under the deposited framework root.
152
+ if (!content.includes(".deft/core/"))
153
+ return false;
154
+ // Reject bodies that look like full skill process docs.
155
+ if (/\n##\s+Phase\b/i.test(content))
156
+ return false;
157
+ if (/\n##\s+Anti-?[Pp]atterns\b/i.test(content))
158
+ return false;
159
+ return true;
160
+ }
161
+ function projectionTarget(projectDir, ...relSegments) {
162
+ const target = join(projectDir, ...relSegments);
163
+ assertDestinationNotSymlink(projectDir, target);
164
+ return target;
165
+ }
166
+ function containedProjectWrite(projectDir, target, data) {
167
+ containedWrite({
168
+ root: resolve(projectDir),
169
+ target,
170
+ data,
171
+ mode: "replace",
172
+ });
173
+ }
174
+ /**
175
+ * Deposit thin skill discovery pointers into enabled multi-host paths.
176
+ * Idempotent: skips write when on-disk content already matches. Never creates
177
+ * symlinks (Windows-safe without elevation).
178
+ */
179
+ export function writeMultiHostSkillDiscovery(projectDir, io, options = {}) {
180
+ const rawPolicy = options.policy !== undefined
181
+ ? options.policy
182
+ : loadHostSkillDiscoveryRawFromProject(projectDir);
183
+ // Production validation surface (#75 SLizard P1): report malformed opt-outs
184
+ // before resolving the deposit enablement map.
185
+ for (const err of validateHostSkillDiscovery(rawPolicy)) {
186
+ io.printf(`WARNING: ${err}\n`);
187
+ }
188
+ const resolved = resolveHostSkillDiscoveryPolicyDetailed(rawPolicy);
189
+ for (const warning of resolved.warnings) {
190
+ io.printf(`WARNING: ${warning}\n`);
191
+ }
192
+ if (resolved.refuseAll) {
193
+ return {
194
+ changed: false,
195
+ changedPaths: [],
196
+ hostsTouched: [],
197
+ hostsSkipped: [...listSkillDiscoveryHosts()],
198
+ };
199
+ }
200
+ // Prefer the public project-root loader when reading disk so policy inspection
201
+ // and deposit share one production call path (not test-only exports).
202
+ const policy = options.policy !== undefined
203
+ ? resolved.policy
204
+ : loadHostSkillDiscoveryPolicyFromProject(projectDir);
205
+ const inventory = options.inventory ?? CONSUMER_SKILL_DISCOVERY_INVENTORY;
206
+ for (const skill of inventory) {
207
+ if (!isThinSkillPointer(skill.content)) {
208
+ throw new Error(`skill discovery inventory entry "${skill.dir}" is not a thin pointer; ` +
209
+ `refusing multi-host deposit (#75 non-inlining).`);
210
+ }
211
+ }
212
+ const changedPaths = [];
213
+ const hostsTouched = new Set();
214
+ const hostsSkipped = [];
215
+ for (const hostId of listSkillDiscoveryHosts()) {
216
+ if (!isHostSkillDiscoveryEnabled(hostId, policy)) {
217
+ hostsSkipped.push(hostId);
218
+ continue;
219
+ }
220
+ for (const skill of inventory) {
221
+ const rel = hostSkillRelativePath(hostId, skill.dir);
222
+ const segments = rel.split("/");
223
+ const abs = projectionTarget(projectDir, ...segments);
224
+ let existing = null;
225
+ if (existsSync(abs)) {
226
+ try {
227
+ existing = readFileSync(abs, "utf8");
228
+ }
229
+ catch {
230
+ existing = null;
231
+ }
232
+ }
233
+ if (existing === skill.content) {
234
+ continue;
235
+ }
236
+ // Never clobber consumer-authored host skills. Only create missing
237
+ // files or rewrite prior managed thin pointers (#75 Greptile P1).
238
+ if (existing !== null && !isThinSkillPointer(existing)) {
239
+ io.printf(`Skill discovery (#75): preserving consumer skill at ${rel} (not a managed thin pointer).\n`);
240
+ continue;
241
+ }
242
+ containedProjectWrite(projectDir, abs, skill.content);
243
+ changedPaths.push(rel.replace(/\\/g, "/"));
244
+ hostsTouched.add(hostId);
245
+ }
246
+ }
247
+ if (hostsSkipped.length > 0) {
248
+ io.printf(`Skill discovery multi-host opt-out (plan.policy.hostSkillDiscovery): skipped ${hostsSkipped.join(", ")}\n`);
249
+ }
250
+ if (changedPaths.length > 0) {
251
+ const hostList = [...hostsTouched].join(", ");
252
+ io.printf(`Multi-host skill discovery deposit (#75): wrote ${changedPaths.length} thin pointer(s) for host(s): ${hostList}\n`);
253
+ }
254
+ else if (hostsSkipped.length < SKILL_DISCOVERY_HOSTS.length) {
255
+ io.printf("Multi-host skill discovery deposit (#75): already current — skipping.\n");
256
+ }
257
+ return {
258
+ changed: changedPaths.length > 0,
259
+ changedPaths,
260
+ hostsTouched: [...hostsTouched],
261
+ hostsSkipped,
262
+ };
263
+ }
264
+ /**
265
+ * Shared inventory helper for `.agents/skills/` (canonical) deposit.
266
+ * Returns true when any pointer was created (matching writeAgentsSkills).
267
+ */
268
+ export function writeAgentsSkillsFromInventory(projectDir, io, inventory = CONSUMER_SKILL_DISCOVERY_INVENTORY) {
269
+ projectionTarget(projectDir, ".agents");
270
+ const allExist = inventory.every((skill) => existsSync(join(projectDir, ".agents", "skills", skill.dir, "SKILL.md")));
271
+ if (allExist) {
272
+ io.printf(".agents/skills/ already present — skipping.\n");
273
+ return false;
274
+ }
275
+ for (const skill of inventory) {
276
+ if (!isThinSkillPointer(skill.content)) {
277
+ throw new Error(`skill discovery inventory entry "${skill.dir}" is not a thin pointer (#75).`);
278
+ }
279
+ const path = projectionTarget(projectDir, ".agents", "skills", skill.dir, "SKILL.md");
280
+ if (existsSync(path))
281
+ continue;
282
+ containedProjectWrite(projectDir, path, skill.content);
283
+ }
284
+ io.printf(".agents/skills/ created — deft skills will be auto-discovered.\n");
285
+ return true;
286
+ }
287
+ //# sourceMappingURL=skill-discovery-deposit.js.map