You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/10/21 09:19:42 UTC

(maka) branch main updated: fix(runtime-host): name the authoritative Skill creation directory in prompts (#6157)

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/main by this push:
     new 16044b3567 fix(runtime-host): name the authoritative Skill creation directory in prompts (#6157)
16044b3567 is described below

commit 16044b356756b744d3ff939ad6d5deaf142c2f5e
Author: 小七 <gg...@gmail.com>
AuthorDate: Wed Oct 21 17:19:37 2026 +0800

    fix(runtime-host): name the authoritative Skill creation directory in prompts (#6157)
    
    fix(runtime-host): name the authoritative Skill creation directory in…
    
    … prompts
    
    The catalog repository already scans `<Host data root>/skills`, but its
    model-facing snapshot did not expose that directory, and the interactive
    prompt rendered no location guidance at all when the catalog was empty.
    A model asked to create a local Skill therefore had to guess a Maka data
    directory and could write to another installation's root while reporting
    success.
    
    Carry the Host-authoritative `<root>/skills` path into the canonical model
    snapshot as `workspaceSkillDirectory`, and render a creation-guidance
    fragment in both the main-session and child-agent prompt paths. The
    fragment is independent of catalog contents: it directs the model to write
    `<directory>/<skill-id>/SKILL.md`, read that exact file back before
    reporting success, and defer to an explicitly requested project, user, or
    managed-source scope. It is prompt guidance only; permissions, sandbox
    rules, discovery precedence, and installation governance are unchanged.
    
    Tests cover the snapshot path, the empty-catalog main prompt, and the
    child-agent prompt.
    
    Refs #5012
    Generated-by: GLM-5.3-Flash (ZCode)
    
    chore(ci): re-register the Skill catalog Windows gate after the new s…
    
    …napshot test
    
    The Windows recovery gate pins the five Skill catalog suites to an exact
    count so a skipped or silently dropped test cannot pass unnoticed; the new
    `workspaceSkillDirectory` snapshot test in #6157 makes that count 95.
    Local run of the same five files: tests 95 / pass 95 / skipped 0 / fail 0.
    
    Refs #5012
    Generated-by: GLM-5.3-Flash (ZCode)
    
    chore(ci): align the workflow-policy shadow check with the 95-test Sk…
    
    …ill gate
    
    `ci-workflow-policy.test.mjs` asserts the windows-recovery workflow still
    pins the Skill catalog suites to their exact count; it still expected 94
    after the gate itself moved to 95 in d7408282b, so the planner lane failed
    while the Windows lane went green. The shadow check now expects 95 too,
    matching the locally verified tests 95 / pass 95 / skipped 0.
    
    Refs #5012
    Generated-by: GLM-5.3-Flash (ZCode)
    
    fix(runtime-host): name skill scopes and join paths in creation guidance
    
    Address two Astro-Han review notes on the Skill creation fragment:
    - render the placeholder skill path with node:path join so Windows shows
      one consistent separator instead of `C:\...\skills/<skill-id>/SKILL.md`;
    - list the standard discovery locations from STANDARD_SKILL_LOCATIONS
      under the scope fallback line, so the model no longer has to guess
      where a project- or user-scoped Skill lives.
    
    Generated-by: GLM-5.3-Flash (ZCode)
---
 .github/workflows/windows-recovery.yml             |  4 +-
 .../src/__tests__/interactive-run-composer.test.ts | 56 ++++++++++++++++++++++
 .../src/__tests__/skill-catalog-repository.test.ts | 19 +++++++-
 .../src/server/interactive-run-composer.ts         | 42 ++++++++++++++++
 .../src/server/skill-catalog-repository.ts         | 17 ++++++-
 scripts/ci-workflow-policy.test.mjs                |  4 +-
 6 files changed, 136 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/windows-recovery.yml b/.github/workflows/windows-recovery.yml
index 2b8e1973c6..f5ef8c2c27 100644
--- a/.github/workflows/windows-recovery.yml
+++ b/.github/workflows/windows-recovery.yml
@@ -269,8 +269,8 @@ jobs:
           $exitCode = $LASTEXITCODE
           if ($exitCode -ne 0) { exit $exitCode }
           $output = Get-Content "$env:RUNNER_TEMP/skill-catalog.tap"
-          if ($output -notcontains '# tests 94' -or $output -notcontains '# pass 94' -or $output -notcontains '# skipped 0') {
-            Write-Error 'Skill catalog gate did not run exactly 94 passing Windows tests'
+          if ($output -notcontains '# tests 95' -or $output -notcontains '# pass 95' -or $output -notcontains '# skipped 0') {
+            Write-Error 'Skill catalog gate did not run exactly 95 passing Windows tests'
             exit 1
           }
 
diff --git a/packages/runtime-host/src/__tests__/interactive-run-composer.test.ts b/packages/runtime-host/src/__tests__/interactive-run-composer.test.ts
index 195d4055ea..0fab9fb47f 100644
--- a/packages/runtime-host/src/__tests__/interactive-run-composer.test.ts
+++ b/packages/runtime-host/src/__tests__/interactive-run-composer.test.ts
@@ -269,6 +269,62 @@ test('scoped Plugin Skill contributions join the canonical model inventory', asy
   assert.match(prompt.text ?? '', /Scoped skill for session-skill/u);
 });
 
+test('main-session prompts name the Host Skill directory even with an empty catalog', async () => {
+  const workspaceSkillDirectory = '/maka-dev/workspaces/default/skills';
+  const composer = createFixtureComposer({
+    skills: {
+      readCanonicalModelInventory: async ({ projectRoot }: { projectRoot: string }) => ({
+        revision: 'base-revision',
+        projectRoot,
+        workspaceSkillDirectory,
+        inventory: [],
+        diagnostics: [],
+        discoveryDiagnostics: [],
+      }),
+    } as unknown as HostSkillCatalogCoordinator,
+  });
+
+  const prompt = await composer.resolveSystemPrompt({
+    sessionId: 'skill-creation-session',
+    turnId: 'skill-creation-turn',
+    cwd: '/maka-dev/workspaces/default',
+  });
+  assert.match(prompt.text ?? '', new RegExp(workspaceSkillDirectory, 'u'));
+  assert.match(prompt.text ?? '', /<skill-id>[\\/]SKILL\.md/u);
+  assert.match(prompt.text ?? '', /read .*SKILL\.md back/iu);
+  assert.match(prompt.text ?? '', /project-level, user-level, or managed-source/iu);
+  assert.match(prompt.text ?? '', /<project>[\\/]\.maka[\\/]skills/u);
+  assert.match(prompt.text ?? '', /<project>[\\/]\.agents[\\/]skills/u);
+  assert.match(prompt.text ?? '', /~[\\/]\.maka[\\/]skills/u);
+  assert.match(prompt.text ?? '', /~[\\/]\.agents[\\/]skills/u);
+});
+
+test('child-agent prompts carry the Skill creation guidance', async () => {
+  const workspaceSkillDirectory = '/maka-dev/workspaces/default/skills';
+  const composer = createFixtureComposer({
+    childInstruction: 'CHILD_ROLE_INSTRUCTION',
+    skills: {
+      readCanonicalModelInventory: async ({ projectRoot }: { projectRoot: string }) => ({
+        revision: 'base-revision',
+        projectRoot,
+        workspaceSkillDirectory,
+        inventory: [],
+        diagnostics: [],
+        discoveryDiagnostics: [],
+      }),
+    } as unknown as HostSkillCatalogCoordinator,
+  });
+
+  const prompt = await composer.resolveSystemPrompt({
+    sessionId: 'child-session',
+    turnId: 'child-turn',
+    cwd: '/maka-dev/workspaces/default',
+  });
+  assert.match(prompt.text ?? '', /CHILD_ROLE_INSTRUCTION/u);
+  assert.match(prompt.text ?? '', new RegExp(workspaceSkillDirectory, 'u'));
+  assert.match(prompt.text ?? '', /<skill-id>[\\/]SKILL\.md/u);
+});
+
 function tool(name: string): MakaTool {
   return {
     name,
diff --git a/packages/runtime-host/src/__tests__/skill-catalog-repository.test.ts b/packages/runtime-host/src/__tests__/skill-catalog-repository.test.ts
index b3ceba861e..5a66aaf5b9 100644
--- a/packages/runtime-host/src/__tests__/skill-catalog-repository.test.ts
+++ b/packages/runtime-host/src/__tests__/skill-catalog-repository.test.ts
@@ -28,7 +28,16 @@ import { RuntimeHostProtocolError } from '../protocol/errors.js';
 import assert from 'node:assert/strict';
 import { execFile } from 'node:child_process';
 import { createHash } from 'node:crypto';
-import { chmod, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs/promises';
+import {
+  chmod,
+  mkdir,
+  mkdtemp,
+  readFile,
+  realpath,
+  rm,
+  symlink,
+  writeFile,
+} from 'node:fs/promises';
 import { tmpdir } from 'node:os';
 import { join } from 'node:path';
 import { afterEach, test } from 'node:test';
@@ -495,6 +504,14 @@ test('one unreadable managed source child makes the Host catalog fail closed', a
   }
 });
 
+test('canonical model snapshot exposes the Host-authoritative workspace Skill directory', async () => {
+  const fixture = await createFixture();
+  const repository = fixture.repository();
+  const model = await repository.readCanonicalModelInventory({ projectRoot: fixture.project });
+  assert.equal(model.workspaceSkillDirectory, join(await realpath(fixture.root), 'skills'));
+  assert.equal(Object.isFrozen(model), true);
+});
+
 test('starter creation uses the shared template and reuses the lowest valid starter', async () => {
   const fixture = await createFixture();
   const repository = fixture.repository();
diff --git a/packages/runtime-host/src/server/interactive-run-composer.ts b/packages/runtime-host/src/server/interactive-run-composer.ts
index 17e3b43e83..ed4a0760a5 100644
--- a/packages/runtime-host/src/server/interactive-run-composer.ts
+++ b/packages/runtime-host/src/server/interactive-run-composer.ts
@@ -17,7 +17,9 @@
  * under the License.
  */
 
+import { join } from 'node:path';
 import { isDeepStrictEqual } from 'node:util';
+import { STANDARD_SKILL_LOCATIONS } from '@maka/core/skill-locations';
 import {
   buildSideConversationSystemPromptFragment,
   isSideConversationSession,
@@ -99,6 +101,41 @@ const CHILD_INSTRUCTION_BOUNDARY = [
   'The child does not implicitly inherit local Memory or personalization context; required background must be included explicitly in the task.',
 ].join(' ');
 
+/**
+ * Scope labels for rendering {@link STANDARD_SKILL_LOCATIONS} as model-facing
+ * paths; `<project>`/`<workspace>` stay placeholders, user scope maps to `~`.
+ */
+const SKILL_SCOPE_BASE_LABEL = {
+  project: '<project>',
+  workspace: '<workspace>',
+  user: '~',
+} as const;
+
+const STANDARD_SKILL_LOCATION_HINT = STANDARD_SKILL_LOCATIONS.map((location) => {
+  const base = SKILL_SCOPE_BASE_LABEL[location.scope];
+  return `- ${location.scope}: \`${join(base, ...location.segments)}\``;
+}).join('\n');
+
+/**
+ * Host-authoritative creation guidance. The catalog may be empty (or every
+ * entry may be filtered out), so this fragment must not depend on catalog
+ * contents; otherwise the model has to guess a data directory.
+ */
+function buildSkillCreationPromptFragment(
+  workspaceSkillDirectory: string | undefined,
+): string | undefined {
+  if (!workspaceSkillDirectory) return undefined;
+  const placeholderSkillPath = join(workspaceSkillDirectory, '<skill-id>', 'SKILL.md');
+  return [
+    '## Local Skill creation',
+    `The Host installs a default workspace Skill at \`${placeholderSkillPath}\`.`,
+    `- Write the new Skill directly to \`${placeholderSkillPath}\`; do not guess another Maka data directory.`,
+    '- Read that exact SKILL.md back and verify its content before reporting success.',
+    '- If the user explicitly asks for a project-level, user-level, or managed-source Skill, follow that scope and its authoritative path instead:',
+    STANDARD_SKILL_LOCATION_HINT,
+  ].join('\n');
+}
+
 export interface InteractiveRunComposerInput {
   readonly runtimePolicy: RuntimePolicySnapshot;
   readonly skills: HostSkillCatalogCoordinator;
@@ -279,9 +316,13 @@ export function createInteractiveRunComposer(input: InteractiveRunComposerInput)
         const workspaceInstructions = promptState.policy.workspaceInstructions.enabled
           ? await buildWorkspaceInstructionsPromptFragment(context.cwd)
           : undefined;
+        // Guidance is independent of catalog contents so an empty catalog still
+        // names the authoritative directory instead of leaving it to be guessed.
+        const skillCreation = buildSkillCreationPromptFragment(inventory.workspaceSkillDirectory);
         const text = childInstruction
           ? joinFragments([
               skills.text,
+              skillCreation,
               workspaceInstructions,
               CHILD_INSTRUCTION_BOUNDARY,
               childInstruction,
@@ -289,6 +330,7 @@ export function createInteractiveRunComposer(input: InteractiveRunComposerInput)
           : assembleMainSessionSystemPrompt([
               buildPersonalizationPromptFragment(promptState.policy.personalization).text,
               skills.text,
+              skillCreation,
               workspaceInstructions,
               promptState.memory,
               input.plan?.mode === 'plan'
diff --git a/packages/runtime-host/src/server/skill-catalog-repository.ts b/packages/runtime-host/src/server/skill-catalog-repository.ts
index ea2bdaab7c..c163a3f381 100644
--- a/packages/runtime-host/src/server/skill-catalog-repository.ts
+++ b/packages/runtime-host/src/server/skill-catalog-repository.ts
@@ -159,6 +159,11 @@ export class SkillCatalogRepositoryError extends Error {
 export interface CanonicalSkillInventorySnapshot {
   readonly revision: SkillCatalogRevision;
   readonly projectRoot: string;
+  /**
+   * Host-authoritative directory for a default workspace Skill. Models create
+   * Skills here; it is the same `<root>/skills` directory the catalog scans.
+   */
+  readonly workspaceSkillDirectory: string;
   readonly inventory: readonly ScannedSkill[];
   readonly diagnostics: readonly SkillScanDiagnostic[];
   readonly discoveryDiagnostics: readonly SkillDiscoveryDiagnostic[];
@@ -463,6 +468,7 @@ export class SkillCatalogRepository {
         const publicationNamespace = await readPublicationNamespace(root);
         return buildSnapshot({
           projectRoot,
+          workspaceSkillDirectory: join(root, 'skills'),
           scan,
           managedSourcesRoot: this.#managedSourcesRoot,
           publicationNamespace,
@@ -743,6 +749,7 @@ export class SkillCatalogRepository {
 
 async function buildSnapshot(input: {
   projectRoot: string;
+  workspaceSkillDirectory: string;
   scan: SkillScanResult;
   managedSourcesRoot: string;
   publicationNamespace: PublicationNamespace;
@@ -909,7 +916,13 @@ async function buildSnapshot(input: {
       effectiveMigration,
     }),
   );
-  const model = freezeModelSnapshot(revision, input.projectRoot, input.scan, effectiveMigration);
+  const model = freezeModelSnapshot(
+    revision,
+    input.projectRoot,
+    input.workspaceSkillDirectory,
+    input.scan,
+    effectiveMigration,
+  );
   return Object.freeze({
     revision,
     projectRoot: input.projectRoot,
@@ -1343,6 +1356,7 @@ function canonicalRevisionFacts(input: {
 function freezeModelSnapshot(
   revision: SkillCatalogRevision,
   projectRoot: string,
+  workspaceSkillDirectory: string,
   scan: SkillScanResult,
   migration: SkillPreferenceMigration | null,
 ): CanonicalSkillInventorySnapshot {
@@ -1374,6 +1388,7 @@ function freezeModelSnapshot(
   return Object.freeze({
     revision,
     projectRoot,
+    workspaceSkillDirectory,
     inventory: Object.freeze(inventory),
     diagnostics: Object.freeze(diagnostics),
     discoveryDiagnostics: Object.freeze(discoveryDiagnostics),
diff --git a/scripts/ci-workflow-policy.test.mjs b/scripts/ci-workflow-policy.test.mjs
index 293ecad845..ad54fa1bda 100644
--- a/scripts/ci-workflow-policy.test.mjs
+++ b/scripts/ci-workflow-policy.test.mjs
@@ -943,8 +943,8 @@ test('Windows recovery executes the complete Skill catalog suite', () => {
   assert.match(recovery, /skill-catalog-repository\.test\.js/u);
   assert.match(recovery, /skill-catalog-transaction\.test\.js/u);
   assert.match(recovery, /skill-catalog-two-client-uds\.test\.js/u);
-  assert.match(recovery, /# tests 94/u);
-  assert.match(recovery, /# pass 94/u);
+  assert.match(recovery, /# tests 95/u);
+  assert.match(recovery, /# pass 95/u);
   assert.match(recovery, /# skipped 0/u);
 });
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org