@inneranimalmedia/agentsam-sdk 2.4.1 → 2.5.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 +7 -6
- package/docs/AGENTSAM_WORKBENCH.md +30 -0
- package/docs/AUTH_IDENTITY_CONTRACT.md +52 -0
- package/docs/CAPABILITIES.md +5 -3
- package/docs/CLI_SHELL.md +57 -80
- package/docs/CMS_STUDIO.md +101 -0
- package/docs/CONTEXT.md +170 -0
- package/docs/LOCAL_OLLAMA.md +58 -0
- package/docs/MERKLE.md +19 -19
- package/docs/PORTABLE_CONTEXT.md +4 -3
- package/docs/PROJECT_CONFIG.md +72 -0
- package/docs/RELEASES.md +26 -2
- package/docs/REPOSITORY_INTELLIGENCE.md +1 -1
- package/docs/REPOSITORY_KNOWLEDGE.md +114 -0
- package/docs/SDK_WORKER.md +86 -0
- package/docs/SECURITY.md +59 -22
- package/docs/client-cms-editor.md +15 -0
- package/docs/local-studio/WORKMODE_DONOR_NOTES.md +485 -0
- package/package.json +17 -4
- package/packages/identity/package.json +11 -2
- package/packages/identity/src/contracts/auth-config.js +98 -0
- package/packages/identity/src/index.js +1 -0
- package/packages/identity/src/oauth/README.md +2 -2
- package/packages/identity/src/oauth/credentials.js +11 -4
- package/packages/identity/src/oauth/iam-platform.js +3 -3
- package/packages/identity/src/providers/iam/index.js +7 -7
- package/packages/identity/src/providers/iam/oauth.js +6 -4
- package/packages/identity/src/providers/iam/profile.js +5 -5
- package/packages/identity/tests/auth-config.test.mjs +57 -0
- package/packages/identity/tests/oauth-credentials.test.mjs +13 -2
- package/protocol/FILEMETA_V1.md +95 -0
- package/protocol/INSPECT_VIEWS_V1.md +40 -0
- package/protocol/MERKLE_PERSISTENCE_V1.md +50 -0
- package/protocol/MERKLE_V1.md +3 -1
- package/protocol/capabilities/manifest.json +32 -3
- package/protocol/capabilities/repository-snapshot.schema.json +1 -0
- package/protocol/context/context-budget.schema.json +41 -0
- package/protocol/context/context-item.schema.json +20 -0
- package/protocol/context/resolved-context-pack.schema.json +42 -0
- package/protocol/context/result-policy.schema.json +17 -0
- package/protocol/knowledge/context-pack.schema.json +33 -0
- package/protocol/knowledge/retrieval-query.schema.json +68 -13
- package/python/README.md +15 -7
- package/python/agentsam_sdk/cli.py +0 -21
- package/python/agentsam_sdk/tui/README.md +17 -12
- package/python/agentsam_sdk/tui/bootstrap.py +2 -2
- package/python/agentsam_sdk/tui/demo.py +25 -10
- package/python/agentsam_sdk/tui/onboarding.py +208 -0
- package/python/tests/test_tui_cli.py +7 -6
- package/skills/README.md +21 -0
- package/skills/agentsam-app-fundamentals/SKILL.md +165 -0
- package/skills/agentsam-app-fundamentals/references/graphs-contracts-ast-merkle.md +89 -0
- package/skills/agentsam-app-fundamentals/references/trust-credentials-and-destinations.md +99 -0
- package/skills/agentsam-jr-dev/SKILL.md +232 -0
- package/skills/agentsam-jr-dev/references/real-application-logic.md +156 -0
- package/skills/agentsam-jr-dev/references/web-application-fundamentals.md +240 -0
- package/skills/agentsam-progression-guard/SKILL.md +197 -0
- package/skills/agentsam-progression-guard/references/checkpoint-chain.md +111 -0
- package/skills/agentsam-progression-guard/references/hooks-operational-io.md +96 -0
- package/skills/catalog.json +53 -0
- package/src/capabilities/index.js +7 -0
- package/src/capabilities/repository-snapshot-view.js +238 -0
- package/src/capabilities/repository-snapshot.js +28 -14
- package/src/cli.js +108 -56
- package/src/commands/context.js +14 -2
- package/src/commands/db.js +4 -7
- package/src/commands/deploy.js +17 -31
- package/src/commands/interactive.js +21 -0
- package/src/commands/knowledge.js +27 -4
- package/src/commands/merkle-persist.js +118 -0
- package/src/commands/merkle.js +32 -17
- package/src/commands/models.js +107 -0
- package/src/commands/ollama.js +259 -0
- package/src/commands/preferences.js +102 -0
- package/src/commands/product.js +86 -16
- package/src/commands/security.js +3 -3
- package/src/commands/shell.js +71 -27
- package/src/commands/skills.js +66 -0
- package/src/commands/start-local.js +1 -1
- package/src/commands/tunnel.js +5 -4
- package/src/context/budget.js +58 -0
- package/src/context/compact.js +28 -0
- package/src/context/index.js +5 -0
- package/src/context/resolve.js +84 -0
- package/src/context/result-policy.js +66 -0
- package/src/index.js +16 -0
- package/src/indexing/execution-boundary.js +144 -0
- package/src/indexing/index.js +8 -0
- package/src/indexing/provider.js +41 -0
- package/src/knowledge/config.js +2 -2
- package/src/knowledge/context-pack.js +12 -1
- package/src/knowledge/contracts.js +9 -4
- package/src/knowledge/engine.js +7 -3
- package/src/knowledge/service/server.js +1 -1
- package/src/lib/bridge-client.js +7 -5
- package/src/lib/cli-preferences.js +74 -0
- package/src/lib/core-client.js +8 -8
- package/src/lib/deploy-receipt/index.js +5 -2
- package/src/lib/detect-context.js +6 -5
- package/src/lib/identity-scaffold.js +1 -1
- package/src/lib/local-scaffold.js +35 -33
- package/src/lib/local-status.js +9 -17
- package/src/lib/merkle/cloudflare-persistence.js +321 -0
- package/src/lib/merkle/filemeta.js +43 -0
- package/src/lib/merkle/git-ignore.js +24 -0
- package/src/lib/merkle/hash.js +1 -0
- package/src/lib/merkle/index.js +22 -0
- package/src/lib/merkle/persistence.js +72 -0
- package/src/lib/merkle/semantic.js +359 -0
- package/src/lib/merkle/snapshot.js +9 -3
- package/src/lib/merkle/tree.js +11 -6
- package/src/lib/project-config.js +227 -0
- package/src/lib/project-rules.js +68 -0
- package/src/lib/save-sdk-token.js +1 -1
- package/src/lib/slash-commands.js +2 -1
- package/src/lib/tools.js +11 -5
- package/src/security/index.js +1 -0
- package/src/security/inventory.js +4 -1
- package/src/security/render.js +27 -5
- package/src/security/scan.js +24 -9
- package/src/security/trust-boundary.js +24 -0
- package/src/skills/index.js +64 -0
- package/src/tools/index.js +1 -0
- package/src/tools/search.js +70 -0
- package/src/ui/ansi.js +1 -1
- package/src/ui/boot.js +56 -0
- package/src/ui/merkle/render.js +1 -0
- package/src/ui/runtime-activity.js +192 -0
- package/src/ui/theme.js +19 -18
- package/test/app-building-skills.test.mjs +61 -0
- package/test/apps-scaffold-contract.test.mjs +56 -0
- package/test/capabilities.test.mjs +53 -4
- package/test/cli-preferences.test.mjs +25 -0
- package/test/context.test.mjs +95 -0
- package/test/indexing-provider.test.mjs +29 -0
- package/test/jr-dev-skill.test.mjs +26 -0
- package/test/knowledge-context-pack.test.mjs +19 -0
- package/test/knowledge.test.mjs +1 -1
- package/test/merkle-persistence.test.mjs +91 -0
- package/test/merkle.test.mjs +77 -3
- package/test/models.test.mjs +37 -0
- package/test/ollama.test.mjs +94 -0
- package/test/project-config.test.mjs +81 -0
- package/test/project-rules.test.mjs +44 -0
- package/test/release-hygiene.test.mjs +34 -0
- package/test/repository-snapshot-view.test.mjs +112 -0
- package/test/runtime-activity.test.mjs +98 -0
- package/test/sdk-worker-contract.test.mjs +68 -0
- package/test/security.test.mjs +46 -0
- package/test/shell.test.mjs +8 -1
- package/test/skills.test.mjs +22 -0
- package/test/smoke.mjs +2 -2
- package/test/theme-portability.test.mjs +14 -0
- package/test/tools-search.test.mjs +27 -0
- package/examples/agentsam-tui-ansi.mjs +0 -149
- package/src/commands/tui.js +0 -120
- package/src/ui/splash-xterm.js +0 -290
- package/src/ui/splash.js +0 -426
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentsam-app-fundamentals
|
|
3
|
+
description: >
|
|
4
|
+
Keep application-building work grounded in execution domains, contracts, credentials,
|
|
5
|
+
dependency graphs, AST evidence, Merkle evidence, and explicit I/O boundaries. Use when
|
|
6
|
+
adding or reviewing a feature, service, package, API, auth flow, secret, integration,
|
|
7
|
+
frontend/backend boundary, worker, webhook, or external credentialed destination. Also
|
|
8
|
+
use for quick reminders when a large codebase makes the underlying mechanics hard to
|
|
9
|
+
keep in working memory. Triggers on "app fundamentals", "quick bytes", "trust boundary",
|
|
10
|
+
"client secret", "redirect URI", "frontend/backend", "AST", "Merkle", "contract drift",
|
|
11
|
+
"service boundary", "credentialed destination", and "where should this logic live".
|
|
12
|
+
metadata:
|
|
13
|
+
short-description: "Application-building laws: ownership, contracts, credentials, graphs, AST, and Merkle evidence"
|
|
14
|
+
aliases:
|
|
15
|
+
- app-fundamentals
|
|
16
|
+
- application-fundamentals
|
|
17
|
+
- quick-bytes
|
|
18
|
+
user-invocable: true
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# AgentSam Application Fundamentals
|
|
22
|
+
|
|
23
|
+
Use this skill as a **small engineering compass**, not a giant textbook. A large
|
|
24
|
+
platform becomes manageable when every feature can answer a few mechanical
|
|
25
|
+
questions: who executes it, who owns authority, what contract crosses the boundary,
|
|
26
|
+
what credential is used, what it depends on, and what evidence proves the change.
|
|
27
|
+
|
|
28
|
+
## Quick bytes
|
|
29
|
+
|
|
30
|
+
- **Execution domain:** trust follows who controls the machine/runtime, not the folder name.
|
|
31
|
+
- **Browser/client:** user-controlled and therefore observable/tamperable. Never make it the final authority for security or privileged state changes.
|
|
32
|
+
- **Server/backend:** operator-controlled execution. Re-verify identity, authorization, ownership, prices, permissions, and other invariants here.
|
|
33
|
+
- **Import:** a dependency edge. **Export:** a public contract another module may depend on.
|
|
34
|
+
- **AST:** parsed code structure. Use it to identify symbols, imports/exports, calls, environment access, and execution-domain contradictions without relying on text grep alone.
|
|
35
|
+
- **Dependency graph/DAG:** the map of what depends on what. It determines blast radius, build order, affected tests, and what can run in parallel.
|
|
36
|
+
- **Schema/contract:** the agreed shape at a boundary. Compile-time types help; runtime validation proves real external data matches the contract.
|
|
37
|
+
- **Merkle/content hash:** identity for observed bytes. A changed root proves something changed; an unchanged root proves the captured content is identical under the same policy.
|
|
38
|
+
- **Semantic metadata root:** identity for the indexed/classified view of those bytes. It can change when execution classification or parser-derived meaning changes even when content does not.
|
|
39
|
+
- **Client ID:** usually a public application identifier. **Client secret/API secret:** a credential proving authority; keep it out of browser code and public bundles.
|
|
40
|
+
- **Redirect URI:** an explicitly registered destination for an authorization flow. The provider returns to the callback; your backend verifies the flow, establishes your app session, then chooses the final in-app destination.
|
|
41
|
+
- **Firewall/WAF:** an ingress filter. It reduces hostile traffic; it does not replace authentication, authorization, ownership checks, runtime validation, or least privilege.
|
|
42
|
+
- **Hook:** code that runs automatically because a lifecycle event occurred. Treat hooks as explicit I/O contracts, not mystery scripts.
|
|
43
|
+
|
|
44
|
+
If one of those concepts is fuzzy for the current task, read the matching reference
|
|
45
|
+
before editing.
|
|
46
|
+
|
|
47
|
+
## The six questions for every feature
|
|
48
|
+
|
|
49
|
+
Before changing code, be able to answer:
|
|
50
|
+
|
|
51
|
+
1. **User behavior:** what can the user now do?
|
|
52
|
+
2. **Execution owner:** which runtime is trusted to make the decision or perform the side effect?
|
|
53
|
+
3. **Contract:** what request/event/type/schema crosses each boundary?
|
|
54
|
+
4. **State:** what is ephemeral, browser-local, durable, cached, or externally owned?
|
|
55
|
+
5. **Credentialed destinations:** which external systems are called, from which runtime, with which public IDs/secrets/scopes?
|
|
56
|
+
6. **Proof:** which tests, AST/index evidence, Merkle receipt, runtime response, or observable metric proves it works?
|
|
57
|
+
|
|
58
|
+
If a feature cannot answer these, it is not ready to be called complete.
|
|
59
|
+
|
|
60
|
+
## Build vertical slices, not disconnected layers
|
|
61
|
+
|
|
62
|
+
For application work, trace the real behavior end to end:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
user action
|
|
66
|
+
-> client intent
|
|
67
|
+
-> validated boundary contract
|
|
68
|
+
-> trusted server/domain operation
|
|
69
|
+
-> database/service/provider side effect
|
|
70
|
+
-> response/event
|
|
71
|
+
-> client state/render
|
|
72
|
+
-> test + runtime proof
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A button without the trusted operation behind it is incomplete. A backend endpoint
|
|
76
|
+
without a real consumer may be dead surface area. A shared type without runtime
|
|
77
|
+
validation is not proof that an external system obeyed the type.
|
|
78
|
+
|
|
79
|
+
## Credentialed-destination card
|
|
80
|
+
|
|
81
|
+
Whenever a feature talks to Google, GitHub, Cloudflare, Stripe, a model provider,
|
|
82
|
+
a database, another Worker/service, or any other privileged destination, write down
|
|
83
|
+
this card before wiring it:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
Destination
|
|
87
|
+
provider/service:
|
|
88
|
+
purpose:
|
|
89
|
+
caller execution domain:
|
|
90
|
+
public identifier(s):
|
|
91
|
+
secret credential(s):
|
|
92
|
+
credential owner/runtime:
|
|
93
|
+
allowed origin/host:
|
|
94
|
+
callback/redirect/webhook URI(s):
|
|
95
|
+
scopes/permissions:
|
|
96
|
+
request contract:
|
|
97
|
+
response contract:
|
|
98
|
+
timeout/retry/idempotency:
|
|
99
|
+
failure behavior:
|
|
100
|
+
audit/observability:
|
|
101
|
+
rotation/revocation path:
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This turns "a pile of env vars" into an explicit relationship. Environment variable
|
|
105
|
+
names are configuration labels; the credential value is the sensitive authority.
|
|
106
|
+
Validate required configuration at boot or boundary entry and fail clearly.
|
|
107
|
+
|
|
108
|
+
Read `references/trust-credentials-and-destinations.md` for auth/OAuth and destination
|
|
109
|
+
mechanics.
|
|
110
|
+
|
|
111
|
+
## Graph law for packages/services/apps
|
|
112
|
+
|
|
113
|
+
As a system grows, do not rely on remembering which file "goes with" another file.
|
|
114
|
+
Make coupling machine-visible:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
package/service A
|
|
118
|
+
imports / calls / subscribes to
|
|
119
|
+
package/service B
|
|
120
|
+
implements contract C
|
|
121
|
+
owns state D
|
|
122
|
+
uses credential E
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Prefer a single contract authority for cross-surface behavior: a shared type/schema,
|
|
126
|
+
OpenAPI/GraphQL/Protobuf definition, event schema, or other versioned interface. Use
|
|
127
|
+
AST/import graphs and package metadata to determine affected dependents instead of
|
|
128
|
+
manually searching a million-line repository.
|
|
129
|
+
|
|
130
|
+
Read `references/graphs-contracts-ast-merkle.md` for the deeper model.
|
|
131
|
+
|
|
132
|
+
## AgentSam evidence tools
|
|
133
|
+
|
|
134
|
+
Prefer deterministic evidence before broad model reasoning:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
agentsam inspect --json
|
|
138
|
+
agentsam inspect --execution-domain browser --view files --json
|
|
139
|
+
agentsam security scan --path .
|
|
140
|
+
agentsam merkle ...
|
|
141
|
+
agentsam index ...
|
|
142
|
+
agentsam search ...
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Use repository/index tools to narrow the relevant graph. Do not dump the whole repo
|
|
146
|
+
or all tool schemas into context.
|
|
147
|
+
|
|
148
|
+
## Rules while building
|
|
149
|
+
|
|
150
|
+
1. Never infer trust from `frontend/`, `backend/`, `worker/`, or `shared/` names alone; verify execution reality.
|
|
151
|
+
2. Never put a long-lived secret into code delivered to a user-controlled runtime.
|
|
152
|
+
3. Never let client-side validation be the only security or correctness check.
|
|
153
|
+
4. Never introduce a second contract authority when an existing canonical schema/type can be extended.
|
|
154
|
+
5. Never change a shared contract without identifying downstream dependents.
|
|
155
|
+
6. Never treat a Merkle hash as proof of correctness; it proves observed identity/change, not behavior.
|
|
156
|
+
7. Never treat AST/index output as infallible; account for parser coverage, generated/framework code, and explicit classification overrides.
|
|
157
|
+
8. Never let a hook silently mutate unrelated state. Bound its inputs, outputs, permissions, timeout, and failure policy.
|
|
158
|
+
9. Never call a credential "just an env var." Record who owns it, where it may exist, and what it authorizes.
|
|
159
|
+
10. Never ship a cross-layer feature from screenshots alone. Exercise the real I/O path.
|
|
160
|
+
|
|
161
|
+
## Handoff to progression guard
|
|
162
|
+
|
|
163
|
+
Once the feature's boundaries are coherent, use `agentsam-progression-guard` to decide
|
|
164
|
+
**when and where those invariants must be re-proven** during commit, CI, deploy, and
|
|
165
|
+
runtime promotion.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Graphs, Contracts, AST, and Merkle Evidence
|
|
2
|
+
|
|
3
|
+
## The codebase is a graph
|
|
4
|
+
|
|
5
|
+
A large application is easier to reason about when you stop treating it as a folder
|
|
6
|
+
maze and start treating it as a graph:
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
files -> symbols -> imports/calls -> packages -> services -> external destinations
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The graph answers questions humans should not have to remember:
|
|
13
|
+
|
|
14
|
+
- If package C changes, which apps depend on it?
|
|
15
|
+
- Which browser entrypoints can reach this server-only module?
|
|
16
|
+
- Which route consumes this schema?
|
|
17
|
+
- Which service owns a database write?
|
|
18
|
+
- Which packages can build/test in parallel?
|
|
19
|
+
- Which consumers must be revalidated after a contract change?
|
|
20
|
+
|
|
21
|
+
A DAG is especially useful for build/test ordering when cycles are absent or have been
|
|
22
|
+
made explicit.
|
|
23
|
+
|
|
24
|
+
## AST is structure, not text coincidence
|
|
25
|
+
|
|
26
|
+
An Abstract Syntax Tree is the parsed structural representation of source code. It can
|
|
27
|
+
reliably distinguish function declarations, imports, calls, environment accesses,
|
|
28
|
+
and other syntax that a plain text search can only approximate.
|
|
29
|
+
|
|
30
|
+
AgentSam should use AST evidence to derive dependency and execution-boundary facts,
|
|
31
|
+
then preserve parser coverage/errors so an agent knows where certainty ends.
|
|
32
|
+
|
|
33
|
+
Useful AST-derived facts include:
|
|
34
|
+
|
|
35
|
+
- imports/exports and resolved local edges;
|
|
36
|
+
- symbol declarations and references;
|
|
37
|
+
- server/runtime-only dependency use;
|
|
38
|
+
- environment variable access names (never secret values);
|
|
39
|
+
- browser-reachable versus server-owned code;
|
|
40
|
+
- contract/schema ownership hints.
|
|
41
|
+
|
|
42
|
+
## Contracts make coupling explicit
|
|
43
|
+
|
|
44
|
+
For a frontend/backend or service/service boundary, prefer one canonical contract
|
|
45
|
+
source. Depending on the system that can be a TypeScript package, runtime schema,
|
|
46
|
+
OpenAPI document, GraphQL schema, Protobuf definition, event schema, or equivalent.
|
|
47
|
+
|
|
48
|
+
Compile-time types catch code drift before build. Runtime validation catches real data
|
|
49
|
+
that violates the contract after types have been erased or when the caller is outside
|
|
50
|
+
the type system. Contract tests can prove independent producer/consumer systems still
|
|
51
|
+
agree.
|
|
52
|
+
|
|
53
|
+
## Merkle is the evidence identity layer
|
|
54
|
+
|
|
55
|
+
Merkle hashing gives a deterministic identity to a captured file tree. If one included
|
|
56
|
+
file changes, the root changes. This makes before/after receipts cheap to compare and
|
|
57
|
+
lets CI/deploy systems cache or target work by content identity.
|
|
58
|
+
|
|
59
|
+
AgentSam separates two identities:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
content root
|
|
63
|
+
observed included bytes/paths
|
|
64
|
+
|
|
65
|
+
semantic metadata root
|
|
66
|
+
classified/indexed meaning derived from those bytes
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The semantic root can change after a classifier/parser upgrade or execution-domain
|
|
70
|
+
classification change even when source bytes remain identical. That distinction is
|
|
71
|
+
important: source identity and interpretation identity answer different questions.
|
|
72
|
+
|
|
73
|
+
## The repair proof loop
|
|
74
|
+
|
|
75
|
+
For structural repairs, prefer:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
snapshot A
|
|
79
|
+
-> contradiction finding + evidence refs
|
|
80
|
+
-> isolated bounded repair
|
|
81
|
+
-> build/type/test/security checks
|
|
82
|
+
-> snapshot B
|
|
83
|
+
-> prove target contradiction disappeared
|
|
84
|
+
-> prove no disallowed new contradictions
|
|
85
|
+
-> emit receipt
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The model may propose the repair, but deterministic evidence should decide whether the
|
|
89
|
+
repair actually satisfied the invariant.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Trust, Credentials, and Credentialed Destinations
|
|
2
|
+
|
|
3
|
+
## Trust is about execution ownership
|
|
4
|
+
|
|
5
|
+
The useful distinction is not "frontend equals UI" and "backend equals logic."
|
|
6
|
+
The useful distinction is who controls execution.
|
|
7
|
+
|
|
8
|
+
A browser, mobile client, or other user-controlled runtime can be inspected and
|
|
9
|
+
modified by that user. Treat requests from it as claims that the trusted side must
|
|
10
|
+
validate. Server-owned runtimes can hold privileged credentials and enforce durable
|
|
11
|
+
invariants, but they still must authenticate callers and apply least privilege.
|
|
12
|
+
|
|
13
|
+
## Public identifiers versus credentials
|
|
14
|
+
|
|
15
|
+
A public client/application ID tells a provider **which registered application** is
|
|
16
|
+
participating. It is often visible in redirect URLs or client configuration and is
|
|
17
|
+
not, by itself, proof of authority.
|
|
18
|
+
|
|
19
|
+
A client secret, API key, signing key, refresh token, database credential, or similar
|
|
20
|
+
secret is authority-bearing material. Its value belongs only in the runtime that is
|
|
21
|
+
allowed to use that authority. Do not confuse a secret's environment variable name
|
|
22
|
+
with the secret itself.
|
|
23
|
+
|
|
24
|
+
## OAuth redirect mental model
|
|
25
|
+
|
|
26
|
+
Keep the endpoints separate:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
/app/auth/login
|
|
30
|
+
-> creates state / PKCE material as appropriate
|
|
31
|
+
-> redirects browser to provider authorization endpoint
|
|
32
|
+
|
|
33
|
+
provider
|
|
34
|
+
-> authenticates user + consent
|
|
35
|
+
-> redirects only to registered callback
|
|
36
|
+
|
|
37
|
+
/app/auth/callback
|
|
38
|
+
-> verifies state and flow binding
|
|
39
|
+
-> exchanges code server-to-server when the flow requires it
|
|
40
|
+
-> validates provider identity claims
|
|
41
|
+
-> finds/creates local user
|
|
42
|
+
-> establishes the app's own session
|
|
43
|
+
-> redirects to the intended in-app destination
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The callback is not the user's final product page. It is a security-sensitive
|
|
47
|
+
boundary where the external authorization flow becomes an internal authenticated
|
|
48
|
+
session.
|
|
49
|
+
|
|
50
|
+
For clients that cannot safely keep a static secret, use the provider's supported
|
|
51
|
+
public-client flow such as Authorization Code + PKCE rather than embedding a secret
|
|
52
|
+
in the client.
|
|
53
|
+
|
|
54
|
+
## Destination registry mindset
|
|
55
|
+
|
|
56
|
+
Treat every external system as a typed destination rather than an ad-hoc URL string.
|
|
57
|
+
For each destination record:
|
|
58
|
+
|
|
59
|
+
- canonical provider/service identity;
|
|
60
|
+
- allowed host/origin and transport;
|
|
61
|
+
- caller execution domain;
|
|
62
|
+
- public IDs versus secret credentials;
|
|
63
|
+
- scopes/permissions;
|
|
64
|
+
- redirect/callback/webhook endpoints;
|
|
65
|
+
- input/output schemas;
|
|
66
|
+
- retry, timeout, idempotency, and rate-limit behavior;
|
|
67
|
+
- audit/logging rules that never emit secrets;
|
|
68
|
+
- rotation/revocation owner.
|
|
69
|
+
|
|
70
|
+
This is the mechanism that makes `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, a
|
|
71
|
+
callback URI, and a login route understandable as one relationship instead of four
|
|
72
|
+
unrelated strings.
|
|
73
|
+
|
|
74
|
+
## Defense in depth
|
|
75
|
+
|
|
76
|
+
Think in layers, each assuming the layer before it can fail:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
internet
|
|
80
|
+
-> edge/DDoS protection
|
|
81
|
+
-> firewall/WAF/bot/rate-limit policy
|
|
82
|
+
-> route/authentication
|
|
83
|
+
-> authorization + ownership validation
|
|
84
|
+
-> runtime schema validation
|
|
85
|
+
-> least-privilege credential/service access
|
|
86
|
+
-> durable audit/observability
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
A WAF can reject known-bad traffic, but it cannot know your business ownership rule.
|
|
90
|
+
Authentication can prove a user identity, but it does not automatically prove that
|
|
91
|
+
user may modify a particular record. A valid credential can authenticate a service
|
|
92
|
+
while still being over-privileged. Re-verify at each boundary.
|
|
93
|
+
|
|
94
|
+
## Fail fast at configuration boundaries
|
|
95
|
+
|
|
96
|
+
Validate required runtime configuration when the process/worker starts or before the
|
|
97
|
+
first privileged operation. Check presence, expected public/secret classification,
|
|
98
|
+
allowed destination, and format where the provider defines one. Never log the secret
|
|
99
|
+
value to explain a validation failure.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentsam-jr-dev
|
|
3
|
+
description: >
|
|
4
|
+
Teach, inspect, build, and revise software in junior-developer-friendly language
|
|
5
|
+
without replacing real engineering with toy explanations. Use when a user asks
|
|
6
|
+
what code, HTTP, frontend/backend, APIs, databases, auth, services, workers,
|
|
7
|
+
repositories, packages, deployments, or application architecture mean; when
|
|
8
|
+
onboarding someone to an unfamiliar repo; or when explaining why a proposed
|
|
9
|
+
implementation belongs in a particular layer. Also use while building or
|
|
10
|
+
reviewing software when the user benefits from understanding the real mechanics.
|
|
11
|
+
Triggers on "jr dev", "junior dev", "explain this", "what is HTTP", "frontend",
|
|
12
|
+
"backend", "API", "service", "microservice", "how does this app work", "repo map",
|
|
13
|
+
"teach me", "break this down", and "why does this go here".
|
|
14
|
+
metadata:
|
|
15
|
+
short-description: "Teach real software mechanics from the actual repo, then prove the implementation"
|
|
16
|
+
aliases:
|
|
17
|
+
- agentsam_jr_dev
|
|
18
|
+
- jr-dev
|
|
19
|
+
user-invocable: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# AgentSam Jr Dev
|
|
23
|
+
|
|
24
|
+
Teach software by connecting **simple mental models to the actual system in front
|
|
25
|
+
of you**. The goal is not to make engineering sound easy. The goal is to make
|
|
26
|
+
real engineering understandable without hiding the mechanics.
|
|
27
|
+
|
|
28
|
+
A successful Jr Dev answer leaves the user knowing:
|
|
29
|
+
|
|
30
|
+
1. **what the thing is,**
|
|
31
|
+
2. **why it exists,**
|
|
32
|
+
3. **where it lives in this project,**
|
|
33
|
+
4. **what talks to it,**
|
|
34
|
+
5. **what state or authority it owns,** and
|
|
35
|
+
6. **how to prove it works.**
|
|
36
|
+
|
|
37
|
+
Do not teach a fake generic architecture when repository evidence is available.
|
|
38
|
+
Inspect first, then explain what is actually there.
|
|
39
|
+
|
|
40
|
+
## Core behavior
|
|
41
|
+
|
|
42
|
+
### 1. Start with the smallest useful explanation
|
|
43
|
+
|
|
44
|
+
Use this progression unless the user asks for a different depth:
|
|
45
|
+
|
|
46
|
+
- **10-second model** — one plain-language sentence.
|
|
47
|
+
- **mechanics** — the actual request/data/control flow.
|
|
48
|
+
- **repo proof** — name the real files, directories, routes, schemas, or services.
|
|
49
|
+
- **engineering consequence** — explain why the boundary matters when building or changing it.
|
|
50
|
+
|
|
51
|
+
Example:
|
|
52
|
+
|
|
53
|
+
> HTTP is the agreed request/response language two programs use to talk over a
|
|
54
|
+
> network. In this repo, the browser calls `/api/models`; the backend route
|
|
55
|
+
> receives that request, uses trusted server-side configuration, and returns a
|
|
56
|
+
> response the frontend can render.
|
|
57
|
+
|
|
58
|
+
Never stop at an analogy when the user needs the real mechanism.
|
|
59
|
+
|
|
60
|
+
### 2. Inspect before teaching repo-specific facts
|
|
61
|
+
|
|
62
|
+
For an unfamiliar project, establish the system shape before making claims:
|
|
63
|
+
|
|
64
|
+
- project/package manifests,
|
|
65
|
+
- top-level tree,
|
|
66
|
+
- runtime entrypoints,
|
|
67
|
+
- frontend entrypoint and routes,
|
|
68
|
+
- backend/server/worker entrypoint,
|
|
69
|
+
- shared contracts,
|
|
70
|
+
- API/transport boundaries,
|
|
71
|
+
- persistence/storage,
|
|
72
|
+
- auth/identity,
|
|
73
|
+
- environment/config,
|
|
74
|
+
- tests,
|
|
75
|
+
- deployment/runtime configuration.
|
|
76
|
+
|
|
77
|
+
Prefer deterministic repository/index/search tools over reading giant trees or
|
|
78
|
+
hundreds of files into context. Read the smallest relevant spans that prove the
|
|
79
|
+
explanation.
|
|
80
|
+
|
|
81
|
+
### 3. Teach boundaries as ownership
|
|
82
|
+
|
|
83
|
+
When explaining architecture, answer **who owns what**:
|
|
84
|
+
|
|
85
|
+
- frontend owns presentation and browser interaction,
|
|
86
|
+
- backend owns trusted execution and privileged access,
|
|
87
|
+
- shared/contracts own the shape both sides agree on,
|
|
88
|
+
- database/storage owns durable state,
|
|
89
|
+
- auth owns verified identity,
|
|
90
|
+
- HTTP/RPC/WebSocket is transport, not business logic,
|
|
91
|
+
- workers/servers are runtime entrypoints, not automatically the whole backend,
|
|
92
|
+
- packages expose reusable capabilities,
|
|
93
|
+
- apps compose those capabilities into complete products,
|
|
94
|
+
- services are independently running capabilities with explicit interfaces.
|
|
95
|
+
|
|
96
|
+
Do not teach folder names as universal laws. A repo may call these layers
|
|
97
|
+
`client/server`, `web/api`, `ui/core`, `worker`, or something else. Explain the
|
|
98
|
+
**responsibility** first, then map it to this repo's names.
|
|
99
|
+
|
|
100
|
+
Read `references/web-application-fundamentals.md` for the canonical beginner
|
|
101
|
+
mental models and request-flow examples.
|
|
102
|
+
|
|
103
|
+
### 4. Real application logic is the standard
|
|
104
|
+
|
|
105
|
+
A polished screen is not proof of a working application. For any build/revision,
|
|
106
|
+
trace the behavior end-to-end:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
user intent
|
|
110
|
+
-> UI/input
|
|
111
|
+
-> validated action/request
|
|
112
|
+
-> trusted business logic
|
|
113
|
+
-> state/storage/provider side effect
|
|
114
|
+
-> response/event
|
|
115
|
+
-> UI state update
|
|
116
|
+
-> verification
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
If the requested feature crosses layers, implement and verify every required
|
|
120
|
+
layer. Do not hide missing backend/storage/auth/integration work behind mocked
|
|
121
|
+
frontend state unless the user explicitly asked for a prototype.
|
|
122
|
+
|
|
123
|
+
Read `references/real-application-logic.md` before claiming a new application,
|
|
124
|
+
service, or cross-layer feature is complete.
|
|
125
|
+
|
|
126
|
+
### 5. Explain changes in terms of consequences
|
|
127
|
+
|
|
128
|
+
Instead of:
|
|
129
|
+
|
|
130
|
+
> I moved this into the backend because that's cleaner.
|
|
131
|
+
|
|
132
|
+
Prefer:
|
|
133
|
+
|
|
134
|
+
> This operation needs a secret and writes durable state, so the browser cannot
|
|
135
|
+
> be its authority. The frontend sends the user's intent; the backend verifies
|
|
136
|
+
> it and performs the write. That keeps the secret off the client and gives us
|
|
137
|
+
> one trusted place to enforce validation.
|
|
138
|
+
|
|
139
|
+
Teach *why*, not just style conventions.
|
|
140
|
+
|
|
141
|
+
## No-bullshit rules
|
|
142
|
+
|
|
143
|
+
1. **Never invent a repo architecture.** Inspect it.
|
|
144
|
+
2. **Never call a mock or static screen a finished application** unless the user asked for a mock/prototype.
|
|
145
|
+
3. **Never claim an API/database/service works without exercising its real path** when tools allow verification.
|
|
146
|
+
4. **Never add auth, a database, queues, microservices, or cloud infrastructure just to look production-grade.** Add them when the behavior requires them.
|
|
147
|
+
5. **Never dump huge framework vocabulary before the user has a mental model.** Introduce terms when they explain a real observed mechanism.
|
|
148
|
+
6. **Never equate HTTP with "the backend."** HTTP is one transport. The backend is the trusted logic/runtime behind the interface.
|
|
149
|
+
7. **Never equate a Worker/server file with all business logic.** Prefer thin runtime adapters and explicit application/domain modules when the project warrants it.
|
|
150
|
+
8. **Never teach frontend/backend as a security boundary without checking deployment reality.** Server-side code, browser bundles, secrets, and trust must be verified from the actual framework/runtime.
|
|
151
|
+
9. **Never replace evidence with confidence.** Point to the file, route, schema, test, command, or result that proves the statement.
|
|
152
|
+
10. **Never make "junior" mean patronizing.** Use plain language while preserving the real technical model.
|
|
153
|
+
|
|
154
|
+
## Repo explanation template
|
|
155
|
+
|
|
156
|
+
When someone asks "how does this repo/app work?", prefer a compact map like:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
Product
|
|
160
|
+
what a user can do
|
|
161
|
+
|
|
162
|
+
Frontend
|
|
163
|
+
entrypoint:
|
|
164
|
+
routes/views:
|
|
165
|
+
state:
|
|
166
|
+
calls out to:
|
|
167
|
+
|
|
168
|
+
Backend
|
|
169
|
+
runtime entrypoint:
|
|
170
|
+
API/actions:
|
|
171
|
+
trusted integrations:
|
|
172
|
+
|
|
173
|
+
Shared contracts
|
|
174
|
+
types/schemas/events:
|
|
175
|
+
|
|
176
|
+
State
|
|
177
|
+
browser-local:
|
|
178
|
+
durable database/storage:
|
|
179
|
+
|
|
180
|
+
External systems
|
|
181
|
+
model providers / Git / payments / etc.:
|
|
182
|
+
|
|
183
|
+
Request flow
|
|
184
|
+
user -> frontend -> transport -> backend -> state/provider -> response -> UI
|
|
185
|
+
|
|
186
|
+
Proof
|
|
187
|
+
tests / health checks / real execution path:
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Only include sections the actual project has.
|
|
191
|
+
|
|
192
|
+
## Build/revision workflow
|
|
193
|
+
|
|
194
|
+
For a real task:
|
|
195
|
+
|
|
196
|
+
1. Restate the user-visible behavior in one sentence.
|
|
197
|
+
2. Identify current architecture from repository evidence.
|
|
198
|
+
3. Identify the authority/state owner for the behavior.
|
|
199
|
+
4. Trace the end-to-end flow before editing.
|
|
200
|
+
5. Reuse existing project patterns/contracts where sound.
|
|
201
|
+
6. Make the smallest coherent cross-layer change.
|
|
202
|
+
7. Exercise the real path.
|
|
203
|
+
8. Explain the result at the user's requested depth.
|
|
204
|
+
|
|
205
|
+
When debugging, teach the failing boundary:
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
input -> frontend -> transport -> backend -> dependency -> persistence -> response
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Find the first point where expected and actual behavior diverge.
|
|
212
|
+
|
|
213
|
+
## Teaching vocabulary
|
|
214
|
+
|
|
215
|
+
Prefer plain term -> precise term:
|
|
216
|
+
|
|
217
|
+
- "the browser screen" -> frontend/client
|
|
218
|
+
- "the trusted code doing the work" -> backend/server
|
|
219
|
+
- "the agreed message shape" -> contract/schema
|
|
220
|
+
- "the request language" -> HTTP
|
|
221
|
+
- "a named HTTP endpoint" -> API route/endpoint
|
|
222
|
+
- "long-lived two-way connection" -> WebSocket
|
|
223
|
+
- "saved state" -> persistence/database/storage
|
|
224
|
+
- "proof of who the user is" -> authentication
|
|
225
|
+
- "what that user is allowed to do" -> authorization
|
|
226
|
+
- "a separately running capability" -> service
|
|
227
|
+
- "a small independently deployed service" -> microservice, only when it actually is one
|
|
228
|
+
- "the program's starting door" -> entrypoint
|
|
229
|
+
- "code reused by multiple products" -> package/library
|
|
230
|
+
|
|
231
|
+
Introduce the precise term immediately after the plain one so the user learns the
|
|
232
|
+
real vocabulary rather than remaining dependent on analogies.
|