@gajae-code/coding-agent 0.2.4 → 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.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/dist/types/async/job-manager.d.ts +145 -2
- package/dist/types/commands/harness.d.ts +37 -0
- package/dist/types/config/settings-schema.d.ts +13 -3
- package/dist/types/config/settings.d.ts +3 -1
- package/dist/types/deep-interview/render-middleware.d.ts +5 -0
- package/dist/types/discovery/helpers.d.ts +1 -0
- package/dist/types/exec/bash-executor.d.ts +8 -1
- package/dist/types/extensibility/custom-tools/types.d.ts +1 -0
- package/dist/types/extensibility/extensions/types.d.ts +6 -0
- package/dist/types/extensibility/shared-events.d.ts +1 -0
- package/dist/types/gjc-runtime/restricted-role-agent-bash.d.ts +2 -0
- package/dist/types/gjc-runtime/state-graph.d.ts +4 -0
- package/dist/types/gjc-runtime/state-migrations.d.ts +24 -0
- package/dist/types/gjc-runtime/state-renderer.d.ts +65 -0
- package/dist/types/gjc-runtime/state-runtime.d.ts +2 -0
- package/dist/types/gjc-runtime/state-validation.d.ts +6 -0
- package/dist/types/gjc-runtime/state-writer.d.ts +137 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +81 -7
- package/dist/types/gjc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +30 -0
- package/dist/types/harness-control-plane/finalize.d.ts +47 -0
- package/dist/types/harness-control-plane/frame-mapper.d.ts +29 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +46 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipts.d.ts +88 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +19 -0
- package/dist/types/harness-control-plane/storage.d.ts +53 -0
- package/dist/types/harness-control-plane/types.d.ts +162 -0
- package/dist/types/hooks/skill-keywords.d.ts +2 -1
- package/dist/types/hooks/skill-state.d.ts +2 -29
- package/dist/types/modes/acp/acp-client-bridge.d.ts +1 -1
- package/dist/types/modes/components/hook-selector.d.ts +1 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +1 -1
- package/dist/types/modes/interactive-mode.d.ts +2 -0
- package/dist/types/modes/theme/defaults/index.d.ts +45 -9477
- package/dist/types/modes/theme/theme.d.ts +1 -5
- package/dist/types/modes/types.d.ts +2 -0
- package/dist/types/sdk.d.ts +4 -0
- package/dist/types/session/agent-session.d.ts +8 -0
- package/dist/types/session/streaming-output.d.ts +11 -0
- package/dist/types/skill-state/active-state.d.ts +3 -0
- package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +1 -1
- package/dist/types/skill-state/workflow-state-contract.d.ts +24 -0
- package/dist/types/task/executor.d.ts +3 -0
- package/dist/types/task/types.d.ts +56 -3
- package/dist/types/tools/bash-allowed-prefixes.d.ts +5 -0
- package/dist/types/tools/bash.d.ts +24 -0
- package/dist/types/tools/cron.d.ts +110 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/dist/types/tools/monitor.d.ts +54 -0
- package/dist/types/tools/subagent.d.ts +11 -1
- package/dist/types/web/search/index.d.ts +1 -0
- package/dist/types/web/search/provider.d.ts +11 -4
- package/dist/types/web/search/providers/duckduckgo.d.ts +57 -0
- package/dist/types/web/search/types.d.ts +1 -1
- package/package.json +7 -7
- package/src/async/job-manager.ts +522 -6
- package/src/cli/agents-cli.ts +3 -0
- package/src/cli/auth-broker-cli.ts +1 -0
- package/src/cli/config-cli.ts +10 -2
- package/src/cli.ts +2 -0
- package/src/commands/harness.ts +592 -0
- package/src/commands/team.ts +36 -39
- package/src/config/settings-schema.ts +15 -2
- package/src/config/settings.ts +49 -7
- package/src/deep-interview/render-middleware.ts +366 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +9 -2
- package/src/defaults/gjc/skills/ralplan/SKILL.md +8 -4
- package/src/defaults/gjc/skills/team/SKILL.md +47 -21
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +78 -11
- package/src/discovery/helpers.ts +5 -0
- package/src/eval/js/shared/rewrite-imports.ts +1 -2
- package/src/exec/bash-executor.ts +20 -9
- package/src/extensibility/custom-tools/types.ts +1 -0
- package/src/extensibility/extensions/types.ts +6 -0
- package/src/extensibility/shared-events.ts +1 -0
- package/src/gjc-runtime/deep-interview-runtime.ts +40 -21
- package/src/gjc-runtime/goal-mode-request.ts +11 -3
- package/src/gjc-runtime/ralplan-runtime.ts +27 -10
- package/src/gjc-runtime/restricted-role-agent-bash.ts +5 -0
- package/src/gjc-runtime/state-graph.ts +86 -0
- package/src/gjc-runtime/state-migrations.ts +132 -0
- package/src/gjc-runtime/state-renderer.ts +345 -0
- package/src/gjc-runtime/state-runtime.ts +733 -21
- package/src/gjc-runtime/state-validation.ts +49 -0
- package/src/gjc-runtime/state-writer.ts +718 -0
- package/src/gjc-runtime/team-runtime.ts +1083 -89
- package/src/gjc-runtime/ultragoal-runtime.ts +348 -19
- package/src/gjc-runtime/workflow-manifest.generated.json +1497 -0
- package/src/gjc-runtime/workflow-manifest.ts +425 -0
- package/src/harness-control-plane/classifier.ts +128 -0
- package/src/harness-control-plane/control-endpoint.ts +137 -0
- package/src/harness-control-plane/finalize.ts +222 -0
- package/src/harness-control-plane/frame-mapper.ts +286 -0
- package/src/harness-control-plane/operate.ts +225 -0
- package/src/harness-control-plane/owner.ts +553 -0
- package/src/harness-control-plane/preserve.ts +102 -0
- package/src/harness-control-plane/receipts.ts +216 -0
- package/src/harness-control-plane/rpc-adapter.ts +276 -0
- package/src/harness-control-plane/seams.ts +39 -0
- package/src/harness-control-plane/session-lease.ts +388 -0
- package/src/harness-control-plane/state-machine.ts +97 -0
- package/src/harness-control-plane/storage.ts +257 -0
- package/src/harness-control-plane/types.ts +214 -0
- package/src/hooks/skill-keywords.ts +4 -2
- package/src/hooks/skill-state.ts +25 -42
- package/src/internal-urls/docs-index.generated.ts +6 -4
- package/src/lsp/render.ts +1 -1
- package/src/modes/acp/acp-agent.ts +1 -1
- package/src/modes/acp/acp-client-bridge.ts +1 -1
- package/src/modes/components/agent-dashboard.ts +1 -1
- package/src/modes/components/assistant-message.ts +5 -1
- package/src/modes/components/diff.ts +2 -2
- package/src/modes/components/hook-selector.ts +72 -2
- package/src/modes/components/skill-hud/render.ts +7 -2
- package/src/modes/controllers/event-controller.ts +71 -6
- package/src/modes/controllers/extension-ui-controller.ts +6 -0
- package/src/modes/controllers/input-controller.ts +19 -3
- package/src/modes/controllers/selector-controller.ts +3 -2
- package/src/modes/interactive-mode.ts +21 -2
- package/src/modes/theme/defaults/index.ts +0 -196
- package/src/modes/theme/theme.ts +35 -35
- package/src/modes/types.ts +2 -0
- package/src/prompts/agents/architect.md +5 -1
- package/src/prompts/agents/critic.md +5 -1
- package/src/prompts/agents/executor.md +13 -0
- package/src/prompts/agents/frontmatter.md +1 -0
- package/src/prompts/agents/planner.md +5 -1
- package/src/prompts/tools/bash.md +9 -0
- package/src/prompts/tools/cron.md +25 -0
- package/src/prompts/tools/monitor.md +30 -0
- package/src/prompts/tools/subagent.md +33 -3
- package/src/runtime-mcp/oauth-flow.ts +4 -2
- package/src/sdk.ts +7 -0
- package/src/session/agent-session.ts +247 -38
- package/src/session/session-manager.ts +13 -1
- package/src/session/streaming-output.ts +21 -0
- package/src/skill-state/active-state.ts +222 -78
- package/src/skill-state/deep-interview-mutation-guard.ts +91 -13
- package/src/skill-state/initial-phase.ts +2 -0
- package/src/skill-state/workflow-state-contract.ts +26 -0
- package/src/task/agents.ts +1 -0
- package/src/task/executor.ts +51 -8
- package/src/task/index.ts +120 -8
- package/src/task/render.ts +6 -3
- package/src/task/types.ts +57 -3
- package/src/tools/ask.ts +28 -7
- package/src/tools/bash-allowed-prefixes.ts +169 -0
- package/src/tools/bash.ts +190 -29
- package/src/tools/browser/tab-worker.ts +1 -1
- package/src/tools/cron.ts +665 -0
- package/src/tools/index.ts +20 -2
- package/src/tools/monitor.ts +136 -0
- package/src/tools/subagent.ts +255 -64
- package/src/vim/engine.ts +3 -3
- package/src/web/search/index.ts +31 -18
- package/src/web/search/provider.ts +57 -12
- package/src/web/search/providers/duckduckgo.ts +279 -0
- package/src/web/search/types.ts +2 -0
- package/src/modes/theme/dark.json +0 -95
- package/src/modes/theme/defaults/alabaster.json +0 -93
- package/src/modes/theme/defaults/amethyst.json +0 -96
- package/src/modes/theme/defaults/anthracite.json +0 -93
- package/src/modes/theme/defaults/basalt.json +0 -91
- package/src/modes/theme/defaults/birch.json +0 -95
- package/src/modes/theme/defaults/dark-abyss.json +0 -91
- package/src/modes/theme/defaults/dark-arctic.json +0 -104
- package/src/modes/theme/defaults/dark-aurora.json +0 -95
- package/src/modes/theme/defaults/dark-catppuccin.json +0 -107
- package/src/modes/theme/defaults/dark-cavern.json +0 -91
- package/src/modes/theme/defaults/dark-copper.json +0 -95
- package/src/modes/theme/defaults/dark-cosmos.json +0 -90
- package/src/modes/theme/defaults/dark-cyberpunk.json +0 -102
- package/src/modes/theme/defaults/dark-dracula.json +0 -98
- package/src/modes/theme/defaults/dark-eclipse.json +0 -91
- package/src/modes/theme/defaults/dark-ember.json +0 -95
- package/src/modes/theme/defaults/dark-equinox.json +0 -90
- package/src/modes/theme/defaults/dark-forest.json +0 -96
- package/src/modes/theme/defaults/dark-github.json +0 -105
- package/src/modes/theme/defaults/dark-gruvbox.json +0 -112
- package/src/modes/theme/defaults/dark-lavender.json +0 -95
- package/src/modes/theme/defaults/dark-lunar.json +0 -89
- package/src/modes/theme/defaults/dark-midnight.json +0 -95
- package/src/modes/theme/defaults/dark-monochrome.json +0 -94
- package/src/modes/theme/defaults/dark-monokai.json +0 -98
- package/src/modes/theme/defaults/dark-nebula.json +0 -90
- package/src/modes/theme/defaults/dark-nord.json +0 -97
- package/src/modes/theme/defaults/dark-ocean.json +0 -101
- package/src/modes/theme/defaults/dark-one.json +0 -100
- package/src/modes/theme/defaults/dark-poimandres.json +0 -141
- package/src/modes/theme/defaults/dark-rainforest.json +0 -91
- package/src/modes/theme/defaults/dark-reef.json +0 -91
- package/src/modes/theme/defaults/dark-retro.json +0 -92
- package/src/modes/theme/defaults/dark-rose-pine.json +0 -96
- package/src/modes/theme/defaults/dark-sakura.json +0 -95
- package/src/modes/theme/defaults/dark-slate.json +0 -95
- package/src/modes/theme/defaults/dark-solarized.json +0 -97
- package/src/modes/theme/defaults/dark-solstice.json +0 -90
- package/src/modes/theme/defaults/dark-starfall.json +0 -91
- package/src/modes/theme/defaults/dark-sunset.json +0 -99
- package/src/modes/theme/defaults/dark-swamp.json +0 -90
- package/src/modes/theme/defaults/dark-synthwave.json +0 -103
- package/src/modes/theme/defaults/dark-taiga.json +0 -91
- package/src/modes/theme/defaults/dark-terminal.json +0 -95
- package/src/modes/theme/defaults/dark-tokyo-night.json +0 -101
- package/src/modes/theme/defaults/dark-tundra.json +0 -91
- package/src/modes/theme/defaults/dark-twilight.json +0 -91
- package/src/modes/theme/defaults/dark-volcanic.json +0 -91
- package/src/modes/theme/defaults/graphite.json +0 -92
- package/src/modes/theme/defaults/light-arctic.json +0 -107
- package/src/modes/theme/defaults/light-aurora-day.json +0 -91
- package/src/modes/theme/defaults/light-canyon.json +0 -91
- package/src/modes/theme/defaults/light-catppuccin.json +0 -106
- package/src/modes/theme/defaults/light-cirrus.json +0 -90
- package/src/modes/theme/defaults/light-coral.json +0 -95
- package/src/modes/theme/defaults/light-cyberpunk.json +0 -96
- package/src/modes/theme/defaults/light-dawn.json +0 -90
- package/src/modes/theme/defaults/light-dunes.json +0 -91
- package/src/modes/theme/defaults/light-eucalyptus.json +0 -95
- package/src/modes/theme/defaults/light-forest.json +0 -100
- package/src/modes/theme/defaults/light-frost.json +0 -95
- package/src/modes/theme/defaults/light-github.json +0 -115
- package/src/modes/theme/defaults/light-glacier.json +0 -91
- package/src/modes/theme/defaults/light-gruvbox.json +0 -108
- package/src/modes/theme/defaults/light-haze.json +0 -90
- package/src/modes/theme/defaults/light-honeycomb.json +0 -95
- package/src/modes/theme/defaults/light-lagoon.json +0 -91
- package/src/modes/theme/defaults/light-lavender.json +0 -95
- package/src/modes/theme/defaults/light-meadow.json +0 -91
- package/src/modes/theme/defaults/light-mint.json +0 -95
- package/src/modes/theme/defaults/light-monochrome.json +0 -101
- package/src/modes/theme/defaults/light-ocean.json +0 -99
- package/src/modes/theme/defaults/light-one.json +0 -99
- package/src/modes/theme/defaults/light-opal.json +0 -91
- package/src/modes/theme/defaults/light-orchard.json +0 -91
- package/src/modes/theme/defaults/light-paper.json +0 -95
- package/src/modes/theme/defaults/light-poimandres.json +0 -141
- package/src/modes/theme/defaults/light-prism.json +0 -90
- package/src/modes/theme/defaults/light-retro.json +0 -98
- package/src/modes/theme/defaults/light-sand.json +0 -95
- package/src/modes/theme/defaults/light-savanna.json +0 -91
- package/src/modes/theme/defaults/light-solarized.json +0 -102
- package/src/modes/theme/defaults/light-soleil.json +0 -90
- package/src/modes/theme/defaults/light-sunset.json +0 -99
- package/src/modes/theme/defaults/light-synthwave.json +0 -98
- package/src/modes/theme/defaults/light-tokyo-night.json +0 -111
- package/src/modes/theme/defaults/light-wetland.json +0 -91
- package/src/modes/theme/defaults/light-zenith.json +0 -89
- package/src/modes/theme/defaults/limestone.json +0 -94
- package/src/modes/theme/defaults/mahogany.json +0 -97
- package/src/modes/theme/defaults/marble.json +0 -93
- package/src/modes/theme/defaults/obsidian.json +0 -91
- package/src/modes/theme/defaults/onyx.json +0 -91
- package/src/modes/theme/defaults/pearl.json +0 -93
- package/src/modes/theme/defaults/porcelain.json +0 -91
- package/src/modes/theme/defaults/quartz.json +0 -96
- package/src/modes/theme/defaults/sandstone.json +0 -95
- package/src/modes/theme/defaults/titanium.json +0 -90
- package/src/modes/theme/light.json +0 -93
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
|
|
2
|
+
import type { SkillManifest } from "./workflow-manifest";
|
|
3
|
+
|
|
4
|
+
function scalar(value: unknown): string | undefined {
|
|
5
|
+
if (typeof value === "string") return value.trim() || undefined;
|
|
6
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
11
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function stateObject(stateJson: Record<string, unknown>): Record<string, unknown> {
|
|
15
|
+
const nested = stateJson.state;
|
|
16
|
+
return isRecord(nested) ? nested : stateJson;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function receiptObject(state: Record<string, unknown>): Record<string, unknown> | undefined {
|
|
20
|
+
return isRecord(state.receipt) ? state.receipt : undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function artifactLinks(state: Record<string, unknown>): string[] {
|
|
24
|
+
const links = new Set<string>();
|
|
25
|
+
for (const key of [
|
|
26
|
+
"artifact",
|
|
27
|
+
"artifact_path",
|
|
28
|
+
"artifact_url",
|
|
29
|
+
"plan_path",
|
|
30
|
+
"spec_path",
|
|
31
|
+
"ledger_path",
|
|
32
|
+
"storage_path",
|
|
33
|
+
"state_path",
|
|
34
|
+
]) {
|
|
35
|
+
const value = scalar(state[key]);
|
|
36
|
+
if (value) links.add(value);
|
|
37
|
+
}
|
|
38
|
+
const artifacts = state.artifacts;
|
|
39
|
+
if (Array.isArray(artifacts)) {
|
|
40
|
+
for (const artifact of artifacts) {
|
|
41
|
+
const value = scalar(artifact);
|
|
42
|
+
if (value) links.add(value);
|
|
43
|
+
if (isRecord(artifact)) {
|
|
44
|
+
for (const key of ["path", "url", "href"]) {
|
|
45
|
+
const nested = scalar(artifact[key]);
|
|
46
|
+
if (nested) links.add(nested);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return [...links];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function keyStateFields(state: Record<string, unknown>, manifest: SkillManifest): Array<[string, string]> {
|
|
55
|
+
const keys = new Set<string>([
|
|
56
|
+
"active",
|
|
57
|
+
"current_phase",
|
|
58
|
+
"phase",
|
|
59
|
+
"status",
|
|
60
|
+
"updated_at",
|
|
61
|
+
"session_id",
|
|
62
|
+
...manifest.hudFields,
|
|
63
|
+
]);
|
|
64
|
+
const fields: Array<[string, string]> = [];
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
const value = scalar(state[key]);
|
|
67
|
+
if (value !== undefined) fields.push([key, value]);
|
|
68
|
+
if (fields.length >= 10) break;
|
|
69
|
+
}
|
|
70
|
+
return fields;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const COMPACT_ELIDE_KEYS = new Set([
|
|
74
|
+
"rounds",
|
|
75
|
+
"ontology_snapshots",
|
|
76
|
+
"architect_findings",
|
|
77
|
+
"new_requirements",
|
|
78
|
+
"ci_gates",
|
|
79
|
+
"research_findings",
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
export const STATE_FIELD_ALLOWLIST = [
|
|
83
|
+
"skill",
|
|
84
|
+
"phase",
|
|
85
|
+
"current_phase",
|
|
86
|
+
"next",
|
|
87
|
+
"active",
|
|
88
|
+
"status",
|
|
89
|
+
"fresh",
|
|
90
|
+
"fresh_until",
|
|
91
|
+
"receipt",
|
|
92
|
+
"artifact_path",
|
|
93
|
+
"plan_path",
|
|
94
|
+
"spec_path",
|
|
95
|
+
"run_id",
|
|
96
|
+
"stage",
|
|
97
|
+
"stage_n",
|
|
98
|
+
"session_id",
|
|
99
|
+
"updated_at",
|
|
100
|
+
"handoff_to",
|
|
101
|
+
"handoff_from",
|
|
102
|
+
"counts",
|
|
103
|
+
"hud",
|
|
104
|
+
] as const;
|
|
105
|
+
|
|
106
|
+
export type StateProjectionField = (typeof STATE_FIELD_ALLOWLIST)[number];
|
|
107
|
+
|
|
108
|
+
export interface StateStatusSummary {
|
|
109
|
+
skill: CanonicalGjcWorkflowSkill;
|
|
110
|
+
phase: string;
|
|
111
|
+
active: boolean;
|
|
112
|
+
fresh: boolean;
|
|
113
|
+
fresh_until?: string;
|
|
114
|
+
next: string[];
|
|
115
|
+
receipt_status: string;
|
|
116
|
+
storage_path: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function compactStateFields(state: Record<string, unknown>): Array<[string, string]> {
|
|
120
|
+
const fields: Array<[string, string]> = [];
|
|
121
|
+
for (const key of COMPACT_ELIDE_KEYS) {
|
|
122
|
+
const value = state[key];
|
|
123
|
+
if (Array.isArray(value)) fields.push([key, `${value.length} entries (elided)`]);
|
|
124
|
+
}
|
|
125
|
+
return fields;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function compactProjectStateJson(
|
|
129
|
+
skill: CanonicalGjcWorkflowSkill,
|
|
130
|
+
stateJson: Record<string, unknown>,
|
|
131
|
+
manifest: SkillManifest,
|
|
132
|
+
): Record<string, unknown> {
|
|
133
|
+
const state = stateObject(stateJson);
|
|
134
|
+
const compact = projectStateFields(skill, stateJson, manifest, STATE_FIELD_ALLOWLIST);
|
|
135
|
+
const elisions: Record<string, unknown> = {};
|
|
136
|
+
for (const key of COMPACT_ELIDE_KEYS) {
|
|
137
|
+
const value = state[key];
|
|
138
|
+
if (Array.isArray(value)) elisions[key] = { type: "array", count: value.length, pointer: `/${key}` };
|
|
139
|
+
}
|
|
140
|
+
if (Object.keys(elisions).length) compact.elided = elisions;
|
|
141
|
+
return compact;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function projectStateFields(
|
|
145
|
+
skill: CanonicalGjcWorkflowSkill,
|
|
146
|
+
stateJson: Record<string, unknown>,
|
|
147
|
+
manifest: SkillManifest,
|
|
148
|
+
fields: readonly StateProjectionField[],
|
|
149
|
+
): Record<string, unknown> {
|
|
150
|
+
const state = stateObject(stateJson);
|
|
151
|
+
const phase = scalar(state.current_phase) ?? scalar(state.phase) ?? manifest.initialState;
|
|
152
|
+
const receipt = receiptObject(state);
|
|
153
|
+
const freshUntil = receipt ? scalar(receipt.fresh_until) : undefined;
|
|
154
|
+
const projected: Record<string, unknown> = {};
|
|
155
|
+
for (const field of fields) {
|
|
156
|
+
switch (field) {
|
|
157
|
+
case "skill":
|
|
158
|
+
projected.skill = skill;
|
|
159
|
+
break;
|
|
160
|
+
case "phase":
|
|
161
|
+
case "current_phase":
|
|
162
|
+
projected[field] = phase;
|
|
163
|
+
break;
|
|
164
|
+
case "next":
|
|
165
|
+
projected.next = manifest.transitions
|
|
166
|
+
.filter(transition => transition.from === phase)
|
|
167
|
+
.map(transition => transition.to);
|
|
168
|
+
break;
|
|
169
|
+
case "fresh":
|
|
170
|
+
projected.fresh = freshUntil ? Date.parse(freshUntil) > Date.now() : false;
|
|
171
|
+
break;
|
|
172
|
+
case "fresh_until":
|
|
173
|
+
projected.fresh_until = freshUntil;
|
|
174
|
+
break;
|
|
175
|
+
case "receipt":
|
|
176
|
+
projected.receipt = receipt;
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
projected[field] = state[field];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return projected;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function buildStateStatusSummary(
|
|
186
|
+
skill: CanonicalGjcWorkflowSkill,
|
|
187
|
+
stateJson: Record<string, unknown>,
|
|
188
|
+
manifest: SkillManifest,
|
|
189
|
+
storagePath: string,
|
|
190
|
+
): StateStatusSummary {
|
|
191
|
+
const state = stateObject(stateJson);
|
|
192
|
+
const phase = scalar(state.current_phase) ?? scalar(state.phase) ?? manifest.initialState;
|
|
193
|
+
const receipt = receiptObject(state);
|
|
194
|
+
const freshUntil = receipt ? scalar(receipt.fresh_until) : undefined;
|
|
195
|
+
return {
|
|
196
|
+
skill,
|
|
197
|
+
phase,
|
|
198
|
+
active: state.active !== false,
|
|
199
|
+
fresh: freshUntil ? Date.parse(freshUntil) > Date.now() : false,
|
|
200
|
+
...(freshUntil ? { fresh_until: freshUntil } : {}),
|
|
201
|
+
next: manifest.transitions.filter(transition => transition.from === phase).map(transition => transition.to),
|
|
202
|
+
receipt_status: receipt ? (scalar(receipt.status) ?? "present") : "missing",
|
|
203
|
+
storage_path: storagePath,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function renderStateStatusLine(summary: StateStatusSummary): string {
|
|
208
|
+
const freshness = summary.fresh ? "fresh" : "stale";
|
|
209
|
+
return `${summary.skill}: phase=${summary.phase} ${freshness} next=${summary.next.length ? summary.next.join(",") : "none"}\n`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function renderContractMarkdown(skill: CanonicalGjcWorkflowSkill, contract: unknown): string {
|
|
213
|
+
const record = isRecord(contract) ? contract : {};
|
|
214
|
+
const lines = [`# ${skill} state contract`, ""];
|
|
215
|
+
for (const [key, value] of Object.entries(record)) {
|
|
216
|
+
if (Array.isArray(value)) lines.push(`- ${key}: ${value.length} entries (--json for full)`);
|
|
217
|
+
else if (isRecord(value)) lines.push(`- ${key}: object (${Object.keys(value).length} keys, --json for full)`);
|
|
218
|
+
else if (value !== undefined) lines.push(`- ${key}: ${String(value)}`);
|
|
219
|
+
}
|
|
220
|
+
return `${lines.join("\n")}\n`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function renderHistoryMarkdown(history: {
|
|
224
|
+
entries: unknown[];
|
|
225
|
+
limit: number;
|
|
226
|
+
since?: string;
|
|
227
|
+
truncated: boolean;
|
|
228
|
+
}): string {
|
|
229
|
+
const lines = ["# state audit history", "", `- entries: ${history.entries.length}`, `- limit: ${history.limit}`];
|
|
230
|
+
if (history.since) lines.push(`- since: ${history.since}`);
|
|
231
|
+
lines.push(`- truncated: ${history.truncated ? "yes" : "no"}`);
|
|
232
|
+
for (const entry of history.entries) {
|
|
233
|
+
if (!isRecord(entry)) continue;
|
|
234
|
+
const ts = scalar(entry.ts) ?? "unknown-time";
|
|
235
|
+
const skill = scalar(entry.skill) ?? "unknown-skill";
|
|
236
|
+
const verb = scalar(entry.verb) ?? "unknown-verb";
|
|
237
|
+
lines.push(`- ${ts} ${skill} ${verb}`);
|
|
238
|
+
}
|
|
239
|
+
return `${lines.join("\n")}\n`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function renderUltragoalStatusMarkdown(summary: {
|
|
243
|
+
exists: boolean;
|
|
244
|
+
status: string;
|
|
245
|
+
paths: { goalsPath: string; ledgerPath?: string };
|
|
246
|
+
gjcObjective?: string;
|
|
247
|
+
currentGoal?: { id: string; status: string; title?: string; objective?: string };
|
|
248
|
+
counts: Record<string, number>;
|
|
249
|
+
goals: unknown[];
|
|
250
|
+
}): string {
|
|
251
|
+
if (!summary.exists)
|
|
252
|
+
return `# ultragoal status\n\n- status: missing\n- No ultragoal plan found at ${summary.paths.goalsPath}. Run \`gjc ultragoal create-goals --brief "..."\` first.\n`;
|
|
253
|
+
const counts = Object.entries(summary.counts)
|
|
254
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
255
|
+
.join(" ");
|
|
256
|
+
const lines = [
|
|
257
|
+
"# ultragoal status",
|
|
258
|
+
"",
|
|
259
|
+
`- status: ${summary.status}`,
|
|
260
|
+
`- goals: ${summary.goals.length} (${counts})`,
|
|
261
|
+
];
|
|
262
|
+
if (summary.gjcObjective) lines.push(`- objective: ${summary.gjcObjective}`);
|
|
263
|
+
if (summary.currentGoal) lines.push(`- current: ${summary.currentGoal.id} (${summary.currentGoal.status})`);
|
|
264
|
+
lines.push(`- goals_path: ${summary.paths.goalsPath}`);
|
|
265
|
+
if (summary.paths.ledgerPath) lines.push(`- ledger_path: ${summary.paths.ledgerPath}`);
|
|
266
|
+
return `${lines.join("\n")}\n`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function renderTeamStatusMarkdown(snapshot: {
|
|
270
|
+
team_name: string;
|
|
271
|
+
phase: string;
|
|
272
|
+
tmux_target?: string;
|
|
273
|
+
tmux_session?: string;
|
|
274
|
+
state_dir: string;
|
|
275
|
+
task_total: number;
|
|
276
|
+
task_counts: Record<string, number>;
|
|
277
|
+
workers: Array<{ id: string; status: string }>;
|
|
278
|
+
notification_summary?: { total: number; replay_eligible: number; by_state: Record<string, number> };
|
|
279
|
+
integration_by_worker?: Record<string, { status?: string; conflict_files?: string[] }>;
|
|
280
|
+
}): string {
|
|
281
|
+
const counts = Object.entries(snapshot.task_counts)
|
|
282
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
283
|
+
.join(" ");
|
|
284
|
+
const lines = [
|
|
285
|
+
"# team status",
|
|
286
|
+
"",
|
|
287
|
+
`- team: ${snapshot.team_name}`,
|
|
288
|
+
`- phase: ${snapshot.phase}`,
|
|
289
|
+
`- tmux: ${snapshot.tmux_target || snapshot.tmux_session || "none"}`,
|
|
290
|
+
`- state: ${snapshot.state_dir}`,
|
|
291
|
+
`- tasks: ${snapshot.task_total} (${counts})`,
|
|
292
|
+
`- workers: ${snapshot.workers.length} (${snapshot.workers.map(worker => `${worker.id}:${worker.status}`).join(" ")})`,
|
|
293
|
+
];
|
|
294
|
+
if (snapshot.notification_summary) {
|
|
295
|
+
lines.push(
|
|
296
|
+
`- notifications: total=${snapshot.notification_summary.total} replay_eligible=${snapshot.notification_summary.replay_eligible}`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
const integrations = Object.entries(snapshot.integration_by_worker ?? {});
|
|
300
|
+
if (integrations.length)
|
|
301
|
+
lines.push(
|
|
302
|
+
`- integrations: ${integrations.map(([worker, state]) => `${worker}:${state.status ?? "unknown"}`).join(" ")}`,
|
|
303
|
+
);
|
|
304
|
+
return `${lines.join("\n")}\n`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export function renderStateMarkdown(
|
|
308
|
+
skill: CanonicalGjcWorkflowSkill,
|
|
309
|
+
stateJson: Record<string, unknown>,
|
|
310
|
+
manifest: SkillManifest,
|
|
311
|
+
): string {
|
|
312
|
+
const state = stateObject(stateJson);
|
|
313
|
+
const phase = scalar(state.current_phase) ?? scalar(state.phase) ?? manifest.initialState;
|
|
314
|
+
const next = manifest.transitions.filter(transition => transition.from === phase).map(transition => transition.to);
|
|
315
|
+
const receipt = receiptObject(state);
|
|
316
|
+
const receiptStatus = receipt ? (scalar(receipt.status) ?? "present") : "missing";
|
|
317
|
+
const artifacts = artifactLinks(state);
|
|
318
|
+
const fields = keyStateFields(state, manifest);
|
|
319
|
+
|
|
320
|
+
const lines = [`# ${skill} state`, "", `- Current phase: ${phase}`];
|
|
321
|
+
lines.push(`- Valid next transitions: ${next.length ? next.join(", ") : "none"}`);
|
|
322
|
+
if (fields.length) {
|
|
323
|
+
lines.push("- Key fields:");
|
|
324
|
+
for (const [key, value] of fields) lines.push(` - ${key}: ${value}`);
|
|
325
|
+
} else {
|
|
326
|
+
lines.push("- Key fields: none");
|
|
327
|
+
}
|
|
328
|
+
lines.push(`- Receipt: ${receiptStatus}`);
|
|
329
|
+
if (receipt) {
|
|
330
|
+
const mutationId = scalar(receipt.mutation_id);
|
|
331
|
+
const freshUntil = scalar(receipt.fresh_until);
|
|
332
|
+
if (mutationId) lines.push(` - mutation_id: ${mutationId}`);
|
|
333
|
+
if (freshUntil) lines.push(` - fresh_until: ${freshUntil}`);
|
|
334
|
+
}
|
|
335
|
+
if (artifacts.length) {
|
|
336
|
+
lines.push("- Artifacts:");
|
|
337
|
+
for (const artifact of artifacts) lines.push(` - ${artifact}`);
|
|
338
|
+
}
|
|
339
|
+
const compactFields = compactStateFields(state);
|
|
340
|
+
if (compactFields.length) {
|
|
341
|
+
lines.push("- Compact elisions:");
|
|
342
|
+
for (const [key, value] of compactFields) lines.push(` - ${key}: ${value}`);
|
|
343
|
+
}
|
|
344
|
+
return `${lines.join("\n")}\n`;
|
|
345
|
+
}
|