@debian777/kairos-mcp 3.3.3 → 3.4.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 (94) hide show
  1. package/README.md +179 -105
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli/commands/mint.d.ts.map +1 -1
  4. package/dist/cli/commands/mint.js +9 -1
  5. package/dist/cli/commands/mint.js.map +1 -1
  6. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002001.md +124 -162
  7. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002002.md +36 -34
  8. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002003.md +195 -0
  9. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002004.md +240 -0
  10. package/dist/embed-docs/mem/README.md +24 -0
  11. package/dist/resources/docs-resources.d.ts.map +1 -1
  12. package/dist/resources/docs-resources.js +9 -1
  13. package/dist/resources/docs-resources.js.map +1 -1
  14. package/dist/resources/embedded-mcp-resources.d.ts +14 -0
  15. package/dist/resources/embedded-mcp-resources.d.ts.map +1 -1
  16. package/dist/resources/embedded-mcp-resources.js +33 -9
  17. package/dist/resources/embedded-mcp-resources.js.map +1 -1
  18. package/dist/resources/mem-resources-boot.d.ts.map +1 -1
  19. package/dist/resources/mem-resources-boot.js +11 -3
  20. package/dist/resources/mem-resources-boot.js.map +1 -1
  21. package/dist/services/chain-step-count.d.ts +23 -0
  22. package/dist/services/chain-step-count.d.ts.map +1 -0
  23. package/dist/services/chain-step-count.js +23 -0
  24. package/dist/services/chain-step-count.js.map +1 -0
  25. package/dist/services/chain-utils.d.ts.map +1 -1
  26. package/dist/services/chain-utils.js +14 -9
  27. package/dist/services/chain-utils.js.map +1 -1
  28. package/dist/services/memory/store-methods.d.ts.map +1 -1
  29. package/dist/services/memory/store-methods.js +20 -12
  30. package/dist/services/memory/store-methods.js.map +1 -1
  31. package/dist/services/qdrant/memory-retrieval.d.ts +6 -1
  32. package/dist/services/qdrant/memory-retrieval.d.ts.map +1 -1
  33. package/dist/services/qdrant/memory-retrieval.js +21 -3
  34. package/dist/services/qdrant/memory-retrieval.js.map +1 -1
  35. package/dist/services/qdrant/service.d.ts +1 -1
  36. package/dist/services/qdrant/service.d.ts.map +1 -1
  37. package/dist/services/qdrant/service.js +2 -2
  38. package/dist/services/qdrant/service.js.map +1 -1
  39. package/dist/tools/kairos-challenge-display.d.ts.map +1 -1
  40. package/dist/tools/kairos-challenge-display.js +32 -2
  41. package/dist/tools/kairos-challenge-display.js.map +1 -1
  42. package/dist/tools/kairos_begin.d.ts +5 -0
  43. package/dist/tools/kairos_begin.d.ts.map +1 -1
  44. package/dist/tools/kairos_begin.js +8 -8
  45. package/dist/tools/kairos_begin.js.map +1 -1
  46. package/dist/tools/kairos_begin_schema.d.ts +5 -0
  47. package/dist/tools/kairos_begin_schema.d.ts.map +1 -1
  48. package/dist/tools/kairos_begin_schema.js +6 -1
  49. package/dist/tools/kairos_begin_schema.js.map +1 -1
  50. package/dist/tools/kairos_dump.js +1 -1
  51. package/dist/tools/kairos_dump.js.map +1 -1
  52. package/dist/tools/kairos_next-previous-step.d.ts.map +1 -1
  53. package/dist/tools/kairos_next-previous-step.js +11 -3
  54. package/dist/tools/kairos_next-previous-step.js.map +1 -1
  55. package/dist/tools/kairos_next_schema.d.ts +5 -0
  56. package/dist/tools/kairos_next_schema.d.ts.map +1 -1
  57. package/dist/tools/kairos_next_schema.js +7 -1
  58. package/dist/tools/kairos_next_schema.js.map +1 -1
  59. package/dist/tools/shell-challenge-invocation.d.ts +32 -0
  60. package/dist/tools/shell-challenge-invocation.d.ts.map +1 -0
  61. package/dist/tools/shell-challenge-invocation.js +113 -0
  62. package/dist/tools/shell-challenge-invocation.js.map +1 -0
  63. package/dist/types/memory.d.ts +10 -0
  64. package/dist/types/memory.d.ts.map +1 -1
  65. package/dist/ui/assets/{AccountPage-kxmPtqQP.js → AccountPage-BL4GHk9f.js} +1 -1
  66. package/dist/ui/assets/{ErrorAlert-ME7tEJ6X.js → ErrorAlert-KEgeKl22.js} +1 -1
  67. package/dist/ui/assets/{HomePage-DxiAsvs-.js → HomePage-DWAvtfBC.js} +1 -1
  68. package/dist/ui/assets/KairosPage-DZpZ35yd.js +1 -0
  69. package/dist/ui/assets/NotFoundPage-BrPNDuhe.js +1 -0
  70. package/dist/ui/assets/{ProtocolDetailPage-DKaSVepL.js → ProtocolDetailPage-R0XlRsIa.js} +1 -1
  71. package/dist/ui/assets/ProtocolEditPage-CzAnruE6.js +5 -0
  72. package/dist/ui/assets/{RenderedMarkdown-DjbuQlBl.js → RenderedMarkdown-CMavJdAJ.js} +1 -1
  73. package/dist/ui/assets/RunGuidedPage-Cm68aCC7.js +1 -0
  74. package/dist/ui/assets/{RunsPage-ctnsEF2U.js → RunsPage-DcDoMCq1.js} +1 -1
  75. package/dist/ui/assets/{SkillBundlePage-CaWW5oGq.js → SkillBundlePage-LuYOnVDQ.js} +1 -1
  76. package/dist/ui/assets/index-0G3wloMr.css +2 -0
  77. package/dist/ui/assets/index-S4_XWO39.js +8 -0
  78. package/dist/ui/assets/{tiptap-kMFBDujG.js → tiptap-CzV8H9Mb.js} +22 -22
  79. package/dist/ui/assets/useProtocol-C3ClZHlN.js +4 -0
  80. package/dist/ui/assets/{useSpaces-BV6eUjY3.js → useSpaces-DQEfGh8E.js} +1 -1
  81. package/dist/ui/assets/{vendor-GiUVcjs7.js → vendor-CVpIjmrD.js} +1 -1
  82. package/dist/ui/index.html +4 -4
  83. package/dist/utils/space-filter.d.ts +8 -0
  84. package/dist/utils/space-filter.d.ts.map +1 -1
  85. package/dist/utils/space-filter.js +18 -0
  86. package/dist/utils/space-filter.js.map +1 -1
  87. package/package.json +2 -1
  88. package/dist/ui/assets/KairosPage-BkqYs3-_.js +0 -1
  89. package/dist/ui/assets/NotFoundPage-DyfbQ-6G.js +0 -1
  90. package/dist/ui/assets/ProtocolEditPage-D-aTavvx.js +0 -1
  91. package/dist/ui/assets/RunGuidedPage-BUD0MaGh.js +0 -1
  92. package/dist/ui/assets/index-Duu55PkQ.css +0 -2
  93. package/dist/ui/assets/index-bQSxsGMU.js +0 -8
  94. package/dist/ui/assets/useProtocol-BruWpIzq.js +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"mint.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mint.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyDpC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmHlD"}
1
+ {"version":3,"file":"mint.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mint.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgEpC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmHlD"}
@@ -2,13 +2,17 @@
2
2
  * kairos mint command
3
3
  */
4
4
  import { closeSync, fstatSync, openSync, readFileSync, readdirSync } from 'fs';
5
- import { join, relative, resolve } from 'path';
5
+ import { basename, join, relative, resolve } from 'path';
6
6
  import { ApiClient } from '../api-client.js';
7
7
  import { handleApiError } from '../auth-error.js';
8
8
  import { writeError, writeJson } from '../output.js';
9
9
  function isMdFileName(name) {
10
10
  return name.endsWith('.md');
11
11
  }
12
+ /** Directory batches skip README.md (human docs in bundles); single-file mint is unchanged. */
13
+ function isBatchSkippedMd(relOrName) {
14
+ return basename(relOrName.replace(/\\/g, '/')) === 'README.md';
15
+ }
12
16
  /**
13
17
  * Open path read-only, require regular file, read UTF-8 from the same fd
14
18
  * (avoids path-based stat-then-read races; CodeQL js/file-system-race).
@@ -33,6 +37,8 @@ function collectMdFiles(absRoot, recursive) {
33
37
  for (const d of dirents) {
34
38
  if (!isMdFileName(d.name))
35
39
  continue;
40
+ if (isBatchSkippedMd(d.name))
41
+ continue;
36
42
  paths.push(join(absRoot, d.name));
37
43
  }
38
44
  return paths.sort((a, b) => a.localeCompare(b));
@@ -42,6 +48,8 @@ function collectMdFiles(absRoot, recursive) {
42
48
  for (const rel of relEntries) {
43
49
  if (!rel || !isMdFileName(rel))
44
50
  continue;
51
+ if (isBatchSkippedMd(rel))
52
+ continue;
45
53
  paths.push(join(absRoot, rel));
46
54
  }
47
55
  return paths.sort((a, b) => a.localeCompare(b));
@@ -1 +1 @@
1
- {"version":3,"file":"mint.js","sourceRoot":"","sources":["../../../src/cli/commands/mint.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,SAAS,YAAY,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,OAAe;IACxC,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1B,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,YAAY,CAAC,EAAE,EAAE,OAAO,CAAW,CAAC;IAC/C,CAAC;YAAS,CAAC;QACP,SAAS,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;AACL,CAAC;AAED,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AC;wBACX,MAAM;oBACV,CAAC;gBACL,CAAC;YACL,CAAC;YAED,SAAS,CAAC;gBACN,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,OAAO;gBACb,OAAO;aACV,CAAC,CAAC;YAEH,IAAI,SAAS,EAAE,CAAC;gBACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7D,UAAU,CAAC,mBAAmB,SAAS,EAAE,CAAC,CAAC;gBAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;YACD,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACvC,CAAC;IACL,CAAC,CACJ,CAAC;AACV,CAAC"}
@@ -1,13 +1,13 @@
1
1
  ---
2
- version: "3.3.3"
2
+ version: "3.4.0"
3
3
  slug: create-new-protocol
4
4
  title: Create New KAIROS Protocol Chain
5
5
  ---
6
6
 
7
7
  # Create New KAIROS Protocol Chain
8
8
 
9
- Guide an AI agent through creating a new executable protocol chain in KAIROS.
10
- This protocol is offered when kairos_search finds no match.
9
+ Guide an AI agent through authoring a new executable protocol chain in KAIROS.
10
+ This protocol is offered when kairos_search finds no match. Review and publishing continue in Chain 2 (`create-new-protocol-review`).
11
11
 
12
12
  ## Natural Language Triggers
13
13
 
@@ -27,7 +27,8 @@ This protocol is offered when kairos_search finds no match.
27
27
  - Confirm with the user that they want to create a new protocol when search found no match.
28
28
  - Include Natural Language Triggers as the first H2 and Completion Rule as the last H2.
29
29
  - Apply DRY: no duplicated H2s, no boilerplate sections — fold shared content into steps or extract to a reference.
30
- - Enforce 350-line max per file. If content exceeds this, split into linked chains (via `mcp` challenge with `kairos_search`) or extract a type extension / reference.
30
+ - Enforce 350-line max per file. If content exceeds this, split into linked chains or extract a type extension / reference.
31
+ - Load `challenge-type-guide` policy via `kairos_begin(key: "challenge-type-guide")` when choosing challenge types for steps. `comment` is the last resort — use `shell` or `mcp` whenever the step produces an observable artifact.
31
32
 
32
33
  **Good trigger examples:**
33
34
  - "Create a new KAIROS protocol for code review" → run this protocol
@@ -37,227 +38,188 @@ This protocol is offered when kairos_search finds no match.
37
38
  - "Run the standardize project protocol" → use search/begin, not this
38
39
  - "Search for deployment protocol" → use kairos_search, not this
39
40
 
40
- ## Confirm Intent
41
-
42
- Ask: "No existing protocol matched your query. Create a new one, or refine your search?"
41
+ ---
43
42
 
44
- ```json
45
- {
46
- "challenge": {
47
- "type": "user_input",
48
- "user_input": { "prompt": "Confirm you want to create a new protocol chain" },
49
- "required": true
50
- }
51
- }
52
- ```
43
+ ## Prerequisites
53
44
 
54
- ## Gather Requirements
45
+ This protocol requires context from the triggering search:
55
46
 
56
- Collect the key details for the new protocol.
47
+ - `{search_query}` — the original user query that yielded no match
48
+ - `{search_results}` — kairos_search results (empty or weak matches)
49
+ - `{trigger_source}` — `user-explicit` (user asked to create) or `agent-offered` (search returned no match)
57
50
 
58
- **1. Determine the pattern:**
51
+ **Work directory:** `$KAIROS_WORK_DIR` is provided by the engine (created at `kairos_begin`, cleaned at `kairos_attest`). All draft files go here.
59
52
 
60
- | Signal | Pattern |
61
- |---|---|
62
- | One workflow, no variants | **Standalone** — one protocol, all steps inline |
63
- | Multiple issue types / output formats / media | **Router + Extensions** — router classifies, routes via `kairos_search` |
64
- | Domain has a decision tree (which type? which format?) | **Router + Extensions** |
65
- | Reference material needed by steps | Extract to a separate file, not a protocol |
53
+ **Security:** Do NOT write credentials, tokens, or secrets into draft files. Use placeholder references (`${SECRET_NAME}`) for sensitive values.
66
54
 
67
- Real examples: Compose (writing router → 5 extensions), BNX/BIB (Jira routers → type-specific creation protocols).
55
+ ---
68
56
 
69
- **2. Collect per protocol:**
57
+ ## Confirm Intent [SUBAGENT]
70
58
 
71
- - **Title**: clear, descriptive (becomes H1)
72
- - **Steps**: what the protocol does (each becomes H2 with a challenge)
73
- - **Challenge type per step**: comment (agent output), user_input (human gate), mcp (tool call), shell (command)
74
- - **Domain reference**: guides/docs the protocol should load?
75
- - **Existing protocols**: `kairos_search` for related — reuse, compose, or extract shared content?
76
- - **DRY check**: what content would be duplicated across extensions? Extract to a shared reference or the router body.
77
- - **Size check**: will any single file exceed 350 lines? If yes, split into chains or extract a reference now — do not plan to "trim later".
59
+ Gate applies only when the **agent** decides to offer protocol creation (kairos_search returned no strong match). Skip when the **user** explicitly requested creation (trigger phrase matched).
78
60
 
79
- **3. If Router pattern:**
61
+ **Input:** `{search_query}`, `{search_results}`, `{trigger_source}`.
80
62
 
81
- - What are the variants? (each becomes an extension protocol)
82
- - What decision questions classify the variant?
83
- - What types are forbidden?
63
+ **Actions:**
64
+ 1. **If `{trigger_source}` = user-explicit:** Set `{intent}` = confirmed. Skip to next step.
65
+ 2. **If `{trigger_source}` = agent-offered:**
66
+ - Present the search results (or lack thereof) to the user.
67
+ - Ask: "No existing protocol matched your query. Create a new one, or refine your search?"
68
+ - Wait for explicit confirmation before proceeding.
84
69
 
85
- Summarize all gathered requirements.
70
+ **Output:** `{intent}` = confirmed | refined-search | cancelled, plus any user clarifications on scope.
86
71
 
87
72
  ```json
88
- {
89
- "challenge": {
90
- "type": "comment",
91
- "comment": { "min_length": 50 },
92
- "required": true
93
- }
94
- }
73
+ {"challenge":{"type":"user_input","user_input":{"prompt":"Confirm you want to create a new protocol chain (auto-confirmed when user explicitly requested creation)"},"required":true}}
95
74
  ```
96
75
 
97
- ## Draft Markdown
76
+ ## Gather Requirements [SUBAGENT]
98
77
 
99
- Using the requirements, draft the full markdown for `kairos_mint`.
78
+ Collect all inputs needed to draft the protocol. Write the requirements summary to `$KAIROS_WORK_DIR/requirements.md`.
100
79
 
101
- **DRY Don't Repeat Yourself:**
80
+ **Input:** `{search_query}`, `{intent}` = confirmed, `$KAIROS_WORK_DIR`, any user clarifications on scope.
102
81
 
103
- Every piece of knowledge must live in exactly one place in the protocol family. Before writing any content, ask: "Does this already exist in another protocol, a shared reference, or CLAUDE.md?"
82
+ **Actions:**
104
83
 
105
- - Boilerplate (auth handling, assignment workflow, error tables, validation checklists) belongs **inside the step that needs it** — one sentence, not a section. If it's identical across a protocol family, extract it to a shared reference file and load it via `kairos_begin(key:...)`.
106
- - If two protocols share >50% of their body, extract the shared logic into a base protocol or reference.
107
- - Every H2 must earn its place: if it has no challenge, it's not a step — fold its content into a step that does.
108
- - Never duplicate an H2 heading within a file. KAIROS treats each H2 as a step — duplicates create phantom steps.
84
+ 1. **Determine the pattern:**
109
85
 
110
- **350-line maximum per file:**
111
-
112
- No protocol file may exceed 350 lines. Both humans and AI lose coherence on longer documents.
113
-
114
- - If a protocol grows beyond 350 lines, **split it** — use an `mcp` challenge with `kairos_begin(key:...)` to link the continuation chain, or extract domain-specific content into a reference/checklist file.
115
- - Router protocols are naturally short (~50–80 lines). Extension protocols should target 100–200 lines.
116
- - Type extensions and reference files (not full protocols) should stay under 150 lines.
117
- - Measure after drafting: `wc -l <file>`. If over 350, refactor before minting.
86
+ | Signal | Pattern |
87
+ |---|---|
88
+ | One workflow, no variants | **Standalone** one protocol, all steps inline |
89
+ | Multiple issue types / output formats / media | **Router + Extensions** — router classifies, routes via `kairos_search` |
90
+ | Domain has a decision tree (which type? which format?) | **Router + Extensions** |
91
+ | Reference material needed by steps | Extract to a separate file, not a protocol |
118
92
 
119
- **Generic-first create generic, link from detailed:**
93
+ Real examples: Compose (writing router → 5 extensions), BNX/BIB (Jira routers → type-specific creation protocols).
120
94
 
121
- Create protocols from generic to detailed. The generic chain comes first and must stand alone — it works even with zero extensions. Specializations (type checklists, domain extensions) are created second and link *back* to the generic via `kairos_begin(key:...)`.
95
+ 2. **Collect per protocol:**
96
+ - **Title**: clear, descriptive (becomes H1)
97
+ - **Steps**: what the protocol does (each becomes H2 with a challenge)
98
+ - **Challenge type per step**: pick using the decision tree from `kairos_begin(key: "challenge-type-guide")` — `shell` or `mcp` first, `comment` only for pure reasoning
99
+ - **Domain reference**: guides/docs the protocol should load?
100
+ - **Existing protocols**: `kairos_search` for related — reuse, compose, or extract shared content?
101
+ - **DRY check**: what content would be duplicated across extensions? Extract to a shared reference or the router body.
102
+ - **Size check**: will any single file exceed 350 lines? If yes, split into chains or extract a reference now — do not plan to "trim later".
122
103
 
123
- - The generic protocol defines the workflow scaffold. The extension defines only what's different.
124
- - Teaching is showing the difference: an extension that only contains the delta is easier to read, write, and maintain than a full copy with scattered overrides.
125
- - Expansion is cheap adding a new type means one new extension file. The generic chains don't change. Zero regression risk on existing paths.
104
+ 3. **If Router pattern:**
105
+ - What are the variants? (each becomes an extension protocol)
106
+ - What decision questions classify the variant?
107
+ - What types are forbidden?
126
108
 
127
- **Slug convention deterministic protocol linking:**
109
+ 4. **Write requirements to file:** Summarize all gathered requirements as structured markdown and write to `$KAIROS_WORK_DIR/requirements.md`.
128
110
 
129
- Every protocol gets a `slug` a short, unique, lowercase-hyphenated key for deterministic linking via `kairos_begin(key: "slug")`. The engine auto-generates it from the H1 title. Add explicit `slug:` frontmatter only when the auto-generated value is too long or ambiguous.
111
+ **Output:** `$KAIROS_WORK_DIR/requirements.md` containing: pattern (standalone/router), title(s), step list with challenge types, slug(s), domain references, DRY assessment, size estimate.
130
112
 
131
- ```yaml
132
- ---
133
- slug: jira-markdown-formatting
134
- ---
135
- # Jira Description Markdown Formatting via MCP
113
+ ```json
114
+ {"challenge":{"type":"shell","shell":{"cmd":"test -f \"$KAIROS_WORK_DIR/requirements.md\" && wc -l < \"$KAIROS_WORK_DIR/requirements.md\" | awk '$1 >= 5'","timeout_seconds":5},"required":true}}
136
115
  ```
137
116
 
138
- **When to use slugs vs. search:**
117
+ ## Author Protocol Structure [SUBAGENT]
139
118
 
140
- - `kairos_begin(key: "slug")`protocol-to-protocol routing (deterministic, exact match). Use when the author knows the target at write time.
141
- - `kairos_search` — user discovery (Natural Language Triggers) and runtime type-dispatch where the target depends on a runtime variable (e.g., `kairos_search("Standardize {project_type}")`).
119
+ Write the protocol markdown content, flow, step definitions, NLT, Completion Rule — but leave challenge blocks empty. This step is pure protocol design, not verification engineering.
142
120
 
143
- **Slug naming rules:**
121
+ **Input:** `$KAIROS_WORK_DIR/requirements.md`.
144
122
 
145
- 1. **Families (router + extensions):** hierarchical. The router slug is the family prefix. Each child expands the parent by one hyphenated segment per routing level:
146
- - `jira` → `jira-bib` → `jira-bib-bug`
147
- - `compose` → `compose-email`
148
- - `standardize` → `standardize-analyze`
149
- - An agent can derive the parent slug by stripping the last segment. This enables mechanical traversal without search.
123
+ **Actions:**
150
124
 
151
- 2. **Standalone protocols (no family):** action-oriented. Describe what the protocol does, not where it lives. The bundle directory is the namespace — the slug does not repeat it.
152
- - Good: `create-merge-request`, `makefile-setup`, `migrate-tf-to-git-sha`
153
- - Bad: `gitlab-create-merge-request` (redundant — it's already in `gitlab/`)
125
+ 1. **Apply protocol structure rules:**
126
+ - H1: protocol title (one H1 = one chain)
127
+ - First H2: Natural Language Triggers
128
+ - Middle H2s: one per step, with a placeholder `<!-- challenge -->` where the challenge block will go
129
+ - Last H2: Completion Rule
154
130
 
155
- 3. **Shared utilities:** prefix with the family they serve, at the family root level:
156
- - `jira-markdown-formatting` (used by all `jira-*` children)
157
- - `jira-alternative-mcp-unavailable`
131
+ 2. **Apply Natural Language Triggers structure (required, exact order):**
132
+ - Trigger phrases 3–6 quoted phrases
133
+ - Trigger pattern — verb + noun formula
134
+ - Must Never — 1–3 cases (imperative, no "should")
135
+ - Must Always — 1–3 mandatory behaviours
136
+ - Good trigger examples — 2–3 with `→ run this protocol`
137
+ - Bad trigger examples — 2–3 with `→ use X instead`
158
138
 
159
- 4. **General rules:**
160
- - Lowercase, hyphen-separated. No underscores, no camelCase.
161
- - Short as possible while remaining unambiguous. Target 2–4 segments.
162
- - The slug is a technical address Natural Language Triggers handle discoverability. The slug does not need to sound like a sentence.
139
+ 3. **Apply DRY — Don't Repeat Yourself:**
140
+ - Every piece of knowledge lives in exactly one place.
141
+ - Boilerplate belongs **inside the step that needs it** — one sentence, not a section.
142
+ - If two protocols share >50% body, extract shared logic into a base protocol or reference.
143
+ - Every H2 earns its place. Never duplicate an H2 heading — KAIROS treats each H2 as a step.
163
144
 
164
- **Protocol structure rules:**
145
+ 4. **Enforce 350-line maximum per file:**
146
+ - Over 350 → split via `mcp` challenge with `kairos_begin(key:...)` or extract to reference.
147
+ - Router protocols: ~50–80 lines. Extension protocols: 100–200 lines.
165
148
 
166
- - H1: protocol title (one H1 = one chain)
167
- - First H2: Natural Language Triggers
168
- - Middle H2s: one per step, each ending with a ```json challenge block
169
- - Last H2: Completion Rule
149
+ 5. **Apply slug convention:**
150
+ - Families: hierarchical. Router slug = prefix. Children expand by one segment.
151
+ - Standalone: action-oriented. Bundle directory is the namespace slug does not repeat it.
170
152
 
171
- **Natural Language Triggers structure (required, exact order):**
153
+ 6. **Apply generic-first principle:**
154
+ - Generic chains first; they stand alone with zero extensions.
155
+ - Extensions define only the delta. New type = one new file.
172
156
 
173
- 1. Trigger phrases 3–6 quoted phrases
174
- 2. Trigger pattern verb + noun formula
175
- 3. Must Never 1–3 cases (imperative, no "should")
176
- 4. Must Always 1–3 mandatory behaviours
177
- 5. Good trigger examples — 2–3 with `→ run this protocol`
178
- 6. Bad trigger examples — 2–3 with `→ use X instead`
157
+ 7. **Make every step SUBAGENT-ELIGIBLE:**
158
+ - `[SUBAGENT]` tag on each H2 step title.
159
+ - Explicit `**Input:**`, numbered `**Actions:**`, and `**Output:**` sections.
160
+ - Enough context that a subagent with no prior conversation can execute the step.
179
161
 
180
- **Challenge types:**
162
+ 8. **If Router pattern:** Draft the router AND each extension as separate markdown files.
163
+ - Classify step: decision tree table, forbidden types, common misclassifications.
164
+ - Route step: `kairos_begin(key: "slug")` per type, fallback.
181
165
 
182
- | Type | Use for | Engine validates |
183
- |---|---|---|
184
- | `comment` | Agent extracts, analyzes, drafts, summarizes | min_length |
185
- | `user_input` | Human confirms, approves, chooses | Non-empty response |
186
- | `mcp` | Agent must call a specific tool | Tool called successfully |
187
- | `shell` | Agent must run a command | Exit code 0 |
166
+ 9. **Write draft to file:** Write the protocol markdown to `$KAIROS_WORK_DIR/draft-protocol.md`. Every middle H2 has a `<!-- challenge -->` placeholder where the verification block will be added in the next step.
188
167
 
189
- **Challenge JSON format** (place at end of each step). Use a **single** concrete `type` per step (`comment`, `user_input`, `mcp`, or `shell`). Do not use pipe-separated placeholders inside `type` — each ` ```json ` block with `{"challenge":...}` becomes its own chain step when minted.
168
+ **Output:** `$KAIROS_WORK_DIR/draft-protocol.md` with complete structure but no challenge blocks.
190
169
 
191
- ```text
192
- {
193
- "challenge": {
194
- "type": "comment",
195
- "comment": { "min_length": 50 },
196
- "required": true
197
- }
198
- }
170
+ ```json
171
+ {"challenge":{"type":"shell","shell":{"cmd":"D=\"$KAIROS_WORK_DIR/draft-protocol.md\" && test -f \"$D\" && grep -c '^## ' \"$D\" | awk '$1 >= 3' && wc -l < \"$D\" | awk '$1 <= 350' && grep -q '^## Natural Language Triggers' \"$D\" && grep -q '^## Completion Rule' \"$D\"","timeout_seconds":5},"required":true}}
199
172
  ```
200
173
 
201
- **Router-specific steps:**
174
+ ## Author Challenge Blocks [SUBAGENT]
202
175
 
203
- - Classify step: decision tree table, forbidden types, common misclassifications. Challenge: `user_input`.
204
- - Route step: `kairos_begin(key: "slug")` per type, fallback field reference. Challenge: `mcp` with `tool_name: "kairos_begin"`.
176
+ Replace every `<!-- challenge -->` placeholder in the draft with a verifiable challenge block by running the challenge-type-guide protocol.
205
177
 
206
- **If Router pattern:** draft the router AND each extension as separate markdown files.
178
+ **Input:** `$KAIROS_WORK_DIR/draft-protocol.md` (from previous step).
207
179
 
208
- Post the full drafted markdown.
180
+ **Actions:**
209
181
 
210
- ```json
211
- {
212
- "challenge": {
213
- "type": "comment",
214
- "comment": { "min_length": 100 },
215
- "required": true
216
- }
217
- }
218
- ```
182
+ 1. **Run challenge type guide:** `kairos_begin(key: "challenge-type-guide")` — execute the full protocol to internalize decision tree, formats, interpreter rules, and anti-patterns.
183
+
184
+ 2. **Apply to each H2 step:** For every `<!-- challenge -->` placeholder, read the step's Actions and Output, apply the decision tree, select the challenge type and interpreter, write the JSON block in place.
219
185
 
220
- ## User Review
186
+ 3. **Favour creativity over formality:** Look for non-obvious verification opportunities — a step that "analyses" might produce a file (verify line count), a step that "selects" might set a variable (verify with `test -n`). The best challenges prove work was done.
221
187
 
222
- Present the drafted protocol(s) to the user. Ask to approve, request changes, or cancel.
188
+ 4. **Write challenge summary:** Append `$KAIROS_WORK_DIR/challenge-summary.md` listing each step, the challenge type chosen, the interpreter (if shell), and a one-line rationale.
223
189
 
224
- If Router pattern, present all files (router + extensions).
190
+ 5. **Overwrite draft:** Save the fully challenged version to `$KAIROS_WORK_DIR/draft-protocol.md`.
191
+
192
+ **Output:** Updated `$KAIROS_WORK_DIR/draft-protocol.md` (no placeholders remain, all JSON valid) and `$KAIROS_WORK_DIR/challenge-summary.md`.
225
193
 
226
194
  ```json
227
- {
228
- "challenge": {
229
- "type": "user_input",
230
- "user_input": { "prompt": "Approve the protocol draft for minting" },
231
- "required": true
232
- }
233
- }
195
+ {"challenge":{"type":"shell","shell":{"cmd":"D=\"$KAIROS_WORK_DIR/draft-protocol.md\" && S=\"$KAIROS_WORK_DIR/challenge-summary.md\" && test -f \"$D\" && test -f \"$S\" && ! grep -q '<!-- challenge -->' \"$D\" && perl -MJSON -0777 -ne '@b=/```json\\s*\\n(\\{.*?\\})\\s*\\n```/gs; die \"No challenge blocks\" unless @b; eval{decode_json($_)} or die \"Bad JSON: $@\" for @b; print scalar(@b).\" valid challenge blocks\\n\"' \"$D\"","timeout_seconds":5},"required":true}}
234
196
  ```
235
197
 
236
- ## Mint Protocol
198
+ ## Chain to Review [SUBAGENT]
199
+
200
+ Hand off the drafted protocol to Chain 2 for format review, stranger review, user approval, and minting.
237
201
 
238
- Call `kairos_mint` with the approved markdown. Use `force_update: false`
239
- unless the user explicitly asks to overwrite.
202
+ **Input:** `$KAIROS_WORK_DIR` (containing `requirements.md` and `draft-protocol.md`).
240
203
 
241
- If Router pattern: mint the router first, then each extension.
204
+ **Actions:**
205
+ 1. Verify both files exist in `$KAIROS_WORK_DIR`.
206
+ 2. Call `kairos_begin(key: "create-new-protocol-review")` to continue in Chain 2.
242
207
 
243
- Report the chain head URI(s) back to the user.
208
+ **Output:** Chain 2 execution begins with `$KAIROS_WORK_DIR` available in the shell session.
244
209
 
245
210
  ```json
246
- {
247
- "challenge": {
248
- "type": "mcp",
249
- "mcp": { "tool_name": "kairos_mint" },
250
- "required": true
251
- }
252
- }
211
+ {"challenge":{"type":"mcp","mcp":{"tool_name":"kairos_begin","arguments":{"key":"create-new-protocol-review"}},"required":true}}
253
212
  ```
254
213
 
255
214
  ## Completion Rule
256
215
 
257
216
  Only reachable after all prior steps are solved.
258
217
 
259
- The user now has a minted KAIROS protocol that:
260
- - Is discoverable via `kairos_search` (Natural Language Triggers)
261
- - Uses appropriate challenge types per step
262
- - If Router pattern: routes to extensions via `mcp` challenge with `kairos_begin(key:...)`
263
- - Has validated structure (triggers, steps, challenges, completion rule)
218
+ Chain 1 is complete when:
219
+ 1. User intent confirmed (or auto-confirmed from explicit trigger).
220
+ 2. Requirements written to `$KAIROS_WORK_DIR/requirements.md` (≥5 lines).
221
+ 3. Protocol structure drafted to `$KAIROS_WORK_DIR/draft-protocol.md` (≥3 H2 steps, ≤350 lines, NLT + Completion Rule present, `<!-- challenge -->` placeholders).
222
+ 4. All `<!-- challenge -->` placeholders replaced with valid challenge JSON blocks.
223
+ 5. Chain 2 (`create-new-protocol-review`) invoked via `kairos_begin`.
224
+
225
+ Execution continues in Chain 2 for review, approval, and minting. `$KAIROS_WORK_DIR` is cleaned up by the engine at `kairos_attest`.
@@ -1,5 +1,6 @@
1
1
  ---
2
- version: "3.3.3"
2
+ version: "3.4.0"
3
+ slug: refine-search
3
4
  title: Get help refining your search
4
5
  ---
5
6
 
@@ -11,19 +12,20 @@ title: Get help refining your search
11
12
 
12
13
  **Run this protocol when:**
13
14
 
14
- - `kairos_search` returned no match, or only choices with low score (e.g. all &lt; 0.5).
15
+ - `kairos_search` returned no match, or only choices with low score (e.g. all < 0.5).
15
16
  - The response included a **refine** (or equivalent) choice directing you to improve the query.
16
17
 
17
18
  **Trigger pattern:** After **kairos_search** when result is no strong match / refine suggested.
18
19
 
19
20
  **Must Never:**
20
21
 
21
- - Run when a strong match (score 0.5) already exists — use that choice and `kairos_begin` instead.
22
+ - Run when a strong match (score >= 0.5) already exists — use that choice and `kairos_begin` instead.
22
23
  - Run when the user has not yet asked for anything (no prior search context).
24
+ - Loop more than once per user request — if two searches fail, the protocol likely does not exist yet.
23
25
 
24
26
  **Must Always:**
25
27
 
26
- - Run at most once per user request if refining twice still yields no match, stop and offer to create a new protocol or ask the user to clarify.
28
+ - Run at most once, then either begin the matched protocol, offer to create a new one, or ask the user to clarify.
27
29
 
28
30
  **Good trigger examples:**
29
31
 
@@ -35,51 +37,51 @@ title: Get help refining your search
35
37
  - Search returned a strong match → use that match, not this protocol
36
38
  - User asked "what protocols exist?" → use search/list, not this protocol
37
39
 
38
- ## Step 1: Extract what the user actually wants
40
+ ## Analyse Intent [SUBAGENT]
39
41
 
40
- From the user's original message, identify:
41
- - **Goal:** What outcome do they want? (e.g. "run tests", "write docs", "create a Jira ticket")
42
- - **Context:** Any project, tool, domain, or proper noun they mentioned?
43
- - **Gaps:** What is missing or ambiguous? (e.g. "which repo?", "which doc type?", "which project key?")
42
+ Extract what the user actually wants from their original message.
44
43
 
45
- If the request was a slash-command or shorthand (e.g. "/ai-docs", "do the thing"), expand it: what would a concrete version of that command look like?
44
+ **Input:** User's original message and the failed `kairos_search` results.
46
45
 
47
- Write your analysis as your solution (goal + context + gaps, minimum 30 characters).
46
+ **Actions:**
47
+
48
+ 1. Identify **Goal** — what outcome does the user want? (e.g. "run tests", "write docs", "create a Jira ticket")
49
+ 2. Identify **Context** — any project, tool, domain, or proper noun mentioned.
50
+ 3. Identify **Gaps** — what is missing or ambiguous? (e.g. "which repo?", "which doc type?", "which project key?")
51
+ 4. If the request was a slash-command or shorthand (e.g. "/ai-docs"), expand it to a concrete description.
52
+
53
+ **Output:** Analysis with goal, context, and gaps (minimum 50 characters).
48
54
 
49
55
  ```json
50
- {
51
- "challenge": {
52
- "type": "comment",
53
- "comment": { "min_length": 30 },
54
- "required": true
55
- }
56
- }
56
+ {"challenge":{"type":"comment","comment":{"min_length":50},"required":true}}
57
57
  ```
58
58
 
59
- ## Step 2: Build and run a refined kairos_search query
59
+ ## Refine and Re-search [SUBAGENT]
60
60
 
61
- Using your Step 1 analysis, construct a single search query:
62
- - Use 3–8 specific words (nouns and verbs, no filler). Examples: "write ai instructions zero-drift template", "jira create story BIB", "npm test lint deploy".
63
- - Include domain or tool names if known (e.g. "jira", "gitlab", "coding standards").
64
- - Do not reuse the user's exact vague phrase — that already failed.
61
+ Construct and execute a better `kairos_search` query based on the intent analysis.
65
62
 
66
- Write your refined query as your solution, then call `kairos_search` with it.
63
+ **Input:** Goal, context, and gaps from previous step.
67
64
 
68
- - **Strong match (score >= 0.5):** Pick that choice and call `kairos_begin` with its URI.
69
- - **Weak matches only (all scores < 0.5):** Ask the user to clarify, or pick the create choice to build a new protocol.
65
+ **Actions:**
70
66
 
71
- Do not loop this refining protocol more than once if two searches fail, the protocol likely does not exist yet.
67
+ 1. Build a query of 3–8 specific words (nouns and verbs, no filler). Include domain/tool names if known.
68
+ 2. Do **not** reuse the user's exact vague phrase — that already failed.
69
+ 3. Call `kairos_search` with the refined query.
70
+ 4. Evaluate results:
71
+ - **Strong match (score >= 0.5):** Pick that choice and call `kairos_begin` with its URI.
72
+ - **Weak matches only:** Ask the user to clarify, or pick the "create" choice to build a new protocol.
73
+
74
+ **Output:** Either a `kairos_begin` call for the matched protocol, or a clear message to the user explaining why no match was found and what to do next.
72
75
 
73
76
  ```json
74
- {
75
- "challenge": {
76
- "type": "mcp",
77
- "mcp": { "tool_name": "kairos_search" },
78
- "required": true
79
- }
80
- }
77
+ {"challenge":{"type":"mcp","mcp":{"tool_name":"kairos_search"},"required":true}}
81
78
  ```
82
79
 
83
80
  ## Completion Rule
84
81
 
85
82
  Only reachable after all prior steps are solved.
83
+
84
+ This protocol is complete when:
85
+ 1. User intent analysed (goal + context + gaps, >= 50 characters).
86
+ 2. Refined `kairos_search` executed with an improved query.
87
+ 3. One of: matched protocol begun via `kairos_begin`, new protocol creation offered, or user asked to clarify.