guardian-framework 0.1.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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +463 -0
  3. package/dist/cli.js +12958 -0
  4. package/dist/exports.js +12765 -0
  5. package/package.json +61 -0
  6. package/templates/languages/go-patterns.md +411 -0
  7. package/templates/languages/java-patterns.md +545 -0
  8. package/templates/languages/python-patterns.md +312 -0
  9. package/templates/languages/rust-patterns.md +232 -0
  10. package/templates/languages/typescript-patterns.md +313 -0
  11. package/templates/pi/INDEX.md +437 -0
  12. package/templates/pi/agent/AGENTS.md +166 -0
  13. package/templates/pi/agents/architecture-coordinator.md +40 -0
  14. package/templates/pi/agents/architecture-validator.md +36 -0
  15. package/templates/pi/agents/bootstrap-implementer.md +37 -0
  16. package/templates/pi/agents/issue-factory.md +31 -0
  17. package/templates/pi/agents/operations-validator.md +32 -0
  18. package/templates/pi/agents/security-validator.md +33 -0
  19. package/templates/pi/architecture/CHANGELOG.md +78 -0
  20. package/templates/pi/architecture/decisions/ADR-template.md +76 -0
  21. package/templates/pi/architecture/diagrams/system-overview.md +159 -0
  22. package/templates/pi/architecture/modules/module-template.md +152 -0
  23. package/templates/pi/context/checklists.md +91 -0
  24. package/templates/pi/context/domain-workflow.md +180 -0
  25. package/templates/pi/context/output-formats.md +135 -0
  26. package/templates/pi/context/patterns-base.md +47 -0
  27. package/templates/pi/context/patterns.md +38 -0
  28. package/templates/pi/context/project.md +88 -0
  29. package/templates/pi/domain/exploration.md +93 -0
  30. package/templates/pi/domain/ubiquitous-language.md +24 -0
  31. package/templates/pi/extensions/architect-lib/generators.ts +528 -0
  32. package/templates/pi/extensions/architect-lib/helpers.ts +344 -0
  33. package/templates/pi/extensions/architect-lib/types.ts +117 -0
  34. package/templates/pi/extensions/architect.ts +1425 -0
  35. package/templates/pi/extensions/ask-user-question.ts +579 -0
  36. package/templates/pi/extensions/bash-guard.ts +556 -0
  37. package/templates/pi/extensions/config-reload.ts +115 -0
  38. package/templates/pi/extensions/coordinator.ts +304 -0
  39. package/templates/pi/extensions/curator.ts +543 -0
  40. package/templates/pi/extensions/domain-explorer.ts +990 -0
  41. package/templates/pi/extensions/filechanges.ts +656 -0
  42. package/templates/pi/extensions/goal-loop.ts +717 -0
  43. package/templates/pi/extensions/hooks.ts +452 -0
  44. package/templates/pi/extensions/kanban.ts +547 -0
  45. package/templates/pi/extensions/pipeline.ts +1246 -0
  46. package/templates/pi/extensions/plan-mode.ts +209 -0
  47. package/templates/pi/extensions/project-scaffolder.ts +284 -0
  48. package/templates/pi/extensions/read-only-mode.ts +192 -0
  49. package/templates/pi/extensions/redaction.ts +128 -0
  50. package/templates/pi/extensions/session-persistence.ts +174 -0
  51. package/templates/pi/extensions/slash-commands.ts +229 -0
  52. package/templates/pi/extensions/snippets.ts +201 -0
  53. package/templates/pi/extensions/validation-runner.ts +100 -0
  54. package/templates/pi/github/agents/architecture-coordinator.agent.md +27 -0
  55. package/templates/pi/github/agents/architecture-validator.agent.md +20 -0
  56. package/templates/pi/github/agents/bootstrap-implementer.agent.md +20 -0
  57. package/templates/pi/github/agents/epic-planner.agent.md +70 -0
  58. package/templates/pi/github/agents/issue-factory.agent.md +20 -0
  59. package/templates/pi/github/agents/operations-validator.agent.md +20 -0
  60. package/templates/pi/github/agents/security-validator.agent.md +20 -0
  61. package/templates/pi/github/copilot/settings.json +16 -0
  62. package/templates/pi/github/copilot-instructions.md +155 -0
  63. package/templates/pi/github/instructions/architecture.instructions.md +71 -0
  64. package/templates/pi/github/instructions/validation.instructions.md +69 -0
  65. package/templates/pi/github/workflows/01-planning-workflow.md +75 -0
  66. package/templates/pi/github/workflows/02-issue-generation-workflow.md +69 -0
  67. package/templates/pi/github/workflows/03-implementation-workflow.md +80 -0
  68. package/templates/pi/github/workflows/04-validation-workflow.md +68 -0
  69. package/templates/pi/preflight_report.json +99 -0
  70. package/templates/pi/prompts/blueprint-update.md +262 -0
  71. package/templates/pi/prompts/blueprint-validate.md +218 -0
  72. package/templates/pi/prompts/bug-fix.md +50 -0
  73. package/templates/pi/prompts/ci-blueprint.md +131 -0
  74. package/templates/pi/prompts/context-refresh.md +258 -0
  75. package/templates/pi/prompts/epic-plan.md +356 -0
  76. package/templates/pi/prompts/epic-template.md +186 -0
  77. package/templates/pi/prompts/feature-development.md +131 -0
  78. package/templates/pi/prompts/git-issues.md +243 -0
  79. package/templates/pi/prompts/hotfix.md +71 -0
  80. package/templates/pi/prompts/issue-closeout.md +342 -0
  81. package/templates/pi/prompts/issue-draft.md +218 -0
  82. package/templates/pi/prompts/issue-implementation-series.md +173 -0
  83. package/templates/pi/prompts/issue-merge.md +372 -0
  84. package/templates/pi/prompts/issue-template-set.md +392 -0
  85. package/templates/pi/prompts/issue-template.md +207 -0
  86. package/templates/pi/prompts/pattern-extract.md +269 -0
  87. package/templates/pi/prompts/plan-to-issues.md +430 -0
  88. package/templates/pi/prompts/refactoring.md +82 -0
  89. package/templates/pi/prompts/scope-analyzer.md +254 -0
  90. package/templates/pi/prompts/sync-check.md +230 -0
  91. package/templates/pi/scripts/categorize-issues.sh +171 -0
  92. package/templates/pi/scripts/ci/check_architecture_conformance.sh +748 -0
  93. package/templates/pi/scripts/ci/check_planning_packet.py +228 -0
  94. package/templates/pi/scripts/ci/run_hardening_stages.sh +264 -0
  95. package/templates/pi/scripts/ci/run_preflight.sh +649 -0
  96. package/templates/pi/scripts/ci/run_stage.sh +193 -0
  97. package/templates/pi/scripts/ci/stage_docs_policy.sh +82 -0
  98. package/templates/pi/scripts/ci/stage_integration.sh +3 -0
  99. package/templates/pi/scripts/ci/stage_lint.sh +130 -0
  100. package/templates/pi/scripts/ci/stage_migration_verify.sh +3 -0
  101. package/templates/pi/scripts/ci/stage_package_build.sh +3 -0
  102. package/templates/pi/scripts/ci/stage_release_readiness.sh +3 -0
  103. package/templates/pi/scripts/ci/stage_remaining.sh +242 -0
  104. package/templates/pi/scripts/ci/stage_security.sh +3 -0
  105. package/templates/pi/scripts/ci/stage_static_analysis.sh +114 -0
  106. package/templates/pi/scripts/ci/stage_unit.sh +119 -0
  107. package/templates/pi/scripts/ci/validate_agent_output.py +181 -0
  108. package/templates/pi/scripts/ci/validate_agent_output.sh +243 -0
  109. package/templates/pi/scripts/create-feature-branch.sh +136 -0
  110. package/templates/pi/scripts/create-mr.sh +117 -0
  111. package/templates/pi/scripts/fetch-issues.sh +131 -0
  112. package/templates/pi/scripts/generate-architecture.sh +161 -0
  113. package/templates/pi/scripts/git/close-epic.sh +69 -0
  114. package/templates/pi/scripts/git/close-issue.sh +35 -0
  115. package/templates/pi/scripts/git/create-tracking-issue.sh +174 -0
  116. package/templates/pi/scripts/git/link-issue-to-epic.sh +51 -0
  117. package/templates/pi/scripts/git/update-tracking-issue.sh +66 -0
  118. package/templates/pi/scripts/languages/go/validate-architecture.sh +139 -0
  119. package/templates/pi/scripts/languages/go/validate-canonical.sh +129 -0
  120. package/templates/pi/scripts/languages/go/validate-ci.sh +132 -0
  121. package/templates/pi/scripts/languages/go/validate-integration.sh +156 -0
  122. package/templates/pi/scripts/languages/go/validate-operations.sh +146 -0
  123. package/templates/pi/scripts/languages/go/validate-security.sh +135 -0
  124. package/templates/pi/scripts/languages/go/validate-tests.sh +125 -0
  125. package/templates/pi/scripts/languages/java/validate-annotations.sh +185 -0
  126. package/templates/pi/scripts/languages/java/validate-architecture.sh +159 -0
  127. package/templates/pi/scripts/languages/java/validate-canonical.sh +114 -0
  128. package/templates/pi/scripts/languages/java/validate-ci.sh +269 -0
  129. package/templates/pi/scripts/languages/java/validate-integration.sh +149 -0
  130. package/templates/pi/scripts/languages/java/validate-operations.sh +142 -0
  131. package/templates/pi/scripts/languages/java/validate-security.sh +174 -0
  132. package/templates/pi/scripts/languages/java/validate-spring-architecture.sh +227 -0
  133. package/templates/pi/scripts/languages/java/validate-tests.sh +159 -0
  134. package/templates/pi/scripts/languages/python/validate-architecture.sh +99 -0
  135. package/templates/pi/scripts/languages/python/validate-canonical.sh +124 -0
  136. package/templates/pi/scripts/languages/python/validate-ci.sh +130 -0
  137. package/templates/pi/scripts/languages/python/validate-integration.sh +119 -0
  138. package/templates/pi/scripts/languages/python/validate-operations.sh +107 -0
  139. package/templates/pi/scripts/languages/python/validate-security.sh +68 -0
  140. package/templates/pi/scripts/languages/python/validate-tests.sh +102 -0
  141. package/templates/pi/scripts/languages/rust/validate-architecture.sh +188 -0
  142. package/templates/pi/scripts/languages/rust/validate-canonical.sh +146 -0
  143. package/templates/pi/scripts/languages/rust/validate-ci.sh +147 -0
  144. package/templates/pi/scripts/languages/rust/validate-integration.sh +149 -0
  145. package/templates/pi/scripts/languages/rust/validate-operations.sh +154 -0
  146. package/templates/pi/scripts/languages/rust/validate-security.sh +153 -0
  147. package/templates/pi/scripts/languages/rust/validate-tests.sh +150 -0
  148. package/templates/pi/scripts/languages/typescript/validate-architecture.sh +157 -0
  149. package/templates/pi/scripts/languages/typescript/validate-canonical.sh +135 -0
  150. package/templates/pi/scripts/languages/typescript/validate-ci.sh +244 -0
  151. package/templates/pi/scripts/languages/typescript/validate-integration.sh +166 -0
  152. package/templates/pi/scripts/languages/typescript/validate-operations.sh +162 -0
  153. package/templates/pi/scripts/languages/typescript/validate-security.sh +169 -0
  154. package/templates/pi/scripts/languages/typescript/validate-tests.sh +158 -0
  155. package/templates/pi/scripts/merge-mr.sh +95 -0
  156. package/templates/pi/scripts/mr-validation.sh +228 -0
  157. package/templates/pi/scripts/validate-architecture-readiness.sh +153 -0
  158. package/templates/pi/scripts/validate-architecture.sh +22 -0
  159. package/templates/pi/scripts/validate-canonical.sh +22 -0
  160. package/templates/pi/scripts/validate-ci.sh +37 -0
  161. package/templates/pi/scripts/validate-integration.sh +22 -0
  162. package/templates/pi/scripts/validate-operations.sh +22 -0
  163. package/templates/pi/scripts/validate-security.sh +22 -0
  164. package/templates/pi/scripts/validate-tests.sh +22 -0
  165. package/templates/pi/scripts/validate-ubiquitous-language.sh +291 -0
  166. package/templates/pi/scripts/validation-cache.sh +139 -0
  167. package/templates/pi/skills/agents/architecture-coordinator.md +178 -0
  168. package/templates/pi/skills/agents/architecture-generator.md +79 -0
  169. package/templates/pi/skills/agents/architecture-validator.md +74 -0
  170. package/templates/pi/skills/agents/ci-mr-validator.md +46 -0
  171. package/templates/pi/skills/agents/code-developer.md +76 -0
  172. package/templates/pi/skills/agents/commit.md +46 -0
  173. package/templates/pi/skills/agents/curator.md +71 -0
  174. package/templates/pi/skills/agents/debug.md +59 -0
  175. package/templates/pi/skills/agents/documentation-maintainer.md +36 -0
  176. package/templates/pi/skills/agents/goal-loop.md +125 -0
  177. package/templates/pi/skills/agents/hooks.md +122 -0
  178. package/templates/pi/skills/agents/integration-validator.md +35 -0
  179. package/templates/pi/skills/agents/issue-creator.md +75 -0
  180. package/templates/pi/skills/agents/issue-factory.md +143 -0
  181. package/templates/pi/skills/agents/kanban.md +85 -0
  182. package/templates/pi/skills/agents/land.md +59 -0
  183. package/templates/pi/skills/agents/operations-validator.md +43 -0
  184. package/templates/pi/skills/agents/pipeline.md +113 -0
  185. package/templates/pi/skills/agents/plan-mode.md +77 -0
  186. package/templates/pi/skills/agents/pull.md +40 -0
  187. package/templates/pi/skills/agents/push.md +41 -0
  188. package/templates/pi/skills/agents/security-validator.md +85 -0
  189. package/templates/pi/skills/agents/session-persistence.md +119 -0
  190. package/templates/pi/skills/agents/slash-commands.md +117 -0
  191. package/templates/pi/skills/agents/snippets.md +99 -0
  192. package/templates/pi/skills/agents/subagent-registry.md +78 -0
  193. package/templates/pi/skills/agents/test-validator.md +42 -0
  194. package/templates/pi/skills/validators/architecture-validator.md +43 -0
  195. package/templates/pi/skills/validators/ci-validator.md +27 -0
  196. package/templates/pi/skills/validators/context-compaction.md +73 -0
  197. package/templates/pi/skills/validators/integration-validator.md +38 -0
  198. package/templates/pi/skills/validators/model-registry.md +96 -0
  199. package/templates/pi/skills/validators/operations-validator.md +34 -0
  200. package/templates/pi/skills/validators/security-guards.md +72 -0
  201. package/templates/pi/skills/validators/security-validator.md +41 -0
  202. package/templates/pi/skills/validators/system-prompt-tiers.md +69 -0
  203. package/templates/pi/skills/validators/test-validator.md +33 -0
  204. package/templates/pi/types.ts +62 -0
  205. package/templates/pi/validators/README.md +93 -0
  206. package/templates/pi/validators/default.toml +209 -0
  207. package/templates/pi/validators/spring.toml +142 -0
  208. package/templates/pi/workpad.md +53 -0
  209. package/templates/project/java/Dockerfile +14 -0
  210. package/templates/project/java/README.md +40 -0
  211. package/templates/project/java/pom.xml +132 -0
  212. package/templates/project/typescript/Dockerfile +15 -0
  213. package/templates/project/typescript/README.md +29 -0
  214. package/templates/project/typescript/package.json +23 -0
  215. package/templates/project/typescript/tsconfig.json +21 -0
  216. package/templates/workflow.md +123 -0
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Snippets Extension for pi
3
+ *
4
+ * Manages reusable prompt fragments (snippets) that can be referenced via
5
+ * #handle tokens in chat. When the agent or user types #handle, the snippet
6
+ * body is expanded into an XML block prepended to the message.
7
+ *
8
+ * Handles:
9
+ * - #handle expansion in user input
10
+ * - /snippet list | add | remove | edit commands
11
+ * - Persistent storage in guardian-snippets.json
12
+ */
13
+
14
+ import * as fs from "node:fs";
15
+ import * as path from "node:path";
16
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
17
+
18
+ interface Snippet {
19
+ id: string;
20
+ handle: string;
21
+ name: string;
22
+ description: string;
23
+ content: string;
24
+ }
25
+
26
+ const SNIPPETS_FILE = "guardian-snippets.json";
27
+ const HANDLE_RE = /^[a-z0-9][a-z0-9-]*$/;
28
+
29
+ function loadSnippets(cwd: string): Snippet[] {
30
+ const p = path.join(cwd, SNIPPETS_FILE);
31
+ if (!fs.existsSync(p)) return [];
32
+ try {
33
+ return JSON.parse(fs.readFileSync(p, "utf-8")) as Snippet[];
34
+ } catch {
35
+ return [];
36
+ }
37
+ }
38
+
39
+ function saveSnippets(cwd: string, snippets: Snippet[]): void {
40
+ const p = path.join(cwd, SNIPPETS_FILE);
41
+ const tmp = `${p}.tmp`;
42
+ fs.writeFileSync(tmp, JSON.stringify(snippets, null, 2), "utf-8");
43
+ fs.renameSync(tmp, p);
44
+ }
45
+
46
+ function newSnippetId(): string {
47
+ return `sn-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
48
+ }
49
+
50
+ function normalizeHandle(raw: string): string {
51
+ return raw
52
+ .trim()
53
+ .toLowerCase()
54
+ .replace(/\s+/g, "-")
55
+ .replace(/[^a-z0-9-]/g, "")
56
+ .replace(/-+/g, "-")
57
+ .replace(/^-+|-+$/g, "");
58
+ }
59
+
60
+ /** Expand #handle tokens in text, returning the body with tokens stripped and snippet XML blocks. */
61
+ function expandSnippetTokens(
62
+ text: string,
63
+ snippets: readonly Snippet[],
64
+ ): { body: string; blocks: string[] } {
65
+ const byHandle = new Map(snippets.map((s) => [s.handle, s]));
66
+ const matched = new Map<string, Snippet>();
67
+
68
+ const re = /(^|\s)#([a-z0-9][a-z0-9-]*)\b/gi;
69
+ const body = text.replace(re, (full, lead: string, raw: string) => {
70
+ const h = raw.toLowerCase();
71
+ const snip = byHandle.get(h);
72
+ if (!snip) return full;
73
+ matched.set(snip.id, snip);
74
+ return lead;
75
+ });
76
+
77
+ const blocks = Array.from(matched.values()).map(
78
+ (s) => `<snippet name="${s.handle}">\n${s.content}\n</snippet>`,
79
+ );
80
+ return { body: body.replace(/[ \t]+\n/g, "\n").trim(), blocks };
81
+ }
82
+
83
+ export default function (pi: ExtensionAPI) {
84
+ let snippets: Snippet[] = [];
85
+
86
+ pi.on("session_start", async (_event, ctx) => {
87
+ snippets = loadSnippets(ctx.cwd);
88
+ if (snippets.length > 0) {
89
+ pi.appendEntry({
90
+ key: "guardian:snippets",
91
+ value: snippets.map((s) => `#${s.handle} — ${s.description}`).join("\n"),
92
+ });
93
+ }
94
+ });
95
+
96
+ // Intercept input for #handle expansion
97
+ pi.on("input", async (event, _ctx) => {
98
+ const input = (event as { input?: string }).input;
99
+ if (!input) return;
100
+ const trimmed = input.trim();
101
+
102
+ // Only expand #handle tokens (not slash commands)
103
+ if (
104
+ !trimmed.startsWith("#") ||
105
+ (trimmed.startsWith("# ") === false && !trimmed.match(/^#[a-z0-9][a-z0-9-]*/i))
106
+ )
107
+ return;
108
+
109
+ const { body, blocks } = expandSnippetTokens(input, snippets);
110
+ if (blocks.length > 0) {
111
+ event.input = [...blocks, body].join("\n\n");
112
+ }
113
+ });
114
+
115
+ // Snippet management commands
116
+ pi.registerCommand("snippet", {
117
+ description: "Manage snippets: list, add, remove, edit",
118
+ handler: async (args, ctx) => {
119
+ snippets = loadSnippets(ctx.cwd); // reload
120
+ const [subcmd, ...rest] = args;
121
+
122
+ if (!subcmd || subcmd === "list") {
123
+ if (snippets.length === 0) {
124
+ ctx.ui.notify(
125
+ "No snippets configured. Use /snippet add <handle> [name] to create one.",
126
+ "info",
127
+ );
128
+ } else {
129
+ const list = snippets
130
+ .map((s) => `#${s.handle.padEnd(20)} ${s.name.padEnd(25)} ${s.description}`)
131
+ .join("\n");
132
+ ctx.ui.notify(
133
+ `Snippets (${snippets.length}):\n\nHandle Name Description\n${"─".repeat(72)}\n${list}`,
134
+ "info",
135
+ );
136
+ }
137
+ return;
138
+ }
139
+
140
+ if (subcmd === "add") {
141
+ const rawHandle = rest[0];
142
+ if (!rawHandle) {
143
+ ctx.ui.notify("Usage: /snippet add <handle> [name]", "error");
144
+ return;
145
+ }
146
+ const handle = normalizeHandle(rawHandle);
147
+ if (!HANDLE_RE.test(handle)) {
148
+ ctx.ui.notify(
149
+ `Invalid handle: "${rawHandle}". Use lowercase letters, numbers, and hyphens.`,
150
+ "error",
151
+ );
152
+ return;
153
+ }
154
+ if (snippets.some((s) => s.handle === handle)) {
155
+ ctx.ui.notify(`Snippet #${handle} already exists. Use /snippet edit to modify.`, "warn");
156
+ return;
157
+ }
158
+ const name = rest.slice(1).join(" ") || handle;
159
+ const content = await ctx.ui.input(`Content for #${handle}`, "Enter snippet body...");
160
+ if (!content) return;
161
+ snippets.push({ id: newSnippetId(), handle, name, description: name, content });
162
+ saveSnippets(ctx.cwd, snippets);
163
+ ctx.ui.notify(`Snippet #${handle} created.`, "success");
164
+ return;
165
+ }
166
+
167
+ if (subcmd === "remove") {
168
+ const handle = normalizeHandle(rest[0] ?? "");
169
+ const before = snippets.length;
170
+ snippets = snippets.filter((s) => s.handle !== handle);
171
+ if (snippets.length === before) {
172
+ ctx.ui.notify(`Snippet #${handle} not found.`, "error");
173
+ } else {
174
+ saveSnippets(ctx.cwd, snippets);
175
+ ctx.ui.notify(`Snippet #${handle} removed.`, "success");
176
+ }
177
+ return;
178
+ }
179
+
180
+ if (subcmd === "edit") {
181
+ const handle = normalizeHandle(rest[0] ?? "");
182
+ const existing = snippets.find((s) => s.handle === handle);
183
+ if (!existing) {
184
+ ctx.ui.notify(`Snippet #${handle} not found.`, "error");
185
+ return;
186
+ }
187
+ const content = await ctx.ui.input(`New content for #${handle}`, existing.content);
188
+ if (!content) return;
189
+ existing.content = content;
190
+ saveSnippets(ctx.cwd, snippets);
191
+ ctx.ui.notify(`Snippet #${handle} updated.`, "success");
192
+ return;
193
+ }
194
+
195
+ ctx.ui.notify(
196
+ "Usage: /snippet list | /snippet add <handle> [name] | /snippet remove <handle> | /snippet edit <handle>",
197
+ "info",
198
+ );
199
+ },
200
+ });
201
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Validation Runner Extension for pi
3
+ *
4
+ * Runs validation scripts as pi tools and commands.
5
+ * See coordinator.ts for guardian_scope and guardian_validate tools.
6
+ */
7
+
8
+ type ShellResult = {
9
+ exitCode: number;
10
+ stdout: string;
11
+ stderr?: string;
12
+ };
13
+
14
+ type ExtensionContext = {
15
+ ui: { notify(message: string, level?: string): void };
16
+ shell: { execute(command: string, options?: { signal?: AbortSignal }): Promise<ShellResult> };
17
+ tools: { execute(name: string, params: Record<string, unknown>): Promise<unknown> };
18
+ };
19
+
20
+ type ExtensionAPI = {
21
+ on(event: string, handler: (event: unknown, ctx: ExtensionContext) => void | Promise<void>): void;
22
+ registerTool(options: {
23
+ name: string;
24
+ label: string;
25
+ description: string;
26
+ parameters: unknown;
27
+ execute(
28
+ toolCallId: string,
29
+ params: Record<string, unknown>,
30
+ signal: AbortSignal,
31
+ onUpdate: (update: { type: string; message: string }) => void,
32
+ ctx: ExtensionContext,
33
+ ): unknown | Promise<unknown>;
34
+ }): void;
35
+ registerCommand(
36
+ name: string,
37
+ options: {
38
+ description: string;
39
+ handler(args: string[], ctx: ExtensionContext): unknown | Promise<unknown>;
40
+ },
41
+ ): void;
42
+ };
43
+
44
+ const VALIDATORS = {
45
+ architecture: ".pi/scripts/validate-architecture.sh",
46
+ canonical: ".pi/scripts/validate-canonical.sh",
47
+ ci: ".pi/scripts/validate-ci.sh",
48
+ integration: ".pi/scripts/validate-integration.sh",
49
+ operations: ".pi/scripts/validate-operations.sh",
50
+ security: ".pi/scripts/validate-security.sh",
51
+ tests: ".pi/scripts/validate-tests.sh",
52
+ } as const;
53
+
54
+ type ValidatorName = keyof typeof VALIDATORS;
55
+
56
+ function isValidatorName(value: string): value is ValidatorName {
57
+ return Object.hasOwn(VALIDATORS, value);
58
+ }
59
+
60
+ export default function (pi: ExtensionAPI) {
61
+ // Session initialization
62
+ pi.on("session_start", async (_event, ctx) => {
63
+ ctx.ui.notify("Guardian validation runner initialized", "info");
64
+ });
65
+
66
+ // Register validate command — runs scripts directly via shell
67
+ pi.registerCommand("validate", {
68
+ description: "Run all or specific validators",
69
+ handler: async (args, ctx) => {
70
+ const validators =
71
+ args.length > 0
72
+ ? args.filter(isValidatorName)
73
+ : ["ci", "tests", "operations", "security", "canonical"];
74
+ ctx.ui.notify(`Running validators: ${validators.join(", ")}`, "info");
75
+
76
+ const results: Record<string, { passed: boolean; output: string }> = {};
77
+
78
+ for (const validator of validators) {
79
+ const scriptPath = VALIDATORS[validator];
80
+ try {
81
+ const result = await ctx.shell.execute(`bash ${scriptPath}`);
82
+ results[validator] = {
83
+ passed: result.exitCode === 0,
84
+ output: result.stdout,
85
+ };
86
+ } catch (error) {
87
+ results[validator] = { passed: false, output: `Error: ${error}` };
88
+ }
89
+ }
90
+
91
+ const allPassed = Object.values(results).every((r) => r.passed);
92
+ ctx.ui.notify(
93
+ allPassed ? "All validations passed" : "Some validations failed",
94
+ allPassed ? "success" : "error",
95
+ );
96
+
97
+ return { summary: allPassed ? "All validations passed" : "Some validations failed", results };
98
+ },
99
+ });
100
+ }
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: Turn goals into bounded execution streams with issue order and controls
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # Architecture Coordinator Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/architecture-coordinator.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Use `.github/workflows/01-planning-workflow.md` for detailed step-by-step execution
14
+ - Output validated by `scripts/ci/check_planning_packet.py` and `scripts/ci/validate_agent_output.py`
15
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
16
+
17
+ ## Execution Flow
18
+
19
+ 1. Read `.pi/agents/architecture-coordinator.md` for role definition
20
+ 2. Follow `.github/workflows/01-planning-workflow.md` for step-by-step
21
+ 3. Draft the planning packet
22
+ 4. Run `python scripts/ci/check_planning_packet.py --input=<packet>`
23
+ 5. Hand off to Issue Factory when validated
24
+
25
+ ---
26
+
27
+ **Token count:** ~30 lines (wrapper only)
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Validate issue/epic output against architecture policy before merge
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # architecture validator Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/architecture-validator.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Output validated by `scripts/ci/validate_agent_output.py`
14
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
15
+
16
+ ## Execution Flow
17
+
18
+ 1. Read `.pi/agents/architecture-validator.md` for role definition
19
+ 2. Follow the relevant workflow for your execution phase
20
+ 3. Run deterministic validation before handing off
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Execute one issue at a time with strict acceptance-criteria closure
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # uootstrap implementer Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/bootstrap-implementer.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Output validated by `scripts/ci/validate_agent_output.py`
14
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
15
+
16
+ ## Execution Flow
17
+
18
+ 1. Read `.pi/agents/bootstrap-implementer.md` for role definition
19
+ 2. Follow the relevant workflow for your execution phase
20
+ 3. Run deterministic validation before handing off
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: Epic Planner
3
+ description: Analyzes architecture and creates epic-level plans
4
+ model: gpt-4o
5
+ tools:
6
+ - view
7
+ - grep
8
+ - glob
9
+ - terminal
10
+ ---
11
+ <!--
12
+ Canonical Reference: .pi/github/agents/epic-planner.agent.md
13
+ Blueprint Source: Guardian Framework v1.2
14
+ DO NOT EDIT DIRECTLY - Source: .pi/prompts/epic-plan.md
15
+ -->
16
+
17
+ # Epic Planner Agent
18
+
19
+ You analyze architecture and create epic-level implementation plans.
20
+
21
+ ## Workflow
22
+
23
+ ### 1. Architecture Analysis
24
+
25
+ ```bash
26
+ # Read architecture modules
27
+ for f in .pi/architecture/modules/*.md; do cat "$f"; done
28
+
29
+ # Understand dependencies
30
+ grep "Dependencies" .pi/architecture/modules/*.md
31
+ ```
32
+
33
+ ### 2. Epic Slicing Criteria
34
+
35
+ Slice epics by:
36
+ - **Module boundaries**: One epic per major module change
37
+ - **Dependency order**: Deps must be complete before dependents
38
+ - **Scope estimation**: Files × complexity per issue
39
+ - **Validation requirements**: Complex epics need more validators
40
+
41
+ ### 3. Validator Review
42
+
43
+ Run validators on epic proposal:
44
+ - Architecture validator: Check alignment
45
+ - Security validator: Check for security implications
46
+ - Operations validator: Check production readiness
47
+
48
+ ### 4. Output Format
49
+
50
+ ```markdown
51
+ ## Epic: [EPIC_NAME]
52
+
53
+ ### Architecture Impact
54
+ - Modules affected: [list]
55
+ - New dependencies: [list]
56
+ - Breaking changes: [yes/no]
57
+
58
+ ### Issues
59
+ 1. #[issue] - [title] - [scope] - [validators]
60
+ 2. #[issue] - [title] - [scope] - [validators]
61
+
62
+ ### Validation Contract
63
+ - Architecture: ✅ Signed
64
+ - Security: ✅ Signed
65
+ - Operations: ✅ Signed
66
+ ```
67
+
68
+ ---
69
+
70
+ *Source: .pi/prompts/epic-plan.md*
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Convert approved planning packets into independently-reviewable issues
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # issue factory Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/issue-factory.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Output validated by `scripts/ci/validate_agent_output.py`
14
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
15
+
16
+ ## Execution Flow
17
+
18
+ 1. Read `.pi/agents/issue-factory.md` for role definition
19
+ 2. Follow the relevant workflow for your execution phase
20
+ 3. Run deterministic validation before handing off
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Verify implementations are production-ready with proper observability and runbooks
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # operations validator Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/operations-validator.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Output validated by `scripts/ci/validate_agent_output.py`
14
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
15
+
16
+ ## Execution Flow
17
+
18
+ 1. Read `.pi/agents/operations-validator.md` for role definition
19
+ 2. Follow the relevant workflow for your execution phase
20
+ 3. Run deterministic validation before handing off
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Verify implementations maintain security controls without regressions
3
+ model: gpt-5.4
4
+ preflight: scripts/ci/run_preflight.sh
5
+ ---
6
+
7
+ # security validator Agent
8
+
9
+ **This is a platform wrapper.** Core content in `.pi/agents/security-validator.md`.
10
+
11
+ ## GitHub Models-Specific Notes
12
+
13
+ - Output validated by `scripts/ci/validate_agent_output.py`
14
+ - Integrate with preflight engine: `./scripts/ci/run_preflight.sh`
15
+
16
+ ## Execution Flow
17
+
18
+ 1. Read `.pi/agents/security-validator.md` for role definition
19
+ 2. Follow the relevant workflow for your execution phase
20
+ 3. Run deterministic validation before handing off
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/github/copilot-cli/main/schemas/settings.json",
3
+ "mergeStrategy": "squash",
4
+ "disabledSkills": [],
5
+ "extraKnownMarketplaces": [],
6
+ "customInstructions": {
7
+ "enabled": true,
8
+ "paths": [".github/copilot-instructions.md", ".github/instructions/*.instructions.md"]
9
+ },
10
+ "agents": {
11
+ "paths": [".github/agents/*.agent.md"]
12
+ },
13
+ "workflows": {
14
+ "paths": [".github/workflows/*.md"]
15
+ }
16
+ }
@@ -0,0 +1,155 @@
1
+ ---
2
+ description: 'Guardian Framework - Token-optimized agentic development workflow'
3
+ applyTo: '**/*'
4
+ ---
5
+ <!--
6
+ Canonical Reference: .pi/github/copilot-instructions.md
7
+ Blueprint Source: Guardian Framework v1.2
8
+ Generated: {{GENERATED_TIMESTAMP}}
9
+ DO NOT EDIT DIRECTLY - Modify source in .pi/agent/AGENTS.md
10
+ -->
11
+
12
+ # {{PROJECT_NAME}} - Guardian Framework Project
13
+
14
+ **Version:** {{PROJECT_VERSION}}
15
+ **Language:** {{LANGUAGE}}
16
+ **Architecture:** Pi-first with canonical references
17
+
18
+ ---
19
+
20
+ ## Project Overview
21
+
22
+ [Project description - edit in .pi/agent/AGENTS.md]
23
+
24
+ ---
25
+
26
+ ## Development Commands
27
+
28
+ ### Build
29
+ ```bash
30
+ {{BUILD_COMMAND}}
31
+ ```
32
+
33
+ ### Test
34
+ ```bash
35
+ {{TEST_COMMAND}}
36
+ ```
37
+
38
+ ### Lint
39
+ ```bash
40
+ {{LINT_COMMAND}}
41
+ ```
42
+
43
+ ### Format
44
+ ```bash
45
+ {{FORMAT_COMMAND}}
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Architecture
51
+
52
+ This project uses **pi-first architecture** with canonical references:
53
+
54
+ - `.pi/` is the source of truth
55
+ - `.claude/`, `.opencode/`, `.github/` are generated exports
56
+ - All implementation files reference `.pi/architecture/modules/`
57
+
58
+ ### Key Files to Read
59
+
60
+ | File | Purpose |
61
+ |------|---------|
62
+ | `.pi/INDEX.md` | Framework quick reference |
63
+ | `.pi/architecture/modules/*.md` | Module architecture docs |
64
+ | `.pi/context/project.md` | Project facts and commands |
65
+ | `.pi/context/patterns.md` | Code templates |
66
+
67
+ ---
68
+
69
+ ## Canonical Reference Requirement
70
+
71
+ **All implementation files must include architecture reference:**
72
+
73
+ ```typescript
74
+ /**
75
+ * Canonical Reference: .pi/architecture/modules/[module].md#[section]
76
+ * Implements: [spec from architecture]
77
+ * Last Architecture Sync: [check CHANGELOG.md]
78
+ */
79
+ ```
80
+
81
+ **Before coding:**
82
+ 1. Check `.pi/architecture/CHANGELOG.md` for pending changes
83
+ 2. Verify architecture module doc for target module
84
+ 3. Reference specific section (not just file)
85
+
86
+ ---
87
+
88
+ ## Coding Standards
89
+
90
+ ### Error Handling
91
+ {{ERROR_HANDLING_PATTERN}}
92
+
93
+ ### Logging
94
+ {{TRACING_PATTERN}}
95
+
96
+ ### Cancellation
97
+ {{CANCELLATION_PATTERN}}
98
+
99
+ ### Atomic Writes
100
+ {{ATOMIC_WRITE_PATTERN}}
101
+
102
+ ---
103
+
104
+ ## Validation
105
+
106
+ Before any commit, ensure:
107
+
108
+ ```bash
109
+ # Run all validators
110
+ bash .pi/scripts/validate-ci.sh
111
+ bash .pi/scripts/validate-canonical.sh
112
+
113
+ # For moderate+ scope, also run:
114
+ bash .pi/scripts/validate-architecture.sh
115
+
116
+ # For complex+ scope, also run:
117
+ bash .pi/scripts/validate-security.sh
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Workflows
123
+
124
+ | Command | Purpose |
125
+ |---------|---------|
126
+ | `/epic-plan` | Architecture analysis + epic slicing |
127
+ | `/blueprint-validate` | Validate .pi/ integrity |
128
+ | `/sync-check` | Verify exports match blueprint |
129
+ | `/issue-closeout` | Validate + create compliance MR |
130
+
131
+ ---
132
+
133
+ ## Repository Tool
134
+
135
+ Using: **{{REPOTOOL}}**
136
+
137
+ | Tool | Commands |
138
+ |------|----------|
139
+ | `gh` | `gh issue create`, `gh pr create`, `gh pr merge` |
140
+ | `glab` | `glab issue create`, `glab mr create`, `glab mr merge` |
141
+
142
+ ---
143
+
144
+ ## Quality Gates
145
+
146
+ - [ ] Build succeeds
147
+ - [ ] Tests pass
148
+ - [ ] Lint clean
149
+ - [ ] Canonical references ≥50% coverage
150
+ - [ ] Architecture CHANGELOG checked
151
+
152
+ ---
153
+
154
+ *Framework version: 1.2.0*
155
+ *Generated by guardian-framework*