@gajae-code/coding-agent 0.11.11 → 0.12.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.
- package/CHANGELOG.md +49 -3
- package/dist/types/cli/read-cli.d.ts +1 -0
- package/dist/types/commands/deep-interview.d.ts +9 -0
- package/dist/types/commands/harness.d.ts +22 -0
- package/dist/types/commands/read.d.ts +6 -0
- package/dist/types/config/model-registry.d.ts +4 -0
- package/dist/types/config/provider-auth-health.d.ts +14 -0
- package/dist/types/config/provider-ranking.d.ts +59 -0
- package/dist/types/config/settings-schema.d.ts +29 -1
- package/dist/types/config/settings.d.ts +2 -0
- package/dist/types/extensibility/extensions/types.d.ts +22 -2
- package/dist/types/extensibility/shared-events.d.ts +6 -0
- package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +5 -12
- package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +17 -32
- package/dist/types/gjc-runtime/deep-interview-stage.d.ts +37 -0
- package/dist/types/gjc-runtime/deep-interview-state.d.ts +4 -135
- package/dist/types/gjc-runtime/gc-runtime.d.ts +1 -1
- package/dist/types/gjc-runtime/memory-guard-owner-claims.d.ts +47 -0
- package/dist/types/gjc-runtime/ralplan-runtime.d.ts +52 -1
- package/dist/types/gjc-runtime/state-writer.d.ts +5 -46
- package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
- package/dist/types/gjc-runtime/team-runtime.d.ts +2 -1
- package/dist/types/gjc-runtime/team-store.d.ts +12 -0
- package/dist/types/gjc-runtime/team-worker-memory-guard.d.ts +92 -0
- package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +7 -0
- package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +8 -0
- package/dist/types/gjc-runtime/workflow-manifest.d.ts +3 -5
- package/dist/types/internal-urls/local-root-gc.d.ts +2 -0
- package/dist/types/main.d.ts +1 -1
- package/dist/types/memories/index.d.ts +2 -0
- package/dist/types/modes/acp/acp-agent.d.ts +8 -0
- package/dist/types/modes/components/assistant-message.d.ts +3 -1
- package/dist/types/modes/components/irc-sidebar.d.ts +41 -0
- package/dist/types/modes/components/read-tool-group.d.ts +4 -4
- package/dist/types/modes/components/session-observer-overlay.d.ts +4 -0
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/components/tool-execution.d.ts +8 -0
- package/dist/types/modes/controllers/event-controller.d.ts +3 -0
- package/dist/types/modes/interactive-mode.d.ts +2 -0
- package/dist/types/modes/irc-observation-ledger.d.ts +17 -1
- package/dist/types/modes/types.d.ts +2 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +5 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +5 -0
- package/dist/types/sdk/bus/control-drain-lease.d.ts +52 -0
- package/dist/types/sdk/bus/index.d.ts +15 -1
- package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +37 -0
- package/dist/types/sdk/bus/prompt-reconciliation.d.ts +2 -1
- package/dist/types/sdk/bus/reconciliation-store.d.ts +65 -0
- package/dist/types/sdk/host/control/operations.d.ts +1 -1
- package/dist/types/sdk/host/host.d.ts +2 -0
- package/dist/types/sdk/host/query/handlers.d.ts +5 -0
- package/dist/types/session/agent-session.d.ts +44 -10
- package/dist/types/session/memory-guard-checkpoint-participant.d.ts +69 -0
- package/dist/types/session/session-manager.d.ts +25 -13
- package/dist/types/session/streaming-output.d.ts +60 -5
- package/dist/types/skill-state/active-state.d.ts +0 -4
- package/dist/types/skill-state/workflow-hud.d.ts +3 -0
- package/dist/types/tools/browser/launch.d.ts +7 -0
- package/dist/types/tools/fetch.d.ts +17 -1
- package/dist/types/tools/output-meta.d.ts +21 -1
- package/dist/types/tools/read-internals.d.ts +12 -0
- package/dist/types/tools/read.d.ts +45 -1
- package/dist/types/tools/resource-gc.d.ts +4 -0
- package/dist/types/tools/tool-result.d.ts +7 -1
- package/package.json +9 -13
- package/scripts/benchmark-sticky-viewport-pr1.ts +239 -0
- package/scripts/capture-sticky-viewport-showcase.ts +292 -0
- package/scripts/generate-sdk-operation-inventory.ts +2 -0
- package/scripts/verify-gjc-sdk-canonicalization.ts +122 -18
- package/scripts/verify-sticky-viewport-showcase.ts +611 -0
- package/src/capability/index.ts +8 -0
- package/src/cli/read-cli.ts +2 -1
- package/src/cli.ts +1 -0
- package/src/commands/deep-interview.ts +29 -9
- package/src/commands/harness.ts +35 -12
- package/src/commands/read.ts +11 -2
- package/src/commands/team.ts +1 -1
- package/src/config/model-registry.ts +21 -2
- package/src/config/provider-auth-health.ts +42 -0
- package/src/config/provider-ranking.ts +119 -0
- package/src/config/settings-schema.ts +23 -1
- package/src/config/settings.ts +246 -108
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +229 -82
- package/src/defaults/gjc/skills/ralplan/SKILL.md +58 -25
- package/src/defaults/gjc/skills/team/SKILL.md +1 -1
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +25 -15
- package/src/eval/py/executor.ts +7 -2
- package/src/extensibility/extensions/types.ts +28 -4
- package/src/extensibility/shared-events.ts +5 -0
- package/src/gjc-runtime/deep-interview-ambiguity.ts +47 -82
- package/src/gjc-runtime/deep-interview-recorder.ts +227 -310
- package/src/gjc-runtime/deep-interview-runtime.ts +109 -270
- package/src/gjc-runtime/deep-interview-stage.ts +1016 -0
- package/src/gjc-runtime/deep-interview-state.ts +12 -943
- package/src/gjc-runtime/gc-render.ts +1 -0
- package/src/gjc-runtime/gc-runtime.ts +11 -1
- package/src/gjc-runtime/memory-guard-owner-claims.ts +389 -0
- package/src/gjc-runtime/ralplan-runtime.ts +742 -85
- package/src/gjc-runtime/state-runtime.ts +2 -1
- package/src/gjc-runtime/state-writer.ts +70 -222
- package/src/gjc-runtime/team-launch.ts +34 -5
- package/src/gjc-runtime/team-runtime.ts +970 -33
- package/src/gjc-runtime/team-store.ts +32 -0
- package/src/gjc-runtime/team-worker-memory-guard.ts +363 -0
- package/src/gjc-runtime/team-workers.ts +1 -0
- package/src/gjc-runtime/tmux-owner-isolation.ts +18 -0
- package/src/gjc-runtime/ultragoal-receipt-freshness.ts +20 -0
- package/src/gjc-runtime/ultragoal-runtime.ts +13 -7
- package/src/gjc-runtime/workflow-manifest.generated.json +97 -350
- package/src/gjc-runtime/workflow-manifest.ts +34 -179
- package/src/hooks/native-skill-hook.ts +17 -4
- package/src/hooks/skill-state.ts +1 -23
- package/src/internal-urls/docs-index.generated.ts +8 -9
- package/src/internal-urls/local-root-gc.ts +127 -0
- package/src/main.ts +9 -5
- package/src/memories/index.ts +10 -0
- package/src/modes/DESIGN.md +47 -0
- package/src/modes/acp/acp-agent.ts +43 -7
- package/src/modes/acp/acp-event-mapper.ts +14 -7
- package/src/modes/acp/acp-mode.ts +39 -3
- package/src/modes/components/assistant-message.ts +123 -22
- package/src/modes/components/irc-sidebar.ts +176 -62
- package/src/modes/components/model-selector.ts +61 -4
- package/src/modes/components/oauth-selector.ts +42 -12
- package/src/modes/components/read-tool-group.ts +82 -14
- package/src/modes/components/session-observer-overlay.ts +187 -32
- package/src/modes/components/settings-selector.ts +60 -18
- package/src/modes/components/tool-execution.ts +138 -27
- package/src/modes/controllers/event-controller.ts +109 -27
- package/src/modes/controllers/extension-ui-controller.ts +19 -2
- package/src/modes/controllers/input-controller.ts +18 -3
- package/src/modes/controllers/selector-controller.ts +83 -37
- package/src/modes/interactive-mode.ts +62 -3
- package/src/modes/irc-observation-ledger.ts +71 -15
- package/src/modes/runtime-init.ts +19 -2
- package/src/modes/types.ts +2 -0
- package/src/modes/utils/ui-helpers.ts +94 -1
- package/src/prompts/agents/architect.md +9 -1
- package/src/prompts/agents/critic.md +9 -0
- package/src/prompts/system/system-prompt.md +0 -1
- package/src/prompts/tools/read.md +4 -2
- package/src/runtime-mcp/smithery-auth.ts +17 -2
- package/src/runtime-mcp/smithery-connect.ts +11 -1
- package/src/sdk/broker/lifecycle.ts +25 -6
- package/src/sdk/bus/control-drain-lease.ts +104 -0
- package/src/sdk/bus/index.ts +341 -38
- package/src/sdk/bus/kind-aware-reconciliation.ts +242 -0
- package/src/sdk/bus/prompt-reconciliation.ts +2 -1
- package/src/sdk/bus/reconciliation-store.ts +224 -0
- package/src/sdk/host/control/dispatch.ts +5 -1
- package/src/sdk/host/control/operations.ts +1 -1
- package/src/sdk/host/host.ts +23 -1
- package/src/sdk/host/query/handlers.ts +55 -0
- package/src/sdk/mcp/server.ts +46 -18
- package/src/sdk/protocol/operation-inventory.generated.json +29 -0
- package/src/sdk/protocol/operation-registry.ts +7 -2
- package/src/sdk/session.ts +13 -1
- package/src/session/agent-session.ts +466 -50
- package/src/session/memory-guard-checkpoint-participant.ts +131 -0
- package/src/session/session-manager.ts +764 -17
- package/src/session/streaming-output.ts +262 -43
- package/src/setup/provider-onboarding.ts +19 -4
- package/src/skill-state/active-state.ts +0 -10
- package/src/skill-state/workflow-hud.ts +25 -2
- package/src/skill-state/workflow-mutation-guard.ts +65 -7
- package/src/tools/ask.ts +89 -69
- package/src/tools/browser/launch.ts +41 -6
- package/src/tools/fetch.ts +114 -23
- package/src/tools/output-meta.ts +176 -9
- package/src/tools/path-utils.ts +5 -1
- package/src/tools/read-internals.ts +44 -0
- package/src/tools/read.ts +1542 -310
- package/src/tools/resource-gc.ts +182 -18
- package/src/tools/tool-result.ts +14 -1
- package/src/web/search/providers/codex.ts +1 -1
- package/dist/types/gjc-runtime/deep-interview-draft.d.ts +0 -8
- package/dist/types/gjc-runtime/deep-interview-payload.d.ts +0 -41
- package/dist/types/gjc-runtime/deep-interview-repair.d.ts +0 -17
- package/src/gjc-runtime/deep-interview-draft.ts +0 -843
- package/src/gjc-runtime/deep-interview-payload.ts +0 -262
- package/src/gjc-runtime/deep-interview-repair.ts +0 -1674
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentMessage } from "@gajae-code/agent-core";
|
|
2
2
|
import type { AssistantMessage, ImageContent, Message } from "@gajae-code/ai";
|
|
3
|
-
import { type Component, Spacer, Text, TruncatedText, type TUI, truncateToWidth } from "@gajae-code/tui";
|
|
3
|
+
import { type Component, Loader, Spacer, Text, TruncatedText, type TUI, truncateToWidth } from "@gajae-code/tui";
|
|
4
4
|
import { settings } from "../../config/settings";
|
|
5
5
|
import { resolveSubskillActivationForSkillInvocation } from "../../extensibility/gjc-plugins";
|
|
6
6
|
import { buildSkillPromptMessage, parseSkillInvocations } from "../../extensibility/skills";
|
|
@@ -85,6 +85,99 @@ export function prepareTranscriptRebuild(ui: TUI, policy: TranscriptRebuildPolic
|
|
|
85
85
|
if (policy === "replace-identity") ui.resetViewportAnchorIntent();
|
|
86
86
|
else ui.prepareViewportAnchorForTranscriptRebuild();
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
export const RESUME_PROGRESS_COMMIT_TIMEOUT_MS = 250;
|
|
90
|
+
|
|
91
|
+
export interface ResumeProgressLease {
|
|
92
|
+
readonly committed: Promise<boolean>;
|
|
93
|
+
clear(): void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Mount a resume loader on the live status rail and wait for its render generation
|
|
98
|
+
* to commit before session I/O begins. The commit is advisory: a stopped or
|
|
99
|
+
* unavailable terminal resolves false and callers continue without blocking.
|
|
100
|
+
*
|
|
101
|
+
* Fail open (no-op lease, committed=false) when the status rail or UI lacks the
|
|
102
|
+
* child-mutation/render-commit surface required to mount progress. Headless and
|
|
103
|
+
* minimal controller contexts keep resume/migration semantics; full interactive
|
|
104
|
+
* TUI containers retain progress-before-switch.
|
|
105
|
+
*/
|
|
106
|
+
export function acquireResumeProgressLease(
|
|
107
|
+
ctx: Pick<InteractiveModeContext, "ui" | "statusContainer">,
|
|
108
|
+
): ResumeProgressLease {
|
|
109
|
+
if (!canMountResumeProgressLease(ctx)) {
|
|
110
|
+
return {
|
|
111
|
+
committed: Promise.resolve(false),
|
|
112
|
+
clear(): void {},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const statusContainer = ctx.statusContainer as ResumeProgressStatusSurface;
|
|
117
|
+
const ui = ctx.ui as ResumeProgressUiSurface;
|
|
118
|
+
const loader = new Loader(
|
|
119
|
+
ui,
|
|
120
|
+
spinner => theme?.fg?.("accent", spinner) ?? spinner,
|
|
121
|
+
message => theme?.fg?.("muted", message) ?? message,
|
|
122
|
+
"Resuming session…",
|
|
123
|
+
);
|
|
124
|
+
statusContainer.addChild(loader);
|
|
125
|
+
const generation = ui.requestRenderWithGeneration(false, "resume-progress");
|
|
126
|
+
let active = true;
|
|
127
|
+
const committed = ui.waitForRenderCommit(generation, RESUME_PROGRESS_COMMIT_TIMEOUT_MS).catch(() => false);
|
|
128
|
+
return {
|
|
129
|
+
committed,
|
|
130
|
+
clear(): void {
|
|
131
|
+
if (!active) return;
|
|
132
|
+
active = false;
|
|
133
|
+
if (statusContainer.children.includes(loader)) statusContainer.removeChild(loader);
|
|
134
|
+
else loader.stop();
|
|
135
|
+
ui.requestRender(false, "resume-progress-clear");
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type ResumeProgressStatusSurface = {
|
|
141
|
+
addChild: (child: Component) => void;
|
|
142
|
+
removeChild: (child: Component) => void;
|
|
143
|
+
children: Component[];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
type ResumeProgressUiSurface = InteractiveModeContext["ui"] & {
|
|
147
|
+
requestRenderWithGeneration: (force?: boolean, source?: string) => number;
|
|
148
|
+
waitForRenderCommit: (generation: number, timeoutMs?: number) => Promise<boolean>;
|
|
149
|
+
requestRender: (force?: boolean, source?: string) => void;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
function canMountResumeProgressLease(ctx: Pick<InteractiveModeContext, "ui" | "statusContainer">): boolean {
|
|
153
|
+
const status = ctx.statusContainer as
|
|
154
|
+
| Partial<{
|
|
155
|
+
addChild: unknown;
|
|
156
|
+
removeChild: unknown;
|
|
157
|
+
children: unknown;
|
|
158
|
+
}>
|
|
159
|
+
| null
|
|
160
|
+
| undefined;
|
|
161
|
+
const ui = ctx.ui as
|
|
162
|
+
| Partial<{
|
|
163
|
+
requestRenderWithGeneration: unknown;
|
|
164
|
+
waitForRenderCommit: unknown;
|
|
165
|
+
requestRender: unknown;
|
|
166
|
+
}>
|
|
167
|
+
| null
|
|
168
|
+
| undefined;
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
!!status &&
|
|
172
|
+
typeof status.addChild === "function" &&
|
|
173
|
+
typeof status.removeChild === "function" &&
|
|
174
|
+
Array.isArray(status.children) &&
|
|
175
|
+
!!ui &&
|
|
176
|
+
typeof ui.requestRenderWithGeneration === "function" &&
|
|
177
|
+
typeof ui.waitForRenderCommit === "function" &&
|
|
178
|
+
typeof ui.requestRender === "function"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
88
181
|
type TextBlock = { type: "text"; text: string };
|
|
89
182
|
interface RenderInitialMessagesOptions {
|
|
90
183
|
preserveExistingChat?: boolean;
|
|
@@ -37,11 +37,19 @@ You may receive a forked parent-conversation snapshot as background. Your read-o
|
|
|
37
37
|
{{restrictedBash}}
|
|
38
38
|
- Never approve code or plans you have not grounded in inspected files.
|
|
39
39
|
- Never give generic advice detached from this codebase.
|
|
40
|
-
- Never approve CRITICAL or HIGH severity issues.
|
|
40
|
+
- Never approve carryover CRITICAL or HIGH severity issues (raised in a prior pass and still unresolved). A fresh CRITICAL/HIGH minted from pass 2 on previously-approved ground blocks only with an explicit why-not-visible-earlier justification (rule 2); without that justification, record it as a non-blocking caveat with its severity noted. On pass 1 every CRITICAL/HIGH blocks.
|
|
41
41
|
- Do not skip spec compliance to jump to style nitpicks.
|
|
42
42
|
- Be constructive: explain why an issue matters and how to fix it or strengthen the design.
|
|
43
43
|
</constraints>
|
|
44
44
|
|
|
45
|
+
<re_review_ratchet>
|
|
46
|
+
- Rule 1 (delta-only): from pass 2, review only the delta against the prior pass plus the resolution of previously raised findings; do not re-litigate previously-approved ground. The prior pass is identified by the re-review context bundle: prior reviewed-plan path, prior same-lane review path, and the explicit run-level pass number supplied in the assignment.
|
|
47
|
+
- Rule 2 (novelty justification): a new blocker on previously-reviewed ground requires an explicit "why this was not visible in the prior pass" justification (e.g. revealed by a fix, new file evidence); without it, demote to a non-blocking caveat.
|
|
48
|
+
- Rule 3 (verdict monotonicity): once all blockers from the prior pass are resolved, neither Architectural Status (`CLEAR`/`WATCH`/`BLOCK`) nor Code Review Recommendation (`APPROVE`/`COMMENT`/`REQUEST CHANGES`) may worsen absent a rule-2-justified new blocker.
|
|
49
|
+
- Rule 4 (severity discipline): carryover CRITICAL or HIGH severity issues (raised in a prior pass and still unresolved) remain blocking regardless of pass number. A fresh CRITICAL/HIGH minted from pass 2 on previously-approved ground blocks only with an explicit why-not-visible-earlier justification (rule 2); without that justification, record it as a non-blocking caveat with its severity noted. On pass 1 every CRITICAL/HIGH blocks.
|
|
50
|
+
- Rule 5 (counter-review awareness): From pass 2 your output is counter-reviewed by Critic for over-engineering and unnecessary scope expansion; unjustified scope inflation is flagged as a review defect and does not force revision passes. On pass 2+, do not broaden scope, add options, or demand synthesis beyond what resolves prior findings; constructive synthesis (Stage 3) stays full-strength on pass 1 only.
|
|
51
|
+
</re_review_ratchet>
|
|
52
|
+
|
|
45
53
|
<review_stages>
|
|
46
54
|
1. Understand the request, spec, plan, or diff.
|
|
47
55
|
2. Gather file-backed evidence.
|
|
@@ -32,6 +32,15 @@ Review plan clarity, completeness, verification, big-picture fit, referenced fil
|
|
|
32
32
|
- For consensus planning, reject shallow alternatives, driver contradictions, vague risks, weak verification, missing acceptance criteria, or under-specified areas needing expansion before execution.
|
|
33
33
|
</constraints>
|
|
34
34
|
|
|
35
|
+
<re_review_ratchet>
|
|
36
|
+
- Rule 1 (delta-only): from pass 2, review only the delta against the prior pass plus the resolution of previously raised findings; do not re-litigate previously-approved ground. The prior pass is identified by the re-review context bundle (WI-3): prior reviewed-plan path, prior same-lane review path, and the explicit run-level pass number supplied in the assignment.
|
|
37
|
+
- Rule 2 (novelty justification): a new blocker on previously-reviewed ground requires an explicit "why this was not visible in the prior pass" justification (e.g. revealed by a fix, new file evidence); without it, demote to a non-blocking caveat.
|
|
38
|
+
- Rule 3 (verdict monotonicity): once all blockers from the prior pass are resolved, the verdict must not worsen (e.g. ITERATE -> REJECT) absent a rule-2-justified new blocker.
|
|
39
|
+
- Rule 4 (severity discipline): carryover blockers (raised in a prior pass, still unresolved) remain blocking regardless of pass number. A fresh high-severity concern minted from pass 2 on previously-approved ground follows rule 2: it blocks only with the why-not-visible-earlier justification, else it is recorded as a non-blocking caveat with severity noted.
|
|
40
|
+
- Rule 5 (counter-review duty): from pass 2, Critic also reviews the Architect output (routed via the context bundle) for over-engineering and unnecessary scope expansion; flag inflation as a review defect and do NOT convert unjustified Architect demands into ITERATE — inflating demands must not force revision passes.
|
|
41
|
+
- Enrichment lane ("spec too thin — expand") preserved verbatim but justification-gated from pass 2: expansion requests on already-reviewed ground need the rule-2 justification.
|
|
42
|
+
</re_review_ratchet>
|
|
43
|
+
|
|
35
44
|
<execution_loop>
|
|
36
45
|
1. Read the plan and referenced artifacts.
|
|
37
46
|
2. Extract and verify file references.
|
|
@@ -24,7 +24,6 @@ Optimize for correctness first, maintainability second, and brevity third. Prefe
|
|
|
24
24
|
- Informational questions are answer-only/read-only unless the user explicitly requests a change, command, or execution.
|
|
25
25
|
- Vague requirements use `/skill:deep-interview`: a requirements-only workflow that must not mutate product code. Its spec hands off as deep-interview → ralplan consensus → pending approval → separately approved execution.
|
|
26
26
|
- Clear work with non-trivial architecture or sequencing risk uses `/skill:ralplan --deliberate` and stops pending approval.
|
|
27
|
-
- Deep-interview state is runtime-owned: diagnose with `gjc deep-interview sanity-check`, inspect only the affected bounded selector, and repair through typed operations using CLI-generated/edited drafts (`draft create|edit|show|check|rebase|discard`) consumed with `--draft-id`. Inline JSON request flags are compatibility-only; normal flow must never reconstruct a payload or full envelope.
|
|
28
27
|
- Use `/skill:ultragoal` for durable goal ledgers and `/skill:team` for approved coordinated persistent work.
|
|
29
28
|
- Delegate large implementation slices to `executor`; use `planner`, `architect`, or `critic` for bounded planning and review.
|
|
30
29
|
- Active skills are authoritative: never ignore an invoked skill; read the full skill text and follow it exactly.
|
|
@@ -9,12 +9,13 @@ Read files, directories, archives, SQLite databases, images, documents, internal
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
- `path` — required. Local path, internal URI (`agent://`, `artifact://`, `rule://`, `local://`), or URL. Append `:<sel>` for line ranges, raw mode, or special modes (e.g. `src/foo.ts:50-200`, `src/foo.ts:raw`, `db.sqlite:users:42`).
|
|
12
|
+
- `truncation` — optional `head` | `last` | `both`; selects which end of an over-budget result to retain. Configured default: {{TRUNCATION_DEFAULT}} (factory default: `last`); non-file routes such as URLs, directories and converted documents default to `head`. A line-range selector still bounds the selection — this only picks which end of that selection survives the byte/line cap. SQLite row queries page via their own `limit`/`offset` and ignore it.
|
|
12
13
|
|
|
13
|
-
## Selectors
|
|
14
14
|
|
|
15
|
+
## Selectors
|
|
15
16
|
Append `:<sel>` to `path`. The bare path falls back to the default mode.
|
|
16
17
|
|
|
17
|
-
- _(none)_ — parseable code → structural summary (signatures kept, bodies elided);
|
|
18
|
+
- _(none)_ — parseable code → structural summary (signatures kept, bodies elided); a plain text file → a bounded receipt of about {{RECEIPT_LINES}} lines or {{RECEIPT_KIB}} KiB, whichever is smaller; the configured truncation direction is {{TRUNCATION_DEFAULT}} (factory default: last). Line+hash anchors keep their real file line numbers and a footer names the omitted range. Archive members use the larger {{DEFAULT_MAX_LINES}}-line / 50 KiB budget. Converted documents, notebooks, URLs and directory listings still start from the beginning.
|
|
18
19
|
- `:50` / `:50-` — read from line 50 onward.
|
|
19
20
|
- `:50-200` — lines 50–200 inclusive.
|
|
20
21
|
- `:50+150` — 150 lines starting at line 50.
|
|
@@ -39,6 +40,7 @@ Append `:<sel>` to `path`. The bare path falls back to the default mode.
|
|
|
39
40
|
`[NN lines across MM elided regions; read <path>:raw or a line range like <path>:1-9999 for verbatim content]`
|
|
40
41
|
|
|
41
42
|
If the elided body is what you actually need, re-issue the **exact selector the footer names**. NEVER guess what's inside `..` / `…` — those markers carry no content.
|
|
43
|
+
- Directional windows identify the retained first/last lines and the omitted range; use the `re-read <path>:1-<total>` or `:raw` hint in the footer to recover the full content.
|
|
42
44
|
|
|
43
45
|
# Documents & Notebooks
|
|
44
46
|
|
|
@@ -2,9 +2,18 @@ import * as fs from "node:fs/promises";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { isEnoent, logger } from "@gajae-code/utils";
|
|
4
4
|
import { getAgentDir } from "@gajae-code/utils/dirs";
|
|
5
|
+
import { $credentialEnv } from "@gajae-code/utils/env";
|
|
5
6
|
|
|
6
7
|
const SMITHERY_AUTH_FILENAME = "smithery.json";
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Smithery web origin, from trusted environment sources only.
|
|
10
|
+
*
|
|
11
|
+
* This origin serves the CLI auth session and the verification URL the user is
|
|
12
|
+
* sent to, so whatever can set it can drive the login flow. `$env` merges the
|
|
13
|
+
* caller's `cwd/.env` into `process.env`, so reading it there would let
|
|
14
|
+
* repository content redirect that flow.
|
|
15
|
+
*/
|
|
16
|
+
const SMITHERY_URL = $credentialEnv("SMITHERY_URL") || "https://smithery.ai";
|
|
8
17
|
|
|
9
18
|
type SmitheryCliAuthSession = {
|
|
10
19
|
sessionId: string;
|
|
@@ -31,6 +40,11 @@ function normalizeApiKey(value: string | undefined): string | undefined {
|
|
|
31
40
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
32
41
|
}
|
|
33
42
|
|
|
43
|
+
/** Test seam: the Smithery origin and env API key as resolved from trusted env. */
|
|
44
|
+
export function resolveSmitheryEnvForTest(): { url: string; apiKey: string | undefined } {
|
|
45
|
+
return { url: SMITHERY_URL, apiKey: normalizeApiKey($credentialEnv("SMITHERY_API_KEY")) };
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
export function getSmitheryLoginUrl(): string {
|
|
35
49
|
return SMITHERY_URL;
|
|
36
50
|
}
|
|
@@ -62,7 +76,8 @@ export async function pollSmitheryCliAuthSession(
|
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
export async function getSmitheryApiKey(): Promise<string | undefined> {
|
|
65
|
-
|
|
79
|
+
// Trusted sources only: this key authenticates every Smithery API call.
|
|
80
|
+
const envKey = normalizeApiKey($credentialEnv("SMITHERY_API_KEY"));
|
|
66
81
|
if (envKey) return envKey;
|
|
67
82
|
|
|
68
83
|
const authPath = getSmitheryAuthPath();
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { $credentialEnv } from "@gajae-code/utils/env";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Smithery API base, from trusted environment sources only.
|
|
5
|
+
*
|
|
6
|
+
* Every request to this base carries `Authorization: Bearer <apiKey>` and the
|
|
7
|
+
* `/connect` routes return the connection records the agent consumes, so
|
|
8
|
+
* whatever can set it receives the key and supplies those records. `$env` merges
|
|
9
|
+
* the caller's `cwd/.env` into `process.env`.
|
|
10
|
+
*/
|
|
11
|
+
const SMITHERY_API_BASE_URL = ($credentialEnv("SMITHERY_API_URL") || "https://api.smithery.ai").replace(/\/+$/, "");
|
|
2
12
|
|
|
3
13
|
export class SmitheryConnectError extends Error {
|
|
4
14
|
status: number;
|
|
@@ -5,7 +5,7 @@ import * as fs from "node:fs/promises";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import type { NativeExactUnlinkResult } from "@gajae-code/natives";
|
|
7
7
|
import * as native from "@gajae-code/natives";
|
|
8
|
-
import { resolveEquivalentPath } from "@gajae-code/utils";
|
|
8
|
+
import { $credentialEnv, resolveEquivalentPath } from "@gajae-code/utils";
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
isModelProfileError,
|
|
@@ -706,12 +706,31 @@ async function reconcileReadyScope(broker: Broker, id: string, scope: string | u
|
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
|
|
709
|
+
/**
|
|
710
|
+
* Operator override for the session-host command, resolved from trusted
|
|
711
|
+
* environment sources only.
|
|
712
|
+
*
|
|
713
|
+
* The result is spawned directly, so whatever can set it chooses which binary
|
|
714
|
+
* the broker runs. `$env` merges the caller's `cwd/.env` into `process.env`, so
|
|
715
|
+
* reading it there would let repository content replace the session host;
|
|
716
|
+
* resolve it the same way provider credentials are (launching shell plus
|
|
717
|
+
* GJC/user-owned `.env` files, never the project `.env`).
|
|
718
|
+
*/
|
|
719
|
+
function sdkSessionCommandOverride(): { file: string; args: string[] } | undefined {
|
|
720
|
+
const configured = $credentialEnv("GJC_SDK_SESSION_COMMAND");
|
|
721
|
+
if (!configured) return undefined;
|
|
722
|
+
const [file, ...args] = configured.trim().split(/\s+/);
|
|
723
|
+
return file ? { file, args } : undefined;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/** Test seam: the session-host command override as resolved from trusted env. */
|
|
727
|
+
export function sdkSessionCommandOverrideForTest(): { file: string; args: string[] } | undefined {
|
|
728
|
+
return sdkSessionCommandOverride();
|
|
729
|
+
}
|
|
730
|
+
|
|
709
731
|
function command(broker: Broker): LifecycleCommand {
|
|
710
|
-
const configured =
|
|
711
|
-
if (configured)
|
|
712
|
-
const [file, ...args] = configured.trim().split(/\s+/);
|
|
713
|
-
if (file) return { file, args };
|
|
714
|
-
}
|
|
732
|
+
const configured = sdkSessionCommandOverride();
|
|
733
|
+
if (configured) return configured;
|
|
715
734
|
return lifecycleCommandResolversForTest.get(broker)?.() ?? resolveSdkInternalSpawnCommand("session-host-internal");
|
|
716
735
|
}
|
|
717
736
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordering seam for an in-band SDK identity transition.
|
|
3
|
+
*
|
|
4
|
+
* A request arrives through predecessor A, so a successful terminal response cannot
|
|
5
|
+
* be published until successor B is ready. Native builds may provide a true
|
|
6
|
+
* send-only connection lease; source/dev builds use the conservative fallback in
|
|
7
|
+
* which the predecessor server remains alive until the terminal write completes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type TerminalSendOutcome = "written" | "disconnected" | "write_failed";
|
|
11
|
+
|
|
12
|
+
/** Fence/capability hooks may return false to reject; undefined means ok. */
|
|
13
|
+
export type IdentityControlGateResult = boolean | undefined;
|
|
14
|
+
export type IdentityControlGate = () => IdentityControlGateResult | Promise<IdentityControlGateResult>;
|
|
15
|
+
|
|
16
|
+
export interface IdentityControlSuccessPathInput {
|
|
17
|
+
/** Fence predecessor inbound work. The fence must not close its response writer. */
|
|
18
|
+
fence: IdentityControlGate;
|
|
19
|
+
/** Optional explicit proof that the predecessor writer is still usable. */
|
|
20
|
+
ensurePredecessorSendCapable?: IdentityControlGate;
|
|
21
|
+
/** Start successor B and resolve only after its public endpoint is ready. */
|
|
22
|
+
startSuccessor: () => Promise<void>;
|
|
23
|
+
/** Write and flush either the success or non-success terminal response. */
|
|
24
|
+
sendTerminal: () => Promise<TerminalSendOutcome>;
|
|
25
|
+
/** Release predecessor A after the terminal response has settled. */
|
|
26
|
+
stopPredecessor: () => Promise<void>;
|
|
27
|
+
/** Set only when a caller cannot use the retained-writer fallback. */
|
|
28
|
+
requireNativeControlDrain?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface IdentityControlTerminalPathInput {
|
|
32
|
+
fenceInbound: IdentityControlGate;
|
|
33
|
+
ensurePredecessorSendCapable?: IdentityControlGate;
|
|
34
|
+
startSuccessorReady: () => Promise<void>;
|
|
35
|
+
sendTerminal: () => Promise<TerminalSendOutcome>;
|
|
36
|
+
stopPredecessor: () => Promise<void>;
|
|
37
|
+
requireNativeControlDrain?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Probe the loaded native addon, never an environment flag or a TypeScript shim.
|
|
42
|
+
* Older/source installs intentionally report false so callers can select the
|
|
43
|
+
* retained-writer fallback or fail closed when detach is mandatory.
|
|
44
|
+
*/
|
|
45
|
+
export function isNativeControlDrainAvailable(): boolean {
|
|
46
|
+
try {
|
|
47
|
+
// Keep the addon lazy: importing the bus must continue to work without a
|
|
48
|
+
// compiled native artifact (tests and source distributions do that often).
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
50
|
+
const natives = require("@gajae-code/natives") as {
|
|
51
|
+
NotificationServer?: {
|
|
52
|
+
prototype?: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const prototype = natives.NotificationServer?.prototype;
|
|
56
|
+
return (
|
|
57
|
+
typeof prototype?.acquireControlDrain === "function" &&
|
|
58
|
+
typeof prototype?.sendTerminalAndWait === "function" &&
|
|
59
|
+
typeof prototype?.closeControlDrain === "function"
|
|
60
|
+
);
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Run the only safe ordering for a successful identity-control response.
|
|
68
|
+
*
|
|
69
|
+
* The `finally` is deliberately around both successor startup and terminal
|
|
70
|
+
* delivery: a failed startup must not leave the fenced predecessor alive, and a
|
|
71
|
+
* failed/disconnected terminal write must still release it. When native detach
|
|
72
|
+
* is unavailable the caller is expected to keep A's server up (not call
|
|
73
|
+
* `stopAndWait`) until `sendTerminal` settles.
|
|
74
|
+
*/
|
|
75
|
+
export async function runIdentityControlSuccessPath(
|
|
76
|
+
input: IdentityControlSuccessPathInput,
|
|
77
|
+
): Promise<TerminalSendOutcome> {
|
|
78
|
+
if (input.requireNativeControlDrain && !isNativeControlDrainAvailable())
|
|
79
|
+
throw new Error("SDK identity control requires the native control-drain lease.");
|
|
80
|
+
|
|
81
|
+
if ((await input.fence()) === false) throw new Error("SDK identity control predecessor fence was not acquired.");
|
|
82
|
+
if ((await input.ensurePredecessorSendCapable?.()) === false)
|
|
83
|
+
throw new Error("SDK identity control predecessor writer is not send-capable.");
|
|
84
|
+
try {
|
|
85
|
+
await input.startSuccessor();
|
|
86
|
+
return await input.sendTerminal();
|
|
87
|
+
} finally {
|
|
88
|
+
await input.stopPredecessor();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Compatibility spelling used by the host wiring design notes. */
|
|
93
|
+
export async function runIdentityControlTerminalPath(
|
|
94
|
+
input: IdentityControlTerminalPathInput,
|
|
95
|
+
): Promise<TerminalSendOutcome> {
|
|
96
|
+
return runIdentityControlSuccessPath({
|
|
97
|
+
fence: input.fenceInbound,
|
|
98
|
+
ensurePredecessorSendCapable: input.ensurePredecessorSendCapable,
|
|
99
|
+
startSuccessor: input.startSuccessorReady,
|
|
100
|
+
sendTerminal: input.sendTerminal,
|
|
101
|
+
stopPredecessor: input.stopPredecessor,
|
|
102
|
+
requireNativeControlDrain: input.requireNativeControlDrain,
|
|
103
|
+
});
|
|
104
|
+
}
|