@gavin-hu/my-pi-agent 0.13.1 → 0.15.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/README.md +66 -41
- package/README.zh-CN.md +53 -36
- package/extensions/bytefly/README.md +321 -186
- package/extensions/bytefly/block/component.ts +7 -15
- package/extensions/bytefly/block/register.ts +6 -1
- package/extensions/bytefly/doctor/config.ts +4 -1
- package/extensions/bytefly/doctor/register.ts +24 -5
- package/extensions/bytefly/doctor/tools.ts +4 -0
- package/extensions/bytefly/footer/collect/snapshot.ts +6 -1
- package/extensions/bytefly/footer/config.ts +10 -6
- package/extensions/bytefly/footer/price/config.ts +3 -2
- package/extensions/bytefly/footer/price/price.ts +5 -3
- package/extensions/bytefly/footer/price/rates.ts +63 -26
- package/extensions/bytefly/footer/render/status.ts +3 -3
- package/extensions/bytefly/header/component.ts +33 -10
- package/extensions/bytefly/header/config.ts +22 -0
- package/extensions/bytefly/header/register.ts +2 -1
- package/extensions/bytefly/index.ts +6 -6
- package/extensions/bytefly/notice/component.ts +8 -3
- package/extensions/bytefly/notify/config.ts +7 -12
- package/extensions/bytefly/notify/dispatch.ts +13 -5
- package/extensions/bytefly/panel/commands.ts +22 -2
- package/extensions/bytefly/panel/format.ts +17 -21
- package/extensions/bytefly/panel/settings-runtime.ts +86 -22
- package/extensions/bytefly/panel/settings.ts +279 -46
- package/extensions/bytefly/panel/themes.ts +32 -0
- package/extensions/bytefly/panel/tui/editing.ts +77 -0
- package/extensions/bytefly/panel/tui/entries.ts +24 -0
- package/extensions/bytefly/panel/tui/extensions-view.ts +13 -8
- package/extensions/bytefly/panel/tui/frame.ts +121 -4
- package/extensions/bytefly/panel/tui/settings-view.ts +98 -13
- package/extensions/bytefly/panel/tui.ts +176 -166
- package/extensions/bytefly/picker/discovery.ts +1 -0
- package/extensions/bytefly/picker/types.ts +2 -0
- package/extensions/bytefly/separator/component.ts +17 -6
- package/extensions/bytefly/separator/config.ts +15 -0
- package/extensions/bytefly/separator/format.ts +60 -6
- package/extensions/bytefly/separator/register.ts +68 -9
- package/extensions/bytefly/separator/types.ts +8 -0
- package/extensions/bytefly/update/cache.ts +58 -19
- package/extensions/bytefly/update/check.ts +35 -0
- package/extensions/bytefly/update/format.ts +76 -35
- package/extensions/bytefly/update/register.ts +144 -55
- package/extensions/bytefly/update/state.ts +4 -2
- package/extensions/bytefly/update/suppress.ts +66 -0
- package/extensions/bytefly/update/types.ts +15 -0
- package/extensions/bytefly/working/config.ts +4 -5
- package/extensions/bytefly/working/format.ts +24 -7
- package/extensions/bytefly/working/register.ts +34 -3
- package/extensions/check/README.md +253 -0
- package/extensions/check/commands.ts +128 -0
- package/extensions/check/config.ts +39 -0
- package/extensions/check/detect.ts +269 -0
- package/extensions/check/failures.ts +230 -0
- package/extensions/check/format.ts +135 -0
- package/extensions/check/index.ts +26 -0
- package/extensions/check/render.ts +185 -0
- package/extensions/check/runner.ts +176 -0
- package/extensions/check/runtime.ts +244 -0
- package/extensions/check/source.ts +80 -0
- package/extensions/check/tools.ts +173 -0
- package/extensions/check/tui.ts +195 -0
- package/extensions/check/types.ts +99 -0
- package/extensions/document/README.md +1 -1
- package/extensions/document/extract/pdf.ts +8 -16
- package/extensions/document/formats.ts +2 -2
- package/extensions/file-browse/README.md +66 -32
- package/extensions/file-browse/client.ts +95 -32
- package/extensions/file-browse/config.ts +9 -9
- package/extensions/file-browse/git.ts +37 -47
- package/extensions/file-browse/html.ts +39 -58
- package/extensions/file-browse/markdown.ts +110 -92
- package/extensions/file-browse/raw-html.ts +478 -0
- package/extensions/file-browse/router.ts +32 -70
- package/extensions/file-browse/server.ts +18 -56
- package/extensions/file-browse/urls.ts +80 -0
- package/extensions/goal/README.md +103 -47
- package/extensions/goal/clarify-parse.ts +4 -9
- package/extensions/goal/clarify.ts +27 -4
- package/extensions/goal/commands.ts +24 -11
- package/extensions/goal/format.ts +41 -10
- package/extensions/goal/index.ts +39 -16
- package/extensions/goal/plan-route.ts +51 -0
- package/extensions/goal/schema.ts +6 -23
- package/extensions/goal/state.ts +39 -57
- package/extensions/goal/tools.ts +26 -20
- package/extensions/goal/types.ts +11 -1
- package/extensions/job/README.md +20 -6
- package/extensions/job/format.ts +18 -68
- package/extensions/job/index.ts +26 -41
- package/extensions/job/log-writer.ts +208 -0
- package/extensions/job/logs.ts +3 -2
- package/extensions/job/process.ts +6 -99
- package/extensions/job/runtime.ts +42 -181
- package/extensions/job/schema.ts +1 -4
- package/extensions/job/tools.ts +1 -15
- package/extensions/job/tui.ts +117 -307
- package/extensions/job/ui.ts +7 -33
- package/extensions/memory/README.md +3 -1
- package/extensions/memory/errors.ts +5 -6
- package/extensions/memory/tui.ts +14 -24
- package/extensions/plan/README.md +106 -18
- package/extensions/plan/commands.ts +9 -5
- package/extensions/plan/format.ts +87 -0
- package/extensions/plan/index.ts +31 -15
- package/extensions/plan/plans.ts +2 -3
- package/extensions/plan/policy.ts +0 -6
- package/extensions/plan/runtime.ts +4 -2
- package/extensions/plan/steps.ts +37 -8
- package/extensions/plan/todos.ts +44 -3
- package/extensions/plan/tools/enter.ts +94 -0
- package/extensions/plan/tools/exit.ts +296 -0
- package/extensions/plan/tools/nested.ts +21 -0
- package/extensions/plan/tools/steps.ts +136 -0
- package/extensions/plan/tools/todo-seed.ts +76 -0
- package/extensions/plan/tools/write.ts +127 -0
- package/extensions/plan/tools.ts +18 -703
- package/extensions/plan/web-client.ts +6 -22
- package/extensions/plan/web-page.ts +19 -30
- package/extensions/plan/web-router.ts +34 -71
- package/extensions/plan/web.ts +13 -40
- package/extensions/question/answers.ts +3 -8
- package/extensions/question/tui.ts +6 -6
- package/extensions/rewind/README.md +95 -22
- package/extensions/rewind/checklist.ts +185 -0
- package/extensions/rewind/commands.ts +8 -0
- package/extensions/rewind/config.ts +3 -11
- package/extensions/rewind/format.ts +220 -2
- package/extensions/rewind/git.ts +74 -7
- package/extensions/rewind/hunk-picker.ts +114 -0
- package/extensions/rewind/patch.ts +88 -0
- package/extensions/rewind/path-picker.ts +67 -100
- package/extensions/rewind/paths.ts +93 -19
- package/extensions/rewind/restore.ts +53 -10
- package/extensions/rewind/review-tui.ts +320 -0
- package/extensions/rewind/review.ts +397 -0
- package/extensions/rewind/rewind-tui.ts +4 -3
- package/extensions/rewind/runtime.ts +94 -17
- package/extensions/subagent/README.md +118 -8
- package/extensions/subagent/background-tui.ts +208 -0
- package/extensions/subagent/background.ts +470 -0
- package/extensions/subagent/commands.ts +80 -0
- package/extensions/subagent/config.ts +62 -0
- package/extensions/subagent/format.ts +24 -1
- package/extensions/subagent/index.ts +116 -1
- package/extensions/subagent/orchestrate.ts +16 -3
- package/extensions/subagent/render.ts +25 -0
- package/extensions/subagent/run.ts +113 -49
- package/extensions/subagent/schema.ts +12 -0
- package/extensions/subagent/transcripts.ts +202 -0
- package/extensions/subagent/types.ts +23 -0
- package/extensions/subagent/ui.ts +50 -0
- package/extensions/todo/README.md +18 -13
- package/extensions/todo/format.ts +3 -2
- package/extensions/todo/runtime.ts +3 -2
- package/extensions/todo/schema.ts +8 -84
- package/extensions/todo/state.ts +5 -46
- package/extensions/todo/tools.ts +2 -1
- package/extensions/todo/types.ts +6 -15
- package/extensions/watch/README.md +16 -6
- package/extensions/watch/child.ts +150 -0
- package/extensions/watch/format.ts +8 -48
- package/extensions/watch/index.ts +42 -58
- package/extensions/watch/runtime.ts +49 -128
- package/extensions/watch/schema.ts +1 -4
- package/extensions/watch/tools.ts +1 -11
- package/extensions/watch/tui.ts +103 -273
- package/extensions/watch/ui.ts +5 -32
- package/extensions/web-access/README.md +1 -1
- package/extensions/web-access/fetch/page.ts +1 -1
- package/extensions/web-access/fetch/tool.ts +6 -2
- package/extensions/web-access/search/search.ts +2 -5
- package/extensions/wechat/README.md +3 -1
- package/extensions/wechat/client.ts +23 -0
- package/extensions/wechat/commands.ts +57 -42
- package/extensions/wechat/deliver.ts +5 -9
- package/extensions/wechat/errors.ts +3 -6
- package/extensions/wechat/inbound.ts +2 -5
- package/extensions/wechat/index.ts +2 -8
- package/extensions/wechat/outbound.ts +2 -4
- package/extensions/wechat/peer-worker.ts +3 -8
- package/extensions/wechat/poll.ts +10 -9
- package/extensions/wechat/presence.ts +35 -62
- package/extensions/wechat/reply-pipeline.ts +3 -1
- package/extensions/wechat/status-screen.ts +1 -1
- package/extensions/wechat/timer.ts +57 -0
- package/extensions/worktree/config.ts +8 -20
- package/extensions/worktree/enter.ts +7 -12
- package/extensions/worktree/git.ts +38 -69
- package/extensions/worktree/index.ts +5 -4
- package/extensions/worktree/registry.ts +7 -7
- package/extensions/worktree/root-tools.ts +2 -2
- package/extensions/worktree/status.ts +3 -2
- package/lib/README.md +22 -8
- package/lib/config.ts +83 -12
- package/lib/errors.ts +12 -0
- package/lib/format.ts +56 -0
- package/lib/git/read.ts +8 -0
- package/lib/goal-state.ts +23 -8
- package/lib/http/headers.ts +54 -0
- package/lib/http/index.ts +13 -0
- package/lib/http/response.ts +46 -0
- package/lib/http/router.ts +52 -0
- package/lib/http/server.ts +91 -0
- package/lib/lines.ts +77 -0
- package/lib/pdf.ts +82 -0
- package/lib/plan-entry.ts +71 -0
- package/lib/plan-state.ts +34 -0
- package/lib/report.ts +99 -0
- package/lib/requirements.ts +25 -19
- package/lib/spawn.ts +170 -0
- package/lib/todo-state.ts +110 -23
- package/lib/tool-names.ts +7 -0
- package/lib/tool-result.ts +33 -0
- package/lib/tui/README.md +68 -3
- package/lib/tui/chrome.ts +28 -4
- package/lib/tui/columns.ts +6 -1
- package/lib/tui/confirm.ts +65 -0
- package/lib/tui/dock-screen.ts +410 -0
- package/lib/tui/glyphs.ts +2 -1
- package/lib/tui/indent.ts +1 -1
- package/lib/tui/index.ts +2 -0
- package/lib/tui/rows.ts +21 -0
- package/lib/tui/status-controller.ts +35 -1
- package/lib/tui/tool.ts +59 -1
- package/lib/web/components.ts +20 -1
- package/lib/web/markup.ts +32 -0
- package/lib/web/runtime.ts +50 -0
- package/package.json +23 -5
- package/skills/init/SKILL.md +165 -0
- package/skills/init/references/agents-md-quality.md +103 -0
- package/skills/init/references/interview-questions.md +81 -0
- package/skills/refactor/SKILL.md +141 -0
- package/themes/bytefly-dark.json +2 -3
- package/themes/bytefly-light.json +2 -3
- package/extensions/watch/process.ts +0 -63
- package/extensions/web-access/fetch/pdf.ts +0 -45
package/lib/web/markup.ts
CHANGED
|
@@ -97,3 +97,35 @@ export function button(options: ButtonOptions): string {
|
|
|
97
97
|
const rendered = attrs.map(([key, value]) => ` ${key}="${escapeHtml(value)}"`).join("");
|
|
98
98
|
return `<button type="button" class="${classes}"${rendered}>${escapeHtml(options.label)}</button>`;
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
/** One row of the keyboard sheet: the key or chord, and what it does. */
|
|
102
|
+
export interface KeyHint {
|
|
103
|
+
/** The key or chord, one `<kbd>` per entry; a single string is one key, chord, or alias run. */
|
|
104
|
+
keys: string | readonly string[];
|
|
105
|
+
/** What the key does. */
|
|
106
|
+
label: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The `?` keyboard sheet: the dialog of key/label rows both pages share, hidden
|
|
111
|
+
* until the client opens it.
|
|
112
|
+
*
|
|
113
|
+
* The ids are the contract with `keysDialogScript` in `runtime.ts` — `#keys-dialog`
|
|
114
|
+
* for the sheet, `#keys-close` for its own close button — and the trigger button
|
|
115
|
+
* is the page's own concern, since the two pages name it differently.
|
|
116
|
+
*/
|
|
117
|
+
export function keysSheet(rows: readonly KeyHint[]): string {
|
|
118
|
+
const kbd = (key: string): string => `<kbd class="bf-kbd">${escapeHtml(key)}</kbd>`;
|
|
119
|
+
const body = rows
|
|
120
|
+
.map((row) => {
|
|
121
|
+
const keys = typeof row.keys === "string" ? kbd(row.keys) : row.keys.map(kbd).join(" ");
|
|
122
|
+
return `<div><dt>${keys}</dt><dd>${escapeHtml(row.label)}</dd></div>`;
|
|
123
|
+
})
|
|
124
|
+
.join("\n");
|
|
125
|
+
return `<div class="bf-dialog" id="keys-dialog" hidden>
|
|
126
|
+
<div class="bf-dialog__panel" role="dialog" aria-modal="true" aria-labelledby="keys-title">
|
|
127
|
+
<div class="bf-dialog__head"><h2 id="keys-title">Keyboard shortcuts</h2><span class="bf-spacer"></span><button type="button" class="bf-btn" id="keys-close">Close</button></div>
|
|
128
|
+
<dl class="bf-keys">${body}</dl>
|
|
129
|
+
</div>
|
|
130
|
+
</div>`;
|
|
131
|
+
}
|
package/lib/web/runtime.ts
CHANGED
|
@@ -66,3 +66,53 @@ export const THEME_TOGGLE_JS = String.raw`(function () {
|
|
|
66
66
|
else if (query.addListener) query.addListener(sync);
|
|
67
67
|
}
|
|
68
68
|
})();`;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The `?` keyboard sheet's wiring, shared by both clients.
|
|
72
|
+
*
|
|
73
|
+
* It owns the sheet's pointer behavior — the page's trigger button, the sheet's
|
|
74
|
+
* own close button, and a click on the backdrop — and nothing else: each page
|
|
75
|
+
* keeps its own keyboard policy in its keydown handler, because the two differ
|
|
76
|
+
* (the review peels `Esc` through a composer first), and calls in through
|
|
77
|
+
* `window.bfKeys`.
|
|
78
|
+
*
|
|
79
|
+
* `triggerId` is the page's own shortcut button, since browse opens the sheet
|
|
80
|
+
* from `#keys-open` and review from `#shortcuts`. The sheet's ids are the fixed
|
|
81
|
+
* contract in `keysSheet` (`lib/web/markup.ts`).
|
|
82
|
+
*
|
|
83
|
+
* Value-only: the open state is the dialog's own `hidden` attribute, so this
|
|
84
|
+
* module holds nothing.
|
|
85
|
+
*/
|
|
86
|
+
export function keysDialogScript(triggerId: string): string {
|
|
87
|
+
return `(function () {
|
|
88
|
+
"use strict";
|
|
89
|
+
var dialog = document.getElementById("keys-dialog");
|
|
90
|
+
if (!dialog) return;
|
|
91
|
+
|
|
92
|
+
function isOpen() {
|
|
93
|
+
return !dialog.hidden;
|
|
94
|
+
}
|
|
95
|
+
function toggle(force) {
|
|
96
|
+
var open = force === undefined ? dialog.hidden : force;
|
|
97
|
+
dialog.hidden = !open;
|
|
98
|
+
if (open) {
|
|
99
|
+
var close = document.getElementById("keys-close");
|
|
100
|
+
if (close && close.focus) close.focus();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var trigger = document.getElementById("${triggerId}");
|
|
105
|
+
if (trigger) trigger.addEventListener("click", function () { toggle(); });
|
|
106
|
+
var closer = document.getElementById("keys-close");
|
|
107
|
+
if (closer) closer.addEventListener("click", function () { toggle(false); });
|
|
108
|
+
dialog.addEventListener("click", function (event) {
|
|
109
|
+
if (event.target === dialog) toggle(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
window.bfKeys = {
|
|
113
|
+
toggle: toggle,
|
|
114
|
+
close: function () { toggle(false); },
|
|
115
|
+
isOpen: isOpen
|
|
116
|
+
};
|
|
117
|
+
})();`;
|
|
118
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gavin-hu/my-pi-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Personal Pi customizations, packaged as a Pi package: worktree isolation and rewind snapshots, question, todo, goal, plan, subagent, job, watch, web-access, file-browse, file-open, document, memory, wechat, and bytefly.",
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "Personal Pi customizations, packaged as a Pi package: worktree isolation and rewind snapshots, question, todo, goal, plan, subagent, job, watch, web-access, file-browse, file-open, document, check, memory, wechat, and bytefly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
7
7
|
"pi",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"goal",
|
|
12
12
|
"objective",
|
|
13
13
|
"plan",
|
|
14
|
+
"question",
|
|
15
|
+
"init",
|
|
16
|
+
"agents-md",
|
|
17
|
+
"refactor",
|
|
18
|
+
"skill",
|
|
14
19
|
"subagent",
|
|
15
20
|
"agents",
|
|
16
21
|
"delegation",
|
|
@@ -45,11 +50,17 @@
|
|
|
45
50
|
"read_doc",
|
|
46
51
|
"memory",
|
|
47
52
|
"cross-session",
|
|
53
|
+
"wechat",
|
|
48
54
|
"web-access",
|
|
49
55
|
"bytefly",
|
|
50
56
|
"footer",
|
|
51
57
|
"separator",
|
|
52
|
-
"transcript"
|
|
58
|
+
"transcript",
|
|
59
|
+
"check",
|
|
60
|
+
"test",
|
|
61
|
+
"lint",
|
|
62
|
+
"typecheck",
|
|
63
|
+
"verification"
|
|
53
64
|
],
|
|
54
65
|
"type": "module",
|
|
55
66
|
"license": "MIT",
|
|
@@ -61,6 +72,7 @@
|
|
|
61
72
|
"files": [
|
|
62
73
|
"extensions/**",
|
|
63
74
|
"lib/**",
|
|
75
|
+
"skills/**",
|
|
64
76
|
"themes/**",
|
|
65
77
|
"!**/*.test.ts"
|
|
66
78
|
],
|
|
@@ -76,6 +88,7 @@
|
|
|
76
88
|
"./extensions/todo/index.ts",
|
|
77
89
|
"./extensions/goal/index.ts",
|
|
78
90
|
"./extensions/plan/index.ts",
|
|
91
|
+
"./extensions/check/index.ts",
|
|
79
92
|
"./extensions/subagent/index.ts",
|
|
80
93
|
"./extensions/job/index.ts",
|
|
81
94
|
"./extensions/watch/index.ts",
|
|
@@ -87,6 +100,9 @@
|
|
|
87
100
|
"./extensions/wechat/index.ts",
|
|
88
101
|
"./extensions/bytefly/index.ts"
|
|
89
102
|
],
|
|
103
|
+
"skills": [
|
|
104
|
+
"./skills"
|
|
105
|
+
],
|
|
90
106
|
"themes": [
|
|
91
107
|
"./themes/*.json"
|
|
92
108
|
],
|
|
@@ -99,12 +115,14 @@
|
|
|
99
115
|
"typecheck": "tsc --noEmit",
|
|
100
116
|
"format": "biome format --write .",
|
|
101
117
|
"format:check": "biome format .",
|
|
102
|
-
"check": "bun run format:check && bun run typecheck
|
|
103
|
-
"check
|
|
118
|
+
"check:static": "bun run format:check && bun run typecheck",
|
|
119
|
+
"check": "bun run check:static && bun run test",
|
|
120
|
+
"check:serial": "bun run check:static && bun run test:serial",
|
|
104
121
|
"release:notes": "bun run scripts/release-notes.ts",
|
|
105
122
|
"config:migrate": "bun run scripts/migrate-config.ts",
|
|
106
123
|
"compat:versions": "bun run scripts/peer-versions.ts",
|
|
107
124
|
"bench:render": "bun run scripts/render-bench.ts",
|
|
125
|
+
"screenshot:file-browse": "bun run scripts/file-browse-shot.ts",
|
|
108
126
|
"screenshot:plan": "bun run scripts/plan-review-shot.ts",
|
|
109
127
|
"screenshot:tools": "bun run scripts/tool-renderings.ts gallery assets/tool-renderings.png",
|
|
110
128
|
"screenshot:tool-pngs": "bun run scripts/tool-renderings.ts tools assets/tools",
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: init
|
|
3
|
+
description: "Initialize or refresh AGENTS.md through a built-in interactive interview and a reviewed plan. Use when the user runs /skill:init or asks to set up project agent instructions."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Initialize AGENTS.md
|
|
8
|
+
|
|
9
|
+
Goal: create or update **`AGENTS.md` at the project root** by combining repository
|
|
10
|
+
evidence with a short, built-in interview. The interview captures intent the code
|
|
11
|
+
cannot show; the repository supplies every command, path, and convention that can
|
|
12
|
+
be verified. Plan mode is the review gate: no write happens before approval.
|
|
13
|
+
|
|
14
|
+
`/skill:init` loads this skill. If plan mode is not active, call
|
|
15
|
+
`enter_plan_mode` and wait for confirmation. Keep the interview and the plan
|
|
16
|
+
review in that order; do not write the file early to save a step.
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
/skill:init
|
|
22
|
+
└─> plan mode (read-only)
|
|
23
|
+
└─> recon: manifests, docs, CI, tests, existing instructions
|
|
24
|
+
└─> interview: one built-in question call (at most 4)
|
|
25
|
+
├─ answers ───────────────> reconcile with evidence
|
|
26
|
+
└─ unavailable/cancelled ─> evidence + recorded assumptions
|
|
27
|
+
└─> draft: new file, exact edits, or an honest no-op
|
|
28
|
+
└─> quality gate
|
|
29
|
+
└─> write_plan ──> exit_plan_mode
|
|
30
|
+
├─ not approved ──> refine the same plan
|
|
31
|
+
└─ approved ──────> write/edit AGENTS.md
|
|
32
|
+
└─ read back + quality gate
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Read [`references/interview-questions.md`](./references/interview-questions.md)
|
|
36
|
+
before the interview. Read
|
|
37
|
+
[`references/agents-md-quality.md`](./references/agents-md-quality.md) before
|
|
38
|
+
drafting and again before writing the plan.
|
|
39
|
+
|
|
40
|
+
## Repository states
|
|
41
|
+
|
|
42
|
+
| State | Interview | Outcome |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| Existing project, no `AGENTS.md` | Purpose (only if unclear; otherwise Priorities), Verify, Rules, Isolation | New smallest-useful file. |
|
|
45
|
+
| Existing `AGENTS.md` | Existing file, Preserve (only if sections are unclear), Priorities (only if stale), Rules | Exact edits that preserve correct instructions, or a no-op. |
|
|
46
|
+
| Empty or near-empty repository | Stack, Commands, Purpose, Priorities | Honest minimal file from the answers and known facts only. |
|
|
47
|
+
| Related instruction files exist | Swap Related docs in for Preserve or Rules | Describe the relationship; do not duplicate the other file. |
|
|
48
|
+
| Git repository with no guidance | Isolation, Verify, Done, External changes | Prefer this set over a generic workflow question. |
|
|
49
|
+
| No UI, inactive tool, or cancelled interview | Skip the call; record the gaps as assumptions | Evidence-based draft; the plan review remains the place to correct it. |
|
|
50
|
+
|
|
51
|
+
The full bank, selectable alternatives, and option wording live in
|
|
52
|
+
`references/interview-questions.md`. The table above is the default, not a menu to
|
|
53
|
+
exhaust.
|
|
54
|
+
|
|
55
|
+
## 1. Recon
|
|
56
|
+
|
|
57
|
+
- Read existing instruction files first: `AGENTS.md`, `AGENTS.override.md`,
|
|
58
|
+
`CLAUDE.md`, and nested `AGENTS.md` files. Note how they relate; do not silently
|
|
59
|
+
absorb or replace one.
|
|
60
|
+
- Read the files that define the project: manifests, lockfiles, README, docs
|
|
61
|
+
index, source layout, tests, CI, formatter and linter configuration.
|
|
62
|
+
- Build a short evidence sheet: stack, layout, install/test/lint/typecheck
|
|
63
|
+
commands, validation gates, release path, and existing rules.
|
|
64
|
+
- List the gaps the interview must fill. Stop the first pass once the shape is
|
|
65
|
+
clear; do not investigate the whole repository before asking.
|
|
66
|
+
- In an empty or near-empty repository, record that evidence is absent. Never
|
|
67
|
+
invent a command from a language's usual tooling.
|
|
68
|
+
- Check that any command you plan to record is copied from a file that defines it.
|
|
69
|
+
- Use `read`, `grep`, `find`, and `ls`. For a large repository, delegate a
|
|
70
|
+
read-only survey to the `explorer` or `reviewer` subagent.
|
|
71
|
+
- Do not read or copy secrets, credentials, tokens, or private environment
|
|
72
|
+
values. If a file looks like a secret store, stop reading it.
|
|
73
|
+
|
|
74
|
+
## 2. Interview
|
|
75
|
+
|
|
76
|
+
Use `ask_user_question` once with at most four questions from the built-in bank.
|
|
77
|
+
Choose the deterministic default set for the repository state.
|
|
78
|
+
|
|
79
|
+
- One call is the default. Make a second call only when an answer leaves a
|
|
80
|
+
material ambiguity that changes what the file says; do not ask a second round
|
|
81
|
+
merely to collect preferences.
|
|
82
|
+
- Fill option labels with evidence: the detected test command, the actual package
|
|
83
|
+
manager, the real instruction file names. Keep a free-form escape on every
|
|
84
|
+
question whose answer cannot be enumerated.
|
|
85
|
+
- Ask only what the evidence cannot answer. Do not ask for the stack when a
|
|
86
|
+
manifest states it, or for a command already documented in CI.
|
|
87
|
+
- Never ask for secrets, credentials, tokens, environment values, or personal
|
|
88
|
+
data.
|
|
89
|
+
- If the answers contradict the repository, keep the conflict visible in the plan
|
|
90
|
+
instead of silently choosing a side.
|
|
91
|
+
- If the user cancels or the tool is unavailable, continue from evidence and
|
|
92
|
+
record each unanswered gap under assumptions in the plan. In an empty
|
|
93
|
+
repository this means an explicit skeleton that says it is newly initialized,
|
|
94
|
+
with no guessed commands.
|
|
95
|
+
- A follow-up question that is cancelled keeps the first round's answers.
|
|
96
|
+
|
|
97
|
+
## 3. Reconcile and draft
|
|
98
|
+
|
|
99
|
+
Treat answers and evidence as different kinds of fact:
|
|
100
|
+
|
|
101
|
+
- Commands, paths, package names, and existing behavior come from the repository.
|
|
102
|
+
- Purpose, priorities, scope, workflow, and preferences come from the user.
|
|
103
|
+
- If they conflict, record the conflict, what the draft uses, and the alternative
|
|
104
|
+
in the plan. Do not quietly rewrite the user's intent or invent a command to
|
|
105
|
+
match it.
|
|
106
|
+
|
|
107
|
+
Then choose the outcome:
|
|
108
|
+
|
|
109
|
+
- **No `AGENTS.md`** — draft the smallest useful file. Use the sections this
|
|
110
|
+
repository needs; omit empty ones.
|
|
111
|
+
- **Existing `AGENTS.md`** — preserve correct instructions and propose exact
|
|
112
|
+
edits for the rest. If the user chose to rewrite, the plan must still list what
|
|
113
|
+
is being removed.
|
|
114
|
+
- **Accurate `AGENTS.md`** — propose no edits and explain the no-op with evidence.
|
|
115
|
+
- **Empty or near-empty repository** — say plainly that it is newly initialized,
|
|
116
|
+
record the interview facts, and omit commands and architecture that do not
|
|
117
|
+
exist yet.
|
|
118
|
+
- **Related instruction files** — state the relationship and link them instead of
|
|
119
|
+
copying their content.
|
|
120
|
+
|
|
121
|
+
Prefer short rules over prose. One instruction should have one job. Link deep
|
|
122
|
+
documentation rather than restating it.
|
|
123
|
+
|
|
124
|
+
## 4. Pass the quality gate
|
|
125
|
+
|
|
126
|
+
Read `references/agents-md-quality.md` before drafting and again before saving the
|
|
127
|
+
plan. Revise a draft that fails the checklist rather than shipping it.
|
|
128
|
+
|
|
129
|
+
For a large or unfamiliar repository, optionally ask the read-only `reviewer`
|
|
130
|
+
subagent to critique the draft against the checklist. Use its findings as
|
|
131
|
+
evidence, not as a replacement for reading the repository.
|
|
132
|
+
|
|
133
|
+
## 5. Plan and review
|
|
134
|
+
|
|
135
|
+
- Save the proposal with `write_plan`. The plan must include:
|
|
136
|
+
- the recon summary and the evidence that supports the draft;
|
|
137
|
+
- the questions asked, the answers, and how each answer was used;
|
|
138
|
+
- the full draft for a new file, or the exact edits for an existing one;
|
|
139
|
+
- assumptions, conflicts, and unanswered gaps from a cancelled or unavailable
|
|
140
|
+
interview;
|
|
141
|
+
- a verification step that reads the written file back against the checklist.
|
|
142
|
+
- Call `exit_plan_mode` with the returned path.
|
|
143
|
+
- If the user refines or rejects the plan, stay in plan mode, rewrite the same
|
|
144
|
+
plan file with `write_plan` (`plan_path`), and present it again.
|
|
145
|
+
- No `AGENTS.md` write may happen before approval.
|
|
146
|
+
|
|
147
|
+
## 6. Apply and verify
|
|
148
|
+
|
|
149
|
+
- Create a new file with `write`, or update an existing one with `edit`.
|
|
150
|
+
- Change only `AGENTS.md`. Do not touch unrelated files.
|
|
151
|
+
- Read the result back from disk and rerun the quality checklist against what is
|
|
152
|
+
actually there, not what you intended to write.
|
|
153
|
+
- Report the path, what the file covers, whether the interview was answered or
|
|
154
|
+
fell back to assumptions, and any real follow-up. Name a missing fact instead of
|
|
155
|
+
inventing it.
|
|
156
|
+
|
|
157
|
+
## Boundaries
|
|
158
|
+
|
|
159
|
+
- One target: `AGENTS.md` at the project root selected in the plan.
|
|
160
|
+
- Plan mode is mandatory. If it is unavailable, stop and explain why instead of
|
|
161
|
+
writing directly.
|
|
162
|
+
- The built-in bank is the default; one custom gap question is allowed only when
|
|
163
|
+
no entry covers a material fact, and it counts toward the four-question cap.
|
|
164
|
+
- Reviewing an existing file never means silently accepting it, and rewriting one
|
|
165
|
+
never means discarding its correct instructions without saying so.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# AGENTS.md quality checklist
|
|
2
|
+
|
|
3
|
+
Use this before drafting and again after writing the file. A draft fails when any
|
|
4
|
+
applicable answer is no. The interview and the written file are checked together:
|
|
5
|
+
an answered question that never reaches the file is as much a defect as an
|
|
6
|
+
invented command.
|
|
7
|
+
|
|
8
|
+
## Question-bank use
|
|
9
|
+
|
|
10
|
+
- [ ] The first call used the deterministic default set for the repository state.
|
|
11
|
+
- [ ] At most four questions were asked in the call.
|
|
12
|
+
- [ ] Options were filled from evidence where the bank names commands, files, or
|
|
13
|
+
instruction documents.
|
|
14
|
+
- [ ] No question duplicated a fact the recon already answered.
|
|
15
|
+
- [ ] No question asked for a secret, credential, token, environment value, or
|
|
16
|
+
personal data.
|
|
17
|
+
- [ ] A second call happened only for a material ambiguity, not to collect extra
|
|
18
|
+
preferences.
|
|
19
|
+
|
|
20
|
+
## Interview quality
|
|
21
|
+
|
|
22
|
+
- [ ] Every answer is reflected in the draft, or the plan states why it was not
|
|
23
|
+
adopted.
|
|
24
|
+
- [ ] A cancelled or unavailable interview left explicit assumptions instead of
|
|
25
|
+
guessed facts.
|
|
26
|
+
- [ ] A conflict between an answer and repository evidence is visible in the
|
|
27
|
+
plan, with the chosen resolution.
|
|
28
|
+
- [ ] The plan names which questions were asked and what the user answered.
|
|
29
|
+
|
|
30
|
+
## Evidence accuracy
|
|
31
|
+
|
|
32
|
+
- [ ] Every command is copied from a manifest, script, Makefile, CI file, or docs
|
|
33
|
+
page that defines it. No command is guessed.
|
|
34
|
+
- [ ] Every path and package name exists in the repository as written.
|
|
35
|
+
- [ ] Every claimed convention is visible in the code or contributor docs.
|
|
36
|
+
- [ ] Unknown facts are omitted or named as unknown. They are never filled with
|
|
37
|
+
plausible-sounding placeholders.
|
|
38
|
+
- [ ] An answer that contradicts the code is treated as intent, not as evidence
|
|
39
|
+
that the code is wrong.
|
|
40
|
+
|
|
41
|
+
## Specificity
|
|
42
|
+
|
|
43
|
+
- [ ] The file tells an agent something it could not learn from a quick look.
|
|
44
|
+
- [ ] It names the actual test, lint, typecheck, and single-test commands.
|
|
45
|
+
- [ ] It names the real architecture boundaries and the traps that matter here.
|
|
46
|
+
- [ ] Isolation, verification, and completion rules say what to do, not just what
|
|
47
|
+
to value.
|
|
48
|
+
- [ ] Generic advice that would fit any repository is removed.
|
|
49
|
+
|
|
50
|
+
## Concision
|
|
51
|
+
|
|
52
|
+
- [ ] Every section earns its place; empty sections are deleted.
|
|
53
|
+
- [ ] Rules are short, imperative, and one job each.
|
|
54
|
+
- [ ] Deep material is linked, not copied.
|
|
55
|
+
- [ ] The file is the smallest version that still prevents likely mistakes.
|
|
56
|
+
|
|
57
|
+
## Actionability
|
|
58
|
+
|
|
59
|
+
- [ ] Each instruction says what to do, where, or in what order.
|
|
60
|
+
- [ ] Commands include their working directory when it is not the root.
|
|
61
|
+
- [ ] Invariants name the failure they prevent.
|
|
62
|
+
- [ ] There is no advice that cannot be followed.
|
|
63
|
+
- [ ] Dependency, network, and off-limits rules name the boundary an agent must
|
|
64
|
+
respect.
|
|
65
|
+
|
|
66
|
+
## Stability
|
|
67
|
+
|
|
68
|
+
- [ ] The file avoids volatile file lists, line numbers, and transient counts.
|
|
69
|
+
- [ ] It favours stable paths, package names, and commands.
|
|
70
|
+
- [ ] It will still be mostly correct after ordinary refactoring.
|
|
71
|
+
|
|
72
|
+
## Non-duplication
|
|
73
|
+
|
|
74
|
+
- [ ] It does not restate the README or contributor guide.
|
|
75
|
+
- [ ] It does not duplicate `AGENTS.override.md`, `CLAUDE.md`, or a nested
|
|
76
|
+
`AGENTS.md`; the relationship is stated instead.
|
|
77
|
+
- [ ] Two sections do not give the same instruction.
|
|
78
|
+
|
|
79
|
+
## Existing files
|
|
80
|
+
|
|
81
|
+
- [ ] Correct existing instructions are preserved.
|
|
82
|
+
- [ ] Stale instructions are changed only when the replacement is supported by
|
|
83
|
+
repository evidence or an explicit answer.
|
|
84
|
+
- [ ] The plan lists exact edits, not a wholesale rewrite.
|
|
85
|
+
- [ ] A rewrite records what is being removed and why.
|
|
86
|
+
- [ ] A genuinely accurate file produces a no-op plan instead of churn.
|
|
87
|
+
|
|
88
|
+
## Empty repository
|
|
89
|
+
|
|
90
|
+
- [ ] No commands, architecture, or conventions are invented.
|
|
91
|
+
- [ ] The file says the repository is newly initialized.
|
|
92
|
+
- [ ] Only known facts and interview answers are recorded.
|
|
93
|
+
- [ ] Empty sections are omitted.
|
|
94
|
+
- [ ] Missing commands are named as missing, not replaced with a framework
|
|
95
|
+
default.
|
|
96
|
+
|
|
97
|
+
## Final read-back
|
|
98
|
+
|
|
99
|
+
- [ ] The written file matches the approved plan.
|
|
100
|
+
- [ ] The file was read back from disk, not recalled from memory.
|
|
101
|
+
- [ ] Only `AGENTS.md` changed.
|
|
102
|
+
- [ ] The report names the path, whether the interview was answered or fell back
|
|
103
|
+
to assumptions, and any real follow-up.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Built-in init questions
|
|
2
|
+
|
|
3
|
+
The `init` skill selects from this bank. It is a menu, not a checklist: one
|
|
4
|
+
`ask_user_question` call with at most four entries is the default, and a second
|
|
5
|
+
call is allowed only for a material ambiguity. Never ask for secrets,
|
|
6
|
+
credentials, tokens, environment values, or personal data.
|
|
7
|
+
|
|
8
|
+
## Consolidation rules
|
|
9
|
+
|
|
10
|
+
The bank merges questions that would otherwise create two copies of the same
|
|
11
|
+
answer:
|
|
12
|
+
|
|
13
|
+
- **Isolation** absorbs the workflow question: worktree, branch, or direct is the
|
|
14
|
+
first decision an agent makes.
|
|
15
|
+
- **Done** absorbs testing and documentation expectations: both define when a
|
|
16
|
+
task is complete.
|
|
17
|
+
- **Sensitive** absorbs generated, vendored, and secret-bearing paths.
|
|
18
|
+
- **External changes** absorbs dependency and network policy.
|
|
19
|
+
- **Commits** absorbs branch naming.
|
|
20
|
+
- **Scope** and **Related docs** stay separate because they decide where the file
|
|
21
|
+
applies and how it relates to another instruction file.
|
|
22
|
+
|
|
23
|
+
## Deterministic default sets
|
|
24
|
+
|
|
25
|
+
Use the first matching row. Fill option labels with evidence before asking.
|
|
26
|
+
|
|
27
|
+
| Repository state | First four questions |
|
|
28
|
+
|---|---|
|
|
29
|
+
| Existing project, no `AGENTS.md` | Purpose (only if unclear; otherwise Priorities), Verify, Rules, Isolation |
|
|
30
|
+
| Existing project, `AGENTS.md` present | Existing file, Preserve (only if sections are unclear), Priorities (only if stale), Rules |
|
|
31
|
+
| Empty or near-empty repository | Stack, Commands, Purpose, Priorities |
|
|
32
|
+
| Related instruction files present | Swap Related docs in for Preserve or Rules |
|
|
33
|
+
| Git repository with no guidance | Isolation, Verify, Done, External changes |
|
|
34
|
+
| No UI, inactive tool, or cancelled interview | No call; record the gaps as assumptions |
|
|
35
|
+
|
|
36
|
+
## Core questions
|
|
37
|
+
|
|
38
|
+
| Header | Question | Shape | Selected when |
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
| Purpose | What is this project, and who will agents work on it for? | Free-form | README and manifest do not state the purpose and audience, or the repository is empty/near-empty. |
|
|
41
|
+
| Verify | Which commands should an agent trust to verify a change? | Multi-select: detected install, build, test, lint, and typecheck commands, plus No reliable command yet; free-form Other for a missing command | Detected commands conflict or are ambiguous, or no command was found. |
|
|
42
|
+
| Rules | What should an agent know that is not obvious from the code? | Free-form | No explicit conventions, invariants, style rules, or traps are found in the source, docs, or contributor files. |
|
|
43
|
+
| Isolation | How should agents isolate and land work? | Single-select: Worktree per task, then PR; Branch in the current checkout, then PR; Commit directly; Follow repository instructions | The project is a Git repository with no stated isolation or branch rule. |
|
|
44
|
+
| Done | What must be true before a task is done? | Multi-select: Tests pass; Lint and typecheck pass; Docs and changelog updated; Diff self-reviewed; Pull request opened | No contributor guide defines done, test level, or documentation expectations. |
|
|
45
|
+
| Sensitive | Are any files, directories, or workflows off-limits for agents? | Free-form, including generated, vendored, and secret-bearing paths | Access boundaries are unclear, or generated, vendored, or secret-bearing paths need explicit exclusion. |
|
|
46
|
+
| External changes | May an agent add dependencies or use the network? | Single-select: Yes, when needed; Ask first; Offline and no new dependencies | A manifest exists and dependency, package-install, or network rules are unclear. |
|
|
47
|
+
| Existing file | How should the `init` skill handle the current `AGENTS.md`? | Single-select: Review and update in place; Keep it and only append missing guidance; Rewrite it from this interview | `AGENTS.md` already exists. |
|
|
48
|
+
|
|
49
|
+
## State questions
|
|
50
|
+
|
|
51
|
+
| Header | Question | Shape | Selected when |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| Stack | What are you building, and with which language or framework? | Free-form | The repository is empty/near-empty, or no manifest or README states the stack. |
|
|
54
|
+
| Commands | What install, build, test, lint, and typecheck commands do you intend to use? | Free-form, with None yet accepted | The repository is empty/near-empty and no real command exists to copy. |
|
|
55
|
+
| Related docs | How should `AGENTS.md` relate to existing instruction files? | Single-select: Link to them and add only gaps; Consolidate them into `AGENTS.md`; Leave them alone | `CLAUDE.md`, `AGENTS.override.md`, or a nested `AGENTS.md` exists. |
|
|
56
|
+
| Preserve | Which current instructions must stay? | Free-form | `AGENTS.md` exists and its authoritative sections are unclear. |
|
|
57
|
+
| Scope | Where should `AGENTS.md` apply? | Single-select: Repository root only; Root plus package-level files; Follow an existing instruction file | The repository is a monorepo, has nested packages, or already has a related instruction file. |
|
|
58
|
+
|
|
59
|
+
## Optional follow-ups
|
|
60
|
+
|
|
61
|
+
| Header | Question | Shape | Selected when |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| Priorities | What should agents optimize for here? | Multi-select: Correctness and safety; Small, reviewable changes; Fast iteration; Test coverage; Match existing style | No `AGENTS.md` yet, or the current priorities are absent or ambiguous. |
|
|
64
|
+
| Planning | When should an agent plan before acting? | Single-select: Non-trivial or multi-file work; Every task; Only when asked; Never | No plan-mode or workflow guidance exists. |
|
|
65
|
+
| Commits | What commit convention and branch naming should agents follow? | Single-select: Conventional Commits with type/scope; Plain descriptive messages; Repository-defined convention; No preference | No commit or branch guidance exists in docs or CI. |
|
|
66
|
+
| Release | What release or versioning process must an agent follow? | Single-select: Maintainer handles releases; Follow documented release steps; No release process; free-form Other | The project is published or versioned and the process is unclear. |
|
|
67
|
+
| Performance | Are there performance budgets or hot paths to protect? | Free-form | The project exposes performance-sensitive code or has benchmarks. |
|
|
68
|
+
| Environment | What local services or setup steps does an agent need? | Free-form, no secrets | Setup requires services, databases, or environment configuration that is not documented. |
|
|
69
|
+
| Finish | Anything else the next agent should know? | Free-form | Always optional, at most once. |
|
|
70
|
+
|
|
71
|
+
## Selection rules
|
|
72
|
+
|
|
73
|
+
- Ask at most four questions in one call, ordered by impact: state-specific
|
|
74
|
+
question first, then command verification, then conventions and limits.
|
|
75
|
+
- Use the deterministic default set for the state. Do not pick a random subset.
|
|
76
|
+
- Never ask for something the recon already answered, and never ask for a secret
|
|
77
|
+
or credential.
|
|
78
|
+
- One custom gap question is allowed only when no bank entry covers a material
|
|
79
|
+
fact. It counts toward the four-question cap.
|
|
80
|
+
- One follow-up call is allowed only when an answer creates a material ambiguity.
|
|
81
|
+
Cancel it cleanly if the user stops; the first round's answers stay valid.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactor
|
|
3
|
+
description: "Find and rank refactoring opportunities in a project or path: duplication, oversized modules, coupling, drift, and high-churn code with weak tests. Use when asked what to refactor, where the code is tangled, or for a refactor audit; discovery is read-only and returns an evidence-based shortlist."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Find refactoring opportunities
|
|
7
|
+
|
|
8
|
+
This is an audit, not an edit session. The deliverable is a ranked shortlist with
|
|
9
|
+
evidence; do not modify files while discovering. The skill is model-invoked when
|
|
10
|
+
a request matches the description; `/skill:refactor` is the explicit fallback.
|
|
11
|
+
|
|
12
|
+
A refactor changes structure without changing behavior. If the request changes
|
|
13
|
+
behavior, call it a behavior change and report it separately. Read the
|
|
14
|
+
repository's own instructions first; they win over this skill.
|
|
15
|
+
|
|
16
|
+
## 1. Resolve the scope
|
|
17
|
+
|
|
18
|
+
The text after `/skill:refactor` is the task. It may contain a path (`@src`,
|
|
19
|
+
`src`, `packages/api`, or a path inside a sentence), a question, or both.
|
|
20
|
+
|
|
21
|
+
- Resolve each path from the working directory. A directory is the audit scope;
|
|
22
|
+
a file is the initial target. Audit multiple paths separately and report them
|
|
23
|
+
together.
|
|
24
|
+
- No path means the current project. If the project is large, propose a scope
|
|
25
|
+
from the documented layout instead of scanning everything blindly.
|
|
26
|
+
- If a path does not exist, say so and ask for a real one. Do not guess. Do not
|
|
27
|
+
leave the working directory unless the user explicitly supplied an outside
|
|
28
|
+
path.
|
|
29
|
+
- State the resolved scope and the number of files examined in the report.
|
|
30
|
+
|
|
31
|
+
## 2. Learn the project's standards
|
|
32
|
+
|
|
33
|
+
- Read the repository's instruction files, contributor guide, architecture
|
|
34
|
+
notes, shared-helper documentation, and CI configuration.
|
|
35
|
+
- Record the languages, layout, test framework, documented check commands, size
|
|
36
|
+
or complexity thresholds, and ignore rules.
|
|
37
|
+
- Do not import an external style guide, install a tool, or apply a threshold the
|
|
38
|
+
project never stated. If there is no stated threshold, compare against the rest
|
|
39
|
+
of the scope and say that is the basis.
|
|
40
|
+
- Note the available evidence: tests, coverage, type checking, linting, git
|
|
41
|
+
history, and any scanner already installed.
|
|
42
|
+
|
|
43
|
+
## 3. Inventory the scope
|
|
44
|
+
|
|
45
|
+
- Map source files, tests, exports, imports, and entry points. Mark public
|
|
46
|
+
surface versus internal modules.
|
|
47
|
+
- Measure cheap facts: file and function sizes, nesting depth, parameter counts,
|
|
48
|
+
export counts, fan-in and fan-out, and the distance to the nearest test.
|
|
49
|
+
- Read git history for churn (`git log --numstat`) inside the scope. Churn is
|
|
50
|
+
context, not a verdict: a frequently changed, tangled file is a stronger
|
|
51
|
+
candidate than a stable, isolated oddity.
|
|
52
|
+
- Skip version-control metadata, dependencies, build output, generated files,
|
|
53
|
+
vendored trees, and secrets unless the user explicitly includes them. Respect
|
|
54
|
+
the project's ignore files.
|
|
55
|
+
- For a large scope, delegate a read-only survey to a read-only helper if the
|
|
56
|
+
host provides one. Keep the filtering and ranking in the main session.
|
|
57
|
+
|
|
58
|
+
## 4. Detect signals
|
|
59
|
+
|
|
60
|
+
For every signal, point at a file and line and explain why it matters here.
|
|
61
|
+
|
|
62
|
+
| Signal | What to look for | Evidence to cite |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Duplication | The same body or a near-identical block in several places; copy-paste with tiny edits; a helper that already exists in a shared location | Paths and line ranges of each copy; the shared location it should use |
|
|
65
|
+
| Size and responsibility | A module or function past the project's limit, or a relative outlier; unrelated exports; deep nesting; long parameter lists | Measured size or responsibility list; the seams where it could split |
|
|
66
|
+
| Coupling | Circular or layer-crossing imports, high fan-in or fan-out, feature envy, repeated type switches | The import edge or repeated branch, with both sides named |
|
|
67
|
+
| Cohesion and drift | A grab-bag utility module; a name that no longer matches behavior; dead exports; commented-out code; two implementations of one concept | The mismatch or unused export, with its callers |
|
|
68
|
+
| Change pressure | High recent churn combined with complexity or weak tests | Churn count over a stated window plus the complexity or test gap |
|
|
69
|
+
| Test friction | Behavior with no direct test; tests that mock the unit heavily or assert internals; duplicated setup that hides a missing seam | The test path and the missing or brittle assertion |
|
|
70
|
+
| Boundary erosion | Leaking internal types, unchecked casts, mode-selecting boolean parameters, null-heavy returns | The boundary location and the caller that must know the internals |
|
|
71
|
+
|
|
72
|
+
## 5. Verify and filter
|
|
73
|
+
|
|
74
|
+
A signal is not a candidate until it is confirmed.
|
|
75
|
+
|
|
76
|
+
- Read the callers and tests, not just the definition. Duplication may be
|
|
77
|
+
intentional for a protocol version; a large module may be cohesive; an
|
|
78
|
+
"unused" export may be public API.
|
|
79
|
+
- Require one concrete artifact: a path with line numbers, a counted duplicate, a
|
|
80
|
+
measured size, a dependency edge, or a test gap. If you cannot point at it,
|
|
81
|
+
drop it.
|
|
82
|
+
- Keep pure refactors separate from behavior changes and bugs. Report a bug as a
|
|
83
|
+
bug; do not smuggle it into the refactor list.
|
|
84
|
+
- Prefer candidates with an existing test that catches a regression. If the
|
|
85
|
+
behavior is untested, mark the candidate "tests first".
|
|
86
|
+
- Reject weak candidates explicitly. A short "not worth it" list proves the
|
|
87
|
+
audit was selective rather than a tour of everything unfamiliar.
|
|
88
|
+
|
|
89
|
+
## 6. Rank
|
|
90
|
+
|
|
91
|
+
Use three tiers:
|
|
92
|
+
|
|
93
|
+
- **Do next:** safe, contained blast radius, high leverage, small or medium
|
|
94
|
+
effort, and a fast verification command.
|
|
95
|
+
- **Worth planning:** high leverage but more risk or effort, a public surface, or
|
|
96
|
+
missing tests.
|
|
97
|
+
- **Leave it:** low confidence, little leverage, or not worth the churn.
|
|
98
|
+
|
|
99
|
+
Within a tier, order by leverage first, then safety, then cost. Do not invent a
|
|
100
|
+
numeric score; the reasons must be readable.
|
|
101
|
+
|
|
102
|
+
## 7. Report
|
|
103
|
+
|
|
104
|
+
Keep the report scannable. Use this shape:
|
|
105
|
+
|
|
106
|
+
- **Scope and method:** path, file count, tools used, and what was not examined.
|
|
107
|
+
- **Top three to five opportunities**, each with a title, tier, evidence at
|
|
108
|
+
`path:line`, the proposed structural change, expected benefit, risk and blast
|
|
109
|
+
radius, effort (S/M/L), and the narrow plus full verification command.
|
|
110
|
+
- **Rejected signals:** one line each with the reason it did not qualify.
|
|
111
|
+
- **Next step:** ask which candidate to take. Do not start editing.
|
|
112
|
+
|
|
113
|
+
## 8. Stop conditions
|
|
114
|
+
|
|
115
|
+
- No worthwhile opportunities: say so with the evidence that was checked instead
|
|
116
|
+
of inventing work.
|
|
117
|
+
- The request is a specific refactor rather than an audit: skip the shortlist,
|
|
118
|
+
but use the handoff below.
|
|
119
|
+
- The request changes behavior or asks for a rewrite: treat it as an approved
|
|
120
|
+
design change, not this audit.
|
|
121
|
+
- The scope cannot be read (missing path, secrets, binary or generated files, or
|
|
122
|
+
an inaccessible tree): report the limitation.
|
|
123
|
+
|
|
124
|
+
## After selection: safe handoff
|
|
125
|
+
|
|
126
|
+
If the user chooses a candidate, execution follows these rules:
|
|
127
|
+
|
|
128
|
+
- State the behavior contract and run the project's documented check to get a
|
|
129
|
+
baseline. Record pre-existing failures.
|
|
130
|
+
- If the behavior is untested, add characterization tests first.
|
|
131
|
+
- Enter plan mode when the host provides it and the change spans files, changes a
|
|
132
|
+
public surface, or has an unknown step list. Otherwise track the steps in a
|
|
133
|
+
todo list or a short written sequence.
|
|
134
|
+
- Make one structural change per step and verify each step. Never mix in
|
|
135
|
+
formatting, bug fixes, or unrelated cleanup.
|
|
136
|
+
- Finish with the full project check and report the diff, results, and remaining
|
|
137
|
+
risk. Do not commit unless the user asks.
|
|
138
|
+
|
|
139
|
+
The audit is done when the scope is stated, every candidate has `path:line`
|
|
140
|
+
evidence and a verification command, the shortlist is capped, rejected signals
|
|
141
|
+
are explained, and no files were modified.
|