@sayknow-cli/coding-agent 0.2.7 → 0.3.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 (138) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/types/async/job-manager.d.ts +3 -1
  3. package/dist/types/cli/daemon-cli.d.ts +25 -0
  4. package/dist/types/cli/notify-cli.d.ts +23 -0
  5. package/dist/types/cli/setup-cli.d.ts +20 -1
  6. package/dist/types/commands/daemon.d.ts +41 -0
  7. package/dist/types/commands/notify.d.ts +41 -0
  8. package/dist/types/config/model-profile-activation.d.ts +12 -0
  9. package/dist/types/config/model-profiles.d.ts +2 -1
  10. package/dist/types/config/model-registry.d.ts +3 -3
  11. package/dist/types/config/models-config-schema.d.ts +5 -0
  12. package/dist/types/config/settings-schema.d.ts +38 -0
  13. package/dist/types/coordinator/contract.d.ts +1 -1
  14. package/dist/types/daemon/builtin.d.ts +20 -0
  15. package/dist/types/daemon/control-types.d.ts +57 -0
  16. package/dist/types/daemon/runtime.d.ts +25 -0
  17. package/dist/types/defaults/skc-defaults.d.ts +13 -2
  18. package/dist/types/extensibility/extensions/types.d.ts +8 -0
  19. package/dist/types/modes/components/oauth-selector.d.ts +2 -0
  20. package/dist/types/modes/controllers/selector-controller.d.ts +2 -2
  21. package/dist/types/modes/interactive-mode.d.ts +1 -1
  22. package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +10 -0
  23. package/dist/types/modes/types.d.ts +7 -1
  24. package/dist/types/notifications/config-commands.d.ts +26 -0
  25. package/dist/types/notifications/config.d.ts +61 -0
  26. package/dist/types/notifications/helpers.d.ts +55 -0
  27. package/dist/types/notifications/html-format.d.ts +62 -0
  28. package/dist/types/notifications/index.d.ts +28 -0
  29. package/dist/types/notifications/rate-limit-pool.d.ts +93 -0
  30. package/dist/types/notifications/telegram-cli.d.ts +19 -0
  31. package/dist/types/notifications/telegram-daemon-cli.d.ts +11 -0
  32. package/dist/types/notifications/telegram-daemon-control.d.ts +56 -0
  33. package/dist/types/notifications/telegram-daemon.d.ts +276 -0
  34. package/dist/types/notifications/telegram-reference.d.ts +111 -0
  35. package/dist/types/notifications/threaded-inbound.d.ts +58 -0
  36. package/dist/types/notifications/threaded-render.d.ts +66 -0
  37. package/dist/types/notifications/topic-registry.d.ts +67 -0
  38. package/dist/types/rlm/index.d.ts +12 -0
  39. package/dist/types/session/agent-session.d.ts +39 -2
  40. package/dist/types/session/auth-storage.d.ts +1 -1
  41. package/dist/types/setup/credential-auto-import.d.ts +63 -0
  42. package/dist/types/setup/credential-import.d.ts +3 -0
  43. package/dist/types/setup/host-plugin-setup.d.ts +39 -0
  44. package/dist/types/skc-runtime/launch-tmux.d.ts +1 -0
  45. package/dist/types/skc-runtime/state-writer.d.ts +2 -0
  46. package/dist/types/skc-runtime/tmux-common.d.ts +3 -0
  47. package/dist/types/skc-runtime/tmux-sessions.d.ts +2 -0
  48. package/dist/types/skc-runtime/ultragoal-guard.d.ts +15 -0
  49. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +14 -0
  50. package/dist/types/tools/ask-answer-registry.d.ts +13 -0
  51. package/dist/types/tools/index.d.ts +18 -0
  52. package/dist/types/tools/subagent.d.ts +3 -0
  53. package/package.json +7 -7
  54. package/scripts/build-binary.ts +3 -0
  55. package/src/async/job-manager.ts +5 -1
  56. package/src/cli/daemon-cli.ts +122 -0
  57. package/src/cli/notify-cli.ts +274 -0
  58. package/src/cli/setup-cli.ts +173 -84
  59. package/src/cli.ts +3 -3
  60. package/src/commands/daemon.ts +47 -0
  61. package/src/commands/notify.ts +61 -0
  62. package/src/commands/setup.ts +11 -1
  63. package/src/config/model-profile-activation.ts +74 -5
  64. package/src/config/model-profiles.ts +7 -4
  65. package/src/config/model-registry.ts +6 -3
  66. package/src/config/models-config-schema.ts +1 -1
  67. package/src/config/settings-schema.ts +29 -0
  68. package/src/coordinator/contract.ts +3 -0
  69. package/src/coordinator-mcp/server.ts +270 -1
  70. package/src/daemon/builtin.ts +46 -0
  71. package/src/daemon/control-types.ts +65 -0
  72. package/src/daemon/runtime.ts +51 -0
  73. package/src/defaults/skc/rules/ponytail.md +68 -0
  74. package/src/defaults/skc/skills/ultragoal/SKILL.md +16 -0
  75. package/src/defaults/skc-defaults.ts +27 -2
  76. package/src/edit/modes/replace.ts +1 -1
  77. package/src/extensibility/extensions/runner.ts +4 -0
  78. package/src/extensibility/extensions/types.ts +8 -0
  79. package/src/goals/tools/goal-tool.ts +11 -2
  80. package/src/hashline/hash.ts +1 -1
  81. package/src/internal-urls/docs-index.generated.ts +10 -8
  82. package/src/main.ts +30 -0
  83. package/src/modes/acp/acp-event-mapper.ts +1 -0
  84. package/src/modes/components/hook-editor.ts +7 -2
  85. package/src/modes/components/oauth-selector.ts +19 -0
  86. package/src/modes/controllers/event-controller.ts +20 -0
  87. package/src/modes/controllers/selector-controller.ts +80 -17
  88. package/src/modes/interactive-mode.ts +6 -2
  89. package/src/modes/runtime-init.ts +1 -0
  90. package/src/modes/shared/agent-wire/event-contract.ts +1 -0
  91. package/src/modes/shared/agent-wire/event-envelope.ts +1 -0
  92. package/src/modes/shared/agent-wire/event-observation.ts +16 -0
  93. package/src/modes/shared/agent-wire/unattended-session.ts +22 -0
  94. package/src/modes/types.ts +7 -1
  95. package/src/modes/utils/ui-helpers.ts +23 -0
  96. package/src/notifications/config-commands.ts +50 -0
  97. package/src/notifications/config.ts +107 -0
  98. package/src/notifications/helpers.ts +135 -0
  99. package/src/notifications/html-format.ts +389 -0
  100. package/src/notifications/index.ts +700 -0
  101. package/src/notifications/rate-limit-pool.ts +179 -0
  102. package/src/notifications/telegram-cli.ts +194 -0
  103. package/src/notifications/telegram-daemon-cli.ts +74 -0
  104. package/src/notifications/telegram-daemon-control.ts +370 -0
  105. package/src/notifications/telegram-daemon.ts +1370 -0
  106. package/src/notifications/telegram-reference.ts +335 -0
  107. package/src/notifications/threaded-inbound.ts +80 -0
  108. package/src/notifications/threaded-render.ts +155 -0
  109. package/src/notifications/topic-registry.ts +133 -0
  110. package/src/rlm/index.ts +19 -0
  111. package/src/sdk.ts +16 -0
  112. package/src/session/agent-session.ts +113 -3
  113. package/src/session/auth-storage.ts +3 -0
  114. package/src/session/session-dump-format.ts +43 -2
  115. package/src/session/session-manager.ts +39 -5
  116. package/src/setup/credential-auto-import.ts +258 -0
  117. package/src/setup/credential-import.ts +17 -0
  118. package/src/setup/hermes/templates/operator-instructions.v1.md +10 -0
  119. package/src/setup/host-plugin-setup.ts +142 -0
  120. package/src/skc-runtime/deep-interview-recorder.ts +2 -2
  121. package/src/skc-runtime/launch-tmux.ts +10 -2
  122. package/src/skc-runtime/state-runtime.ts +18 -10
  123. package/src/skc-runtime/state-writer.ts +8 -8
  124. package/src/skc-runtime/tmux-common.ts +8 -0
  125. package/src/skc-runtime/tmux-sessions.ts +8 -1
  126. package/src/skc-runtime/ultragoal-guard.ts +57 -2
  127. package/src/skc-runtime/ultragoal-runtime.ts +105 -19
  128. package/src/skc-runtime/workflow-manifest.generated.json +27 -2
  129. package/src/skc-runtime/workflow-manifest.ts +11 -1
  130. package/src/slash-commands/builtin-registry.ts +4 -1
  131. package/src/task/executor.ts +5 -1
  132. package/src/tools/ask-answer-registry.ts +25 -0
  133. package/src/tools/ask.ts +77 -6
  134. package/src/tools/image-gen.ts +5 -8
  135. package/src/tools/index.ts +19 -0
  136. package/src/tools/inspect-image.ts +16 -11
  137. package/src/tools/subagent-render.ts +7 -0
  138. package/src/tools/subagent.ts +38 -7
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Static built-in daemon controller map.
3
+ *
4
+ * Intentionally a static map keyed by daemon kind rather than a mutable plugin
5
+ * registry: there is exactly one kind today (`telegram`). Promote to a richer
6
+ * registry only when a second daemon kind exists.
7
+ */
8
+
9
+ import type { Settings } from "../config/settings";
10
+ import { type TelegramDaemonControlDeps, TelegramDaemonController } from "../notifications/telegram-daemon-control";
11
+ import type { BuiltInDaemonController, DaemonKind } from "./control-types";
12
+
13
+ export const BUILT_IN_DAEMON_KINDS = ["telegram"] as const satisfies readonly DaemonKind[];
14
+
15
+ export interface BuiltInDaemonControllerDeps {
16
+ telegram?: TelegramDaemonControlDeps;
17
+ }
18
+
19
+ export function createBuiltInDaemonControllers(
20
+ settings: Settings,
21
+ deps: BuiltInDaemonControllerDeps = {},
22
+ ): Record<DaemonKind, BuiltInDaemonController> {
23
+ return {
24
+ telegram: new TelegramDaemonController(settings, deps.telegram),
25
+ };
26
+ }
27
+
28
+ /**
29
+ * Resolve the controllers a command should act on. `--all` selects every
30
+ * built-in kind; otherwise the explicit `kinds` (defaulting to `telegram`).
31
+ */
32
+ export function selectDaemonControllers(
33
+ settings: Settings,
34
+ kinds: DaemonKind[] | undefined,
35
+ all: boolean,
36
+ deps: BuiltInDaemonControllerDeps = {},
37
+ ): BuiltInDaemonController[] {
38
+ const map = createBuiltInDaemonControllers(settings, deps);
39
+ if (all) return Object.values(map);
40
+ const selected = kinds && kinds.length > 0 ? kinds : (["telegram"] as DaemonKind[]);
41
+ return selected.map(kind => {
42
+ const controller = map[kind];
43
+ if (!controller) throw new Error(`unknown daemon kind: ${kind}`);
44
+ return controller;
45
+ });
46
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Public types for the `skc daemon` control plane.
3
+ *
4
+ * Deliberately compact: a small result/status surface plus a built-in
5
+ * controller contract. There is exactly one daemon kind today (`telegram`);
6
+ * a richer registry is intentionally deferred until a second kind exists.
7
+ */
8
+
9
+ export type DaemonKind = "telegram";
10
+
11
+ export type DaemonAction = "list" | "status" | "stop" | "reload";
12
+
13
+ export type DaemonHealth = "not_configured" | "stopped" | "running" | "stale" | "stopping" | "error";
14
+
15
+ export interface DaemonRuntimeInfo {
16
+ /** `source` when respawn goes through bun/node + the entry script; `compiled` for a single-file binary. */
17
+ mode: "source" | "compiled";
18
+ execPath: string;
19
+ /** True only in source/dev mode, where a respawn loads amended TypeScript directly. */
20
+ reloadPicksUpSourceEdits: boolean;
21
+ /** Present when the runtime mode constrains what reload can achieve (e.g. compiled binary). */
22
+ warning?: string;
23
+ }
24
+
25
+ export interface DaemonStatus {
26
+ kind: DaemonKind;
27
+ configured: boolean;
28
+ health: DaemonHealth;
29
+ pid?: number;
30
+ ownerId?: string;
31
+ startedAt?: number;
32
+ heartbeatAt?: number;
33
+ roots?: string[];
34
+ rootCount?: number;
35
+ runtime: DaemonRuntimeInfo;
36
+ detail?: string;
37
+ }
38
+
39
+ export interface DaemonOperationOptions {
40
+ /** How long to wait for cooperative release before escalating. */
41
+ gracefulTimeoutMs?: number;
42
+ /** How long to wait for the old pid to die after SIGKILL. */
43
+ killTimeoutMs?: number;
44
+ /** Allow hard-kill escalation / acting on a still-live owner. */
45
+ force?: boolean;
46
+ /** For reload: spawn a fresh owner even when none is currently running. */
47
+ spawnIfStopped?: boolean;
48
+ }
49
+
50
+ export interface DaemonOperationResult {
51
+ kind: DaemonKind;
52
+ action: Exclude<DaemonAction, "list">;
53
+ ok: boolean;
54
+ before?: DaemonStatus;
55
+ after?: DaemonStatus;
56
+ warnings: string[];
57
+ message: string;
58
+ }
59
+
60
+ export interface BuiltInDaemonController {
61
+ readonly kind: DaemonKind;
62
+ status(): Promise<DaemonStatus>;
63
+ stop(opts?: DaemonOperationOptions): Promise<DaemonOperationResult>;
64
+ reload(opts?: DaemonOperationOptions): Promise<DaemonOperationResult>;
65
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared source-vs-compiled runtime detection for daemon spawning.
3
+ *
4
+ * Centralizes the logic previously embedded in `ensureTelegramDaemonRunning`
5
+ * so session autostart, reload, and status reporting agree on how a daemon
6
+ * process is launched and whether a reload can pick up amended source.
7
+ */
8
+
9
+ import * as path from "node:path";
10
+
11
+ export interface SkcRuntimeSpawnInfo {
12
+ execPath: string;
13
+ mode: "source" | "compiled";
14
+ /** Prefix prepended before the skc subcommand args; `[Bun.main]` in source mode, otherwise `[]`. */
15
+ argsPrefix: string[];
16
+ /** True only when respawn loads edited TypeScript directly (source/dev mode). */
17
+ reloadPicksUpSourceEdits: boolean;
18
+ /** Set in compiled mode to explain that a rebuild is required before reload picks up source edits. */
19
+ warning?: string;
20
+ }
21
+
22
+ const COMPILED_RELOAD_WARNING =
23
+ "Compiled binary: reload respawns the same binary. Rebuild the binary first for amended source to take effect.";
24
+
25
+ /**
26
+ * Resolve how to spawn a detached skc subcommand for the current runtime.
27
+ *
28
+ * Source/dev mode (bun/node) prepends the entry script (`Bun.main`) so the
29
+ * respawn loads edited source. A compiled single-file binary self-spawns its
30
+ * own subcommand directly and cannot pick up workspace source edits.
31
+ */
32
+ export function resolveSkcRuntimeSpawnInfo(execPath: string = process.execPath): SkcRuntimeSpawnInfo {
33
+ const base = path.basename(execPath).toLowerCase();
34
+ const fromSource = base === "bun" || base === "node" || base.startsWith("bun") || base.startsWith("node");
35
+ const mainScript = fromSource && typeof Bun !== "undefined" ? (Bun as unknown as { main?: string }).main : undefined;
36
+ if (fromSource) {
37
+ return {
38
+ execPath,
39
+ mode: "source",
40
+ argsPrefix: mainScript ? [mainScript] : [],
41
+ reloadPicksUpSourceEdits: true,
42
+ };
43
+ }
44
+ return {
45
+ execPath,
46
+ mode: "compiled",
47
+ argsPrefix: [],
48
+ reloadPicksUpSourceEdits: false,
49
+ warning: COMPILED_RELOAD_WARNING,
50
+ };
51
+ }
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: ponytail
3
+ description: "Lazy senior dev mode — always pick the simplest, shortest solution that works (YAGNI, reuse, stdlib/native first), never cutting validation, error handling, security, or accessibility."
4
+ alwaysApply: true
5
+ license: MIT
6
+ source: https://github.com/DietrichGebert/ponytail
7
+ ---
8
+
9
+ # Ponytail — lazy senior dev mode
10
+
11
+ You write code like the laziest senior dev in the room. Lazy means efficient,
12
+ not careless. The best code is the code you never wrote. This rule governs
13
+ *what* you build, not how you talk.
14
+
15
+ ## The ladder
16
+
17
+ After you understand the problem, stop at the first rung that holds:
18
+
19
+ 1. **Does this need to exist at all?** Speculative need → skip it, say so in one line (YAGNI).
20
+ 2. **Already in this codebase?** A helper, util, type, or pattern that lives here → reuse it. Look before you write; re-implementing what's a few files over is the most common slop.
21
+ 3. **Stdlib does it?** Use it.
22
+ 4. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, DB constraint over app code.
23
+ 5. **Already-installed dependency solves it?** Use it. Never add a new dependency for what a few lines can do.
24
+ 6. **Can it be one line?** One line.
25
+ 7. **Only then:** the minimum code that works.
26
+
27
+ The ladder runs *after* comprehension, not instead of it. Read the task and the
28
+ code it touches, trace the real flow end to end, then climb. Two rungs work →
29
+ take the higher one and move on.
30
+
31
+ **Bug fix = root cause, not symptom.** Grep every caller of the function you are
32
+ about to touch. One guard in the shared function is a smaller diff than a guard
33
+ in every caller — and patching only the path the ticket names leaves every
34
+ sibling caller broken.
35
+
36
+ ## Rules
37
+
38
+ - No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
39
+ - No boilerplate or scaffolding "for later" — later can scaffold for itself.
40
+ - Deletion over addition. Boring over clever; clever is what someone decodes at 3am.
41
+ - Fewest files possible. Shortest working diff wins — but only once you understand the problem. The smallest change in the wrong place is a second bug, not laziness.
42
+ - Two stdlib options the same size? Take the one that is correct on edge cases.
43
+ - Mark deliberate simplifications with a `ponytail:` comment that names the ceiling and the upgrade path (e.g. `// ponytail: global lock, per-account locks if throughput matters`).
44
+
45
+ ## Output
46
+
47
+ Code first. Then at most three short lines: what was skipped, when to add it.
48
+ No essays defending a simplification — every paragraph of defense is complexity
49
+ smuggled back in as prose. Explanation the user explicitly asked for (a report,
50
+ a walkthrough) is not debt; give it in full.
51
+
52
+ Pattern: `[code] → skipped: [X], add when [Y].`
53
+
54
+ ## When NOT to be lazy
55
+
56
+ Never simplify away: input validation at trust boundaries, error handling that
57
+ prevents data loss, security measures, accessibility basics, or anything
58
+ explicitly requested. Never be lazy about *understanding* the problem — the
59
+ ladder shortens the solution, never the reading. A confident small diff in the
60
+ wrong place is the dangerous kind of lazy.
61
+
62
+ Non-trivial logic (a branch, loop, parser, money/security path) leaves ONE
63
+ runnable check behind — the smallest thing that fails if the logic breaks. No
64
+ frameworks or fixtures unless asked. Trivial one-liners need no test.
65
+
66
+ ---
67
+
68
+ Adapted from [ponytail](https://github.com/DietrichGebert/ponytail) (MIT) by DietrichGebert.
@@ -107,6 +107,21 @@ Loop until `skc ultragoal status` reports all goals complete:
107
107
  `skc ultragoal checkpoint --goal-id <id> --status blocked --evidence "<completed legacy SKC goal blocks goal create in this thread>" --skc-goal-json <goal-get-json-or-path>`
108
108
  11. Resume failed goals with `skc ultragoal complete-goals --retry-failed`.
109
109
 
110
+ ## Blocker triage and pause discipline
111
+
112
+ An active Ultragoal run must not give up on a blocker by pausing the goal and asking the user. Classify every blocker before deciding what to do, and default to `resolvable` when unsure:
113
+
114
+ - **`resolvable`** — anything the agent can act on: failing tests, missing implementation, a dependency to install, an ambiguous-but-inferable detail, investigation. **Never pause.** Exhaust autonomous resolution first: investigate, `skc ultragoal steer --kind add_subgoal --title "Investigate blocker" --objective "..." --evidence "..." --rationale "..."`, delegate an `executor`, or preserve the blocker durably with `skc ultragoal checkpoint --status blocked` / `skc ultragoal record-review-blockers` and keep scheduling the next goal.
115
+ - **`human_blocked`** — only the user can act: credentials/secrets, a manual or physical step, an external approval/decision, access the agent lacks. Pause is the last resort and is gated.
116
+
117
+ `goal({"op":"pause"})` is **blocked at runtime** while an Ultragoal run is active unless the latest durable ledger event classifies the current blocker as `human_blocked`. To pause, record the classification immediately before pausing and cite the human-only dependency as evidence:
118
+
119
+ ```sh
120
+ skc ultragoal classify-blocker --classification human_blocked --evidence "<the specific human-only dependency>" [--goal-id <id>]
121
+ ```
122
+
123
+ Recording `--classification resolvable` is an audit note only; it never authorizes a pause. The `ask` tool stays blocked during active runs regardless of classification — record unresolved decisions as durable blockers instead of prompting.
124
+
110
125
  ## Dynamic steering
111
126
 
112
127
  Use `skc ultragoal steer` when real findings or blockers prove the current story decomposition should change while the aggregate objective and constraints stay fixed. Steering is explicit-only and evidence-backed; broad natural-language requests are rejected instead of guessed.
@@ -199,6 +214,7 @@ An ultragoal story cannot be checkpointed `complete` until the active agent has
199
214
  - CLI surfaces require runtime argv replay: `replaySafe: true`, an allowlisted argv `command`, and replayed normalized stdout matching `recordedStdout`; unsafe commands require audited `replayExempt` metadata with exact fields `reasonCode`, `reason`, `approvedBy`, and `fallbackArtifactRefs` plus a structurally valid fallback artifact. Allowed `reasonCode` values are exactly `unsafe_side_effect`, `requires_credentials`, `requires_network`, `non_deterministic_external`, `destructive`, `interactive_only`, and `platform_unavailable`.
200
215
  - Native/desktop/tui surfaces require a structurally valid screenshot, PTY capture with terminal control codes, or app-automation transcript.
201
216
  - API/package/algorithm/math surfaces require a real artifact file or typed receipt. Bare `inlineEvidence` text alone is not sufficient for any surface.
217
+ - The mandatory **computer-use** red-team suite (`kill-switch-bypass`, `suspended-enforcement`, `permission-revoked`, …) is conditional, not universal: require it only when computer/desktop control is genuinely part of the product surface being dogfooded. For every other product type, prove the change through the matching live surface instead — browser-use automation for web/GUI, bash/CLI live invocation or argv replay for CLI, and real artifacts or typed receipts for API/package/algorithm/math. Editing docs, prompts, or skills that merely mention computer-use does not by itself make the computer-use suite applicable; pick the red-team surface that matches what the change actually ships.
202
218
  7. The executor QA/red-team lane must report a matrix using `executorQa.contractCoverage`, `executorQa.surfaceEvidence`, `executorQa.adversarialCases`, and `executorQa.artifactRefs`. Not-applicable rows are allowed only in `contractCoverage` and `surfaceEvidence`; each `status: "not_applicable"` row requires `contractRef` plus `reason`. `adversarialCases` rows cannot be not-applicable.
203
219
  8. Run a final code review pass and fold it into the strict quality gate. Clean means `architectReview.architectureStatus`, `architectReview.productStatus`, and `architectReview.codeStatus` are all `"CLEAR"`, `architectReview.recommendation` is `"APPROVE"`, executor QA statuses are `"passed"`, iteration is `"passed"` with `fullRerun: true`, every evidence field is non-empty, every required matrix row is present, and every blockers array is empty. `COMMENT`, `WATCH`, `REQUEST CHANGES`, `BLOCK`, missing evidence, missing or shallow matrix rows, plan/code mismatches, or non-empty blockers are non-clean.
204
220
  9. If any lane finds an issue, do **not** checkpoint `complete` and do **not** call `goal({"op":"complete"})`. Record durable blocker work instead:
@@ -10,10 +10,11 @@ import ralplanSkill from "./skc/skills/ralplan/SKILL.md" with { type: "text" };
10
10
  import teamSkill from "./skc/skills/team/SKILL.md" with { type: "text" };
11
11
  import aiSlopCleanerFragment from "./skc/skills/ultragoal/ai-slop-cleaner.md" with { type: "text" };
12
12
  import ultragoalSkill from "./skc/skills/ultragoal/SKILL.md" with { type: "text" };
13
+ import ponytailRule from "./skc/rules/ponytail.md" with { type: "text" };
13
14
 
14
15
  export const DEFAULT_SKC_DEFINITION_NAMES = ["deep-interview", "ralplan", "team", "ultragoal"] as const;
15
16
  export type DefaultSkcDefinitionName = (typeof DEFAULT_SKC_DEFINITION_NAMES)[number];
16
- export type DefaultSkcDefinitionKind = "skill" | "skill-fragment";
17
+ export type DefaultSkcDefinitionKind = "skill" | "skill-fragment" | "rule";
17
18
  export type EmbeddedDefaultSkcSkill = {
18
19
  name: DefaultSkcDefinitionName;
19
20
  description: string;
@@ -39,7 +40,17 @@ export interface DefaultSkcSkillFragmentDefinition {
39
40
  content: string;
40
41
  }
41
42
 
42
- export type DefaultSkcDefinition = DefaultSkcSkillDefinition | DefaultSkcSkillFragmentDefinition;
43
+ export interface DefaultSkcRuleDefinition {
44
+ kind: "rule";
45
+ name: string;
46
+ relativePath: string;
47
+ content: string;
48
+ }
49
+
50
+ export type DefaultSkcDefinition =
51
+ | DefaultSkcSkillDefinition
52
+ | DefaultSkcSkillFragmentDefinition
53
+ | DefaultSkcRuleDefinition;
43
54
 
44
55
  export interface InstallDefaultSkcDefinitionsOptions {
45
56
  check?: boolean;
@@ -59,6 +70,12 @@ export type DefaultSkcDefinitionInstallFile =
59
70
  parentSkillName: DefaultSkcDefinitionName;
60
71
  path: string;
61
72
  status: DefaultSkcInstallStatus;
73
+ }
74
+ | {
75
+ kind: "rule";
76
+ name: string;
77
+ path: string;
78
+ status: DefaultSkcInstallStatus;
62
79
  };
63
80
 
64
81
  export interface DefaultSkcDefinitionInstallResult {
@@ -106,6 +123,7 @@ const DEFAULT_SKC_DEFINITIONS: readonly DefaultSkcDefinition[] = [
106
123
  relativePath: "skill-fragments/ultragoal/ai-slop-cleaner.md",
107
124
  content: aiSlopCleanerFragment,
108
125
  },
126
+ { kind: "rule", name: "ponytail", relativePath: "rules/ponytail.md", content: ponytailRule },
109
127
  ];
110
128
 
111
129
  export function getDefaultSkcDefinitions(): readonly DefaultSkcDefinition[] {
@@ -174,6 +192,13 @@ export async function installDefaultSkcDefinitions(
174
192
  path: destination,
175
193
  status,
176
194
  });
195
+ } else if (definition.kind === "rule") {
196
+ files.push({
197
+ kind: definition.kind,
198
+ name: definition.name,
199
+ path: destination,
200
+ status,
201
+ });
177
202
  } else {
178
203
  files.push({
179
204
  kind: definition.kind,
@@ -42,7 +42,7 @@ let scoreSequenceFuzzyNative:
42
42
  let findBestFuzzyMatchNative:
43
43
  | ((content: string, target: string, threshold: number) => NativeBestFuzzyMatchResult)
44
44
  | undefined;
45
- void import("../../../../natives/native/index.js")
45
+ void import("@sayknow-cli/natives")
46
46
  .then(mod => {
47
47
  if (typeof mod.h02ScoreSequenceFuzzy === "function") {
48
48
  scoreSequenceFuzzyNative = mod.h02ScoreSequenceFuzzy;
@@ -6,6 +6,7 @@ import type { CredentialDisabledEvent, ImageContent, Model, ProviderResponseMeta
6
6
  import type { KeyId } from "@sayknow-cli/tui";
7
7
  import { logger } from "@sayknow-cli/utils";
8
8
  import type { ModelRegistry } from "../../config/model-registry";
9
+ import type { WorkflowGateEmitter } from "../../modes/shared/agent-wire/unattended-session";
9
10
  import { type Theme, theme } from "../../modes/theme/theme";
10
11
  import type { SessionManager } from "../../session/session-manager";
11
12
  import type {
@@ -180,6 +181,7 @@ export class ExtensionRunner {
180
181
  #getContextUsageFn: () => ContextUsage | undefined = () => undefined;
181
182
  #compactFn: (instructionsOrOptions?: string | CompactOptions) => Promise<void> = async () => {};
182
183
  #getSystemPromptFn: () => string[] = () => [];
184
+ #getWorkflowGateFn: () => WorkflowGateEmitter | undefined = () => undefined;
183
185
  #newSessionHandler: NewSessionHandler = async () => ({ cancelled: false });
184
186
  #branchHandler: BranchHandler = async () => ({ cancelled: false });
185
187
  #navigateTreeHandler: NavigateTreeHandler = async () => ({ cancelled: false });
@@ -234,6 +236,7 @@ export class ExtensionRunner {
234
236
  this.#hasPendingMessagesFn = contextActions.hasPendingMessages;
235
237
  this.#shutdownHandler = contextActions.shutdown;
236
238
  this.#getSystemPromptFn = contextActions.getSystemPrompt;
239
+ this.#getWorkflowGateFn = contextActions.getWorkflowGate ?? (() => undefined);
237
240
 
238
241
  // Command context actions (optional, only for interactive mode)
239
242
  if (commandContextActions) {
@@ -463,6 +466,7 @@ export class ExtensionRunner {
463
466
  shutdown: () => this.#shutdownHandler(),
464
467
  getSystemPrompt: () => this.#getSystemPromptFn(),
465
468
  hasQueuedMessages: () => this.#hasPendingMessagesFn(), // deprecated alias
469
+ workflowGate: this.#getWorkflowGateFn(),
466
470
  };
467
471
  }
468
472
 
@@ -32,6 +32,7 @@ import type { PythonResult } from "../../eval/py/executor";
32
32
  import type { BashResult } from "../../exec/bash-executor";
33
33
  import type { ExecOptions, ExecResult } from "../../exec/exec";
34
34
  import type { CustomEditor } from "../../modes/components/custom-editor";
35
+ import type { WorkflowGateEmitter } from "../../modes/shared/agent-wire/unattended-session";
35
36
  import type { Theme } from "../../modes/theme/theme";
36
37
  import type { CustomMessage } from "../../session/messages";
37
38
  import type { ReadonlySessionManager, SessionManager } from "../../session/session-manager";
@@ -310,6 +311,11 @@ export interface ExtensionContext {
310
311
  getSystemPrompt(): string[];
311
312
  /** @deprecated Use hasPendingMessages() instead */
312
313
  hasQueuedMessages(): boolean;
314
+ /**
315
+ * Unattended workflow-gate bridge. Present only when the session runs in
316
+ * unattended/RPC mode; `undefined` in interactive/TUI mode (notify-only).
317
+ */
318
+ workflowGate?: WorkflowGateEmitter;
313
319
  }
314
320
 
315
321
  /**
@@ -1234,6 +1240,8 @@ export interface ExtensionContextActions {
1234
1240
  getContextUsage: () => ContextUsage | undefined;
1235
1241
  compact: (instructionsOrOptions?: string | CompactOptions) => Promise<void>;
1236
1242
  getSystemPrompt: () => string[];
1243
+ /** Unattended workflow-gate bridge (present only in unattended/RPC mode). */
1244
+ getWorkflowGate?: () => WorkflowGateEmitter | undefined;
1237
1245
  }
1238
1246
 
1239
1247
  /** Actions for ExtensionCommandContext (ctx.* in command handlers). */
@@ -6,7 +6,7 @@ import * as z from "zod/v4";
6
6
  import type { RenderResultOptions } from "../../extensibility/custom-tools/types";
7
7
  import type { Theme, ThemeColor } from "../../modes/theme/theme";
8
8
  import goalDescription from "../../prompts/tools/goal.md" with { type: "text" };
9
- import { assertCanCompleteCurrentGoal } from "../../skc-runtime/ultragoal-guard";
9
+ import { assertCanCompleteCurrentGoal, assertUltragoalPauseAllowed } from "../../skc-runtime/ultragoal-guard";
10
10
  import { formatDuration } from "../../slash-commands/helpers/format";
11
11
  import type { ToolSession } from "../../tools";
12
12
  import { formatErrorMessage, TRUNCATE_LENGTHS } from "../../tools/render-utils";
@@ -94,6 +94,11 @@ async function executeGoalOperation(session: ToolSession, params: GoalToolInput)
94
94
  return buildGoalToolResponse(resumed.goal);
95
95
  }
96
96
  if (params.op === "pause") {
97
+ try {
98
+ await assertUltragoalPauseAllowed(session.cwd);
99
+ } catch (error) {
100
+ throw new ToolError(error instanceof Error ? error.message : String(error));
101
+ }
97
102
  const paused = await runtime.pauseGoal();
98
103
  return buildGoalToolResponse(paused?.goal ?? null);
99
104
  }
@@ -102,7 +107,11 @@ async function executeGoalOperation(session: ToolSession, params: GoalToolInput)
102
107
  return buildGoalToolResponse(dropped ?? null);
103
108
  }
104
109
  try {
105
- await assertCanCompleteCurrentGoal({ cwd: session.cwd, currentGoal: session.getGoalModeState?.()?.goal ?? null });
110
+ await assertCanCompleteCurrentGoal({
111
+ cwd: session.cwd,
112
+ currentGoal: session.getGoalModeState?.()?.goal ?? null,
113
+ sessionId: session.getSessionId?.(),
114
+ });
106
115
  } catch (error) {
107
116
  throw new ToolError(error instanceof Error ? error.message : String(error));
108
117
  }
@@ -9,7 +9,7 @@ import bigrams from "./bigrams.json" with { type: "json" };
9
9
  // module evaluation so this core module (and its re-exported helpers) stays
10
10
  // usable and falls back to the TS loop if the native addon is unavailable.
11
11
  let formatHashLinesNative: ((text: string, startLine?: number) => string) | undefined;
12
- void import("../../../natives/native/index.js")
12
+ void import("@sayknow-cli/natives")
13
13
  .then(mod => {
14
14
  if (typeof mod.h06FormatHashLines === "function") {
15
15
  formatHashLinesNative = mod.h06FormatHashLines;